use of edu.harvard.iq.dataverse.authorization.DataverseRole 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.DataverseRole 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.DataverseRole in project dataverse by IQSS.
the class ManageFilePermissionsPage method grantAccessToRequests.
private void grantAccessToRequests(AuthenticatedUser au, List<DataFile> files) {
boolean actionPerformed = false;
// Find the built in file downloader role (currently by alias)
DataverseRole fileDownloaderRole = roleService.findBuiltinRoleByAlias(DataverseRole.FILE_DOWNLOADER);
for (DataFile file : files) {
if (assignRole(au, file, fileDownloaderRole)) {
file.getFileAccessRequesters().remove(au);
datafileService.save(file);
actionPerformed = true;
}
}
if (actionPerformed) {
JsfHelper.addSuccessMessage("File Access request by " + au.getDisplayInfo().getTitle() + " was granted.");
userNotificationService.sendNotification(au, new Timestamp(new Date().getTime()), UserNotification.Type.GRANTFILEACCESS, dataset.getId());
initMaps();
}
}
use of edu.harvard.iq.dataverse.authorization.DataverseRole in project dataverse by IQSS.
the class RoleAssigneeServiceBean method getAssigneeDataverseRoleFor.
public List<DataverseRole> getAssigneeDataverseRoleFor(DataverseRequest dataverseRequest) {
if (dataverseRequest == null) {
throw new NullPointerException("dataverseRequest cannot be null!");
}
AuthenticatedUser au = dataverseRequest.getAuthenticatedUser();
if (au.getUserIdentifier() == null) {
return null;
}
String roleAssigneeIdentifier = "@" + au.getUserIdentifier();
List<DataverseRole> retList = new ArrayList<>();
// remove spaces from string
roleAssigneeIdentifier = roleAssigneeIdentifier.replaceAll("\\s", "");
List<String> userGroups = getUserExplicitGroups(au);
List<String> userRunTimeGroups = getUserRuntimeGroups(dataverseRequest);
String identifierClause = " WHERE r.assigneeIdentifier= '" + roleAssigneeIdentifier + "'";
if (userGroups != null || userRunTimeGroups != null) {
identifierClause = getGroupIdentifierClause(roleAssigneeIdentifier, userGroups, userRunTimeGroups);
}
String qstr = "SELECT distinct r.role_id";
qstr += " FROM RoleAssignment r";
qstr += identifierClause;
qstr += ";";
msg("qstr: " + qstr);
for (Object o : em.createNativeQuery(qstr).getResultList()) {
retList.add(dataverseRoleService.find((Long) o));
}
return retList;
}
use of edu.harvard.iq.dataverse.authorization.DataverseRole in project dataverse by IQSS.
the class RolePermissionFragment method createNewRole.
public void createNewRole(ActionEvent e) {
setRole(new DataverseRole());
role.setOwner(dvObject);
}
Aggregations