use of edu.harvard.iq.dataverse.authorization.DataverseRole 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.DataverseRole in project dataverse by IQSS.
the class ManagePermissionsPage method createNewRole.
public void createNewRole(ActionEvent e) {
setRole(new DataverseRole());
role.setOwner(dvObject);
}
use of edu.harvard.iq.dataverse.authorization.DataverseRole in project dataverse by IQSS.
the class PermissionServiceBean method getRolesClause.
/*
Method takes in a user and optional list of roles and dvobject type
queries the role assigment table filtering by optional roles and dv
returns dvobject ids
*/
private String getRolesClause(List<DataverseRole> roles) {
StringBuilder roleStringBld = new StringBuilder();
if (roles != null && !roles.isEmpty()) {
roleStringBld.append(" and role_id in (");
boolean first = true;
for (DataverseRole role : roles) {
if (!first) {
roleStringBld.append(",");
}
roleStringBld.append(role.getId());
first = false;
}
roleStringBld.append(")");
}
return roleStringBld.toString();
}
use of edu.harvard.iq.dataverse.authorization.DataverseRole in project dataverse by IQSS.
the class RolePermissionFragment method cloneRole.
public void cloneRole(String roleId) {
DataverseRole clonedRole = new DataverseRole();
clonedRole.setOwner(dvObject);
DataverseRole originalRole = roleService.find(Long.parseLong(roleId));
clonedRole.addPermissions(originalRole.permissions());
setRole(clonedRole);
}
use of edu.harvard.iq.dataverse.authorization.DataverseRole 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());
}
Aggregations