diff --git a/build.sh b/build.sh index 6a18d98ecec05885651675049490ca44c990ec7f..ef4f10565705b3eb3d0fae54b60de23671f356bf 100755 --- a/build.sh +++ b/build.sh @@ -26,7 +26,7 @@ else DOCKER="sudo docker" fi -IMAGE="kfilippopolitis/portal-backend" +IMAGE="hbpmip/portal-backend" VCS_REF=$(git describe --tags --dirty) VERSION=$(git describe --tags --dirty) diff --git a/src/main/java/eu/hbp/mip/configuration/SecurityConfiguration.java b/src/main/java/eu/hbp/mip/configuration/SecurityConfiguration.java index 90d05b9d3254d1f36989a533923a6d5961d56549..7836edf941914247a7a86d41d63108bfb33d3316 100644 --- a/src/main/java/eu/hbp/mip/configuration/SecurityConfiguration.java +++ b/src/main/java/eu/hbp/mip/configuration/SecurityConfiguration.java @@ -274,7 +274,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { public void logout() { // POSTã™ã‚‹ãƒªã‚¯ã‚¨ã‚¹ãƒˆãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ãƒ¼ã‚’ä½œæˆ - ActionLogging.LogAction("refresh token ", this.oauth2ClientContext.getAccessToken().getRefreshToken().getValue()); + Logging.LogAction("refresh token ", this.oauth2ClientContext.getAccessToken().getRefreshToken().getValue()); RestTemplate restTemplate = new RestTemplate(); MultiValueMap<String, String> formParams = new LinkedMultiValueMap<>(); formParams.add("client_id", hbp().getClientId()); @@ -284,7 +284,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); // ãƒªã‚¯ã‚¨ã‚¹ãƒˆã‚’ä½œæˆ - ActionLogging.LogAction("logoutUri is ", logoutUri); + Logging.LogAction("logoutUri is ", logoutUri); RequestEntity<MultiValueMap<String, String>> requestEntity = new RequestEntity<>(formParams, httpHeaders, HttpMethod.POST, URI.create(logoutUri)); diff --git a/src/main/java/eu/hbp/mip/controllers/AlgorithmsApi.java b/src/main/java/eu/hbp/mip/controllers/AlgorithmsApi.java index db9b7d124bf76e3cec71c9c99399a48b6544868d..8310973a308ec810853519552dc48855f494e4d7 100644 --- a/src/main/java/eu/hbp/mip/controllers/AlgorithmsApi.java +++ b/src/main/java/eu/hbp/mip/controllers/AlgorithmsApi.java @@ -13,7 +13,7 @@ import eu.hbp.mip.model.UserInfo; import eu.hbp.mip.model.galaxy.WorkflowDTO; import eu.hbp.mip.utils.CustomResourceLoader; import eu.hbp.mip.utils.HTTPUtil; -import eu.hbp.mip.utils.ActionLogging; +import eu.hbp.mip.utils.Logging; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -57,24 +57,24 @@ public class AlgorithmsApi { @ApiOperation(value = "List all algorithms", response = String.class) @RequestMapping(method = RequestMethod.GET) public ResponseEntity<List<AlgorithmDTO>> getAlgorithms() { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Executing..."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Executing..."); LinkedList<AlgorithmDTO> exaremeAlgorithms = getExaremeAlgorithms(); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Loaded " + exaremeAlgorithms.size() + " exareme algorithms"); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Loaded " + exaremeAlgorithms.size() + " exareme algorithms"); LinkedList<AlgorithmDTO> galaxyAlgorithms = getGalaxyWorkflows(); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Loaded " + galaxyAlgorithms.size() + " galaxy algorithms"); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Loaded " + galaxyAlgorithms.size() + " galaxy algorithms"); LinkedList<AlgorithmDTO> algorithms = new LinkedList<>(); if (exaremeAlgorithms != null) { algorithms.addAll(exaremeAlgorithms); } else { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Getting exareme algorithms failed and returned null"); } if (galaxyAlgorithms != null) { algorithms.addAll(galaxyAlgorithms); } else { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Getting galaxy workflows failed and returned null"); } @@ -82,7 +82,7 @@ public class AlgorithmsApi { try { disabledAlgorithms = getDisabledAlgorithms(); } catch (IOException e) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", disabledAlgorithmsCouldNotBeLoaded); } @@ -93,7 +93,7 @@ public class AlgorithmsApi { allowedAlgorithms.add(algorithm); } } - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Successfully listed " + allowedAlgorithms.size() + " algorithms"); return ResponseEntity.ok(allowedAlgorithms); } @@ -116,11 +116,11 @@ public class AlgorithmsApi { }.getType() ); } catch (IOException e) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "An exception occurred: " + e.getMessage()); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "An exception occurred: " + e.getMessage()); return null; } - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Completed, returned " + algorithms.size() + " algorithms."); return algorithms; } @@ -140,7 +140,7 @@ public class AlgorithmsApi { workflowList = new ArrayList<>(workflowsClient.getWorkflows()); } catch (Exception e) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Error when calling list galaxy workflows: " + e.getMessage()); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Error when calling list galaxy workflows: " + e.getMessage()); return null; } @@ -160,28 +160,28 @@ public class AlgorithmsApi { } else { // Something unexpected happened String msgErr = gson.toJson(response.errorBody()); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Error Response: " + msgErr); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Error Response: " + msgErr); return null; } } catch (Exception e) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "An exception occurred: " + e.getMessage()); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "An exception occurred: " + e.getMessage()); return null; } } - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Workflows fetched: " + workflows.size()); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Workflows fetched: " + workflows.size()); // Convert the workflows to algorithms LinkedList<AlgorithmDTO> algorithms = new LinkedList<>(); for (WorkflowDTO workflow : workflows) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Converting workflow: " + workflow); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Converting workflow: " + workflow); algorithms.add(workflow.convertToAlgorithmDTO()); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Converted algorithm: " + algorithms.get(algorithms.size() - 1)); } - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Completed!"); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /algorithms", "Completed!"); return algorithms; } diff --git a/src/main/java/eu/hbp/mip/controllers/ArticlesApi.java b/src/main/java/eu/hbp/mip/controllers/ArticlesApi.java index e73b2d061d45329a064e725492186a73fe7a2074..d4eb46e9f3d072255e23be8a37a4e956add16873 100644 --- a/src/main/java/eu/hbp/mip/controllers/ArticlesApi.java +++ b/src/main/java/eu/hbp/mip/controllers/ArticlesApi.java @@ -10,7 +10,7 @@ import eu.hbp.mip.model.Article; import eu.hbp.mip.model.User; import eu.hbp.mip.model.UserInfo; import eu.hbp.mip.repositories.ArticleRepository; -import eu.hbp.mip.utils.ActionLogging; +import eu.hbp.mip.utils.Logging; import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -43,7 +43,7 @@ public class ArticlesApi { ) { User user = userInfo.getUser(); Iterable<Article> articles; - ActionLogging.LogUserAction(user.getUsername(), "(GET) /articles", "Loading articles..."); + Logging.LogUserAction(user.getUsername(), "(GET) /articles", "Loading articles..."); if (own != null && own) { articles = articleRepository.findByCreatedBy(user); @@ -60,7 +60,7 @@ public class ArticlesApi { articlesSize++; } } - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /articles", "Successfully Loaded " + articlesSize + " articles"); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /articles", "Successfully Loaded " + articlesSize + " articles"); return ResponseEntity.ok(articles); } @@ -74,7 +74,7 @@ public class ArticlesApi { ) { User user = userInfo.getUser(); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /articles", "Creating article..."); + Logging.LogUserAction(user.getUsername(), "(POST) /articles", "Creating article..."); article.setCreatedAt(new Date()); if ("published".equals(article.getStatus())) { @@ -116,7 +116,7 @@ public class ArticlesApi { } articleRepository.save(article); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /articles", "Successfully created article with id : " + article.getSlug()); + Logging.LogUserAction(user.getUsername(), "(POST) /articles", "Successfully created article with id : " + article.getSlug()); return new ResponseEntity<>(HttpStatus.CREATED); } @@ -126,7 +126,7 @@ public class ArticlesApi { public ResponseEntity<Article> getAnArticle( @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug ) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /articles/{slug}", "Loading article with id : " + slug); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /articles/{slug}", "Loading article with id : " + slug); User user = userInfo.getUser(); Article article; @@ -134,7 +134,7 @@ public class ArticlesApi { if (article == null) { //LOGGER.warn("Cannot find article : " + slug); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /articles/{slug}", "Article not found"); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /articles/{slug}", "Article not found"); return ResponseEntity.badRequest().body(null); } @@ -142,7 +142,7 @@ public class ArticlesApi { return new ResponseEntity<>(HttpStatus.FORBIDDEN); } - ActionLogging.LogUserAction(user.getUsername(), "(GET) /articles/{slug}", "Successfully Loaded article with id : " + slug); + Logging.LogUserAction(user.getUsername(), "(GET) /articles/{slug}", "Successfully Loaded article with id : " + slug); return ResponseEntity.ok(article); } @@ -155,7 +155,7 @@ public class ArticlesApi { @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug, @RequestBody @ApiParam(value = "Article to update", required = true) @Valid Article article ) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(PUT) /articles/{slug}", "Updating article with id : " + slug); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(PUT) /articles/{slug}", "Updating article with id : " + slug); User user = userInfo.getUser(); @@ -185,7 +185,7 @@ public class ArticlesApi { articleRepository.save(article); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(PUT) /articles/{slug}", "Successfully pdated article with id : " + slug); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(PUT) /articles/{slug}", "Successfully pdated article with id : " + slug); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } diff --git a/src/main/java/eu/hbp/mip/controllers/ExperimentApi.java b/src/main/java/eu/hbp/mip/controllers/ExperimentApi.java index b4a7d2bbd63def24b4e48d3a08e417a0252a4749..e81d2ee5ba782718e2db98b5a4e40f35b853ef8d 100644 --- a/src/main/java/eu/hbp/mip/controllers/ExperimentApi.java +++ b/src/main/java/eu/hbp/mip/controllers/ExperimentApi.java @@ -19,7 +19,7 @@ import eu.hbp.mip.repositories.ExperimentRepository; import eu.hbp.mip.repositories.ModelRepository; import eu.hbp.mip.utils.ClaimUtils; import eu.hbp.mip.utils.HTTPUtil; -import eu.hbp.mip.utils.ActionLogging; +import eu.hbp.mip.utils.Logging; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -92,28 +92,28 @@ public class ExperimentApi { UUID experimentUuid; User user = userInfo.getUser(); - ActionLogging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}", "Loading Experiment with uuid : " + uuid); + Logging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}", "Loading Experiment with uuid : " + uuid); try { experimentUuid = UUID.fromString(uuid); } catch (IllegalArgumentException iae) { - ActionLogging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}", "Invalid Experiment UUID."); + Logging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}", "Invalid Experiment UUID."); return ResponseEntity.badRequest().body("Invalid Experiment UUID"); } experiment = experimentRepository.findOne(experimentUuid); if (experiment == null) { - ActionLogging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}", "Experiment Not found."); + Logging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}", "Experiment Not found."); return new ResponseEntity<>("Not found", HttpStatus.NOT_FOUND); } if (!experiment.isShared() && !experiment.getCreatedBy().getUsername().equals(user.getUsername())) { - ActionLogging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}", "Accessing Experiment is unauthorized."); + Logging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}", "Accessing Experiment is unauthorized."); return new ResponseEntity<>("You don't have access to the experiment.", HttpStatus.UNAUTHORIZED); } - ActionLogging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}", "Experiment was Loaded with uuid : " + uuid + "."); + Logging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}", "Experiment was Loaded with uuid : " + uuid + "."); return new ResponseEntity<>(gsonOnlyExposed.toJson(experiment.jsonify()), HttpStatus.OK); } @@ -127,7 +127,7 @@ public class ExperimentApi { String algorithmType = experimentExecutionDTO.getAlgorithms().get(0).getType(); String algorithmName = experimentExecutionDTO.getAlgorithms().get(0).getName(); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Executing " + algorithmName + " with algorithmType : " + algorithmType + "."); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Executing " + algorithmName + " with algorithmType : " + algorithmType + "."); if (authenticationIsEnabled) { // Getting the dataset from the experiment parameters @@ -140,7 +140,7 @@ public class ExperimentApi { } if (experimentDatasets == null || experimentDatasets.equals("")) { - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "A dataset should be specified to run an algorithm."); return ResponseEntity.badRequest().body("Please provide at least one dataset to run the algorithm."); } @@ -153,10 +153,10 @@ public class ExperimentApi { // Run with the appropriate engine if (algorithmType.equals("workflow")) { - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Algorithm runs on Galaxy."); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Algorithm runs on Galaxy."); return runGalaxyWorkflow(experimentExecutionDTO); } else { - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Algorithm runs on Exareme."); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Algorithm runs on Exareme."); return runExaremeAlgorithm(experimentExecutionDTO); } } @@ -170,24 +170,24 @@ public class ExperimentApi { UUID experimentUuid; User user = userInfo.getUser(); - ActionLogging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}/markAsViewed", "Marking as viewed the experiment with uuid : " + uuid + "."); + Logging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}/markAsViewed", "Marking as viewed the experiment with uuid : " + uuid + "."); try { experimentUuid = UUID.fromString(uuid); } catch (IllegalArgumentException iae) { - ActionLogging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}/markAsViewed", "Invalid Experiment UUID" + uuid + "."); + Logging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}/markAsViewed", "Invalid Experiment UUID" + uuid + "."); return ResponseEntity.badRequest().body("Invalid Experiment UUID"); } experiment = experimentRepository.findOne(experimentUuid); if (!experiment.getCreatedBy().getUsername().equals(user.getUsername())) { - ActionLogging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}/markAsViewed", "You're not the owner of this experiment"); + Logging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}/markAsViewed", "You're not the owner of this experiment"); return new ResponseEntity<>("You're not the owner of this experiment", HttpStatus.UNAUTHORIZED); } experiment.setResultsViewed(true); experimentRepository.save(experiment); - ActionLogging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}/markAsViewed", "Experiment with uuid: " + uuid + " was marked as viewed."); + Logging.LogUserAction(user.getUsername(), "(GET) /experiments/{uuid}/markAsViewed", "Experiment with uuid: " + uuid + " was marked as viewed."); return new ResponseEntity<>(gsonOnlyExposed.toJson(experiment.jsonify()), HttpStatus.OK); } @@ -197,7 +197,7 @@ public class ExperimentApi { public ResponseEntity<String> markExperimentAsShared( @ApiParam(value = "uuid", required = true) @PathVariable("uuid") String uuid) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /experiments/{uuid}/markAsShared", "Marking as shared the experiment with uuid : " + uuid + "."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /experiments/{uuid}/markAsShared", "Marking as shared the experiment with uuid : " + uuid + "."); return doMarkExperimentAsShared(uuid, true); } @@ -206,7 +206,7 @@ public class ExperimentApi { @RequestMapping(value = "/{uuid}/markAsUnshared", method = RequestMethod.GET) public ResponseEntity<String> markExperimentAsUnshared( @ApiParam(value = "uuid", required = true) @PathVariable("uuid") String uuid) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /experiments/{uuid}/markAs/Unshared", "Marking as unshared the experiment with uuid : " + uuid + "."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /experiments/{uuid}/markAs/Unshared", "Marking as unshared the experiment with uuid : " + uuid + "."); return doMarkExperimentAsShared(uuid, false); } @@ -216,10 +216,10 @@ public class ExperimentApi { public ResponseEntity<String> listExperiments( @ApiParam(value = "maxResultCount") @RequestParam int maxResultCount) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /experiments/{maxResultCount}", "Listing experiments with a maximum amount of : " + maxResultCount + "."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /experiments/{maxResultCount}", "Listing experiments with a maximum amount of : " + maxResultCount + "."); List<Experiment> expList = doListExperiments(false, null); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /experiments/{maxResultCount}", "Successfully listed experiments."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /experiments/{maxResultCount}", "Successfully listed experiments."); return new ResponseEntity<>(gsonOnlyExposed.toJson(expList), HttpStatus.OK); } @@ -229,7 +229,7 @@ public class ExperimentApi { public ResponseEntity<String> listExperiments(@ApiParam(value = "slug") @RequestParam("slug") String modelSlug, @ApiParam(value = "maxResultCount") @RequestParam("maxResultCount") int maxResultCount) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /experiments/{slug}/{maxResultCount}", "Listing experiments with a maximum amount of :" + maxResultCount + "with modelSlug : " + modelSlug + "."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /experiments/{slug}/{maxResultCount}", "Listing experiments with a maximum amount of :" + maxResultCount + "with modelSlug : " + modelSlug + "."); if (maxResultCount <= 0 || modelSlug == null || "".equals(modelSlug)) { return new ResponseEntity<>("You must provide at least a slug or a limit of result", @@ -237,16 +237,16 @@ public class ExperimentApi { } List<Experiment> expList = doListExperiments(false, null); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /experiments/{slug}/{maxResultCount}", "Successfully listed my experiments."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /experiments/{slug}/{maxResultCount}", "Successfully listed my experiments."); return new ResponseEntity<>(gsonOnlyExposed.toJson(expList), HttpStatus.OK); } @ApiOperation(value = "list my experiments", response = Experiment.class, responseContainer = "List") @RequestMapping(method = RequestMethod.GET, params = {"mine"}) public ResponseEntity<String> listMyExperiments(Authentication authentication, @ApiParam(value = "mine") @RequestParam("mine") boolean mine) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /experiments/{mine}", "Listing my experiments."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /experiments/{mine}", "Listing my experiments."); List<Experiment> expList = doListExperiments(true, null); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /experiments/{mine}", "Successfully listed my experiments."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /experiments/{mine}", "Successfully listed my experiments."); return new ResponseEntity<>(gsonOnlyExposed.toJson(expList), HttpStatus.OK); } @@ -285,7 +285,7 @@ public class ExperimentApi { } catch (IllegalArgumentException iae) { //LOGGER.trace("Invalid UUID", iae); //LOGGER.warn("An invalid Experiment UUID was received !"); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "List my experiments", "Listing my experiments."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "List my experiments", "Listing my experiments."); return ResponseEntity.badRequest().body("Invalid Experiment UUID"); } @@ -297,7 +297,7 @@ public class ExperimentApi { experiment.setShared(shared); experimentRepository.save(experiment); - ActionLogging.LogUserAction(user.getUsername(), "Experiment updated (marked as shared)", ""); + Logging.LogUserAction(user.getUsername(), "Experiment updated (marked as shared)", ""); return new ResponseEntity<>(gsonOnlyExposed.toJson(experiment.jsonify()), HttpStatus.OK); } @@ -316,26 +316,26 @@ public class ExperimentApi { experiment.setName(experimentExecutionDTO.getName()); experimentRepository.save(experiment); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " id : " + experiment.getUuid()); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " algorithms : " + experiment.getAlgorithms()); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " model : " + experiment.getModel().getSlug()); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " name : " + experiment.getName()); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " id : " + experiment.getUuid()); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " algorithms : " + experiment.getAlgorithms()); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " model : " + experiment.getModel().getSlug()); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " name : " + experiment.getName()); return experiment; } private void saveExperiment(Experiment experiment) { User user = userInfo.getUser(); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " id : " + experiment.getUuid()); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " algorithms : " + experiment.getAlgorithms()); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " model : " + experiment.getModel().getSlug()); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " name : " + experiment.getName()); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " historyId : " + experiment.getWorkflowHistoryId()); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " status : " + experiment.getWorkflowStatus()); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " id : " + experiment.getUuid()); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " algorithms : " + experiment.getAlgorithms()); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " model : " + experiment.getModel().getSlug()); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " name : " + experiment.getName()); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " historyId : " + experiment.getWorkflowHistoryId()); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " status : " + experiment.getWorkflowStatus()); experimentRepository.save(experiment); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Saved experiment"); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Saved experiment"); } private void finishExperiment(Experiment experiment) { @@ -352,11 +352,11 @@ public class ExperimentApi { * @return the response to be returned */ public ResponseEntity<String> runExaremeAlgorithm(ExperimentExecutionDTO experimentExecutionDTO) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/runAlgorithm", "Running the algorithm..."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/runAlgorithm", "Running the algorithm..."); Experiment experiment = createExperiment(experimentExecutionDTO); User user = userInfo.getUser(); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/runAlgorithm", "Created experiment with uuid :" + experiment.getUuid()); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/runAlgorithm", "Created experiment with uuid :" + experiment.getUuid()); // Run the 1st algorithm from the list String algorithmName = experimentExecutionDTO.getAlgorithms().get(0).getName(); @@ -367,30 +367,30 @@ public class ExperimentApi { String body = gson.toJson(algorithmParameters); String url = queryExaremeUrl + "/" + algorithmName; - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "url: " + url + ", body: " + body); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "url: " + url + ", body: " + body); ResponseEntity<String> response = new ResponseEntity<>(gsonOnlyExposed.toJson(experiment.jsonify()), HttpStatus.OK); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Completed, returning: " + experiment.toString()); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Starting exareme execution thread"); new Thread(() -> { // ATTENTION: Inside the Thread only LogExperimentAction should be used, not LogUserAction! - ActionLogging.LogExperimentAction(experiment.getName(), "Thread named :" + Thread.currentThread().getName() + " with id :" + Thread.currentThread().getId() + " started!"); + Logging.LogExperimentAction(experiment.getName(), "Thread named :" + Thread.currentThread().getName() + " with id :" + Thread.currentThread().getId() + " started!"); try { StringBuilder results = new StringBuilder(); int code = HTTPUtil.sendPost(url, body, results); - ActionLogging.LogExperimentAction(experiment.getName(), "Algorithm finished with code: " + code); + Logging.LogExperimentAction(experiment.getName(), "Algorithm finished with code: " + code); // Results are stored in the experiment object experiment.setResult("[" + results.toString() + "]"); experiment.setHasError(code >= 400); experiment.setHasServerError(code >= 500); } catch (Exception e) { - ActionLogging.LogExperimentAction(experiment.getName(), "There was an exception: " + e.getMessage()); + Logging.LogExperimentAction(experiment.getName(), "There was an exception: " + e.getMessage()); experiment.setHasError(true); experiment.setHasServerError(true); @@ -398,7 +398,7 @@ public class ExperimentApi { } finishExperiment(experiment); - ActionLogging.LogExperimentAction(experiment.getName(), "Finished the experiment: " + experiment.toString()); + Logging.LogExperimentAction(experiment.getName(), "Finished the experiment: " + experiment.toString()); }).start(); return response; @@ -414,10 +414,10 @@ public class ExperimentApi { * @return the response to be returned */ public ResponseEntity<String> runGalaxyWorkflow(ExperimentExecutionDTO experimentExecutionDTO) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/runAlgorithm", "Running a workflow..."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/runAlgorithm", "Running a workflow..."); Experiment experiment = createExperiment(experimentExecutionDTO); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/runAlgorithm", "Created experiment with uuid :" + experiment.getUuid()); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/runAlgorithm", "Created experiment with uuid :" + experiment.getUuid()); User user = userInfo.getUser(); @@ -447,7 +447,7 @@ public class ExperimentApi { } } if (workflow == null) { - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Could not find algorithm code: " + workflowId); return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body(new ErrorResponse("Could not find galaxy algorithm.").toString()); @@ -466,7 +466,7 @@ public class ExperimentApi { // Create the request client RetroFitGalaxyClients service = RetrofitClientInstance.getRetrofitInstance().create(RetroFitGalaxyClients.class); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Running Galaxy workflow with id: " + workflow.getId()); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Running Galaxy workflow with id: " + workflow.getId()); // Call Galaxy to run the workflow Call<PostWorkflowToGalaxyDtoResponse> call = service.postWorkflowToGalaxy(workflow.getId(), galaxyApiKey, requestBodyJson); @@ -475,7 +475,7 @@ public class ExperimentApi { if (response.code() == 200) { // Call succeeded String responseBody = gson.toJson(response.body()); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Response: " + responseBody); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Response: " + responseBody); String historyId = (String) new JSONObject(responseBody).get("history_id"); experiment.setWorkflowHistoryId(historyId); @@ -485,7 +485,7 @@ public class ExperimentApi { } else { // Something unexpected happened String msgErr = gson.toJson(response.errorBody()); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Error Response: " + msgErr); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Error Response: " + msgErr); // Values are read from streams. JSONObject jObjectError = new JSONObject(msgErr); @@ -497,7 +497,7 @@ public class ExperimentApi { } } catch (Exception e) { - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "An exception occurred: " + e.getMessage()); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "An exception occurred: " + e.getMessage()); experiment.setHasError(true); experiment.setHasServerError(true); experiment.setResult(e.getMessage()); @@ -507,7 +507,7 @@ public class ExperimentApi { // Start the process of fetching the status updateWorkflowExperiment(experiment); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Run workflow completed!"); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Run workflow completed!"); return new ResponseEntity(gsonOnlyExposed.toJson(experiment.jsonify()), HttpStatus.OK); } @@ -524,53 +524,53 @@ public class ExperimentApi { User user = userInfo.getUser(); if (experiment == null) { - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "The experiment does not exist."); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "The experiment does not exist."); return; } - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", " Experiment id : " + experiment.getUuid()); if (experiment.getWorkflowHistoryId() == null) { - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "History Id does not exist."); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "History Id does not exist."); return; } - ActionLogging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Starting Thread..."); + Logging.LogUserAction(user.getUsername(), "(POST) /experiments/runAlgorithm", "Starting Thread..."); new Thread(() -> { while (true) { // ATTENTION: Inside the Thread only LogExperimentAction should be used, not LogExperimentAction! - ActionLogging.LogExperimentAction(experiment.getName(), "Thread is running..."); + Logging.LogExperimentAction(experiment.getName(), "Thread is running..."); try { sleep(2000); } catch (InterruptedException e) { - ActionLogging.LogExperimentAction(experiment.getName(), "Sleep was disrupted: " + e.getMessage()); + Logging.LogExperimentAction(experiment.getName(), "Sleep was disrupted: " + e.getMessage()); } - ActionLogging.LogExperimentAction(experiment.getName(), "Fetching status for experiment Id: " + experiment.getUuid()); + Logging.LogExperimentAction(experiment.getName(), "Fetching status for experiment Id: " + experiment.getUuid()); String state = getWorkflowStatus(experiment.getWorkflowHistoryId(), experiment.getName()); - ActionLogging.LogExperimentAction(experiment.getName(), "State is: " + state); + Logging.LogExperimentAction(experiment.getName(), "State is: " + state); switch (state) { case "running": // Do nothing, when the experiment is created the status is set to running - ActionLogging.LogExperimentAction(experiment.getName(), "Workflow is still running."); + Logging.LogExperimentAction(experiment.getName(), "Workflow is still running."); break; case "completed": // Get only the job result that is visible List<GalaxyWorkflowResult> workflowJobsResults = getWorkflowResults(experiment); - ActionLogging.LogExperimentAction(experiment.getName(), "Results are: " + workflowJobsResults.toString()); + Logging.LogExperimentAction(experiment.getName(), "Results are: " + workflowJobsResults.toString()); boolean resultFound = false; for (GalaxyWorkflowResult jobResult : workflowJobsResults) { if (jobResult.getVisible()) { - ActionLogging.LogExperimentAction(experiment.getName(), "Visible result are: " + jobResult.getId()); + Logging.LogExperimentAction(experiment.getName(), "Visible result are: " + jobResult.getId()); String result = getWorkflowResultBody(experiment, jobResult.getId()); - ActionLogging.LogExperimentAction(experiment.getName(), "Result: " + result); + Logging.LogExperimentAction(experiment.getName(), "Result: " + result); if (result == null) { experiment.setHasError(true); experiment.setHasServerError(true); @@ -582,7 +582,7 @@ public class ExperimentApi { } if (!resultFound) { // If there is no visible result - ActionLogging.LogExperimentAction(experiment.getName(), "No visible result"); + Logging.LogExperimentAction(experiment.getName(), "No visible result"); experiment.setResult("[" + new ErrorResponse("The workflow has no visible result.").toString() + "]"); experiment.setHasError(true); experiment.setHasServerError(true); @@ -594,16 +594,16 @@ public class ExperimentApi { case "error": // Get the job result that failed workflowJobsResults = getWorkflowResults(experiment); - ActionLogging.LogExperimentAction(experiment.getName(), "Error results are: " + workflowJobsResults.toString()); + Logging.LogExperimentAction(experiment.getName(), "Error results are: " + workflowJobsResults.toString()); boolean failedJobFound = false; for (GalaxyWorkflowResult jobResult : workflowJobsResults) { if (jobResult.getState().equals("error")) { - ActionLogging.LogExperimentAction(experiment.getName(), "Failed job is: " + jobResult.getId()); + Logging.LogExperimentAction(experiment.getName(), "Failed job is: " + jobResult.getId()); String result = getWorkflowJobError(jobResult.getId(), experiment.getName()); - ActionLogging.LogExperimentAction(experiment.getName(), "Job result: " + result); + Logging.LogExperimentAction(experiment.getName(), "Job result: " + result); if (result == null) { experiment.setHasError(true); experiment.setHasServerError(true); @@ -615,7 +615,7 @@ public class ExperimentApi { } if (!failedJobFound) { // If there is no visible failed job - ActionLogging.LogExperimentAction(experiment.getName(), "No failed result"); + Logging.LogExperimentAction(experiment.getName(), "No failed result"); experiment.setResult("[" + new ErrorResponse("The workflow has no failed result.").toString() + "]"); experiment.setHasError(true); experiment.setHasServerError(true); @@ -633,7 +633,7 @@ public class ExperimentApi { // If result exists return if (experiment.getResult() != null) { - ActionLogging.LogExperimentAction(experiment.getName(), "Result exists: " + experiment.getResult()); + Logging.LogExperimentAction(experiment.getName(), "Result exists: " + experiment.getResult()); return; } } @@ -650,7 +650,7 @@ public class ExperimentApi { */ public String getWorkflowStatus(String historyId, String experimentName) { // ATTENTION: This function is used from a Thread. Only LogExperimentAction should be used, not LogUserAction! - ActionLogging.LogExperimentAction(experimentName, " History Id : " + historyId); + Logging.LogExperimentAction(experimentName, " History Id : " + historyId); // Create the request client RetroFitGalaxyClients service = RetrofitClientInstance.getRetrofitInstance().create(RetroFitGalaxyClients.class); @@ -660,15 +660,15 @@ public class ExperimentApi { try { Response<Object> response = call.execute(); if (response.code() >= 400) { - ActionLogging.LogExperimentAction(experimentName, " Response code: " + Logging.LogExperimentAction(experimentName, " Response code: " + response.code() + "" + " with body: " + (response.errorBody() != null ? response.errorBody().string() : " ")); return "internalError"; } result = new Gson().toJson(response.body()); - ActionLogging.LogExperimentAction(experimentName, " Result: " + result); + Logging.LogExperimentAction(experimentName, " Result: " + result); } catch (IOException e) { - ActionLogging.LogExperimentAction(experimentName + Logging.LogExperimentAction(experimentName , " An exception happened: " + e.getMessage()); return "internalError"; } @@ -678,12 +678,12 @@ public class ExperimentApi { JSONObject resultJson = new JSONObject(result); state = resultJson.getString("state"); } catch (JSONException e) { - ActionLogging.LogExperimentAction(experimentName + Logging.LogExperimentAction(experimentName , " An exception happened: " + e.getMessage()); return "internalError"; } - ActionLogging.LogExperimentAction(experimentName, " Completed!"); + Logging.LogExperimentAction(experimentName, " Completed!"); switch (state) { case "ok": return "completed"; @@ -707,7 +707,7 @@ public class ExperimentApi { String historyId = experiment.getWorkflowHistoryId(); String experimentName = experiment.getName(); - ActionLogging.LogExperimentAction(experimentName, " historyId : " + historyId); + Logging.LogExperimentAction(experimentName, " historyId : " + historyId); RetroFitGalaxyClients service = RetrofitClientInstance.getRetrofitInstance().create(RetroFitGalaxyClients.class); Call<List<GalaxyWorkflowResult>> call = service.getWorkflowResultsFromGalaxy(historyId, galaxyApiKey); @@ -716,20 +716,20 @@ public class ExperimentApi { try { Response<List<GalaxyWorkflowResult>> response = call.execute(); if (response.code() >= 400) { - ActionLogging.LogExperimentAction(experimentName, " Response code: " + Logging.LogExperimentAction(experimentName, " Response code: " + response.code() + "" + " with body: " + (response.errorBody() != null ? response.errorBody().string() : " ")); return null; } getGalaxyWorkflowResultList = response.body(); - ActionLogging.LogExperimentAction(experimentName, " Result: " + response.body()); + Logging.LogExperimentAction(experimentName, " Result: " + response.body()); } catch (IOException e) { - ActionLogging.LogExperimentAction(experimentName + Logging.LogExperimentAction(experimentName , " An exception happened: " + e.getMessage()); return null; } - ActionLogging.LogExperimentAction(experimentName, " Completed!"); + Logging.LogExperimentAction(experimentName, " Completed!"); return getGalaxyWorkflowResultList; } @@ -744,7 +744,7 @@ public class ExperimentApi { String historyId = experiment.getWorkflowHistoryId(); String experimentName = experiment.getName(); - ActionLogging.LogExperimentAction(experimentName, " historyId : " + historyId); + Logging.LogExperimentAction(experimentName, " historyId : " + historyId); RetroFitGalaxyClients service = RetrofitClientInstance.getRetrofitInstance().create(RetroFitGalaxyClients.class); Call<Object> call = @@ -754,20 +754,20 @@ public class ExperimentApi { try { Response<Object> response = call.execute(); if (response.code() >= 400) { - ActionLogging.LogExperimentAction(experimentName, " Response code: " + Logging.LogExperimentAction(experimentName, " Response code: " + response.code() + "" + " with body: " + (response.errorBody() != null ? response.errorBody().string() : " ")); return null; } resultJson = new Gson().toJson(response.body()); - ActionLogging.LogExperimentAction(experimentName, " Result: " + resultJson); + Logging.LogExperimentAction(experimentName, " Result: " + resultJson); } catch (IOException e) { - ActionLogging.LogExperimentAction(experimentName, + Logging.LogExperimentAction(experimentName, " An exception happened: " + e.getMessage()); return null; } - ActionLogging.LogExperimentAction(experimentName, " Completed!"); + Logging.LogExperimentAction(experimentName, " Completed!"); return resultJson; } @@ -777,7 +777,7 @@ public class ExperimentApi { * @return the error that was produced or null if an error occurred */ public String getWorkflowJobError(String jobId, String experimentName) { - ActionLogging.LogExperimentAction(experimentName, " jobId : " + jobId); + Logging.LogExperimentAction(experimentName, " jobId : " + jobId); RetroFitGalaxyClients service = RetrofitClientInstance.getRetrofitInstance().create(RetroFitGalaxyClients.class); Call<Object> callError = service.getErrorMessageOfWorkflowFromGalaxy(jobId, galaxyApiKey); @@ -786,7 +786,7 @@ public class ExperimentApi { try { Response<Object> response = callError.execute(); if (response.code() >= 400) { - ActionLogging.LogExperimentAction(experimentName, "Response code: " + Logging.LogExperimentAction(experimentName, "Response code: " + response.code() + " with body: " + (response.errorBody() != null ? response.errorBody().string() : " ")); return null; } @@ -796,19 +796,19 @@ public class ExperimentApi { JsonElement jsonElement = new JsonParser().parse(jsonString); JsonObject rootObject = jsonElement.getAsJsonObject(); fullError = rootObject.get("stderr").getAsString(); - ActionLogging.LogExperimentAction(experimentName, "Error: " + fullError); + Logging.LogExperimentAction(experimentName, "Error: " + fullError); String[] arrOfStr = fullError.split("ValueError", 0); String specError = arrOfStr[arrOfStr.length - 1]; returnError = specError.substring(1); - ActionLogging.LogExperimentAction(experimentName, "Parsed Error: " + returnError); + Logging.LogExperimentAction(experimentName, "Parsed Error: " + returnError); } catch (IOException e) { - ActionLogging.LogExperimentAction(experimentName, "Exception: " + e.getMessage()); + Logging.LogExperimentAction(experimentName, "Exception: " + e.getMessage()); return null; } - ActionLogging.LogExperimentAction(experimentName, "Completed successfully!"); + Logging.LogExperimentAction(experimentName, "Completed successfully!"); return returnError; } diff --git a/src/main/java/eu/hbp/mip/controllers/FilesAPI.java b/src/main/java/eu/hbp/mip/controllers/FilesAPI.java index 34f64984c96ab584f08e354abd1d519c10cfdbb2..69e7f3ba94702ee9b5465920d3234ca4dcac0248 100644 --- a/src/main/java/eu/hbp/mip/controllers/FilesAPI.java +++ b/src/main/java/eu/hbp/mip/controllers/FilesAPI.java @@ -5,8 +5,6 @@ import eu.hbp.mip.model.UserInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; @@ -15,9 +13,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -import eu.hbp.mip.utils.ActionLogging; - -import java.time.LocalDateTime; +import eu.hbp.mip.utils.Logging; /** * Created by mirco on 08.05.17. @@ -38,10 +34,10 @@ public class FilesAPI { @ApiParam(value = "filename", required = true) @PathVariable("filename") String filename ) { User user = userInfo.getUser(); - ActionLogging.LogUserAction(user.getUsername(), "(GET) /protected/{filename:.+}", "Loading protected file with filename : " + filename); + Logging.LogUserAction(user.getUsername(), "(GET) /protected/{filename:.+}", "Loading protected file with filename : " + filename); String filepath = "/protected/" + filename; - ActionLogging.LogUserAction(user.getUsername(), "(GET) /protected/{filename:.+}" + filepath, "Downloaded protected file"); + Logging.LogUserAction(user.getUsername(), "(GET) /protected/{filename:.+}" + filepath, "Downloaded protected file"); HttpHeaders headers = new HttpHeaders(); headers.add("X-Accel-Redirect", filepath); diff --git a/src/main/java/eu/hbp/mip/controllers/MiningApi.java b/src/main/java/eu/hbp/mip/controllers/MiningApi.java index a5fc94b78f729aaaa69186f333191c04561dbcff..6a198cc0d4571c58b1ff424e590bc418893a39f1 100644 --- a/src/main/java/eu/hbp/mip/controllers/MiningApi.java +++ b/src/main/java/eu/hbp/mip/controllers/MiningApi.java @@ -4,18 +4,12 @@ import eu.hbp.mip.utils.HTTPUtil; import com.google.gson.Gson; -import eu.hbp.mip.model.Mining; -import eu.hbp.mip.model.User; import eu.hbp.mip.model.UserInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.cache.annotation.Cacheable; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; @@ -23,9 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -import eu.hbp.mip.utils.ActionLogging; - -import org.springframework.web.bind.annotation.*; +import eu.hbp.mip.utils.Logging; import java.util.*; @@ -52,7 +44,7 @@ public class MiningApi { @ApiOperation(value = "Create a histogram on Exareme", response = String.class) @RequestMapping(value = "/histograms", method = RequestMethod.POST) public ResponseEntity runExaremeHistograms(@RequestBody List<HashMap<String, String>> queryList) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /mining/histogram", "Executing histogram..."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /mining/histogram", "Executing histogram..."); String query = gson.toJson(queryList); String url = queryExaremeUrl + "/" + "MULTIPLE_HISTOGRAMS"; @@ -61,10 +53,10 @@ public class MiningApi { StringBuilder results = new StringBuilder(); int code = HTTPUtil.sendPost(url, query, results); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /mining/histogram", "Executed histogram with result :" + results.toString()); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /mining/histogram", "Executed histogram with result :" + results.toString()); return ResponseEntity.ok(gson.toJson(results.toString())); } catch (IOException e) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /mining/histogram", "Histogram algorithm was not found"); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /mining/histogram", "Histogram algorithm was not found"); return new ResponseEntity<>("Not found", HttpStatus.NOT_FOUND); } } @@ -72,7 +64,7 @@ public class MiningApi { @ApiOperation(value = "Create a descriptive statistic on Exareme", response = String.class) @RequestMapping(value = "/descriptive_stats", method = RequestMethod.POST) public ResponseEntity runExaremeDescriptiveStats(@RequestBody List<HashMap<String, String>> queryList) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/descriptive_stats", "Executing Exareme descriptive stats..."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/descriptive_stats", "Executing Exareme descriptive stats..."); String query = gson.toJson(queryList); String url = queryExaremeUrl + "/" + "DESCRIPTIVE_STATS"; @@ -80,10 +72,10 @@ public class MiningApi { try { StringBuilder results = new StringBuilder(); int code = HTTPUtil.sendPost(url, query, results); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/descriptive_stats", "Executed descriptive stats with result : " + results.toString()); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/descriptive_stats", "Executed descriptive stats with result : " + results.toString()); return ResponseEntity.ok(gson.toJson(results.toString())); } catch (IOException e) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/descriptive_stats", "Descriptive stats algorithm was not found"); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/descriptive_stats", "Descriptive stats algorithm was not found"); return new ResponseEntity<>("Not found", HttpStatus.NOT_FOUND); } } @@ -91,7 +83,7 @@ public class MiningApi { @ApiOperation(value = "Create a descriptive statistic on Exareme", response = String.class) @RequestMapping(value = "/descriptive_stats_v2", method = RequestMethod.POST) public ResponseEntity runExaremeDescriptiveStatsV2(@RequestBody List<HashMap<String, String>> queryList) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/descriptive_stats_v2", "Executing an Exareme descriptive stats v2"); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/descriptive_stats_v2", "Executing an Exareme descriptive stats v2"); String query = gson.toJson(queryList); String url = queryExaremeUrl + "/" + "DESCRIPTIVE_STATS_v2"; @@ -100,10 +92,10 @@ public class MiningApi { StringBuilder results = new StringBuilder(); int code = HTTPUtil.sendPost(url, query, results); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/descriptive_stats_v2", "Successfully executed descriptive stats v2 with results : " + results.toString()); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/descriptive_stats_v2", "Successfully executed descriptive stats v2 with results : " + results.toString()); return ResponseEntity.ok(gson.toJson(results.toString())); } catch (IOException e) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/descriptive_stats_v2", "Descriptive stats v2 algorithm was not found"); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/descriptive_stats_v2", "Descriptive stats v2 algorithm was not found"); return new ResponseEntity<>("Not found", HttpStatus.NOT_FOUND); } } @@ -111,7 +103,7 @@ public class MiningApi { @ApiOperation(value = "Check if a formula is valid", response = String.class) @RequestMapping(value = "/checkFormula", method = RequestMethod.POST) public ResponseEntity checkFormulaValidity(String formula) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/checkFormula", "Executing checkFormula ..."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /experiments/checkFormula", "Executing checkFormula ..."); return ResponseEntity.ok(""); } diff --git a/src/main/java/eu/hbp/mip/controllers/ModelsApi.java b/src/main/java/eu/hbp/mip/controllers/ModelsApi.java index 08f5199eada383a5a3553d14a4ead3a6954ef880..6f013ee336815bbb25514b37cdb764fe7710e8fd 100644 --- a/src/main/java/eu/hbp/mip/controllers/ModelsApi.java +++ b/src/main/java/eu/hbp/mip/controllers/ModelsApi.java @@ -11,13 +11,11 @@ import eu.hbp.mip.model.UserInfo; import eu.hbp.mip.model.Variable; import eu.hbp.mip.repositories.*; import io.swagger.annotations.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -import eu.hbp.mip.utils.ActionLogging; +import eu.hbp.mip.utils.Logging; import java.io.IOException; import java.util.*; @@ -54,7 +52,7 @@ public class ModelsApi { @ApiParam(value = "Only ask own models") @RequestParam(value = "own", required = false) Boolean own, @ApiParam(value = "Only ask published models") @RequestParam(value = "valid", required = false) Boolean valid ) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /models", "Loading models ..."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /models", "Loading models ..."); User user = userInfo.getUser(); @@ -81,7 +79,7 @@ public class ModelsApi { modelsList.add(m); } - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /models", "Successfully loaded " + modelsList.size() + " models."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /models", "Successfully loaded " + modelsList.size() + " models."); return ResponseEntity.ok(modelsList); } @@ -94,7 +92,7 @@ public class ModelsApi { @RequestBody @ApiParam(value = "Model to create", required = true) Model model ) { User user = userInfo.getUser(); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /models", "Creating a model"); + Logging.LogUserAction(user.getUsername(), "(POST) /models", "Creating a model"); model.setTitle(model.getConfig().getTitle().get("text")); model.setCreatedBy(user); @@ -122,7 +120,7 @@ public class ModelsApi { } modelRepository.save(model); - ActionLogging.LogUserAction(user.getUsername(), "(POST) /models", "Created model with id : " + model.getSlug() + ", model.config and model.query"); + Logging.LogUserAction(user.getUsername(), "(POST) /models", "Created model with id : " + model.getSlug() + ", model.config and model.query"); return ResponseEntity.status(HttpStatus.CREATED).body(model); } @@ -181,17 +179,17 @@ public class ModelsApi { User user = userInfo.getUser(); - ActionLogging.LogUserAction(user.getUsername(), "(GET) /models/{slug}", "Loading model with id : " + slug); + Logging.LogUserAction(user.getUsername(), "(GET) /models/{slug}", "Loading model with id : " + slug); Model model = modelRepository.findOne(slug); if (model == null) { //LOGGER.warn("Cannot find model : " + slug); - ActionLogging.LogUserAction(user.getUsername(), "(GET) /models/{slug}", "Model was not found"); + Logging.LogUserAction(user.getUsername(), "(GET) /models/{slug}", "Model was not found"); return ResponseEntity.badRequest().body(null); } if (!model.getValid() && !model.getCreatedBy().getUsername().equals(user.getUsername())) { - ActionLogging.LogUserAction(user.getUsername(), "(GET) /models/{slug}", "You are not authorized to retrieve models. "); + Logging.LogUserAction(user.getUsername(), "(GET) /models/{slug}", "You are not authorized to retrieve models. "); return new ResponseEntity<>(HttpStatus.FORBIDDEN); } @@ -199,7 +197,7 @@ public class ModelsApi { Collection<String> yAxisVarsColl = new LinkedHashSet<>(yAxisVars); model.getConfig().setyAxisVariables(new LinkedList<>(yAxisVarsColl)); - ActionLogging.LogUserAction(user.getUsername(), "(GET) /models/{slug}", "Loaded model with id : " + slug); + Logging.LogUserAction(user.getUsername(), "(GET) /models/{slug}", "Loaded model with id : " + slug); return ResponseEntity.ok(model); } @@ -212,7 +210,7 @@ public class ModelsApi { @RequestBody @ApiParam(value = "Model to update", required = true) Model model ) { User user = userInfo.getUser(); - ActionLogging.LogUserAction(user.getUsername(), "(PUT) /models/{slug}", "Updating model with id : " + slug); + Logging.LogUserAction(user.getUsername(), "(PUT) /models/{slug}", "Updating model with id : " + slug); Model oldModel = modelRepository.findOne(slug); if (!user.getUsername().equals(oldModel.getCreatedBy().getUsername())) { @@ -253,7 +251,7 @@ public class ModelsApi { datasetRepository.save(model.getDataset()); modelRepository.save(model); - ActionLogging.LogUserAction(user.getUsername(), "(PUT) /models/{slug}", "Updated model and saved/updated model.config and model.query"); + Logging.LogUserAction(user.getUsername(), "(PUT) /models/{slug}", "Updated model and saved/updated model.config and model.query"); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } diff --git a/src/main/java/eu/hbp/mip/controllers/PathologiesApi.java b/src/main/java/eu/hbp/mip/controllers/PathologiesApi.java index 0469056a81622d8a83fb60ef5afe76449fe35e5d..77916981465827ae4e0806366663a16c7ad1e70b 100644 --- a/src/main/java/eu/hbp/mip/controllers/PathologiesApi.java +++ b/src/main/java/eu/hbp/mip/controllers/PathologiesApi.java @@ -11,10 +11,9 @@ import eu.hbp.mip.model.UserInfo; import eu.hbp.mip.utils.ClaimUtils; import eu.hbp.mip.utils.CustomResourceLoader; import eu.hbp.mip.utils.InputStreamConverter; -import eu.hbp.mip.utils.ActionLogging; +import eu.hbp.mip.utils.Logging; import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.Resource; import org.springframework.http.ResponseEntity; @@ -48,7 +47,7 @@ public class PathologiesApi { @RequestMapping(name = "/pathologies", method = RequestMethod.GET) public ResponseEntity<String> getPathologies(Authentication authentication) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /pathologies", "Loading pathologies ..."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /pathologies", "Loading pathologies ..."); // Load pathologies from file Resource resource = resourceLoader.getResource("file:/opt/portal/api/pathologies.json"); @@ -57,17 +56,17 @@ public class PathologiesApi { allPathologies = gson.fromJson(InputStreamConverter.convertInputStreamToString(resource.getInputStream()), new TypeToken<List<PathologyDTO>>() { }.getType()); } catch (IOException e) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /pathologies", "Unable to load pathologies"); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /pathologies", "Unable to load pathologies"); return ResponseEntity.badRequest().body(pathologiesCouldNotBeLoaded); } // If authentication is disabled return everything if (!authenticationIsEnabled) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /pathologies", "Successfully loaded " + allPathologies.size() + " pathologies"); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /pathologies", "Successfully loaded " + allPathologies.size() + " pathologies"); return ResponseEntity.ok().body(gson.toJson(allPathologies)); } - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /pathologies", "Successfully loaded all authorized pathologies"); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /pathologies", "Successfully loaded all authorized pathologies"); return ResponseEntity.ok().body(ClaimUtils.getAuthorizedPathologies( userInfo.getUser().getUsername(), authentication.getAuthorities(), allPathologies)); } diff --git a/src/main/java/eu/hbp/mip/controllers/SecurityApi.java b/src/main/java/eu/hbp/mip/controllers/SecurityApi.java index a1eb3e8b77c27ed01933b8061400cb63b47f92db..4e412aea08da5612f47d60baafd4bac791f2fc6e 100644 --- a/src/main/java/eu/hbp/mip/controllers/SecurityApi.java +++ b/src/main/java/eu/hbp/mip/controllers/SecurityApi.java @@ -8,14 +8,13 @@ import eu.hbp.mip.configuration.SecurityConfiguration; import eu.hbp.mip.model.User; import eu.hbp.mip.model.UserInfo; import eu.hbp.mip.repositories.UserRepository; -import eu.hbp.mip.utils.ActionLogging; +import eu.hbp.mip.utils.Logging; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.security.access.AccessDeniedException; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -45,7 +44,7 @@ public class SecurityApi { public Object user(Principal principal, HttpServletResponse response) { ObjectMapper mapper = new ObjectMapper(); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /user", "Loading user : " + userInfo.getUser().getUsername()); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /user", "Loading user : " + userInfo.getUser().getUsername()); try { String userJSON = mapper.writeValueAsString(userInfo.getUser()); Cookie cookie = new Cookie("user", URLEncoder.encode(userJSON, "UTF-8")); @@ -77,7 +76,7 @@ public class SecurityApi { userRepository.save(user); } - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /user", "User has agreed on the NDA"); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(POST) /user", "User has agreed on the NDA"); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @@ -86,7 +85,7 @@ public class SecurityApi { @ConditionalOnExpression("${hbp.authentication.enabled:0}") public void noLogin(HttpServletResponse httpServletResponse) throws IOException { userInfo.setFakeAuth(true); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /user/login/hbp", "Unathorized login."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /user/login/hbp", "Unathorized login."); httpServletResponse.sendRedirect(securityConfiguration.getFrontendRedirectAfterLogin()); } @@ -114,7 +113,7 @@ public class SecurityApi { JsonObject object = new JsonObject(); object.addProperty("authorization", stringEncoded); object.addProperty("context", galaxyContext); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /user/galaxy", "Successfully Loaded galaxy information."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /user/galaxy", "Successfully Loaded galaxy information."); return ResponseEntity.ok(gson.toJson(object)); } diff --git a/src/main/java/eu/hbp/mip/controllers/StatsApi.java b/src/main/java/eu/hbp/mip/controllers/StatsApi.java index 77ef125dbfe55f201d35c5a2f67fb703b1e67ac6..8bd109e535b7c29b5dac96b68b2ba59329ca6a59 100644 --- a/src/main/java/eu/hbp/mip/controllers/StatsApi.java +++ b/src/main/java/eu/hbp/mip/controllers/StatsApi.java @@ -8,7 +8,7 @@ import eu.hbp.mip.model.GeneralStats; import eu.hbp.mip.model.UserInfo; import eu.hbp.mip.repositories.ArticleRepository; import eu.hbp.mip.repositories.UserRepository; -import eu.hbp.mip.utils.ActionLogging; +import eu.hbp.mip.utils.Logging; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -36,14 +36,14 @@ public class StatsApi { @ApiOperation(value = "Get general statistics", response = GeneralStats.class) @RequestMapping(method = RequestMethod.GET) public ResponseEntity<GeneralStats> getGeneralStatistics() { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /stats", "Loading general statistics"); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /stats", "Loading general statistics"); GeneralStats stats = new GeneralStats(); stats.setUsers(userRepository.count()); stats.setArticles(articleRepository.count()); - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /stats", "Loaded " + userRepository.count() + " user statistics and " + articleRepository.count() + " artcle statistics."); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /stats", "Loaded " + userRepository.count() + " user statistics and " + articleRepository.count() + " artcle statistics."); return ResponseEntity.ok(stats); } diff --git a/src/main/java/eu/hbp/mip/controllers/UsersApi.java b/src/main/java/eu/hbp/mip/controllers/UsersApi.java index 4dc7de343b810ebf5965498b15de447ef276f982..b791a7858e216d8ce0f8cd36610763c5c123e66a 100644 --- a/src/main/java/eu/hbp/mip/controllers/UsersApi.java +++ b/src/main/java/eu/hbp/mip/controllers/UsersApi.java @@ -7,7 +7,7 @@ package eu.hbp.mip.controllers; import eu.hbp.mip.model.User; import eu.hbp.mip.model.UserInfo; import eu.hbp.mip.repositories.UserRepository; -import eu.hbp.mip.utils.ActionLogging; +import eu.hbp.mip.utils.Logging; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -36,7 +36,7 @@ public class UsersApi { public ResponseEntity<User> getAUser( @ApiParam(value = "username", required = true) @PathVariable("username") String username ) { - ActionLogging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /users/{username}", "Loaded a user with username : " + userInfo.getUser().getUsername()); + Logging.LogUserAction(userInfo.getUser().getUsername(), "(GET) /users/{username}", "Loaded a user with username : " + userInfo.getUser().getUsername()); return ResponseEntity.ok(userRepository.findOne(username)); } diff --git a/src/main/java/eu/hbp/mip/utils/ClaimUtils.java b/src/main/java/eu/hbp/mip/utils/ClaimUtils.java index 2749a96d60f7a5a1a90ec355cc481b148de5cf67..e71d3f19083d03ae0067176b2fccfe4f06175915 100644 --- a/src/main/java/eu/hbp/mip/utils/ClaimUtils.java +++ b/src/main/java/eu/hbp/mip/utils/ClaimUtils.java @@ -27,7 +27,7 @@ public class ClaimUtils { List<String> userClaims = Arrays.asList(authorities.toString().toLowerCase() .replaceAll("[\\s+\\]\\[]", "").split(",")); - ActionLogging.LogUserAction(username, "(POST) /experiments/runAlgorithm", userClaims.toString()); + Logging.LogUserAction(username, "(POST) /experiments/runAlgorithm", userClaims.toString()); // Don't check for dataset claims if "super" claim exists allowing everything if (!userClaims.contains(ClaimUtils.allDatasetsAllowedClaim())) { @@ -35,12 +35,12 @@ public class ClaimUtils { for (String dataset : experimentDatasets.split(",")) { String datasetRole = ClaimUtils.getDatasetClaim(dataset); if (!userClaims.contains(datasetRole.toLowerCase())) { - ActionLogging.LogUserAction(username, "(POST) /experiments/runAlgorithm", + Logging.LogUserAction(username, "(POST) /experiments/runAlgorithm", "You are not allowed to use dataset: " + dataset); return false; } } - ActionLogging.LogUserAction(username, "(POST) /experiments/runAlgorithm", + Logging.LogUserAction(username, "(POST) /experiments/runAlgorithm", "User is authorized to use the datasets: " + experimentDatasets); } return true; @@ -49,13 +49,13 @@ public class ClaimUtils { public static String getAuthorizedPathologies(String username, Collection<? extends GrantedAuthority> authorities, List<PathologyDTO> allPathologies) { // --- Providing only the allowed pathologies/datasets to the user --- - ActionLogging.LogUserAction(username, + Logging.LogUserAction(username, "(GET) /pathologies", "Filter out the unauthorised datasets."); List<String> userClaims = Arrays.asList(authorities.toString().toLowerCase() .replaceAll("[\\s+\\]\\[]", "").split(",")); - ActionLogging.LogUserAction(username, + Logging.LogUserAction(username, "(GET) /pathologies", "User Claims: " + userClaims); // If the "dataset_all" claim exists then return everything @@ -68,14 +68,14 @@ public class ClaimUtils { List<PathologyDTO.PathologyDatasetDTO> userPathologyDatasets = new ArrayList<PathologyDTO.PathologyDatasetDTO>(); for (PathologyDTO.PathologyDatasetDTO dataset : curPathology.getDatasets()) { if (userClaims.contains(ClaimUtils.getDatasetClaim(dataset.getCode()))) { - ActionLogging.LogUserAction(username, "(GET) /pathologies", + Logging.LogUserAction(username, "(GET) /pathologies", "Added dataset: " + dataset.getCode()); userPathologyDatasets.add(dataset); } } if (userPathologyDatasets.size() > 0) { - ActionLogging.LogUserAction(username, "(GET) /pathologies", + Logging.LogUserAction(username, "(GET) /pathologies", "Added pathology '" + curPathology.getLabel() + "' with datasets: '" + userPathologyDatasets + "'"); diff --git a/src/main/java/eu/hbp/mip/utils/ActionLogging.java b/src/main/java/eu/hbp/mip/utils/Logging.java similarity index 92% rename from src/main/java/eu/hbp/mip/utils/ActionLogging.java rename to src/main/java/eu/hbp/mip/utils/Logging.java index 7004fb89e7d829324381954a0230acf0eda97a6c..89218110811d089c5b54b79ed5ded4bf72492a3e 100644 --- a/src/main/java/eu/hbp/mip/utils/ActionLogging.java +++ b/src/main/java/eu/hbp/mip/utils/Logging.java @@ -3,11 +3,9 @@ package eu.hbp.mip.utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.UUID; +public class Logging { -public class ActionLogging { - - private static final Logger LOGGER = LoggerFactory.getLogger(ActionLogging.class); + private static final Logger LOGGER = LoggerFactory.getLogger(Logging.class); private static Integer maxEndpointLen = 5; private static Integer maxInfoLen = 5;