diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ba0e47bc045da7e0a05280341866c2331afc8c18..e03eeedc5c02253b2e73bc34669b0c54cf0ce3b0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,10 +18,11 @@ stages: test-backend: script: - "mvn -f fda-container-service/pom.xml clean test" - - "mvn -f fda-table-service/pom.xml clean test" - "mvn -f fda-database-service/pom.xml clean test" - - "mvn -f fda-discovery-server/pom.xml clean test" + - "mvn -f fda-discovery-service/pom.xml clean test" + - "mvn -f fda-gateway-service/pom.xml clean test" - "mvn -f fda-query-service/pom.xml clean test" + - "mvn -f fda-table-service/pom.xml clean test" stage: test test-frontend: script: diff --git a/docker-compose.yml b/docker-compose.yml index d9c244566e61a6a5941a568a2500d88adf35529d..2c495261271a21f680866ab931eb48cd2ba443f9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -36,12 +36,12 @@ services: POSTGRES_PASSWORD: postgres POSTGRES_DB: fda - fda-discovery-server: + fda-discovery-service: restart: always - container_name: fda-discovery-server - hostname: fda-discovery-server - build: ./fda-discovery-server - image: fda-discovery-server + container_name: fda-discovery-service + hostname: fda-discovery-service + build: ./fda-discovery-service + image: fda-discovery-service networks: - fda-public environment: @@ -62,13 +62,13 @@ services: ports: - 9095:9095 links: - - fda-discovery-server + - fda-discovery-service - fda-database-service - fda-container-service - fda-query-service - fda-table-service depends_on: - - fda-discovery-server + - fda-discovery-service logging: driver: json-file @@ -86,11 +86,11 @@ services: ports: - 9092:9092 links: - - fda-discovery-server + - fda-discovery-service - fda-container-service - fda-metadata-db depends_on: - - fda-discovery-server + - fda-discovery-service - fda-container-service - fda-metadata-db logging: @@ -111,10 +111,10 @@ services: volumes: - /var/run/docker.sock:/var/run/docker.sock links: - - fda-discovery-server + - fda-discovery-service - fda-metadata-db depends_on: - - fda-discovery-server + - fda-discovery-service - fda-metadata-db logging: driver: json-file @@ -135,10 +135,10 @@ services: volumes: - /tmp:/tmp links: - - fda-discovery-server + - fda-discovery-service - fda-container-service depends_on: - - fda-discovery-server + - fda-discovery-service - fda-container-service logging: driver: json-file @@ -161,10 +161,10 @@ services: - /tmp:/tmp links: - fda-metadata-db - - fda-discovery-server + - fda-discovery-service depends_on: - fda-metadata-db - - fda-discovery-server + - fda-discovery-service fda-analyse-service: restart: always @@ -177,8 +177,8 @@ services: - fda-userdb command: sh -c "/wait && flask run" environment: - EUREKA_SERVER: http://fda-discovery-server:9090/eureka - WAIT_HOSTS: fda-discovery-server:9090 + EUREKA_SERVER: http://fda-discovery-service:9090/eureka + WAIT_HOSTS: fda-discovery-service:9090 WAIT_HOSTS_TIMEOUT: 600 WAIT_SLEEP_INTERVAL: 30 WAIT_HOST_CONNECT_TIMEOUT: 30 @@ -187,9 +187,9 @@ services: volumes: - /tmp:/tmp links: - - fda-discovery-server + - fda-discovery-service depends_on: - - fda-discovery-server + - fda-discovery-service logging: driver: json-file diff --git a/fda-discovery-server/.gitignore b/fda-discovery-service/.gitignore similarity index 100% rename from fda-discovery-server/.gitignore rename to fda-discovery-service/.gitignore diff --git a/fda-discovery-server/.mvn/wrapper/MavenWrapperDownloader.java b/fda-discovery-service/.mvn/wrapper/MavenWrapperDownloader.java similarity index 100% rename from fda-discovery-server/.mvn/wrapper/MavenWrapperDownloader.java rename to fda-discovery-service/.mvn/wrapper/MavenWrapperDownloader.java diff --git a/fda-discovery-server/.mvn/wrapper/maven-wrapper.jar b/fda-discovery-service/.mvn/wrapper/maven-wrapper.jar similarity index 100% rename from fda-discovery-server/.mvn/wrapper/maven-wrapper.jar rename to fda-discovery-service/.mvn/wrapper/maven-wrapper.jar diff --git a/fda-discovery-server/.mvn/wrapper/maven-wrapper.properties b/fda-discovery-service/.mvn/wrapper/maven-wrapper.properties similarity index 100% rename from fda-discovery-server/.mvn/wrapper/maven-wrapper.properties rename to fda-discovery-service/.mvn/wrapper/maven-wrapper.properties diff --git a/fda-discovery-server/Dockerfile b/fda-discovery-service/Dockerfile similarity index 73% rename from fda-discovery-server/Dockerfile rename to fda-discovery-service/Dockerfile index c93c53ada9d6eb59d155986328942842d9c67f80..2bc44d90f72701def2bcfc241922deac70569a1f 100644 --- a/fda-discovery-server/Dockerfile +++ b/fda-discovery-service/Dockerfile @@ -8,11 +8,11 @@ RUN mvn -fn -B dependency:go-offline > /dev/null COPY ./src ./src -RUN mvn -q clean package > /dev/null +RUN mvn -q clean package -DskipTests ###### SECOND STAGE ###### FROM openjdk:11-jre-slim as runtime -COPY --from=build ./target/fda-discovery-server-*.jar ./discovery.jar +COPY --from=build ./target/fda-discovery-service-*.jar ./discovery.jar ENTRYPOINT ["java", "-jar", "./discovery.jar"] \ No newline at end of file diff --git a/fda-discovery-server/mvnw b/fda-discovery-service/mvnw similarity index 100% rename from fda-discovery-server/mvnw rename to fda-discovery-service/mvnw diff --git a/fda-discovery-server/mvnw.cmd b/fda-discovery-service/mvnw.cmd similarity index 100% rename from fda-discovery-server/mvnw.cmd rename to fda-discovery-service/mvnw.cmd diff --git a/fda-discovery-server/pom.xml b/fda-discovery-service/pom.xml similarity index 50% rename from fda-discovery-server/pom.xml rename to fda-discovery-service/pom.xml index f2848f4d329c16747747e8fe06cf1d38d1e7690b..04fe2081ba2367ed9450f9cc57c478d44a50078d 100644 --- a/fda-discovery-server/pom.xml +++ b/fda-discovery-service/pom.xml @@ -7,21 +7,41 @@ <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.10.RELEASE</version> </parent> + <groupId>at.tuwien</groupId> - <artifactId>fda-discovery-server</artifactId> + <artifactId>fda-discovery-service</artifactId> <version>0.0.1-SNAPSHOT</version> - <name>fda-discovery-server</name> + <name>fda-discovery-service</name> <description>Demo project for Spring Boot</description> + <packaging>jar</packaging> + <modules /> + <properties> <java.version>11</java.version> <spring-cloud.version>3.0.1</spring-cloud.version> </properties> <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> <dependency> <groupId>org.springframework.cloud</groupId> - <artifactId>${spring-cloud.version}</artifactId> + <artifactId>spring-cloud-starter-bootstrap</artifactId> + <version>${spring-cloud.version}</version> + </dependency> + <dependency> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> + <version>${spring-cloud.version}</version> + </dependency> + <!-- Testing --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> </dependency> </dependencies> diff --git a/fda-discovery-server/src/main/java/at/tuwien/discoveryserver/DiscoveryServerApplication.java b/fda-discovery-service/src/main/java/at/tuwien/discoveryserver/DiscoveryServerApplication.java similarity index 100% rename from fda-discovery-server/src/main/java/at/tuwien/discoveryserver/DiscoveryServerApplication.java rename to fda-discovery-service/src/main/java/at/tuwien/discoveryserver/DiscoveryServerApplication.java diff --git a/fda-discovery-server/src/main/resources/application-docker.properties b/fda-discovery-service/src/main/resources/application-docker.properties similarity index 79% rename from fda-discovery-server/src/main/resources/application-docker.properties rename to fda-discovery-service/src/main/resources/application-docker.properties index 3651a86d1bc07f479f86c13c4d7f4af549538b69..bf8f244bad159abda76f94975817352d01255426 100644 --- a/fda-discovery-server/src/main/resources/application-docker.properties +++ b/fda-discovery-service/src/main/resources/application-docker.properties @@ -1,11 +1,11 @@ server.port=9090 -spring.application.name=fda-discovery-server +spring.application.name=fda-discovery-service spring.main.banner-mode=off spring.cloud.loadbalancer.ribbon.enabled=false logging.level.root=warn logging.level.at.=info logging.pattern.console=%d %highlight(%-5level): %msg%n -eureka.instance.hostname=fda-discovery-server +eureka.instance.hostname=fda-discovery-service eureka.client.register-with-eureka=false eureka.client.fetch-registry=false eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/ \ No newline at end of file diff --git a/fda-discovery-server/src/main/resources/application.properties b/fda-discovery-service/src/main/resources/application.properties similarity index 84% rename from fda-discovery-server/src/main/resources/application.properties rename to fda-discovery-service/src/main/resources/application.properties index 1d094e2b4558c4ae8cd9d765c37af945d9726e59..abc64bb1824894fe5796144032d3b50c5a9620b3 100644 --- a/fda-discovery-server/src/main/resources/application.properties +++ b/fda-discovery-service/src/main/resources/application.properties @@ -1,5 +1,5 @@ server.port=9090 -spring.application.name=fda-discovery-server +spring.application.name=fda-discovery-service eureka.client.register-with-eureka=false eureka.client.fetch-registry=false eureka.instance.hostname=localhost diff --git a/fda-discovery-server/src/main/resources/config.properties b/fda-discovery-service/src/main/resources/config.properties similarity index 100% rename from fda-discovery-server/src/main/resources/config.properties rename to fda-discovery-service/src/main/resources/config.properties diff --git a/fda-discovery-server/src/test/java/at/tuwien/discoveryserver/DiscoveryServerApplicationTests.java b/fda-discovery-service/src/test/java/at/tuwien/discoveryserver/DiscoveryServerApplicationTests.java similarity index 100% rename from fda-discovery-server/src/test/java/at/tuwien/discoveryserver/DiscoveryServerApplicationTests.java rename to fda-discovery-service/src/test/java/at/tuwien/discoveryserver/DiscoveryServerApplicationTests.java diff --git a/fda-gateway-service/pom.xml b/fda-gateway-service/pom.xml index fa3f712cc4b4ff2507fb2fe443a4d752b2a54c2c..3684a9d81f49ffeea8a02f66142e05daf2e693e7 100644 --- a/fda-gateway-service/pom.xml +++ b/fda-gateway-service/pom.xml @@ -31,6 +31,7 @@ <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-gateway</artifactId> + <version>${spring-cloud.version}</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> diff --git a/fda-query-service/pom.xml b/fda-query-service/pom.xml index 016e0e430b246b4e4dc4ea4289bc5d5a3d38e655..93153591362c51d82c014a10e471f605095ba01c 100644 --- a/fda-query-service/pom.xml +++ b/fda-query-service/pom.xml @@ -39,6 +39,7 @@ <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-bootstrap</artifactId> <version>${spring-cloud.version}</version> + </dependency> <!-- Data Source --> <dependency> diff --git a/fda-query-service/rest-service/src/main/java/at/tuwien/endpoint/QueryEndpoint.java b/fda-query-service/rest-service/src/main/java/at/tuwien/endpoint/QueryEndpoint.java index 277dd71b669238c80bd03a9d0f755834265805f3..a95bde0d31160ab9b5ca661214d4afdad1e8f819 100644 --- a/fda-query-service/rest-service/src/main/java/at/tuwien/endpoint/QueryEndpoint.java +++ b/fda-query-service/rest-service/src/main/java/at/tuwien/endpoint/QueryEndpoint.java @@ -1,7 +1,6 @@ package at.tuwien.endpoint; import at.tuwien.dto.ExecuteQueryDTO; -import at.tuwien.dto.ExecuteStatementDTO; import at.tuwien.dto.QueryDto; import at.tuwien.entity.Query; import at.tuwien.entity.QueryResult; @@ -15,6 +14,7 @@ import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -22,11 +22,8 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import java.sql.SQLSyntaxErrorException; import java.util.List; import java.util.stream.Collectors; @@ -65,9 +62,10 @@ public class QueryEndpoint { @ApiResponse(code = 404, message = "The database does not exist."), @ApiResponse(code = 405, message = "The container is not running."), @ApiResponse(code = 409, message = "The container image is not supported."),}) - public ResponseEntity create(@PathVariable Long id) throws ImageNotSupportedException, DatabaseConnectionException, DatabaseNotFoundException { + public ResponseEntity<?> create(@PathVariable Long id) throws ImageNotSupportedException, DatabaseConnectionException, DatabaseNotFoundException { queryService.create(id); - return ResponseEntity.status(HttpStatus.CREATED).build(); + return ResponseEntity.status(HttpStatus.CREATED) + .build(); } @PutMapping("/query") @@ -77,25 +75,23 @@ public class QueryEndpoint { @ApiResponse(code = 404, message = "The database does not exist."), @ApiResponse(code = 405, message = "The container is not running."), @ApiResponse(code = 409, message = "The container image is not supported."),}) - public Response modify(@PathVariable Long id, @RequestBody ExecuteQueryDTO dto) throws DatabaseNotFoundException, ImageNotSupportedException, SQLSyntaxErrorException { + public ResponseEntity<?> modify(@PathVariable Long id, @RequestBody ExecuteQueryDTO dto) throws DatabaseNotFoundException, ImageNotSupportedException, SQLSyntaxErrorException { QueryResult qr = queryService.executeStatement(id, queryMapper.queryDTOtoQuery(dto)); - return Response - .status(Response.Status.OK) - .type(MediaType.APPLICATION_JSON) + return ResponseEntity.status(HttpStatus.OK) + .contentType(MediaType.APPLICATION_JSON) .build(); } @PutMapping("/query/version/{timestamp}") @ApiOperation(value = "executes a query with a given timestamp") - @ApiResponses(value = {@ApiResponse(code = 201, message = "result of Query with Timestamp", response = Response.class)}) - public Response modify(@PathVariable Long id, @PathVariable String timestamp, @RequestBody ExecuteQueryDTO dto) throws DatabaseNotFoundException, ImageNotSupportedException, SQLSyntaxErrorException { + @ApiResponses(value = {@ApiResponse(code = 201, message = "result of Query with Timestamp")}) + public ResponseEntity<?> modify(@PathVariable Long id, @PathVariable String timestamp, @RequestBody ExecuteQueryDTO dto) throws DatabaseNotFoundException, ImageNotSupportedException, SQLSyntaxErrorException { queryService.executeStatement(id, queryMapper.queryDTOtoQuery(dto)); - return Response - .status(Response.Status.OK) - .type(MediaType.APPLICATION_JSON) + return ResponseEntity.status(HttpStatus.OK) + .contentType(MediaType.APPLICATION_JSON) .build(); } diff --git a/fda-table-service/pom.xml b/fda-table-service/pom.xml index c980f2351a3c73131a89a033dbbc3526d3a56ba2..4926ec294abb682d30f1ba41f7f58cec752fe6b6 100644 --- a/fda-table-service/pom.xml +++ b/fda-table-service/pom.xml @@ -2,27 +2,28 @@ <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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> - <packaging>pom</packaging> - <modules> - <module>rest-service</module> - <module>services</module> - <module>gateways</module> - </modules> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>2.3.4.RELEASE</version> - <relativePath/> <!-- lookup parent from repository --> + <version>2.3.10.RELEASE</version> </parent> + <groupId>at.tuwien</groupId> <artifactId>fda-table-service</artifactId> <version>0.0.1-SNAPSHOT</version> <name>fda-table-service</name> <description>Demo project for Spring Boot</description> + <packaging>pom</packaging> + <modules> + <module>rest-service</module> + <module>services</module> + <module>gateways</module> + </modules> + <properties> <java.version>11</java.version> - <spring-cloud.version>Hoxton.SR8</spring-cloud.version> + <spring-cloud.version>3.0.1</spring-cloud.version> <mapstruct.version>1.4.2.Final</mapstruct.version> <docker.version>3.2.7</docker.version> <testcontainers.version>1.15.2</testcontainers.version> @@ -41,14 +42,8 @@ </dependency> <dependency> <groupId>org.springframework.cloud</groupId> - <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> - <version>3.0.1</version> - <exclusions> - <exclusion> - <groupId>javax.ws.rs</groupId> - <artifactId>jsr311-api</artifactId> - </exclusion> - </exclusions> + <artifactId>spring-cloud-starter</artifactId> + <version>${spring-cloud.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> @@ -166,15 +161,4 @@ <version>1.0.1.RELEASE</version> </dependency> </dependencies> - <dependencyManagement> - <dependencies> - <dependency> - <groupId>org.springframework.cloud</groupId> - <artifactId>spring-cloud-dependencies</artifactId> - <version>${spring-cloud.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> </project>