Commit 8be304a9 authored by Administrator's avatar Administrator
Browse files

Merge branch 'master' into 'master'

From pro-sd/pro-sd-ump:master into public-group/pro-sd-ump:master

See merge request !3
parents f1a4e015 d6523d04
Pipeline #98 failed with stages
in 1 second
......@@ -3,12 +3,12 @@ services:
ump-swarmvisualizer:
image: localhost:5000/ump-swarmvisualizer:0.1.0
ports:
- "9001:8080"
- "9001:8080"
networks:
- ump-network
- ump-network
volumes:
- ump-volume:/ump
- /var/run/docker.sock:/var/run/docker.sock
- ump-volume:/ump
- /var/run/docker.sock:/var/run/docker.sock
deploy:
mode: global
restart_policy:
......@@ -18,11 +18,11 @@ services:
ump-bootadminserver:
image: localhost:5000/ump-bootadminserver:0.1.0
ports:
- "9000:9000"
- "9000:9000"
networks:
- ump-network
- ump-network
volumes:
- ump-volume:/ump
- ump-volume:/ump
environment:
HOST: ump-bootadminserver
HTTP_PORT: 9000
......@@ -32,11 +32,11 @@ services:
ump-config:
image: localhost:5000/ump-config:0.1.0
ports:
- "8888:8888"
- "8888:8888"
networks:
- ump-network
- ump-network
volumes:
- ump-volume:/ump
- ump-volume:/ump
environment:
HOST: ump-config
HTTP_PORT: 8888
......@@ -47,13 +47,13 @@ services:
ump-registry:
image: localhost:5000/ump-registry:0.1.0
ports:
- "8761:8761"
- "8761:8761"
networks:
- ump-network
- ump-network
volumes:
- ump-volume:/ump
- ump-volume:/ump
depends_on:
- "ump-config"
- "ump-config"
deploy:
mode: global
restart_policy:
......@@ -69,12 +69,12 @@ services:
ump-gateway:
image: localhost:5000/ump-gateway:0.1.0
ports:
- "80:80" #http
- "443:443" #https
- "80:80" #http
- "443:443" #https
networks:
- ump-network
- ump-network
volumes:
- ump-volume:/ump
- ump-volume:/ump
# - /etc/letsencrypt:/etc/letsencrypt
deploy:
mode: global
......
......@@ -27,7 +27,7 @@
<spring-cloud-starter-eureka.version>2.0.1.RELEASE</spring-cloud-starter-eureka.version>
<maven-surefire-plugin.version>2.22.1</maven-surefire-plugin.version>
<sonar-maven-plugin.version>3.7.0.1746</sonar-maven-plugin.version>
<docker-maven-plugin.version>0.26.1</docker-maven-plugin.version>
</properties>
......@@ -39,6 +39,7 @@
<module>ump-bootadminserver</module>
<module>ump-config</module>
<module>ump-registry</module>
<module>ump-mattermostio</module>
<module>ump-logstash</module>
<module>ump-elasticsearch</module>
<module>ump-kibana</module>
......@@ -99,6 +100,13 @@
</executions>
</plugin>
<!-- https://mvnrepository.com/artifact/org.sonarsource.scanner.maven/sonar-maven-plugin -->
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar-maven-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
......
......@@ -72,6 +72,10 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
......
......@@ -19,6 +19,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<maven-surefire-plugin.version>2.22.1</maven-surefire-plugin.version>
<sonar-maven-plugin.version>3.7.0.1746</sonar-maven-plugin.version>
</properties>
<build>
......@@ -57,6 +58,11 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar-maven-plugin.version}</version>
</plugin>
</plugins>
</build>
......
......@@ -2,6 +2,7 @@ package com.asvoip.ump.commonmodule.dto;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* Списочный запрос данных.
......@@ -92,28 +93,16 @@ public class ListRequest {
if (!(o instanceof ListRequest)) {
return false;
}
ListRequest that = (ListRequest) o;
if (limit != null ? !limit.equals(that.limit) : that.limit != null) {
return false;
}
if (offset != null ? !offset.equals(that.offset) : that.offset != null) {
return false;
}
if (sort != null ? !sort.equals(that.sort) : that.sort != null) {
return false;
}
return filters != null ? filters.equals(that.filters) : that.filters == null;
return Objects.equals(limit, that.limit) &&
Objects.equals(offset, that.offset) &&
Objects.equals(sort, that.sort) &&
Objects.equals(filters, that.filters);
}
@Override
public int hashCode() {
int result = limit != null ? limit.hashCode() : 0;
result = 31 * result + (offset != null ? offset.hashCode() : 0);
result = 31 * result + (sort != null ? sort.hashCode() : 0);
result = 31 * result + (filters != null ? filters.hashCode() : 0);
return result;
return Objects.hash(limit, offset, sort, filters);
}
@Override
......
......@@ -2,14 +2,15 @@ package com.asvoip.ump.commonmodule.dto;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* Списочный результат данных.
* Data Transfer Object (DTO).
*
* @param <Type> Тип полученной из СУБД сущности
* @param <T> Тип полученной из СУБД сущности
*/
public class ListResult<Type> extends ListRequest {
public class ListResult<T> extends ListRequest {
/**
* Общее число сущностей для запроса данных
......@@ -24,7 +25,7 @@ public class ListResult<Type> extends ListRequest {
/**
* Список возвращаемых сущностей
*/
private List<Type> list = new ArrayList<Type>();
private List<T> list = new ArrayList<>();
public ListResult() {
super();
......@@ -50,18 +51,40 @@ public class ListResult<Type> extends ListRequest {
this.count = count;
}
public List<Type> getList() {
public List<T> getList() {
return list;
}
public void setList(List<Type> list) {
public void setList(List<T> list) {
this.list = list;
}
public void addObject(Type object) {
public void addObject(T object) {
list.add(object);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ListResult)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ListResult<?> that = (ListResult<?>) o;
return Objects.equals(totalCount, that.totalCount) &&
Objects.equals(count, that.count) &&
Objects.equals(list, that.list);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), totalCount, count, list);
}
@Override
public String toString() {
return "ListResult{totalCount=" + totalCount + ", count=" + count + ", " + super.toString() + '}';
......
......@@ -65,6 +65,10 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
......
......@@ -14,10 +14,10 @@ public class ComponentApplication {
private static final Logger log = LoggerFactory.getLogger(ComponentApplication.class);
public static void main(String[] args) throws Exception {
public static void main(String[] args) {
final ApplicationContext context = SpringApplication.run(ComponentApplication.class, args);
log.info("Starting up");
log.info("Starting up, ApplicationName: {}", context.getApplicationName());
//TODO main method
}
}
......@@ -89,6 +89,10 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
......
......@@ -12,7 +12,7 @@ spring:
native:
searchLocations: classpath:/shared
profiles:
active: native
active: native
security:
user:
username: user
......
......@@ -17,6 +17,10 @@
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
......
......@@ -17,6 +17,10 @@
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
......
......@@ -17,6 +17,10 @@
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
......
......@@ -17,6 +17,10 @@
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>ump-mattermostio</artifactId>
<version>0.1.0</version>
<packaging>jar</packaging>
<name>UMP Mattermost IO</name>
<description>UMP Mattermost IO</description>
<parent>
<groupId>com.asvoip.ump</groupId>
<artifactId>ump</artifactId>
<version>0.1.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<properties>
<java.version>1.8</java.version>
<lombok.version>1.18.8</lombok.version>
</properties>
<dependencies>
<dependency>
<groupId>com.asvoip.ump</groupId>
<artifactId>ump-commonmodule</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot-starter-test.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-integration</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.bis5.mattermost4j</groupId>
<artifactId>mattermost4j-core</artifactId>
<version>0.16.0</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.asvoip.ump.mattermostio;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
/**
* Main class - MattermostIOApplication.
*/
@SpringBootApplication
public class MattermostIOApplication {
private static final Logger log = LoggerFactory.getLogger(MattermostIOApplication.class);
public static void main(String[] args) {
final ApplicationContext context = SpringApplication.run(MattermostIOApplication.class, args);
log.info("Starting up, ApplicationName: {}", context.getApplicationName());
}
}
package com.asvoip.ump.mattermostio.service;
import net.bis5.mattermost.client4.ApiResponse;
public interface IncomingWebhookClientService {
ApiResponse<Boolean> postByIncomingWebhook(String text);
ApiResponse<Boolean> postByIncomingWebhook(String[] texts);
}
package com.asvoip.ump.mattermostio.service;
import net.bis5.mattermost.client4.ApiResponse;
import net.bis5.mattermost.model.Post;
public interface MattermostClientService {
ApiResponse<Post> createPost(String message);
}
package com.asvoip.ump.mattermostio.service.impl;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.asvoip.ump.mattermostio.service.IncomingWebhookClientService;
import net.bis5.mattermost.client4.ApiResponse;
import net.bis5.mattermost.client4.hook.IncomingWebhookClient;
import net.bis5.mattermost.model.IncomingWebhookRequest;
import net.bis5.mattermost.model.SlackAttachment;
@Service
public class IncomingWebhookClientServiceImpl implements IncomingWebhookClientService {
private static final Logger log = LoggerFactory.getLogger(IncomingWebhookClientServiceImpl.class);
@Value("${mattermost.incoming.webhook.url}")
private String hookUrl;
@Value("${mattermost.channel.name}")
private String channelName;
private IncomingWebhookClient incomingWebhookClient;
@PostConstruct
public void init() {
incomingWebhookClient = new IncomingWebhookClient(hookUrl);
}
@Override
public ApiResponse<Boolean> postByIncomingWebhook(String text) {
IncomingWebhookRequest request = new IncomingWebhookRequest();
request.setChannel(channelName);
request.setText(text);
ApiResponse<Boolean> response = incomingWebhookClient.postByIncomingWebhook(request);
log.info("postByIncomingWebhook text:{}, response: {}", text, response);
return response;
}
@Override
public ApiResponse<Boolean> postByIncomingWebhook(String[] texts) {
IncomingWebhookRequest request = new IncomingWebhookRequest();
request.setChannel(channelName);
List<SlackAttachment> attachments = new ArrayList<>(texts.length);
for (String text : texts) {
SlackAttachment attachment = new SlackAttachment();
attachment.setText(text);
attachments.add(attachment);
}
request.setAttachments(attachments);
ApiResponse<Boolean> response = incomingWebhookClient.postByIncomingWebhook(request);
log.info("postByIncomingWebhook texts:{}, response: {}", texts, response);
return response;
}
}
package com.asvoip.ump.mattermostio.service.impl;
import com.asvoip.ump.mattermostio.service.MattermostClientService;
import net.bis5.mattermost.client4.ApiResponse;
import net.bis5.mattermost.client4.MattermostClient;
import net.bis5.mattermost.model.Channel;
import net.bis5.mattermost.model.Post;
import net.bis5.mattermost.model.Team;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.logging.Level;
@Service
public class MattermostClientServiceImpl implements MattermostClientService {
private static final Logger log = LoggerFactory.getLogger(MattermostClientServiceImpl.class);
@Value("${mattermost.server.url}")
private String url;
@Value("${mattermost.server.token}")
private String token;
@Value("${mattermost.team.name}")
private String teamName;
@Value("${mattermost.channel.name}")
private String channelName;
private MattermostClient mattermostClient;