From 8a65e51898479dd25a0cc538d4c464e1441c72e4 Mon Sep 17 00:00:00 2001 From: kfilippopolitis <kostasfilippop@gmail.com> Date: Thu, 12 Nov 2020 07:47:14 -0800 Subject: [PATCH] Fixed dependencies that blocked the GET /algorithms. --- pom.xml | 1 - .../eu/hbp/mip/controllers/AlgorithmsApi.java | 39 +++++++++++-------- src/main/resources/application.yml | 4 +- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/pom.xml b/pom.xml index b64596e79..0c3f8a8c2 100644 --- a/pom.xml +++ b/pom.xml @@ -244,7 +244,6 @@ <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>logging-interceptor</artifactId> - <version>4.10.0-RC1</version> </dependency> <dependency> diff --git a/src/main/java/eu/hbp/mip/controllers/AlgorithmsApi.java b/src/main/java/eu/hbp/mip/controllers/AlgorithmsApi.java index 07ab6ef29..8fc9fcbf9 100644 --- a/src/main/java/eu/hbp/mip/controllers/AlgorithmsApi.java +++ b/src/main/java/eu/hbp/mip/controllers/AlgorithmsApi.java @@ -61,24 +61,26 @@ public class AlgorithmsApi { @ApiOperation(value = "List all algorithms", response = String.class) @RequestMapping(method = RequestMethod.GET) public ResponseEntity<List<AlgorithmDTO>> getAlgorithms() { - Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Executing..."); + String username = userInfo.getUser().getUsername(); + String endpoint = "(GET) /algorithms"; + Logging.LogUserAction(username, endpoint, "Executing..."); LinkedList<AlgorithmDTO> exaremeAlgorithms = getExaremeAlgorithms(); - Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Loaded " + exaremeAlgorithms.size() + " exareme algorithms"); + Logging.LogUserAction(username, endpoint, "Loaded " + exaremeAlgorithms.size() + " exareme algorithms"); LinkedList<AlgorithmDTO> galaxyAlgorithms = getGalaxyWorkflows(); - Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Loaded " + galaxyAlgorithms.size() + " galaxy algorithms"); + Logging.LogUserAction(username, endpoint, "Loaded " + galaxyAlgorithms.size() + " galaxy algorithms"); LinkedList<AlgorithmDTO> algorithms = new LinkedList<>(); if (exaremeAlgorithms != null) { algorithms.addAll(exaremeAlgorithms); } else { - Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", + Logging.LogUserAction(username, endpoint, "Getting exareme algorithms failed and returned null"); } if (galaxyAlgorithms != null) { algorithms.addAll(galaxyAlgorithms); } else { - Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", + Logging.LogUserAction(username, endpoint, "Getting galaxy workflows failed and returned null"); } @@ -86,7 +88,7 @@ public class AlgorithmsApi { try { disabledAlgorithms = getDisabledAlgorithms(); } catch (IOException e) { - Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", + Logging.LogUserAction(username, endpoint, "The disabled algorithms could not be loaded."); } @@ -97,7 +99,7 @@ public class AlgorithmsApi { allowedAlgorithms.add(algorithm); } } - Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", + Logging.LogUserAction(username, endpoint, "Successfully listed " + allowedAlgorithms.size() + " algorithms"); return ResponseEntity.ok(allowedAlgorithms); } @@ -108,6 +110,8 @@ public class AlgorithmsApi { * @return a list of AlgorithmDTOs or null if something fails */ public LinkedList<AlgorithmDTO> getExaremeAlgorithms() { + String username = userInfo.getUser().getUsername(); + String endpoint = "(GET) /algorithms"; LinkedList<AlgorithmDTO> algorithms = new LinkedList<>(); // Get exareme algorithms try { @@ -120,11 +124,11 @@ public class AlgorithmsApi { }.getType() ); } catch (IOException e) { - Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "An exception occurred: " + e.getMessage()); + Logging.LogUserAction(username, endpoint, "An exception occurred: " + e.getMessage()); return null; } - Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", + Logging.LogUserAction(username, endpoint, "Completed, returned " + algorithms.size() + " algorithms."); return algorithms; } @@ -135,7 +139,8 @@ public class AlgorithmsApi { * @return a list of AlgorithmDTOs or null if something fails */ public LinkedList<AlgorithmDTO> getGalaxyWorkflows() { - + String username = userInfo.getUser().getUsername(); + String endpoint = "(GET) /algorithms"; List<Workflow> workflowList; try { // Get all the workflows with the galaxy client @@ -144,7 +149,7 @@ public class AlgorithmsApi { workflowList = new ArrayList<>(workflowsClient.getWorkflows()); } catch (Exception e) { - Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Error when calling list galaxy workflows: " + e.getMessage()); + Logging.LogUserAction(username, endpoint, "Error when calling list galaxy workflows: " + e.getMessage()); return null; } @@ -164,28 +169,28 @@ public class AlgorithmsApi { } else { // Something unexpected happened String msgErr = gson.toJson(response.errorBody()); - Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Error Response: " + msgErr); + Logging.LogUserAction(username, endpoint, "Error Response: " + msgErr); return null; } } catch (Exception e) { - Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "An exception occurred: " + e.getMessage()); + Logging.LogUserAction(username, endpoint, "An exception occurred: " + e.getMessage()); return null; } } - Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Workflows fetched: " + workflows.size()); + Logging.LogUserAction(username, endpoint, "Workflows fetched: " + workflows.size()); // Convert the workflows to algorithms LinkedList<AlgorithmDTO> algorithms = new LinkedList<>(); for (WorkflowDTO workflow : workflows) { - Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Converting workflow: " + workflow); + Logging.LogUserAction(username, endpoint, "Converting workflow: " + workflow); algorithms.add(workflow.convertToAlgorithmDTO()); - Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", + Logging.LogUserAction(username, endpoint, "Converted algorithm: " + algorithms.get(algorithms.size() - 1)); } - Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Completed!"); + Logging.LogUserAction(username, endpoint, "Completed!"); return algorithms; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a4c205725..1728999c2 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -36,8 +36,8 @@ frontend: logging: level: - root: "DEBUG" - org: "DEBUG" + root: "ERROR" + org: "ERROR" eu: hbp: "DEBUG" -- GitLab