diff --git a/config/application.yml b/config/application.yml index aba6d24c8361d21d4e4a899afb617ef8dbd0595a..d8a9f7180221e6812a3a1057a1e266e99da2d17f 100644 --- a/config/application.yml +++ b/config/application.yml @@ -40,7 +40,7 @@ server: timeout: 2592000 workflow: - miningUrl: http://mip.humanbrainproject.eu/services/mining - exaremeListAlgoUrl: http://hbps2.chuv.ch:9090/mining/algorithms - exaremeQueryUrl: http://hbps2.chuv.ch:9090/mining/query + listMethodsUrl: http://dockerhost:8087/list-methods + miningMipUrl: http://dockerhost:8087/mining + miningExaremeUrl: http://hbps2.chuv.ch:9090/mining/query diff --git a/config/application_hbps1.yml b/config/application_hbps1.yml new file mode 100644 index 0000000000000000000000000000000000000000..d8a9f7180221e6812a3a1057a1e266e99da2d17f --- /dev/null +++ b/config/application_hbps1.yml @@ -0,0 +1,46 @@ +# Configuration for the portal running inside a Docker container for development + +connection: + url: "jdbc:postgresql://portaldb:5432/postgres" + username: "postgres" + password: "test" + +security: + enabled: false + +hbp: + client: + clientId: 996f97c5-a3ca-460e-b18b-00df3e2be89a + clientSecret: aD0Tueb3KkNkcZqZgQbNyDWgnM95IfZ0xPCQ_6Z9dQNHXY00RIrnAD_m7sNJh1oofYSX8aHkl72MkwI0K626Ug + accessTokenUri: https://services.humanbrainproject.eu/oidc/token + userAuthorizationUri: https://services.humanbrainproject.eu/oidc/authorize + tokenName: oauth_token + authenticationScheme: query + clientAuthenticationScheme: form + # use-current-uri: false # For both production and HBPS1 deployments + # pre-established-redirect-uri: https://mip.humanbrainproject.eu/services/login/hbp # For production deployment + # pre-established-redirect-uri: http://hbps1.chuv.ch/services/login/hbp # For HBPS1 deployment + resource: + userInfoUri: https://services.humanbrainproject.eu/oidc/userinfo + +logging: + level: + org.springframework.security: DEBUG + +spring: + resources: + chain: + enabled: true + +server: + contextPath: /services + port: 8080 + use-forward-headers: true + session: + timeout: 2592000 + +workflow: + listMethodsUrl: http://dockerhost:8087/list-methods + miningMipUrl: http://dockerhost:8087/mining + miningExaremeUrl: http://hbps2.chuv.ch:9090/mining/query + diff --git a/pom.xml b/pom.xml index 265cb8ff9eb44aee1ddc040d3233f8175fcb1059..74b2de5540109d183d5eaee2295dbb75c652a856 100644 --- a/pom.xml +++ b/pom.xml @@ -68,8 +68,10 @@ <hibernate.dialect>org.hibernate.dialect.PostgreSQL82Dialect</hibernate.dialect> <schema.deploy>false</schema.deploy> <frontend.redirect>http://frontend/home</frontend.redirect> - <workflow.experimentUrl>http://hbps1.chuv.ch:8087/experiment</workflow.experimentUrl> - <workflow.listMethodsUrl>http://hbps1.chuv.ch:8087/list-methods</workflow.listMethodsUrl> + <workflow.experimentUrl>http://dockerhost:8087/experiment</workflow.experimentUrl> + <workflow.listMethodsUrl>http://dockerhost:8087/list-methods</workflow.listMethodsUrl> + <workflow.miningMipUrl>http://dockerhost:8087/mining</workflow.miningMipUrl> + <workflow.miningExaremeUrl>http://dockerhost:8087/mining/query</workflow.miningExaremeUrl> <flyway.url>${connection.url}</flyway.url> <flyway.user>${connection.username}</flyway.user> <flyway.password>${connection.password}</flyway.password> diff --git a/src/main/java/org/hbp/mip/controllers/ExperimentApi.java b/src/main/java/org/hbp/mip/controllers/ExperimentApi.java index e71ee947f6a46583f375c52e680f9c865afffd49..ed54ed0b4f3f8ecfa177ed34375f776d8131ad76 100644 --- a/src/main/java/org/hbp/mip/controllers/ExperimentApi.java +++ b/src/main/java/org/hbp/mip/controllers/ExperimentApi.java @@ -43,11 +43,11 @@ public class ExperimentApi { .excludeFieldsWithoutExposeAnnotation() .create(); - @Value("#{'${workflow.experimentUrl:http://hbps1.chuv.ch:8087/experiment}'}") + @Value("#{'${workflow.experimentUrl:http://dockerhost:8087/experiment}'}") private String experimentUrl; - @Value("#{'${workflow.listMethodsUrl:http://hbps1.chuv.ch:8087/list-methods}'}") + @Value("#{'${workflow.listMethodsUrl:http://dockerhost:8087/list-methods}'}") private String listMethodsUrl; @Autowired diff --git a/src/main/java/org/hbp/mip/controllers/MiningApi.java b/src/main/java/org/hbp/mip/controllers/MiningApi.java index 2fc2882d7ee1a9e401c02b879dcb598a1dcb9407..cc99c1fcec3772eaf3e2e438ca18e7753284331f 100644 --- a/src/main/java/org/hbp/mip/controllers/MiningApi.java +++ b/src/main/java/org/hbp/mip/controllers/MiningApi.java @@ -23,14 +23,14 @@ import java.net.UnknownHostException; @Api(value = "/mining", description = "Forward mining API") public class MiningApi { - @Value("#{'${workflow.miningUrl:http://localhost:8087/mining}'}") - private String miningUrl; + @Value("#{'${workflow.listMethodsUrl:http://hbps1.chuv.ch:8087/list-methods}'}") + private String listMethodsUrl; - @Value("#{'${workflow.exaremeListAlgoUrl:http://localhost:9090/mining/algorithms}'}") - private String exaremeListAlgoUrl; + @Value("#{'${workflow.miningMipUrl:http://hbps1.chuv.ch:8087/mining}'}") + private String miningMipUrl; - @Value("#{'${workflow.exaremeQueryUrl:http://localhost:9090/mining/query}'}") - private String exaremeQueryUrl; + @Value("#{'${workflow.miningExaremeUrl:http://hbps2.chuv.ch:9090/mining/query}'}") + private String miningExaremeQueryUrl; @ApiOperation(value = "Send a request to the workflow for data mining", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) @@ -38,26 +38,22 @@ public class MiningApi { public ResponseEntity<String> postMining( @RequestBody @ApiParam(value = "Query for the data mining", required = true) String query ) throws Exception { - try { - StringBuilder results = new StringBuilder(); - int code = sendPost(miningUrl, query, results); + // TODO : switch between sources - return new ResponseEntity<>(results.toString(), HttpStatus.valueOf(code)); - } - catch(UnknownHostException uhe) { - uhe.printStackTrace(); - return new ResponseEntity<>(HttpStatus.BAD_GATEWAY); + StringBuilder response = new StringBuilder(); + + int code = sendGet(listMethodsUrl, response); + if (code < 200 || code > 299) { + return new ResponseEntity<>(response.toString(), HttpStatus.valueOf(code)); } + + return null; } - @ApiOperation(value = "Send a request to the Exareme service to list available algorithms", response = String.class) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(path = "/exareme/algorithms", method = RequestMethod.GET) - public ResponseEntity<String> getExaremeAlgoList( - ) throws Exception { + private ResponseEntity<String> postMipMining(String query) throws Exception { try { StringBuilder results = new StringBuilder(); - int code = sendGet(exaremeListAlgoUrl, results); + int code = sendPost(miningMipUrl, query, results); return new ResponseEntity<>(results.toString(), HttpStatus.valueOf(code)); } @@ -67,18 +63,13 @@ public class MiningApi { } } - @ApiOperation(value = "Send a request to the Exareme service to run an algorithm", response = String.class) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(path = "/exareme/query/{algo}", method = RequestMethod.POST) - public ResponseEntity<String> postExaremeQuery( - @ApiParam(value = "algo", required = true) @PathVariable("algo") String algo, - @RequestBody(required = false) @ApiParam(value = "Query for the data mining") String query - ) throws Exception { + + public ResponseEntity<String> postExaremeMining(String algo, String query) throws Exception { try { /* Launch computation */ - String url = exaremeQueryUrl+"/"+algo+"/?format=true"; + String url = miningExaremeQueryUrl +"/"+algo+"/?format=true"; StringBuilder results = new StringBuilder(); int code = sendPost(url, query, results); if (code < 200 || code > 299) @@ -91,7 +82,7 @@ public class MiningApi { /* Wait for result */ - url = exaremeQueryUrl+"/"+key+"/status"; + url = miningExaremeQueryUrl +"/"+key+"/status"; double progress = 0; while (progress < 100) { @@ -107,7 +98,7 @@ public class MiningApi { /* Get result */ - url = exaremeQueryUrl+"/"+key+"/result"; + url = miningExaremeQueryUrl +"/"+key+"/result"; results = new StringBuilder(); code = sendPost(url, query, results);