From 9b29df68c65592817312ec1e1cc0520bb4bd9b26 Mon Sep 17 00:00:00 2001
From: Martin Weise <martin.weise@tuwien.ac.at>
Date: Sun, 9 May 2021 15:55:29 +0200
Subject: [PATCH] docker compiles

---
 .gitlab-ci.yml                                |   5 ++-
 docker-compose.yml                            |  38 ++++++++---------
 .../.gitignore                                |   0
 .../.mvn/wrapper/MavenWrapperDownloader.java  |   0
 .../.mvn/wrapper/maven-wrapper.jar            | Bin
 .../.mvn/wrapper/maven-wrapper.properties     |   0
 .../Dockerfile                                |   4 +-
 .../mvnw                                      |   0
 .../mvnw.cmd                                  |   0
 .../pom.xml                                   |  26 ++++++++++--
 .../DiscoveryServerApplication.java           |   0
 .../resources/application-docker.properties   |   4 +-
 .../src/main/resources/application.properties |   2 +-
 .../src/main/resources/config.properties      |   0
 .../DiscoveryServerApplicationTests.java      |   0
 fda-gateway-service/pom.xml                   |   1 +
 fda-query-service/pom.xml                     |   1 +
 .../at/tuwien/endpoint/QueryEndpoint.java     |  26 +++++-------
 fda-table-service/pom.xml                     |  40 ++++++------------
 19 files changed, 75 insertions(+), 72 deletions(-)
 rename {fda-discovery-server => fda-discovery-service}/.gitignore (100%)
 rename {fda-discovery-server => fda-discovery-service}/.mvn/wrapper/MavenWrapperDownloader.java (100%)
 rename {fda-discovery-server => fda-discovery-service}/.mvn/wrapper/maven-wrapper.jar (100%)
 rename {fda-discovery-server => fda-discovery-service}/.mvn/wrapper/maven-wrapper.properties (100%)
 rename {fda-discovery-server => fda-discovery-service}/Dockerfile (73%)
 rename {fda-discovery-server => fda-discovery-service}/mvnw (100%)
 rename {fda-discovery-server => fda-discovery-service}/mvnw.cmd (100%)
 rename {fda-discovery-server => fda-discovery-service}/pom.xml (50%)
 rename {fda-discovery-server => fda-discovery-service}/src/main/java/at/tuwien/discoveryserver/DiscoveryServerApplication.java (100%)
 rename {fda-discovery-server => fda-discovery-service}/src/main/resources/application-docker.properties (79%)
 rename {fda-discovery-server => fda-discovery-service}/src/main/resources/application.properties (84%)
 rename {fda-discovery-server => fda-discovery-service}/src/main/resources/config.properties (100%)
 rename {fda-discovery-server => fda-discovery-service}/src/test/java/at/tuwien/discoveryserver/DiscoveryServerApplicationTests.java (100%)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ba0e47bc04..e03eeedc5c 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 d9c244566e..2c49526127 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 c93c53ada9..2bc44d90f7 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 f2848f4d32..04fe2081ba 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 3651a86d1b..bf8f244bad 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 1d094e2b45..abc64bb182 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 fa3f712cc4..3684a9d81f 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 016e0e430b..9315359136 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 277dd71b66..a95bde0d31 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 c980f2351a..4926ec294a 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>
-- 
GitLab