From b903356d80a314ac2bec686041877a804776fac0 Mon Sep 17 00:00:00 2001 From: "Fuentes Serna Juan Mariano (ID SIS)" <juanf@bs-mbpr28.d.ethz.ch> Date: Tue, 6 Feb 2018 12:17:22 +0100 Subject: [PATCH] SSDM-6001 - Microservice, some refactoring + basic documentation --- microservice-server/README.md | 80 +++++++++++++++++++ microservice-server/build.gradle | 2 +- .../microservices/server/startup/Main.java | 9 ++- .../{server/startup => util}/HttpClient.java | 2 +- .../store/AbstractFileServiceTest.java | 2 +- 5 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 microservice-server/README.md rename microservice-server/src/main/java/ch/ethz/sis/microservices/{server/startup => util}/HttpClient.java (97%) diff --git a/microservice-server/README.md b/microservice-server/README.md new file mode 100644 index 00000000000..404d6e820c0 --- /dev/null +++ b/microservice-server/README.md @@ -0,0 +1,80 @@ +## MICROSERVICE SERVER ## + +# Introduction # + +This project holds is supposed to be used to developed Java micro services. + +# Configuration # + +A json file with the configuration should be given during the startup as an argument, if not given the default "config.json" will be loaded (mostly used for distribution) and if not found "./conf/config.json" is loaded (mostly used for development). + +# Build # + +./gradlew distZip + +The build will be found at ./build/distributions/microservice-server.zip + +# Startup # + +Unzip the build and execute + +./bin/microservice-server + +# Main packages # + +## ch.ethz.sis.microservices.api ## +Supposed to contain only immutable DTOs annotated with lombok's @Data. + +## ch.ethz.sis.microservices.server.json ## +JSON object mapper interface and implementations. + +## ch.ethz.sis.microservices.server.logging ## +Logging interface and implementation. + +## ch.ethz.sis.microservices.server.services ## +Service interface and implementation. + +## ch.ethz.sis.microservices.server.startup ## +Main class and launcher. + +## ch.ethz.sis.microservices.util ## +Utility classes. + +# Configuration # + +The json configuration file currently have two sections. + +{ + "port" : 8080, + "services" : [] +} + +The port used by the web server and a list of Services. + +## ch.ethz.sis.microservices.server.services.store.FileInfoHandler ## + +{ + "className" : "ch.ethz.sis.microservices.server.services.store.FileInfoHandler", + "url" : "/file-information", + "parameters" : { + "openbis-url" : "http://localhost:8888/openbis/openbis/rmi-application-server-v3", + "datastore-url" : "http://localhost:8889/datastore_server/rmi-data-store-server-v3", + "services-timeout" : "10000", + "allowedExternalDMSCode" : "ADMIN-BS-MBPR28.D.ETHZ.CH-E96954A7", + "allowedContentCopyPath" : "/Users/localadmin/obis_data/" + } +} + +## ch.ethz.sis.microservices.server.services.store.DownloadHandler ## + +{ + "className" : "ch.ethz.sis.microservices.server.services.store.DownloadHandler", + "url" : "/download", + "parameters" : { + "openbis-url" : "http://localhost:8888/openbis/openbis/rmi-application-server-v3", + "datastore-url" : "http://localhost:8889/datastore_server/rmi-data-store-server-v3", + "services-timeout" : "10000", + "allowedExternalDMSCode" : "ADMIN-BS-MBPR28.D.ETHZ.CH-E96954A7", + "allowedContentCopyPath" : "/Users/localadmin/obis_data/" + } +} \ No newline at end of file diff --git a/microservice-server/build.gradle b/microservice-server/build.gradle index 102904d0663..646dd1cdbfe 100644 --- a/microservice-server/build.gradle +++ b/microservice-server/build.gradle @@ -25,7 +25,7 @@ dependencies { } -mainClassName = "ch.ethz.sis.microservices.download.server.startup.Main" +mainClassName = "ch.ethz.sis.microservices.server.startup.Main" distZip { into(project.name) { diff --git a/microservice-server/src/main/java/ch/ethz/sis/microservices/server/startup/Main.java b/microservice-server/src/main/java/ch/ethz/sis/microservices/server/startup/Main.java index 2fc922e26a4..9194cdb64d5 100644 --- a/microservice-server/src/main/java/ch/ethz/sis/microservices/server/startup/Main.java +++ b/microservice-server/src/main/java/ch/ethz/sis/microservices/server/startup/Main.java @@ -27,7 +27,14 @@ public class Main if (args.length < 1) { configFile = new File("./conf/config.json"); - logger.info("No arguments given, starting with default config file: " + (configFile.getAbsolutePath())); + if(configFile.exists()) { + logger.info("No arguments given, starting with default config file: " + (configFile.getAbsolutePath())); + } else { + configFile = new File("./config.json"); + if(configFile.exists()) { + logger.info("No arguments given, starting with default config file: " + (configFile.getAbsolutePath())); + } + } } else { configFile = new File(args[0]); diff --git a/microservice-server/src/main/java/ch/ethz/sis/microservices/server/startup/HttpClient.java b/microservice-server/src/main/java/ch/ethz/sis/microservices/util/HttpClient.java similarity index 97% rename from microservice-server/src/main/java/ch/ethz/sis/microservices/server/startup/HttpClient.java rename to microservice-server/src/main/java/ch/ethz/sis/microservices/util/HttpClient.java index ce95d4f4bb9..5e1ef57a354 100644 --- a/microservice-server/src/main/java/ch/ethz/sis/microservices/server/startup/HttpClient.java +++ b/microservice-server/src/main/java/ch/ethz/sis/microservices/util/HttpClient.java @@ -1,4 +1,4 @@ -package ch.ethz.sis.microservices.server.startup; +package ch.ethz.sis.microservices.util; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/microservice-server/src/test/java/ch/ethz/sis/microservices/server/services/store/AbstractFileServiceTest.java b/microservice-server/src/test/java/ch/ethz/sis/microservices/server/services/store/AbstractFileServiceTest.java index 3652c69da61..4dcf5b8da81 100644 --- a/microservice-server/src/test/java/ch/ethz/sis/microservices/server/services/store/AbstractFileServiceTest.java +++ b/microservice-server/src/test/java/ch/ethz/sis/microservices/server/services/store/AbstractFileServiceTest.java @@ -5,7 +5,7 @@ import java.util.Map; import ch.ethz.sis.microservices.server.logging.LogManager; import ch.ethz.sis.microservices.server.logging.log4j.Log4J2LogFactory; -import ch.ethz.sis.microservices.server.startup.HttpClient; +import ch.ethz.sis.microservices.util.HttpClient; import ch.ethz.sis.openbis.generic.asapi.v3.IApplicationServerApi; import ch.systemsx.cisd.common.spring.HttpInvokerUtils; -- GitLab