diff --git a/pom.xml b/pom.xml index b64596e794adb4c824a7a6a59d932cb6e6ebaddf..0c3f8a8c2b04bbf95b26ce18c1e75b9549780ac9 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 07ab6ef291b4dcb32123e4c66f26a625e8b99261..8fc9fcbf93ffb65ad33dcda8617ebf515e0f306d 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 a4c205725b44f860118b7f8417fb14ef9f88f555..1728999c2c96e9ad3dc9625a6145964ffaa91b21 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"