use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class SearchPermissionsServiceBean method getRoleAssignee.
private RoleAssignee getRoleAssignee(String idtf) {
RoleAssignee ra = roleAssigneeCache.get(idtf);
if (ra != null) {
return ra;
}
ra = roleAssigneeService.getRoleAssignee(idtf);
roleAssigneeCache.put(idtf, ra);
if (roleAssigneeCache.size() > MAX_CACHE_SIZE) {
roleAssigneeCache.remove(roleAssigneeCache.keySet().iterator().next());
}
return ra;
}
use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class SearchPermissionsServiceBean method findWhoHasDirectAssignments.
@Deprecated
private List<RoleAssignee> findWhoHasDirectAssignments(DvObject dvObject) {
List<RoleAssignee> emptyList = new ArrayList<>();
List<RoleAssignee> peopleWhoCanSearch = emptyList;
resetRoleAssigneeCache();
List<RoleAssignment> assignmentsOn = permissionService.assignmentsOn(dvObject);
for (RoleAssignment roleAssignment : assignmentsOn) {
if (roleAssignment.getRole().permissions().contains(getRequiredSearchPermission(dvObject))) {
RoleAssignee userOrGroup = getRoleAssignee(roleAssignment.getAssigneeIdentifier());
if (userOrGroup != null) {
peopleWhoCanSearch.add(userOrGroup);
}
}
}
resetRoleAssigneeCache();
return peopleWhoCanSearch;
}
use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class PrivateUrlUtilTest method testGetDraftDatasetVersionFromRoleAssignmentSuccess.
@Test
public void testGetDraftDatasetVersionFromRoleAssignmentSuccess() {
DataverseRole aRole = null;
PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
RoleAssignee anAssignee = privateUrlUser;
Dataset dataset = new Dataset();
List<DatasetVersion> versions = new ArrayList<>();
DatasetVersion datasetVersionIn = new DatasetVersion();
datasetVersionIn.setVersionState(DatasetVersion.VersionState.DRAFT);
versions.add(datasetVersionIn);
dataset.setVersions(versions);
String privateUrlToken = null;
RoleAssignment ra = new RoleAssignment(aRole, anAssignee, dataset, privateUrlToken);
DatasetVersion datasetVersionOut = PrivateUrlUtil.getDraftDatasetVersionFromRoleAssignment(ra);
assertNotNull(datasetVersionOut);
assertEquals("#42", ra.getAssigneeIdentifier());
}
use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class PrivateUrlUtilTest method testGetDraftDatasetVersionFromRoleAssignmentLastestIsNotDraft.
@Test
public void testGetDraftDatasetVersionFromRoleAssignmentLastestIsNotDraft() {
DataverseRole aRole = null;
PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
RoleAssignee anAssignee = privateUrlUser;
Dataset dataset = new Dataset();
List<DatasetVersion> versions = new ArrayList<>();
DatasetVersion datasetVersionIn = new DatasetVersion();
datasetVersionIn.setVersionState(DatasetVersion.VersionState.RELEASED);
versions.add(datasetVersionIn);
dataset.setVersions(versions);
String privateUrlToken = null;
RoleAssignment ra = new RoleAssignment(aRole, anAssignee, dataset, privateUrlToken);
DatasetVersion datasetVersionOut = PrivateUrlUtil.getDraftDatasetVersionFromRoleAssignment(ra);
assertNull(datasetVersionOut);
}
use of edu.harvard.iq.dataverse.authorization.RoleAssignee in project dataverse by IQSS.
the class PrivateUrlUtilTest method testGetDatasetFromRoleAssignmentNullDefinitionPoint.
@Test
public void testGetDatasetFromRoleAssignmentNullDefinitionPoint() {
DataverseRole aRole = null;
PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
RoleAssignee anAssignee = privateUrlUser;
DvObject nullDefinitionPoint = null;
String privateUrlToken = null;
RoleAssignment ra = new RoleAssignment(aRole, anAssignee, nullDefinitionPoint, privateUrlToken);
assertNull(PrivateUrlUtil.getDatasetFromRoleAssignment(ra));
}
Aggregations