Skip to content
Snippets Groups Projects
Commit 8a65e518 authored by kfilippopolitis's avatar kfilippopolitis
Browse files

Fixed dependencies that blocked the GET /algorithms.

parent 94dffcf0
No related branches found
No related tags found
1 merge request!19Feat/186 experiment refactor
......@@ -244,7 +244,6 @@
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>4.10.0-RC1</version>
</dependency>
<dependency>
......
......@@ -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;
}
......
......@@ -36,8 +36,8 @@ frontend:
logging:
level:
root: "DEBUG"
org: "DEBUG"
root: "ERROR"
org: "ERROR"
eu:
hbp: "DEBUG"
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment