diff --git a/src/main/java/eu/hbp/mip/controllers/GalaxyAPI.java b/src/main/java/eu/hbp/mip/controllers/GalaxyAPI.java
index 6d9a617f317ffe3fe8d0e759e4d46f1805bdfdb5..52ccdc6658dfd87fc8be5c5495696417db97333e 100644
--- a/src/main/java/eu/hbp/mip/controllers/GalaxyAPI.java
+++ b/src/main/java/eu/hbp/mip/controllers/GalaxyAPI.java
@@ -13,7 +13,6 @@ import eu.hbp.mip.dto.ErrorResponse;
import eu.hbp.mip.dto.GetWorkflowResultsFromGalaxyDtoResponse;
import eu.hbp.mip.dto.PostWorkflowToGalaxyDtoResponse;
import eu.hbp.mip.dto.StringDtoResponse;
-import eu.hbp.mip.helpers.GenParameters;
import eu.hbp.mip.helpers.LogHelper;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
@@ -38,10 +37,10 @@ class GalaxyAPI {
private static final Logger logger = LoggerFactory.getLogger(GalaxyAPI.class);
//The galaxy URL
- private final String url = GenParameters.getGenParamInstance().getGalaxyURL();
+ private final String url = "123";
//The galaxy ApiKey
- private final String apiKey = GenParameters.getGenParamInstance().getGalaxyApiKey();
+ private final String apiKey = "123;";
/**
* Test if integration works.
@@ -64,8 +63,8 @@ class GalaxyAPI {
@ResponseStatus(value = HttpStatus.OK)
public ResponseEntity getGalaxyBasicAccessToken(@AuthenticationPrincipal UserDetails userDetails){
logger.info(LogHelper.logUser(userDetails) + "Get Galaxy Basic Access Token called");
- String username = GenParameters.getGenParamInstance().getGalaxyReverseProxyUsername();
- String password = GenParameters.getGenParamInstance().getGalaxyReverseProxyPassword();
+ String username = "admin";
+ String password = "passwrod";
String stringEncoded = Base64.getEncoder().encodeToString((username + ":" + password).getBytes());
logger.info(LogHelper.logUser(userDetails) + "Get Galaxy Basic Access Token completed");
diff --git a/src/main/java/eu/hbp/mip/controllers/MethodsApi.java b/src/main/java/eu/hbp/mip/controllers/MethodsApi.java
index f88f6795156f566b4b4e6e70288a5e4d535a67da..271ee5c2e971730993e7d867a0b20c6f5affb283 100644
--- a/src/main/java/eu/hbp/mip/controllers/MethodsApi.java
+++ b/src/main/java/eu/hbp/mip/controllers/MethodsApi.java
@@ -1,41 +1,43 @@
package eu.hbp.mip.controllers;
+import com.github.jmchilton.blend4j.galaxy.GalaxyInstance;
+import com.github.jmchilton.blend4j.galaxy.GalaxyInstanceFactory;
+import com.github.jmchilton.blend4j.galaxy.WorkflowsClient;
+import com.github.jmchilton.blend4j.galaxy.beans.Workflow;
+import com.github.jmchilton.blend4j.galaxy.beans.WorkflowDetails;
import com.google.gson.*;
+import com.sun.jersey.api.client.ClientHandlerException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
-import eu.hbp.mip.model.User;
import eu.hbp.mip.model.UserInfo;
import eu.hbp.mip.utils.HTTPUtil;
import org.springframework.beans.factory.annotation.Value;
import java.io.IOException;
-import eu.hbp.mip.utils.JWTUtil;
+import java.net.SocketException;
+import java.util.ArrayList;
+import java.util.List;
+
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import org.springframework.beans.factory.annotation.Autowired;
import eu.hbp.mip.utils.UserActionLogging;
@RestController
@RequestMapping(value = "/methods", produces = { APPLICATION_JSON_VALUE })
-@Api(value = "/methods", description = "the methods API")
+@Api(value = "/methods")
public class MethodsApi {
-
private static final Gson gson = new Gson();
@Value("#{'${services.exareme.algorithmsUrl:http://localhost:9090/mining/algorithms.json}'}")
private String exaremeAlgorithmsUrl;
- @Value("#{'${services.workflows.workflowUrl}'}")
- private String workflowUrl;
-
- @Value("#{'${services.workflows.jwtSecret}'}")
- private String jwtSecret;
+ @Value("#{'${services.galaxy.galaxyUrl}'}")
+ private String galaxyUrl;
- @Autowired
- private UserInfo userInfo;
+ @Value("#{'${services.galaxy.galaxyApiKey}'}")
+ private String galaxyApiKey;
@ApiOperation(value = "List Exareme algorithms and validations", response = String.class)
@RequestMapping(value = "/exareme", method = RequestMethod.GET)
@@ -60,16 +62,22 @@ public class MethodsApi {
UserActionLogging.LogAction("List Galaxy workflows", "");
try {
- User user = userInfo.getUser();
- String token = JWTUtil.getJWT(jwtSecret, user.getEmail());
-
- StringBuilder response = new StringBuilder();
- HTTPUtil.sendAuthorizedHTTP(workflowUrl + "/getAllWorkflowWithDetails", "", response, "GET", "Bearer " + token);
- JsonElement element = new JsonParser().parse(response.toString());
-
- return ResponseEntity.ok(gson.toJson(element));
- } catch (IOException e) {
- return ResponseEntity.status(500).body(e.getMessage());
+ final GalaxyInstance instance = GalaxyInstanceFactory.get(galaxyUrl, galaxyApiKey);
+ final WorkflowsClient workflowsClient = instance.getWorkflowsClient();
+
+ List<Workflow> workflowList = new ArrayList<>();
+ for(Workflow workflow : workflowsClient.getWorkflows()) {
+ workflowList.add(workflow);
+ }
+
+ List<WorkflowDetails> workflowDetailsList = new ArrayList<>();
+ for(Workflow workflow : workflowList){
+ workflowDetailsList.add(workflowsClient.showWorkflow(workflow.getId()));
+ }
+
+ return ResponseEntity.ok(workflowDetailsList);
+ } catch (ClientHandlerException e) {
+ return ResponseEntity.ok(new ArrayList<>());
}
}
diff --git a/src/main/java/eu/hbp/mip/controllers/retrofit/RetrofitClientInstance.java b/src/main/java/eu/hbp/mip/controllers/retrofit/RetrofitClientInstance.java
index 46328df332c40c5a756ae6e9f31c2526df22925c..b78fb2c93ed64970ea7afa34168d422fbc23a125 100644
--- a/src/main/java/eu/hbp/mip/controllers/retrofit/RetrofitClientInstance.java
+++ b/src/main/java/eu/hbp/mip/controllers/retrofit/RetrofitClientInstance.java
@@ -1,8 +1,8 @@
package eu.hbp.mip.controllers.retrofit;
-import eu.hbp.mip.helpers.GenParameters;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
+import org.springframework.beans.factory.annotation.Value;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
@@ -10,7 +10,10 @@ public class RetrofitClientInstance {
private static Retrofit retrofit;
- private static final String BASE_URL = GenParameters.getGenParamInstance().getGalaxyURL() + "/api/";
+ @Value("#{'${services.galaxy.galaxyUrl}'}")
+ private static String galaxyUrl;
+
+ private static final String BASE_URL = galaxyUrl + "/api/";
public static Retrofit getRetrofitInstance() {
if (retrofit == null) {
diff --git a/src/main/java/eu/hbp/mip/helpers/GenParameters.java b/src/main/java/eu/hbp/mip/helpers/GenParameters.java
deleted file mode 100644
index 696a90b551525794bb0a1d7b3425d95e0075d323..0000000000000000000000000000000000000000
--- a/src/main/java/eu/hbp/mip/helpers/GenParameters.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Developed by Kechagias Konstantinos.
- * Copyright (c) 2019. MIT License
- */
-
-package eu.hbp.mip.helpers;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GenParameters {
-
- private static final Logger logger = LoggerFactory.getLogger(GenParameters.class);
-
- private static GenParameters genParams;
-
- private String jwtSecret;
-
- private String jwtIssuer;
-
- private String galaxyURL;
-
- private String galaxyApiKey;
-
- private String galaxyReverseProxyUsername;
-
- private String galaxyReverseProxyPassword;
-
- private GenParameters() {
-
- }
-
- public static GenParameters getGenParamInstance() {
- if (genParams == null) {
- logger.info("->>>>>>>Reading Enviroment variables");
- genParams = new GenParameters();
-
- genParams.setJwtSecret(System.getenv("JWT_SECRET"));
- genParams.setJwtIssuer(System.getenv("JWT_ISSUER"));
- genParams.setGalaxyURL(System.getenv("GALAXY_URL"));
- genParams.setGalaxyApiKey(System.getenv("GALAXY_API_KEY"));
- genParams.setGalaxyReverseProxyUsername(System.getenv("GALAXY_REVERSE_PROXY_USERNAME"));
- genParams.setGalaxyReverseProxyPassword(System.getenv("GALAXY_REVERSE_PROXY_PASSWORD"));
-
- if (genParams.getJwtSecret() == null) {
- throw new RuntimeException("Cannot find Environment Variables");
- }
- }
- return genParams;
- }
-
- public String getJwtSecret() {
- return jwtSecret;
- }
-
- private void setJwtSecret(String jwtSecret) {
- this.jwtSecret = jwtSecret;
- }
-
- public String getJwtIssuer() {
- return jwtIssuer;
- }
-
- private void setJwtIssuer(String jwtIssuer) {
- this.jwtIssuer = jwtIssuer;
- }
-
- public String getGalaxyURL() {
- return galaxyURL;
- }
-
- private void setGalaxyURL(String galaxyURL) {
- this.galaxyURL = galaxyURL;
- }
-
- public String getGalaxyApiKey() {
- return galaxyApiKey;
- }
-
- private void setGalaxyApiKey(String galaxyApiKey) {
- this.galaxyApiKey = galaxyApiKey;
- }
-
- public String getGalaxyReverseProxyUsername() {
- return galaxyReverseProxyUsername;
- }
-
- public void setGalaxyReverseProxyUsername(String galaxyReverseProxyUsername) {
- this.galaxyReverseProxyUsername = galaxyReverseProxyUsername;
- }
-
- public String getGalaxyReverseProxyPassword() {
- return galaxyReverseProxyPassword;
- }
-
- public void setGalaxyReverseProxyPassword(String galaxyReverseProxyPassword) {
- this.galaxyReverseProxyPassword = galaxyReverseProxyPassword;
- }
-}
\ No newline at end of file