use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class PermissionServiceBean method getUsersWithPermissionOn.
public List<AuthenticatedUser> getUsersWithPermissionOn(Permission permission, DvObject dvo) {
List<AuthenticatedUser> usersHasPermissionOn = new LinkedList<>();
Set<RoleAssignment> ras = roleService.rolesAssignments(dvo);
for (RoleAssignment ra : ras) {
if (ra.getRole().permissions().contains(permission)) {
RoleAssignee raee = roleAssigneeService.getRoleAssignee(ra.getAssigneeIdentifier());
usersHasPermissionOn.addAll(roleAssigneeService.getExplicitUsers(raee));
}
}
return usersHasPermissionOn;
}
use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class ManageFilePermissionsPage method addFileToRoleAssignee.
private void addFileToRoleAssignee(RoleAssignment assignment) {
RoleAssignee ra = roleAssigneeService.getRoleAssignee(assignment.getAssigneeIdentifier());
List<RoleAssignmentRow> assignments = roleAssigneeMap.get(ra);
if (assignments == null) {
assignments = new ArrayList<>();
roleAssigneeMap.put(ra, assignments);
}
assignments.add(new RoleAssignmentRow(assignment, ra.getDisplayInfo()));
}
use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class ManageGroupsPage method createExplicitGroup.
public void createExplicitGroup(ActionEvent ae) {
ExplicitGroup eg = explicitGroupService.getProvider().makeGroup();
eg.setDisplayName(getExplicitGroupName());
eg.setGroupAliasInOwner(getExplicitGroupIdentifier());
eg.setDescription(getNewExplicitGroupDescription());
if (getNewExplicitGroupRoleAssignees() != null) {
try {
for (RoleAssignee ra : getNewExplicitGroupRoleAssignees()) {
eg.add(ra);
}
} catch (GroupException ge) {
JsfHelper.JH.addMessage(FacesMessage.SEVERITY_ERROR, "Group Creation failed.", ge.getMessage());
return;
}
}
try {
eg = engineService.submit(new CreateExplicitGroupCommand(dvRequestService.getDataverseRequest(), this.dataverse, eg));
explicitGroups.add(eg);
JsfHelper.addSuccessMessage("Succesfully created group " + eg.getDisplayName() + ". Refresh to update your page.");
} catch (CreateExplicitGroupCommand.GroupAliasExistsException gaee) {
explicitGroupIdentifierField.setValid(false);
FacesContext.getCurrentInstance().addMessage(explicitGroupIdentifierField.getClientId(), new FacesMessage(FacesMessage.SEVERITY_ERROR, gaee.getMessage(), null));
} catch (CommandException ex) {
logger.log(Level.WARNING, "Group creation failed", ex);
JsfHelper.JH.addMessage(FacesMessage.SEVERITY_ERROR, "Group Creation failed.", ex.getMessage());
} catch (Exception ex) {
JH.addMessage(FacesMessage.SEVERITY_FATAL, "The role was not able to be saved.");
logger.log(Level.SEVERE, "Error saving role: " + ex.getMessage(), ex);
}
showAssignmentMessages();
}
use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class ManageGroupsPage method getMembershipString.
public String getMembershipString(ExplicitGroup eg) {
long userCount = 0;
long groupCount = 0;
for (RoleAssignee ra : eg.getDirectMembers()) {
if (ra instanceof User) {
userCount++;
} else {
groupCount++;
}
}
if (userCount == 0 && groupCount == 0) {
return "No members";
}
String memberString = "";
if (userCount == 1) {
memberString = "1 user";
} else if (userCount != 1) {
memberString = Long.toString(userCount) + " users";
}
if (groupCount == 1) {
memberString = memberString + ", 1 group";
} else if (groupCount != 1) {
memberString = memberString + ", " + Long.toString(groupCount) + " groups";
}
return memberString;
}
use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class SearchPermissionsServiceBean method findDvObjectPerms.
public List<String> findDvObjectPerms(DvObject dvObject) {
List<String> permStrings = new ArrayList<>();
resetRoleAssigneeCache();
Set<RoleAssignment> roleAssignments = rolesSvc.rolesAssignments(dvObject);
for (RoleAssignment roleAssignment : roleAssignments) {
logger.fine("role assignment on dvObject " + dvObject.getId() + ": " + roleAssignment.getAssigneeIdentifier());
if (roleAssignment.getRole().permissions().contains(getRequiredSearchPermission(dvObject))) {
RoleAssignee userOrGroup = getRoleAssignee(roleAssignment.getAssigneeIdentifier());
String indexableUserOrGroupPermissionString = getIndexableStringForUserOrGroup(userOrGroup);
if (indexableUserOrGroupPermissionString != null) {
permStrings.add(indexableUserOrGroupPermissionString);
}
}
}
resetRoleAssigneeCache();
return permStrings;
}
Aggregations