use of edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser in project dataverse by IQSS.
the class PrivateUrlPage method init.
public String init() {
try {
PrivateUrlRedirectData privateUrlRedirectData = privateUrlService.getPrivateUrlRedirectDataFromToken(token);
String draftDatasetPageToBeRedirectedTo = privateUrlRedirectData.getDraftDatasetPageToBeRedirectedTo() + "&faces-redirect=true";
PrivateUrlUser privateUrlUser = privateUrlRedirectData.getPrivateUrlUser();
session.setUser(privateUrlUser);
logger.info("Redirecting PrivateUrlUser '" + privateUrlUser.getIdentifier() + "' to " + draftDatasetPageToBeRedirectedTo);
return draftDatasetPageToBeRedirectedTo;
} catch (Exception ex) {
logger.info("Exception processing Private URL token '" + token + "':" + ex);
return "/404.xhtml";
}
}
use of edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser 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.users.PrivateUrlUser 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.users.PrivateUrlUser in project dataverse by IQSS.
the class PrivateUrlUtilTest method testGetPrivateUrlUserFromRoleAssignmentAndAssigneeNull.
@Test
public void testGetPrivateUrlUserFromRoleAssignmentAndAssigneeNull() {
PrivateUrlUser privateUrl = PrivateUrlUtil.getPrivateUrlUserFromRoleAssignment(null, null);
assertNull(privateUrl);
}
use of edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser 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