Skip to content

Commit

Permalink
Added: Fetch registered bridgeheads for project manager admin
Browse files Browse the repository at this point in the history
  • Loading branch information
djuarezgf committed Jan 30, 2024
1 parent ab104cc commit 6a743ad
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/main/java/de/samply/app/ProjectManagerConst.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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";
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/de/samply/app/ProjectManagerController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -86,6 +89,7 @@ public ProjectManagerController(ProjectEventService projectEventService,
this.projectService = projectService;
this.projectBridgeheadService = projectBridgeheadService;
this.notificationService = notificationService;
this.bridgeheadConfiguration = bridgeheadConfiguration;
}

@GetMapping(value = ProjectManagerConst.INFO)
Expand Down Expand Up @@ -841,6 +845,14 @@ public ResponseEntity<String> 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<Resource> fetchAllRegisteredBridgeheads() {
return convertToResponseEntity(() -> bridgeheadConfiguration.getRegisteredBridgeheads());
}


private ResponseEntity convertToResponseEntity(RunnableWithException runnable) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -92,5 +93,9 @@ public String fetchBridgeheadForTokenManagerId(String tokenManagerId) {
return fetchBridgehead(tokenManagerId, tokenManagerIdBridgeheadMap);
}

public Set<String> getRegisteredBridgeheads() {
return config.keySet();
}


}

0 comments on commit 6a743ad

Please sign in to comment.