use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class PrivateUrlUtilTest method testGetDatasetFromRoleAssignmentNonDataset.
@Test
public void testGetDatasetFromRoleAssignmentNonDataset() {
DataverseRole aRole = null;
PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
RoleAssignee anAssignee = privateUrlUser;
DvObject nonDataset = new Dataverse();
String privateUrlToken = null;
RoleAssignment ra = new RoleAssignment(aRole, anAssignee, nonDataset, privateUrlToken);
assertNull(PrivateUrlUtil.getDatasetFromRoleAssignment(ra));
}
use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class PrivateUrlUtilTest method testGetUserFromRoleAssignmentSucess.
@Test
public void testGetUserFromRoleAssignmentSucess() {
DataverseRole aRole = null;
PrivateUrlUser privateUrlUserIn = new PrivateUrlUser(42);
RoleAssignee anAssignee = privateUrlUserIn;
DvObject dataset = new Dataset();
dataset.setId(123l);
String privateUrlToken = null;
RoleAssignment ra = new RoleAssignment(aRole, anAssignee, dataset, privateUrlToken);
PrivateUrlUser privateUrlUserOut = PrivateUrlUtil.getPrivateUrlUserFromRoleAssignment(ra);
assertNotNull(privateUrlUserOut);
}
use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class PrivateUrlUtilTest method testGetPrivateUrlUserFromRoleAssignmentAndAssigneeSuccess.
@Test
public void testGetPrivateUrlUserFromRoleAssignmentAndAssigneeSuccess() {
DataverseRole aRole = null;
PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
RoleAssignee assignee = privateUrlUser;
DvObject dataset = new Dataset();
dataset.setId(42l);
String privateUrlToken = "cd71e9d7-73a7-4ec8-b890-3d00499e8693";
RoleAssignment assignment = new RoleAssignment(aRole, assignee, dataset, privateUrlToken);
PrivateUrlUser privateUrl = PrivateUrlUtil.getPrivateUrlUserFromRoleAssignment(assignment, assignee);
assertNotNull(privateUrl);
}
use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class ManageFilePermissionsPage method grantAccess.
public void grantAccess(ActionEvent evt) {
// Find the built in file downloader role (currently by alias)
DataverseRole fileDownloaderRole = roleService.findBuiltinRoleByAlias(DataverseRole.FILE_DOWNLOADER);
for (RoleAssignee roleAssignee : selectedRoleAssignees) {
boolean sendNotification = false;
for (DataFile file : selectedFiles) {
if (assignRole(roleAssignee, file, fileDownloaderRole)) {
if (file.isReleased()) {
sendNotification = true;
}
// remove request, if it exist
if (file.getFileAccessRequesters().remove(roleAssignee)) {
datafileService.save(file);
}
}
}
if (sendNotification) {
for (AuthenticatedUser au : roleAssigneeService.getExplicitUsers(roleAssignee)) {
userNotificationService.sendNotification(au, new Timestamp(new Date().getTime()), UserNotification.Type.GRANTFILEACCESS, dataset.getId());
}
}
}
initMaps();
}
use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class ManageGroupsPage method saveExplicitGroup.
public void saveExplicitGroup(ActionEvent ae) {
ExplicitGroup eg = selectedGroup;
if (getSelectedGroupAddRoleAssignees() != null) {
try {
for (RoleAssignee ra : getSelectedGroupAddRoleAssignees()) {
eg.add(ra);
}
} catch (GroupException ge) {
JsfHelper.JH.addMessage(FacesMessage.SEVERITY_ERROR, "Group edit failed.", ge.getMessage());
return;
}
}
try {
eg = engineService.submit(new UpdateExplicitGroupCommand(dvRequestService.getDataverseRequest(), eg));
JsfHelper.addSuccessMessage("Succesfully saved group " + eg.getDisplayName());
} catch (CommandException ex) {
JsfHelper.JH.addMessage(FacesMessage.SEVERITY_ERROR, "Group Save 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();
}
Aggregations