use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class SearchPermissionsServiceBean method findDirectAssignments.
@Deprecated
private List<String> findDirectAssignments(DvObject dvObject) {
List<String> permStrings = new ArrayList<>();
List<RoleAssignee> roleAssignees = findWhoHasDirectAssignments(dvObject);
for (RoleAssignee roleAssignee : roleAssignees) {
logger.fine("user or group (findDirectAssignments): " + roleAssignee.getIdentifier());
String indexableUserOrGroupPermissionString = getIndexableStringForUserOrGroup(roleAssignee);
if (indexableUserOrGroupPermissionString != null) {
permStrings.add(indexableUserOrGroupPermissionString);
}
}
return permStrings;
}
use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class JsonPrinterTest method testJson_RoleAssignment.
@Test
public void testJson_RoleAssignment() {
DataverseRole aRole = new DataverseRole();
PrivateUrlUser privateUrlUserIn = new PrivateUrlUser(42);
RoleAssignee anAssignee = privateUrlUserIn;
Dataset dataset = new Dataset();
dataset.setId(123l);
String privateUrlToken = "e1d53cf6-794a-457a-9709-7c07629a8267";
RoleAssignment ra = new RoleAssignment(aRole, anAssignee, dataset, privateUrlToken);
JsonObjectBuilder job = JsonPrinter.json(ra);
assertNotNull(job);
JsonObject jsonObject = job.build();
assertEquals("#42", jsonObject.getString("assignee"));
assertEquals(123, jsonObject.getInt("definitionPointId"));
assertEquals("e1d53cf6-794a-457a-9709-7c07629a8267", jsonObject.getString("privateUrlToken"));
}
use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class ManagePermissionsPage method initRoleAssignments.
public List<RoleAssignmentRow> initRoleAssignments() {
List<RoleAssignmentRow> raList = null;
if (dvObject != null && dvObject.getId() != null) {
Set<RoleAssignment> ras = roleService.rolesAssignments(dvObject);
raList = new ArrayList<>(ras.size());
for (RoleAssignment roleAssignment : ras) {
// for files, only show role assignments which can download
if (!(dvObject instanceof DataFile) || roleAssignment.getRole().permissions().contains(Permission.DownloadFile)) {
RoleAssignee roleAssignee = roleAssigneeService.getRoleAssignee(roleAssignment.getAssigneeIdentifier());
if (roleAssignee != null) {
raList.add(new RoleAssignmentRow(roleAssignment, roleAssignee.getDisplayInfo()));
} else {
logger.info("Could not find role assignee based on role assignment id " + roleAssignment.getId());
}
}
}
}
return raList;
}
use of edu.harvard.iq.dataverse.authorization.RoleAssignee 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);
}
}
use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class ManagePermissionsPage method assignRole.
public void assignRole(ActionEvent evt) {
logger.info("Got to assignRole");
List<RoleAssignee> selectedRoleAssigneesList = getRoleAssignSelectedRoleAssignees();
if (selectedRoleAssigneesList == null) {
logger.info("** SELECTED role asignees is null");
selectedRoleAssigneesList = new LinkedList<>();
}
for (RoleAssignee roleAssignee : selectedRoleAssigneesList) {
assignRole(roleAssignee, roleService.find(selectedRoleId));
}
roleAssignments = initRoleAssignments();
}
Aggregations