Search in sources :

Example 1 with RevokeRoleCommand

use of edu.harvard.iq.dataverse.engine.command.impl.RevokeRoleCommand in project dataverse by IQSS.

the class ManageFilePermissionsPage method revokeRole.

// internal method used by removeRoleAssignments
private void revokeRole(Long roleAssignmentId) {
    try {
        RoleAssignment ra = em.find(RoleAssignment.class, roleAssignmentId);
        commandEngine.submit(new RevokeRoleCommand(ra, dvRequestService.getDataverseRequest()));
        JsfHelper.addSuccessMessage(ra.getRole().getName() + " role for " + roleAssigneeService.getRoleAssignee(ra.getAssigneeIdentifier()).getDisplayInfo().getTitle() + " was removed.");
    } catch (PermissionException ex) {
        JH.addMessage(FacesMessage.SEVERITY_ERROR, "The role assignment was not able to be removed.", "Permissions " + ex.getRequiredPermissions().toString() + " missing.");
    } catch (CommandException ex) {
        JH.addMessage(FacesMessage.SEVERITY_FATAL, "The role assignment could not be removed.");
        logger.log(Level.SEVERE, "Error removing role assignment: " + ex.getMessage(), ex);
    }
}
Also used : PermissionException(edu.harvard.iq.dataverse.engine.command.exception.PermissionException) RevokeRoleCommand(edu.harvard.iq.dataverse.engine.command.impl.RevokeRoleCommand) CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException)

Example 2 with RevokeRoleCommand

use of edu.harvard.iq.dataverse.engine.command.impl.RevokeRoleCommand in project dataverse by IQSS.

the class RolePermissionFragment method revokeRole.

public void revokeRole(Long roleAssignmentId) {
    try {
        commandEngine.submit(new RevokeRoleCommand(em.find(RoleAssignment.class, roleAssignmentId), dvRequestService.getDataverseRequest()));
        JH.addMessage(FacesMessage.SEVERITY_INFO, "Role assignment revoked successfully");
    } catch (PermissionException ex) {
        JH.addMessage(FacesMessage.SEVERITY_ERROR, "Cannot revoke role assignment - you're missing permission", ex.getRequiredPermissions().toString());
        logger.log(Level.SEVERE, "Error revoking role assignment: " + ex.getMessage(), ex);
    } catch (CommandException ex) {
        JH.addMessage(FacesMessage.SEVERITY_ERROR, "Cannot revoke role assignment: " + ex.getMessage());
        logger.log(Level.SEVERE, "Error revoking role assignment: " + ex.getMessage(), ex);
    }
}
Also used : PermissionException(edu.harvard.iq.dataverse.engine.command.exception.PermissionException) RevokeRoleCommand(edu.harvard.iq.dataverse.engine.command.impl.RevokeRoleCommand) CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException)

Example 3 with RevokeRoleCommand

use of edu.harvard.iq.dataverse.engine.command.impl.RevokeRoleCommand in project dataverse by IQSS.

the class Dataverses method deleteAssignment.

@DELETE
@Path("{identifier}/assignments/{id}")
public Response deleteAssignment(@PathParam("id") long assignmentId, @PathParam("identifier") String dvIdtf) {
    RoleAssignment ra = em.find(RoleAssignment.class, assignmentId);
    if (ra != null) {
        try {
            findDataverseOrDie(dvIdtf);
            execCommand(new RevokeRoleCommand(ra, createDataverseRequest(findUserOrDie())));
            return ok("Role " + ra.getRole().getName() + " revoked for assignee " + ra.getAssigneeIdentifier() + " in " + ra.getDefinitionPoint().accept(DvObject.NamePrinter));
        } catch (WrappedResponse ex) {
            return ex.getResponse();
        }
    } else {
        return error(Status.NOT_FOUND, "Role assignment " + assignmentId + " not found");
    }
}
Also used : RevokeRoleCommand(edu.harvard.iq.dataverse.engine.command.impl.RevokeRoleCommand) RoleAssignment(edu.harvard.iq.dataverse.RoleAssignment) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 4 with RevokeRoleCommand

use of edu.harvard.iq.dataverse.engine.command.impl.RevokeRoleCommand in project dataverse by IQSS.

the class ManagePermissionsPage method revokeRole.

// internal method used by removeRoleAssignment and saveConfiguration
private void revokeRole(RoleAssignment ra) {
    try {
        commandEngine.submit(new RevokeRoleCommand(ra, dvRequestService.getDataverseRequest()));
        JsfHelper.addSuccessMessage(ra.getRole().getName() + " role for " + roleAssigneeService.getRoleAssignee(ra.getAssigneeIdentifier()).getDisplayInfo().getTitle() + " was removed.");
        RoleAssignee assignee = roleAssigneeService.getRoleAssignee(ra.getAssigneeIdentifier());
        notifyRoleChange(assignee, UserNotification.Type.REVOKEROLE);
    } catch (PermissionException ex) {
        JH.addMessage(FacesMessage.SEVERITY_ERROR, "The role assignment was not able to be removed.", "Permissions " + ex.getRequiredPermissions().toString() + " missing.");
    } catch (CommandException ex) {
        JH.addMessage(FacesMessage.SEVERITY_FATAL, "The role assignment could not be removed.");
        logger.log(Level.SEVERE, "Error removing role assignment: " + ex.getMessage(), ex);
    }
}
Also used : PermissionException(edu.harvard.iq.dataverse.engine.command.exception.PermissionException) RevokeRoleCommand(edu.harvard.iq.dataverse.engine.command.impl.RevokeRoleCommand) CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) RoleAssignee(edu.harvard.iq.dataverse.authorization.RoleAssignee)

Aggregations

RevokeRoleCommand (edu.harvard.iq.dataverse.engine.command.impl.RevokeRoleCommand)4 CommandException (edu.harvard.iq.dataverse.engine.command.exception.CommandException)3 PermissionException (edu.harvard.iq.dataverse.engine.command.exception.PermissionException)3 RoleAssignment (edu.harvard.iq.dataverse.RoleAssignment)1 RoleAssignee (edu.harvard.iq.dataverse.authorization.RoleAssignee)1 DELETE (javax.ws.rs.DELETE)1 Path (javax.ws.rs.Path)1