From f8528ae678877303b4c51d2c3a15a2e6a546cc61 Mon Sep 17 00:00:00 2001 From: djuarezgf Date: Wed, 26 Jun 2024 16:16:18 +0200 Subject: [PATCH] Added: RStudio in Coder --- CHANGELOG.md | 3 ++- .../java/de/samply/app/ProjectManagerConst.java | 5 ++++- .../de/samply/app/ProjectManagerController.java | 1 + src/main/java/de/samply/coder/CoderService.java | 14 ++++++++++---- src/main/java/de/samply/project/ProjectType.java | 3 ++- src/main/resources/email-templates.json | 4 ++-- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22e7625..00714be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [0.0.1 - 2024-06-13] +## [0.0.1 - 2024-06-26] ### Added - First version of the project - Spring Application @@ -135,3 +135,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Max time to wait focus task in minutes - Check export execution status - Coder Service +- RStudio in Coder diff --git a/src/main/java/de/samply/app/ProjectManagerConst.java b/src/main/java/de/samply/app/ProjectManagerConst.java index aa0f3cb..147a542 100644 --- a/src/main/java/de/samply/app/ProjectManagerConst.java +++ b/src/main/java/de/samply/app/ProjectManagerConst.java @@ -274,6 +274,7 @@ public class ProjectManagerConst { public final static String CODER_SESSION_TOKEN_HEADER = "Coder-Session-Token"; public final static String CODER_ENABLE_JUPYTER_LAB_PARAM_KEY = "Enable Jupyter Lab?"; + public final static String CODER_ENABLE_RSTUDIO_PARAM_KEY = "Enable RStudio?"; public final static String CODER_ENABLE_VS_CODE_SERVER_PARAM_KEY = "Enable VS Code Server?"; public final static String CODER_DOTFILES_URL_PARAM_KEY = "Your Dotfiles URL"; public final static String CODER_ENABLE_FILE_RECEIVER_PARAM_KEY = "Samply.Beam: Enable file receiver"; @@ -340,6 +341,7 @@ public class ProjectManagerConst { public final static String CODER_SESSION_TOKEN = "CODER_SESSION_TOKEN"; public final static String CODER_ENABLE_JUPYTER_LAB_PARAM_VALUE = "CODER_ENABLE_JUPYTER_LAB_PARAM_VALUE"; + public final static String CODER_ENABLE_RSTUDIO_PARAM_VALUE = "CODER_ENABLE_RSTUDIO_PARAM_VALUE"; public final static String CODER_ENABLE_VS_CODE_SERVER_PARAM_VALUE = "CODER_ENABLE_VS_CODE_SERVER_PARAM_VALUE"; public final static String CODER_DOTFILES_URL_PARAM_VALUE = "CODER_DOTFILES_URL_PARAM_VALUE"; public final static String CODER_ENABLE_FILE_RECEIVER_PARAM_VALUE = "CODER_ENABLE_FILE_RECEIVER_PARAM_VALUE"; @@ -388,7 +390,7 @@ public class ProjectManagerConst { public final static String DATASHIELD_TEMPLATES_SV = HEAD_SV + DATASHIELD_TEMPLATES + BOTTOM_SV; public final static String TOKEN_MANAGER_URL_SV = HEAD_SV + TOKEN_MANAGER_URL + BOTTOM_SV; public final static String FOCUS_PROJECT_MANAGER_ID_SV = HEAD_SV + FOCUS_PROJECT_MANAGER_ID + BOTTOM_SV; - public final static String FOCUS_TTL_SV = HEAD_SV + FOCUS_TTL + ":10s" + BOTTOM_SV; + public final static String FOCUS_TTL_SV = HEAD_SV + FOCUS_TTL + ":60s" + BOTTOM_SV; public final static String FOCUS_FAILURE_STRATEGY_BACKOFF_IN_MILLISECONDS_SV = HEAD_SV + FOCUS_FAILURE_STRATEGY_BACKOFF_IN_MILLISECONDS + ":1000" + BOTTOM_SV; public final static String FOCUS_FAILURE_STRATEGY_MAX_TRIES_SV = HEAD_SV + FOCUS_FAILURE_STRATEGY_MAX_TRIES + ":5" + BOTTOM_SV; @@ -422,6 +424,7 @@ public class ProjectManagerConst { public final static String CODER_SESSION_TOKEN_SV = HEAD_SV + CODER_SESSION_TOKEN + BOTTOM_SV; public final static String CODER_ENABLE_JUPYTER_LAB_PARAM_VALUE_SV = HEAD_SV + CODER_ENABLE_JUPYTER_LAB_PARAM_VALUE + ":1" + BOTTOM_SV; + public final static String CODER_ENABLE_RSTUDIO_PARAM_VALUE_SV = HEAD_SV + CODER_ENABLE_RSTUDIO_PARAM_VALUE + ":1" + BOTTOM_SV; public final static String CODER_ENABLE_VS_CODE_SERVER_PARAM_VALUE_SV = HEAD_SV + CODER_ENABLE_VS_CODE_SERVER_PARAM_VALUE + ":0" + BOTTOM_SV; public final static String CODER_DOTFILES_URL_PARAM_VALUE_SV = HEAD_SV + CODER_DOTFILES_URL_PARAM_VALUE + ":" + BOTTOM_SV; public final static String CODER_ENABLE_FILE_RECEIVER_PARAM_VALUE_SV = HEAD_SV + CODER_ENABLE_FILE_RECEIVER_PARAM_VALUE + ":1" + BOTTOM_SV; diff --git a/src/main/java/de/samply/app/ProjectManagerController.java b/src/main/java/de/samply/app/ProjectManagerController.java index 5aec983..46336e0 100644 --- a/src/main/java/de/samply/app/ProjectManagerController.java +++ b/src/main/java/de/samply/app/ProjectManagerController.java @@ -713,6 +713,7 @@ public ResponseEntity uploadVotum( @RoleConstraints(projectRoles = {ProjectRole.CREATOR, ProjectRole.BRIDGEHEAD_ADMIN, ProjectRole.PROJECT_MANAGER_ADMIN}) @StateConstraints(projectStates = {ProjectState.FINISHED}) + @EmailSender(templateType = EmailTemplateType.NEW_PUBLICATION, recipients = {EmailRecipientType.PROJECT_ALL}) @FrontendSiteModule(site = ProjectManagerConst.PROJECT_VIEW_SITE, module = ProjectManagerConst.PROJECT_DOCUMENTS_MODULE) @FrontendAction(action = ProjectManagerConst.ADD_PUBLICATION_URL_ACTION) @PostMapping(value = ProjectManagerConst.ADD_PUBLICATION_URL) diff --git a/src/main/java/de/samply/coder/CoderService.java b/src/main/java/de/samply/coder/CoderService.java index 9486410..f6c10f3 100644 --- a/src/main/java/de/samply/coder/CoderService.java +++ b/src/main/java/de/samply/coder/CoderService.java @@ -40,6 +40,7 @@ public class CoderService { private final String coderCreatePath; private final String coderDeletePath; private final String enableJupyterLab; + private final String enableRstudio; private final String enableVsCodeServer; private final String dotFilesUrl; private final String enableFileReceiver; @@ -54,11 +55,11 @@ public CoderService( @Value(ProjectManagerConst.ENABLE_CODER_SV) boolean coderEnabled, @Value(ProjectManagerConst.CODER_BASE_URL_SV) String coderBaseUrl, @Value(ProjectManagerConst.CODER_ORGANISATION_ID_SV) String coderOrganizationId, - @Value(ProjectManagerConst.CODER_MEMBER_ID_SV) String coderMemberId, @Value(ProjectManagerConst.CODER_TEMPLATE_VERSION_ID_SV) String coderTemplateVersionId, @Value(ProjectManagerConst.CODER_CREATE_PATH_SV) String coderCreatePath, @Value(ProjectManagerConst.CODER_DELETE_PATH_SV) String coderDeletePath, @Value(ProjectManagerConst.CODER_ENABLE_JUPYTER_LAB_PARAM_VALUE_SV) String enableJupyterLab, + @Value(ProjectManagerConst.CODER_ENABLE_RSTUDIO_PARAM_VALUE_SV) String enableRstudio, @Value(ProjectManagerConst.CODER_ENABLE_VS_CODE_SERVER_PARAM_VALUE_SV) String enableVsCodeServer, @Value(ProjectManagerConst.CODER_DOTFILES_URL_PARAM_VALUE_SV) String dotFilesUrl, @Value(ProjectManagerConst.CODER_ENABLE_FILE_RECEIVER_PARAM_VALUE_SV) String enableFileReceiver, @@ -69,12 +70,12 @@ public CoderService( this.notificationService = notificationService; this.projectRepository = projectRepository; this.enableJupyterLab = enableJupyterLab; + this.enableRstudio = enableRstudio; this.enableVsCodeServer = enableVsCodeServer; this.dotFilesUrl = dotFilesUrl; this.enableFileReceiver = enableFileReceiver; this.coderSessionToken = coderSessionToken; - Map pathVariables = Map.of(ProjectManagerConst.CODER_ORGANISATION_ID, coderOrganizationId, - ProjectManagerConst.CODER_MEMBER_ID, coderMemberId); + Map pathVariables = Map.of(ProjectManagerConst.CODER_ORGANISATION_ID, coderOrganizationId); this.coderCreatePath = replaceVariablesInPath(coderCreatePath, pathVariables); this.coderDeletePath = replaceVariablesInPath(coderDeletePath, pathVariables); @@ -119,7 +120,8 @@ public void createWorkspace(@NotNull String email, @NotNull Project project) { private Mono createWorkspace(ProjectCoder projectCoder, CreateRequestBody createRequestBody) { return this.webClient.post() - .uri(uriBuilder -> uriBuilder.path(ProjectManagerConst.CODER_API_PATH).path(coderCreatePath).build()) + .uri(uriBuilder -> uriBuilder.path(ProjectManagerConst.CODER_API_PATH).path( + replaceVariablesInPath(coderCreatePath, Map.of(ProjectManagerConst.CODER_MEMBER_ID, fetchCoderMemberId(projectCoder.getEmail())))).build()) .header(ProjectManagerConst.CODER_SESSION_TOKEN_HEADER, coderSessionToken) .contentType(MediaType.APPLICATION_JSON) .bodyValue(createRequestBody) @@ -198,6 +200,7 @@ private CreateRequestBody generateCreateRequestBody(ProjectCoder projectCoder) { private void addRichParameterValues(CreateRequestBody createRequestBody, ProjectCoder projectCoder) { List createRequestParameters = List.of( + new CreateRequestParameter(ProjectManagerConst.CODER_ENABLE_RSTUDIO_PARAM_KEY, enableRstudio), new CreateRequestParameter(ProjectManagerConst.CODER_ENABLE_JUPYTER_LAB_PARAM_KEY, enableJupyterLab), new CreateRequestParameter(ProjectManagerConst.CODER_ENABLE_VS_CODE_SERVER_PARAM_KEY, enableVsCodeServer), new CreateRequestParameter(ProjectManagerConst.CODER_DOTFILES_URL_PARAM_KEY, dotFilesUrl), @@ -216,4 +219,7 @@ private String generateAppSecret() { return UUID.randomUUID().toString(); } + private String fetchCoderMemberId(@NotNull String email) { + return email.substring(0, email.indexOf("@")).replace(".", ""); + } } diff --git a/src/main/java/de/samply/project/ProjectType.java b/src/main/java/de/samply/project/ProjectType.java index 2fb31c9..d7e8362 100644 --- a/src/main/java/de/samply/project/ProjectType.java +++ b/src/main/java/de/samply/project/ProjectType.java @@ -3,5 +3,6 @@ public enum ProjectType { EXPORT, DATASHIELD - //DATA_SCIENCE_ORCHESTRATOR //TODO: Data Science Orchestrator + //, + //RESEARCH_ENVIRONMENT } diff --git a/src/main/resources/email-templates.json b/src/main/resources/email-templates.json index 7af3565..f67ec8a 100644 --- a/src/main/resources/email-templates.json +++ b/src/main/resources/email-templates.json @@ -66,13 +66,13 @@ "RESULTS_ACCEPTED": { "subject": "Results accepted", "files": { - "DEFAULT": "default-admin-results-accepted.html" + "DEFAULT": "default-results-accepted.html" } }, "RESULTS_REJECTED": { "subject": "Results rejected", "files": { - "DEFAULT": "default-admin-results-rejected.html" + "DEFAULT": "default-results-rejected.html" } }, "REQUEST_CHANGES_IN_PROJECT": {