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);
}
}
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);
}
}
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");
}
}
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);
}
}
Aggregations