Skip to content
Snippets Groups Projects
Commit 2b40e18e authored by Martin Weise's avatar Martin Weise
Browse files

Merge branch 'master' into dev

parents d8e490a2 7c493f9c
No related branches found
No related tags found
2 merge requests!81New stable release,!43Merge dev to master
Showing
with 351 additions and 132 deletions
......@@ -3,7 +3,7 @@ CREATE SEQUENCE seq_user;
CREATE TYPE gender AS ENUM ('F', 'M', 'T');
CREATE TYPE accesstype AS ENUM ('R', 'W');
CREATE TABLE md_DATA (
CREATE TABLE DATA (
ID INTEGER PRIMARY KEY DEFAULT nextval('seq_data'),
PROVENANCE TEXT,
FileEncoding TEXT,
......@@ -24,12 +24,12 @@ CREATE TABLE md_USERS (
Main_Email TEXT
);
CREATE TABLE md_CONTACTPERSON (
cUserID INTEGER PRIMARY KEY REFERENCES md_USERS(UserID),
CREATE TABLE CONTACTPERSON (
cUserID INTEGER PRIMARY KEY REFERENCES USERS(UserID),
Email TEXT
);
CREATE TABLE md_DATABASES (
CREATE TABLE DATABASES (
DBID TEXT PRIMARY KEY, -- (= DockerContainer ID)
Title VARCHAR(50),
ResourceType TEXT,
......@@ -38,11 +38,11 @@ CREATE TABLE md_DATABASES (
Publisher VARCHAR(50),
Year DATE DEFAULT CURRENT_DATE,
Open BOOLEAN DEFAULT TRUE,
Contact INTEGER REFERENCES md_CONTACTPERSON(cUserID)
Contact INTEGER REFERENCES CONTACTPERSON(cUserID)
);
CREATE TABLE md_TABLES (
tDBID TEXT REFERENCES md_DATABASES(DBID),
CREATE TABLE TABLES (
tDBID TEXT REFERENCES DATABASES(DBID),
tName VARCHAR(50),
NumCols INTEGER,
NumRows INTEGER,
......@@ -50,7 +50,7 @@ CREATE TABLE md_TABLES (
PRIMARY KEY(tDBID,tName)
);
CREATE TABLE md_COLUMNS (
CREATE TABLE COLUMNS (
cDBID TEXT NOT NULL,
tName VARCHAR(50) NOT NULL,
cName VARCHAR(50),
......@@ -105,24 +105,24 @@ CREATE TABLE md_VIEW (
PRIMARY KEY (vDBID,vName)
);
CREATE TABLE md_feed (
CREATE TABLE feed (
fDBID TEXT,
fName VARCHAR(50),
fUserId INTEGER REFERENCES md_USERS(UserID),
fDataID INTEGER REFERENCES md_DATA(ID),
FOREIGN KEY (fDBID,fName) REFERENCES md_TABLES(tDBID,tNAME),
fUserId INTEGER REFERENCES USERS(UserID),
fDataID INTEGER REFERENCES DATA(ID),
FOREIGN KEY (fDBID,fName) REFERENCES TABLES(tDBID,tNAME),
PRIMARY KEY (fDBID,fName,fUserId, fDataID)
);
CREATE TABLE md_update (
uUserID INTEGER REFERENCES md_USERS(UserID),
uDBID TEXT REFERENCES md_DATABASES(DBID),
CREATE TABLE update (
uUserID INTEGER REFERENCES USERS(UserID),
uDBID TEXT REFERENCES Databases(DBID),
PRIMARY KEY (uUserID,uDBID)
);
CREATE TABLE md_access (
aUserID INTEGER REFERENCES md_USERS(UserID),
aDBID TEXT REFERENCES md_DATABASES(DBID),
CREATE TABLE access (
aUserID INTEGER REFERENCES USERS(UserID),
aDBID TEXT REFERENCES Databases(DBID),
attime TIMESTAMP,
download BOOLEAN,
PRIMARY KEY (aUserID, aDBID)
......
......@@ -6,7 +6,7 @@ spring:
username: postgres
password: postgres
jpa:
show-sql: true
show-sql: false
database-platform: org.hibernate.dialect.PostgreSQLDialect
hibernate:
ddl-auto: update
......@@ -15,7 +15,7 @@ spring:
name: fda-container-service
cloud:
loadbalancer.ribbon.enabled: false
server.port: 9091
server.port: 9093
logging:
pattern.console: "%d %highlight(%-5level) %msg%n"
level:
......
# https://github.com/Netflix/Hystrix/issues/275
\ No newline at end of file
package at.tuwien;
import at.tuwien.entities.container.Container;
import at.tuwien.entities.container.image.ContainerImage;
import at.tuwien.entities.container.image.ContainerImageEnvironmentItem;
import org.springframework.test.context.TestPropertySource;
import java.time.Instant;
import java.util.List;
import static java.time.temporal.ChronoUnit.DAYS;
import static java.time.temporal.ChronoUnit.HOURS;
@TestPropertySource(locations = "classpath:application.properties")
public abstract class BaseIntegrationTest {
public final String IMAGE_1_REPOSITORY = "postgres";
public final String IMAGE_1_TAG = "13-alpine";
public final String IMAGE_1_HASH = "83b40f2726e5";
public final Integer IMAGE_1_PORT = 5432;
public final Instant IMAGE_1_BUILT = Instant.now().minus(40, HOURS);
public final List<ContainerImageEnvironmentItem> IMAGE_1_ENV = List.of(ContainerImageEnvironmentItem.builder()
.key("POSTGRES_USER")
.value("postgres")
.build(),
ContainerImageEnvironmentItem.builder()
.key("POSTGRES_PASSWORD")
.value("postgres")
.build());
public final String IMAGE_2_REPOSITORY = "redis";
public final String IMAGE_2_TAG = "latest";
public final String IMAGE_2_HASH = "f877e80bb9ef";
public final Integer IMAGE_2_PORT = 6379;
public final Instant IMAGE_2_BUILT = Instant.now().minus(9, DAYS);
public final List<ContainerImageEnvironmentItem> IMAGE_2_ENV = List.of(ContainerImageEnvironmentItem.builder()
.key("POSTGRES_USER")
.value("postgres")
.build(),
ContainerImageEnvironmentItem.builder()
.key("POSTGRES_PASSWORD")
.value("postgres")
.build());
public final ContainerImage IMAGE_1 = ContainerImage.builder()
.repository(IMAGE_1_REPOSITORY)
.tag(IMAGE_1_TAG)
.hash(IMAGE_1_HASH)
.compiled(IMAGE_1_BUILT)
.environment(IMAGE_1_ENV)
.defaultPort(IMAGE_1_PORT)
.build();
public final ContainerImage IMAGE_2 = ContainerImage.builder()
.repository(IMAGE_2_REPOSITORY)
.tag(IMAGE_2_TAG)
.hash(IMAGE_2_HASH)
.compiled(IMAGE_2_BUILT)
.environment(IMAGE_2_ENV)
.defaultPort(IMAGE_2_PORT)
.build();
public final Long CONTAINER_1_ID = 1L;
public final String CONTAINER_1_HASH = "deadbeef";
public final ContainerImage CONTAINER_1_IMAGE = IMAGE_1;
public final String CONTAINER_1_NAME = "u01";
public final String CONTAINER_1_DATABASE = "univie";
public final String CONTAINER_1_IP = "231.145.98.83";
public final Instant CONTAINER_1_CREATED = Instant.now().minus(1, HOURS);
public final Long CONTAINER_2_ID = 2L;
public final String CONTAINER_2_HASH = "0ff1ce";
public final ContainerImage CONTAINER_2_IMAGE = IMAGE_2;
public final String CONTAINER_2_NAME = "t01";
public final String CONTAINER_2_DATABASE = "tuw";
public final String CONTAINER_2_IP = "233.145.99.83";
public final Instant CONTAINER_2_CREATED = Instant.now().minus(1, HOURS);
public final Container CONTAINER_1 = Container.builder()
.id(CONTAINER_1_ID)
.name(CONTAINER_1_NAME)
.image(CONTAINER_1_IMAGE)
.hash(CONTAINER_1_HASH)
.containerCreated(CONTAINER_1_CREATED)
.build();
public final Container CONTAINER_2 = Container.builder()
.id(CONTAINER_2_ID)
.name(CONTAINER_2_NAME)
.image(CONTAINER_2_IMAGE)
.hash(CONTAINER_2_HASH)
.containerCreated(CONTAINER_2_CREATED)
.build();
}
......@@ -63,7 +63,7 @@ public class ImageEndpointUnitTest extends BaseUnitTest {
}
@Test
public void create_succeeds() {
public void create_succeeds() throws ImageNotFoundException {
final ImageCreateDto request = ImageCreateDto.builder()
.repository(IMAGE_1_REPOSITORY)
.tag(IMAGE_1_TAG)
......@@ -81,7 +81,7 @@ public class ImageEndpointUnitTest extends BaseUnitTest {
}
@Test
public void create_duplicate_fails() {
public void create_duplicate_fails() throws ImageNotFoundException {
final ImageCreateDto request = ImageCreateDto.builder()
.repository(IMAGE_1_REPOSITORY)
.tag(IMAGE_1_TAG)
......@@ -100,7 +100,7 @@ public class ImageEndpointUnitTest extends BaseUnitTest {
}
@Test
public void create_notExists_fails() {
public void create_notExists_fails() throws ImageNotFoundException {
final ImageCreateDto request = ImageCreateDto.builder()
.repository(IMAGE_1_REPOSITORY)
.tag(IMAGE_1_TAG)
......@@ -119,7 +119,7 @@ public class ImageEndpointUnitTest extends BaseUnitTest {
}
@Test
public void findById_succeeds() {
public void findById_succeeds() throws ImageNotFoundException {
when(imageService.getById(IMAGE_1_ID))
.thenReturn(CONTAINER_1_IMAGE);
......@@ -130,7 +130,7 @@ public class ImageEndpointUnitTest extends BaseUnitTest {
}
@Test
public void findById_notFound_fails() {
public void findById_notFound_fails() throws ImageNotFoundException {
given(imageService.getById(IMAGE_1_ID))
.willAnswer(invocation -> {
throw new ImageNotFoundException("not existing in docker hub");
......@@ -143,7 +143,7 @@ public class ImageEndpointUnitTest extends BaseUnitTest {
}
@Test
public void delete_fails() {
public void delete_fails() throws ImageNotFoundException {
doThrow(new ImageNotFoundException("not found"))
.when(imageService)
.delete(IMAGE_1_ID);
......@@ -155,7 +155,7 @@ public class ImageEndpointUnitTest extends BaseUnitTest {
}
@Test
public void update_succeeds() {
public void update_succeeds() throws ImageNotFoundException {
final ImageChangeDto request = ImageChangeDto.builder()
.defaultPort(1111)
.build();
......@@ -166,7 +166,7 @@ public class ImageEndpointUnitTest extends BaseUnitTest {
}
@Test
public void update_notFound_fails() {
public void update_notFound_fails() throws ImageNotFoundException {
final ImageChangeDto request = ImageChangeDto.builder()
.defaultPort(1111)
.environment(IMAGE_1_ENV_DTO)
......
package at.tuwien.mapper;
import com.github.dockerjava.api.command.InspectContainerResponse;
import com.github.dockerjava.api.model.ContainerNetwork;
import com.github.dockerjava.api.model.NetworkSettings;
import lombok.SneakyThrows;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import java.lang.reflect.Field;
import java.util.Map;
public abstract class BaseMappingTest {
@Configuration
@ComponentScan(basePackages = {"at.tuwien"})
public static class BaseMappingContext {
}
final String CONTAINER_ID = "deadbeef";
final String CONTAINER_NETWORK_IP = "154.234.88.15";
@SneakyThrows
final InspectContainerResponse mockInspectResponse() {
final InspectContainerResponse responseC = new InspectContainerResponse();
final Object response = responseC.getClass().getConstructor().newInstance();
final Field idField = responseC.getClass().getDeclaredField("id");
idField.setAccessible(true);
idField.set(response, CONTAINER_ID);
final Field networkSettingsField = responseC.getClass().getDeclaredField("networkSettings");
networkSettingsField.setAccessible(true);
// define the network and address
final ContainerNetwork networkC = new ContainerNetwork();
final Object network = networkC.getClass().getConstructor().newInstance();
final Field ipField = networkC.getClass().getDeclaredField("ipAddress");
ipField.setAccessible(true);
ipField.set(network, CONTAINER_NETWORK_IP);
final Map<String, ContainerNetwork> map = Map.of("fda-userdb", (ContainerNetwork) network);
// add to network settings
final NetworkSettings settingsC = new NetworkSettings();
final Object settings = settingsC.getClass().getConstructor().newInstance();
final Field networksField = settingsC.getClass().getDeclaredField("networks");
networksField.setAccessible(true);
networksField.set(settings, map);
networkSettingsField.set(response, settings);
return (InspectContainerResponse) response;
}
}
package at.tuwien.mapper;
import com.github.dockerjava.api.command.InspectContainerResponse;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@ExtendWith(SpringExtension.class)
@SpringBootTest
public class ContainerMappingTest extends BaseMappingTest {
@Test
public void inspectContainerResponseToDatabaseContainerMappingTest_succeeds() {
final InspectContainerResponse response = mockInspectResponse();
assertNotNull(response, "response must not be null");
assertEquals(CONTAINER_ID, response.getId());
assertNotNull(response.getNetworkSettings(), "networkSettings must not be null");
assertNotNull(response.getNetworkSettings().getNetworks(), "networkSettings.networks must not be null");
assertNotNull(response.getNetworkSettings().getNetworks().get("fda-userdb"), "networkSettings.networks['fda-userdb'] must not be null");
assertNotNull(response.getNetworkSettings().getNetworks().get("fda-userdb").getIpAddress(), "networkSettings.networks['fda-userdb'].ipAddress must not be null");
assertEquals(CONTAINER_NETWORK_IP, response.getNetworkSettings().getNetworks().get("fda-userdb").getIpAddress());
}
}
......@@ -4,10 +4,7 @@ import at.tuwien.BaseUnitTest;
import at.tuwien.api.container.ContainerCreateRequestDto;
import at.tuwien.api.container.ContainerStateDto;
import at.tuwien.entities.container.Container;
import at.tuwien.exception.ContainerNotFoundException;
import at.tuwien.exception.ContainerNotRunningException;
import at.tuwien.exception.ContainerStillRunningException;
import at.tuwien.exception.DockerClientException;
import at.tuwien.exception.*;
import at.tuwien.repository.ContainerRepository;
import at.tuwien.repository.ImageRepository;
import com.github.dockerjava.api.DockerClient;
......@@ -143,7 +140,7 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
}
@Test
public void getContainerState_succeeds() {
public void getContainerState_succeeds() throws DockerClientException {
/* test */
final ContainerStateDto response = containerService.getContainerState(CONTAINER_1_HASH);
......@@ -162,7 +159,7 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
}
@Test
public void create_succeeds() {
public void create_succeeds() throws DockerClientException, ImageNotFoundException {
final ContainerCreateRequestDto request = ContainerCreateRequestDto.builder()
.repository(IMAGE_1_REPOSITORY)
.tag(IMAGE_1_TAG)
......@@ -185,7 +182,7 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
}
@Test
public void change_start_succeeds() {
public void change_start_succeeds() throws DockerClientException {
dockerClient.stopContainerCmd(CONTAINER_1_HASH).exec();
/* test */
......@@ -193,7 +190,7 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
}
@Test
public void change_stop_succeeds() {
public void change_stop_succeeds() throws DockerClientException {
/* test */
containerService.stop(CONTAINER_1_ID);
......@@ -209,7 +206,7 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
}
@Test
public void remove_succeeds() {
public void remove_succeeds() throws DockerClientException {
dockerClient.stopContainerCmd(CONTAINER_1_HASH).exec();
/* test */
......
......@@ -55,7 +55,7 @@ public class ImageServiceUnitTest extends BaseUnitTest {
}
@Test
public void getById_succeeds() {
public void getById_succeeds() throws ImageNotFoundException {
when(imageRepository.findById(IMAGE_1_ID))
.thenReturn(Optional.of(IMAGE_1));
......@@ -77,7 +77,7 @@ public class ImageServiceUnitTest extends BaseUnitTest {
}
@Test
public void create_notFound_fails() {
public void create_notFound_fails() throws ImageNotFoundException {
final ImageCreateDto request = ImageCreateDto.builder()
.repository(IMAGE_1_REPOSITORY)
.tag(IMAGE_1_TAG)
......@@ -94,7 +94,7 @@ public class ImageServiceUnitTest extends BaseUnitTest {
}
@Test
public void create_duplicate_fails() {
public void create_duplicate_fails() throws ImageNotFoundException {
final ImageCreateDto request = ImageCreateDto.builder()
.repository(IMAGE_1_REPOSITORY)
.tag(IMAGE_1_TAG)
......@@ -111,7 +111,7 @@ public class ImageServiceUnitTest extends BaseUnitTest {
}
@Test
public void update_succeeds() {
public void update_succeeds() throws ImageNotFoundException {
final ImageChangeDto request = ImageChangeDto.builder()
.environment(IMAGE_1_ENV_DTO)
.defaultPort(IMAGE_1_PORT)
......@@ -143,7 +143,7 @@ public class ImageServiceUnitTest extends BaseUnitTest {
}
@Test
public void delete_succeeds() {
public void delete_succeeds() throws ImageNotFoundException {
doNothing()
.when(imageRepository)
.deleteById(IMAGE_1_ID);
......
......@@ -2,17 +2,20 @@ package at.tuwien.exception;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.server.ResponseStatusException;
@ResponseStatus(code = HttpStatus.BAD_REQUEST, reason = "Docker failed")
public class DockerClientException extends ResponseStatusException {
public class DockerClientException extends Exception {
public DockerClientException(String message) {
super(HttpStatus.BAD_REQUEST, message);
super(message);
}
public DockerClientException(String message, Throwable thr) {
super(HttpStatus.BAD_REQUEST, message, thr);
super(message, thr);
}
public DockerClientException(Throwable thr) {
super(thr);
}
}
......@@ -2,17 +2,20 @@ package at.tuwien.exception;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.server.ResponseStatusException;
@ResponseStatus(code = HttpStatus.NOT_FOUND, reason = "Image not found")
public class ImageNotFoundException extends ResponseStatusException {
public class ImageNotFoundException extends Exception {
public ImageNotFoundException(String message) {
super(HttpStatus.NOT_FOUND, message);
super(message);
}
public ImageNotFoundException(String message, Throwable thr) {
super(HttpStatus.NOT_FOUND, message, thr);
super(message, thr);
}
public ImageNotFoundException(Throwable thr) {
super(thr);
}
}
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
File added
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
......@@ -12,7 +12,6 @@ RUN mvn -fn -B dependency:go-offline > /dev/null
COPY --from=dependency /root/.m2/repository/at/tuwien /root/.m2/repository/at/tuwien
COPY ./rest-service ./rest-service
COPY ./gateway ./gateway
COPY ./services ./services
COPY ./report ./report
......
<?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>
<parent>
<artifactId>fda-database-service</artifactId>
<groupId>at.tuwien</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>gateway</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>fda-database-service-gateway</name>
<dependencies />
</project>
\ No newline at end of file
package at.tuwien.config;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
@Component
public class RestClient extends RestTemplate {
}
package at.tuwien.endpoint;
import at.tuwien.api.container.ContainerDto;
import at.tuwien.config.RestClient;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@Log4j2
@Service
public class ContainerGateway {
/** @apiNote this url is already in Eureka and NOT docker */
private static final String URL = "http://fda-container-service/api/container/";
private final RestClient restClient;
@Autowired
public ContainerGateway(RestClient restClient) {
this.restClient = restClient;
}
// public ContainerDto inspect(Long id) {
// final ResponseEntity<ContainerDto> response;
// response = restClient.exchange(URL + id, HttpMethod.GET, null, new ParameterizedTypeReference<>() {
// });
// return response.getBody();
// }
}
package at.tuwien.exception;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(code = HttpStatus.NOT_ACCEPTABLE, reason = "external service failed")
public class ExternalComponentException extends Exception {
public ExternalComponentException(String message) {
super(message);
}
public ExternalComponentException(String message, Throwable thr) {
super(message, thr);
}
public ExternalComponentException(Throwable thr) {
super(thr);
}
}
......@@ -16,7 +16,6 @@
<packaging>pom</packaging>
<modules>
<module>gateway</module>
<module>rest-service</module>
<module>services</module>
<module>report</module>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment