From 6a743adb1b863ae3ac7794d242114754c8458d4a Mon Sep 17 00:00:00 2001 From: juarez Date: Tue, 30 Jan 2024 18:39:31 +0100 Subject: [PATCH] Added: Fetch registered bridgeheads for project manager admin --- CHANGELOG.md | 1 + .../java/de/samply/app/ProjectManagerConst.java | 2 ++ .../de/samply/app/ProjectManagerController.java | 14 +++++++++++++- .../samply/bridgehead/BridgeheadConfiguration.java | 5 +++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82caf6f..ced3d04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,3 +84,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fetch User Visible Projects and User Visible Notifications without constraints - Fetch Project - Fetch Project States +- Fetch registered bridgeheads for project manager admin diff --git a/src/main/java/de/samply/app/ProjectManagerConst.java b/src/main/java/de/samply/app/ProjectManagerConst.java index 33dcab4..297bf21 100644 --- a/src/main/java/de/samply/app/ProjectManagerConst.java +++ b/src/main/java/de/samply/app/ProjectManagerConst.java @@ -70,6 +70,7 @@ public class ProjectManagerConst { public final static String SET_NOTIFICATION_AS_READ_ACTION = "SET_NOTIFICATION_AS_READ"; public final static String FETCH_PROJECT_ACTION = "FETCH_PROJECT_ACTION"; public final static String FETCH_PROJECT_STATES_ACTION = "FETCH_PROJECT_STATES"; + public final static String FETCH_ALL_REGISTERED_BRIDGEHEADS_ACTION = "FETCH_ALL_REGISTERED_BRIDGEHEADS"; // REST Services @@ -128,6 +129,7 @@ public class ProjectManagerConst { public final static String FETCH_OTHER_DOCUMENTS = "/other-documents"; public final static String FETCH_NOTIFICATIONS = "/notifications"; public final static String SET_NOTIFICATION_AS_READ = "/read-notification"; + public final static String FETCH_ALL_REGISTERED_BRIDGEHEADS = "/bridgeheads"; // REST Parameters public final static String PROJECT_CODE = "project-code"; diff --git a/src/main/java/de/samply/app/ProjectManagerController.java b/src/main/java/de/samply/app/ProjectManagerController.java index b6fed4d..6f8a068 100644 --- a/src/main/java/de/samply/app/ProjectManagerController.java +++ b/src/main/java/de/samply/app/ProjectManagerController.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import de.samply.annotations.*; +import de.samply.bridgehead.BridgeheadConfiguration; import de.samply.db.model.ProjectDocument; import de.samply.document.DocumentService; import de.samply.document.DocumentServiceException; @@ -65,6 +66,7 @@ public class ProjectManagerController { private final ProjectService projectService; private final ProjectBridgeheadService projectBridgeheadService; private final NotificationService notificationService; + private final BridgeheadConfiguration bridgeheadConfiguration; public ProjectManagerController(ProjectEventService projectEventService, FrontendService frontendService, @@ -75,7 +77,8 @@ public ProjectManagerController(ProjectEventService projectEventService, TokenManagerService tokenManagerService, ProjectService projectService, ProjectBridgeheadService projectBridgeheadService, - NotificationService notificationService) { + NotificationService notificationService, + BridgeheadConfiguration bridgeheadConfiguration) { this.projectEventService = projectEventService; this.frontendService = frontendService; this.userService = userService; @@ -86,6 +89,7 @@ public ProjectManagerController(ProjectEventService projectEventService, this.projectService = projectService; this.projectBridgeheadService = projectBridgeheadService; this.notificationService = notificationService; + this.bridgeheadConfiguration = bridgeheadConfiguration; } @GetMapping(value = ProjectManagerConst.INFO) @@ -841,6 +845,14 @@ public ResponseEntity setNotificationAsRead( return convertToResponseEntity(() -> this.notificationService.setNotificationAsRead(notificationId)); } + @RoleConstraints(organisationRoles = {OrganisationRole.PROJECT_MANAGER_ADMIN}) + @FrontendSiteModule(site = ProjectManagerConst.PROJECT_VIEW_SITE, module = ProjectManagerConst.PROJECT_DOCUMENTS_MODULE) + @FrontendAction(action = ProjectManagerConst.FETCH_ALL_REGISTERED_BRIDGEHEADS_ACTION) + @GetMapping(value = ProjectManagerConst.FETCH_ALL_REGISTERED_BRIDGEHEADS) + public ResponseEntity fetchAllRegisteredBridgeheads() { + return convertToResponseEntity(() -> bridgeheadConfiguration.getRegisteredBridgeheads()); + } + private ResponseEntity convertToResponseEntity(RunnableWithException runnable) { try { diff --git a/src/main/java/de/samply/bridgehead/BridgeheadConfiguration.java b/src/main/java/de/samply/bridgehead/BridgeheadConfiguration.java index e385e91..e4c2a30 100644 --- a/src/main/java/de/samply/bridgehead/BridgeheadConfiguration.java +++ b/src/main/java/de/samply/bridgehead/BridgeheadConfiguration.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; +import java.util.Set; @Configuration @ConfigurationProperties(prefix = ProjectManagerConst.REGISTERED_BRIDGEHEADS) @@ -92,5 +93,9 @@ public String fetchBridgeheadForTokenManagerId(String tokenManagerId) { return fetchBridgehead(tokenManagerId, tokenManagerIdBridgeheadMap); } + public Set getRegisteredBridgeheads() { + return config.keySet(); + } + }