Search in sources :

Example 1 with AuthorityRequired

use of org.pmiops.workbench.annotations.AuthorityRequired in project workbench by all-of-us.

the class ProfileController method reviewIdVerification.

@Override
@AuthorityRequired({ Authority.REVIEW_ID_VERIFICATION })
public ResponseEntity<IdVerificationListResponse> reviewIdVerification(Long userId, IdVerificationReviewRequest review) {
    BlockscoreIdVerificationStatus status = review.getNewStatus();
    Boolean oldVerification = userDao.findUserByUserId(userId).getBlockscoreVerificationIsValid();
    String newValue;
    if (status == BlockscoreIdVerificationStatus.VERIFIED) {
        userService.setIdVerificationApproved(userId, true);
        newValue = "true";
    } else {
        userService.setIdVerificationApproved(userId, false);
        newValue = "false";
    }
    userService.logAdminUserAction(userId, "manual ID verification", oldVerification, newValue);
    return getIdVerificationsForReview();
}
Also used : BlockscoreIdVerificationStatus(org.pmiops.workbench.model.BlockscoreIdVerificationStatus) AuthorityRequired(org.pmiops.workbench.annotations.AuthorityRequired)

Example 2 with AuthorityRequired

use of org.pmiops.workbench.annotations.AuthorityRequired in project workbench by all-of-us.

the class ProfileController method getIdVerificationsForReview.

@Override
@AuthorityRequired({ Authority.REVIEW_ID_VERIFICATION })
public ResponseEntity<IdVerificationListResponse> getIdVerificationsForReview() {
    IdVerificationListResponse response = new IdVerificationListResponse();
    List<Profile> responseList = new ArrayList<Profile>();
    try {
        for (User user : userService.getNonVerifiedUsers()) {
            responseList.add(profileService.getProfile(user));
        }
    } catch (ApiException e) {
        log.log(Level.INFO, "Error calling FireCloud", e);
        return ResponseEntity.status(e.getCode()).build();
    }
    response.setProfileList(responseList);
    return ResponseEntity.ok(response);
}
Also used : IdVerificationListResponse(org.pmiops.workbench.model.IdVerificationListResponse) User(org.pmiops.workbench.db.model.User) ArrayList(java.util.ArrayList) Profile(org.pmiops.workbench.model.Profile) ApiException(org.pmiops.workbench.firecloud.ApiException) AuthorityRequired(org.pmiops.workbench.annotations.AuthorityRequired)

Example 3 with AuthorityRequired

use of org.pmiops.workbench.annotations.AuthorityRequired in project workbench by all-of-us.

the class WorkspacesController method getWorkspacesForReview.

// Note we do not paginate the workspaces list, since we expect few workspaces
// to require review.
// 
// We can add pagination in the DAO by returning Slice<Workspace> if we want the method to return
// pagination information (e.g. are there more workspaces to get), and Page<Workspace> if we
// want the method to return both pagination information and a total count.
@Override
@AuthorityRequired({ Authority.REVIEW_RESEARCH_PURPOSE })
public ResponseEntity<WorkspaceListResponse> getWorkspacesForReview() {
    WorkspaceListResponse response = new WorkspaceListResponse();
    List<org.pmiops.workbench.db.model.Workspace> workspaces = workspaceService.findForReview();
    response.setItems(workspaces.stream().map(TO_CLIENT_WORKSPACE).collect(Collectors.toList()));
    return ResponseEntity.ok(response);
}
Also used : WorkspaceListResponse(org.pmiops.workbench.model.WorkspaceListResponse) Workspace(org.pmiops.workbench.model.Workspace) AuthorityRequired(org.pmiops.workbench.annotations.AuthorityRequired)

Example 4 with AuthorityRequired

use of org.pmiops.workbench.annotations.AuthorityRequired in project workbench by all-of-us.

the class WorkspacesController method reviewWorkspace.

/**
 * Record approval or rejection of research purpose.
 */
@Override
@AuthorityRequired({ Authority.REVIEW_RESEARCH_PURPOSE })
public ResponseEntity<EmptyResponse> reviewWorkspace(String ns, String id, ResearchPurposeReviewRequest review) {
    org.pmiops.workbench.db.model.Workspace workspace = workspaceService.get(ns, id);
    userService.logAdminWorkspaceAction(workspace.getWorkspaceId(), "research purpose approval", workspace.getApproved(), review.getApproved());
    workspaceService.setResearchPurposeApproved(ns, id, review.getApproved());
    return ResponseEntity.ok(new EmptyResponse());
}
Also used : EmptyResponse(org.pmiops.workbench.model.EmptyResponse) AuthorityRequired(org.pmiops.workbench.annotations.AuthorityRequired)

Example 5 with AuthorityRequired

use of org.pmiops.workbench.annotations.AuthorityRequired in project workbench by all-of-us.

the class AuthDomainController method addUserToAuthDomain.

@Override
@AuthorityRequired({ Authority.MANAGE_GROUP })
public ResponseEntity<Void> addUserToAuthDomain(String groupName, AuthDomainRequest request) {
    User user = userDao.findUserByEmail(request.getEmail());
    DataAccessLevel previousAccess = user.getDataAccessLevel();
    try {
        fireCloudService.addUserToGroup(request.getEmail(), groupName);
    } catch (ApiException e) {
        ExceptionUtils.convertFirecloudException(e);
    }
    // TODO(blrubenstein): Parameterize this.
    user.setDataAccessLevel(DataAccessLevel.REGISTERED);
    user.setDisabled(false);
    userDao.save(user);
    userService.logAdminUserAction(user.getUserId(), "user access to  " + groupName + " domain", previousAccess, DataAccessLevel.REGISTERED);
    return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}
Also used : User(org.pmiops.workbench.db.model.User) DataAccessLevel(org.pmiops.workbench.model.DataAccessLevel) ApiException(org.pmiops.workbench.firecloud.ApiException) AuthorityRequired(org.pmiops.workbench.annotations.AuthorityRequired)

Aggregations

AuthorityRequired (org.pmiops.workbench.annotations.AuthorityRequired)7 User (org.pmiops.workbench.db.model.User)3 ApiException (org.pmiops.workbench.firecloud.ApiException)3 DataAccessLevel (org.pmiops.workbench.model.DataAccessLevel)2 ArrayList (java.util.ArrayList)1 BadRequestException (org.pmiops.workbench.exceptions.BadRequestException)1 Authority (org.pmiops.workbench.model.Authority)1 BlockscoreIdVerificationStatus (org.pmiops.workbench.model.BlockscoreIdVerificationStatus)1 EmptyResponse (org.pmiops.workbench.model.EmptyResponse)1 IdVerificationListResponse (org.pmiops.workbench.model.IdVerificationListResponse)1 Profile (org.pmiops.workbench.model.Profile)1 Workspace (org.pmiops.workbench.model.Workspace)1 WorkspaceListResponse (org.pmiops.workbench.model.WorkspaceListResponse)1