Search in sources :

Example 21 with PrivateUrlUser

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";
    }
}
Also used : PrivateUrlUser(edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser)

Example 22 with PrivateUrlUser

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());
}
Also used : Dataset(edu.harvard.iq.dataverse.Dataset) PrivateUrlUser(edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser) RoleAssignment(edu.harvard.iq.dataverse.RoleAssignment) ArrayList(java.util.ArrayList) DatasetVersion(edu.harvard.iq.dataverse.DatasetVersion) DataverseRole(edu.harvard.iq.dataverse.authorization.DataverseRole) RoleAssignee(edu.harvard.iq.dataverse.authorization.RoleAssignee) Test(org.junit.Test)

Example 23 with PrivateUrlUser

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);
}
Also used : Dataset(edu.harvard.iq.dataverse.Dataset) PrivateUrlUser(edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser) RoleAssignment(edu.harvard.iq.dataverse.RoleAssignment) ArrayList(java.util.ArrayList) DatasetVersion(edu.harvard.iq.dataverse.DatasetVersion) DataverseRole(edu.harvard.iq.dataverse.authorization.DataverseRole) RoleAssignee(edu.harvard.iq.dataverse.authorization.RoleAssignee) Test(org.junit.Test)

Example 24 with PrivateUrlUser

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);
}
Also used : PrivateUrlUser(edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser) Test(org.junit.Test)

Example 25 with PrivateUrlUser

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));
}
Also used : DvObject(edu.harvard.iq.dataverse.DvObject) PrivateUrlUser(edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser) RoleAssignment(edu.harvard.iq.dataverse.RoleAssignment) DataverseRole(edu.harvard.iq.dataverse.authorization.DataverseRole) RoleAssignee(edu.harvard.iq.dataverse.authorization.RoleAssignee) Test(org.junit.Test)

Aggregations

PrivateUrlUser (edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser)33 RoleAssignment (edu.harvard.iq.dataverse.RoleAssignment)22 Test (org.junit.Test)21 DataverseRole (edu.harvard.iq.dataverse.authorization.DataverseRole)18 RoleAssignee (edu.harvard.iq.dataverse.authorization.RoleAssignee)18 Dataset (edu.harvard.iq.dataverse.Dataset)14 DvObject (edu.harvard.iq.dataverse.DvObject)11 PrivateUrl (edu.harvard.iq.dataverse.privateurl.PrivateUrl)6 DatasetVersion (edu.harvard.iq.dataverse.DatasetVersion)5 CommandException (edu.harvard.iq.dataverse.engine.command.exception.CommandException)4 IllegalCommandException (edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException)4 ArrayList (java.util.ArrayList)3 JsonObject (javax.json.JsonObject)3 Dataverse (edu.harvard.iq.dataverse.Dataverse)2 DataverseRoleServiceBean (edu.harvard.iq.dataverse.DataverseRoleServiceBean)2 FileMetadata (edu.harvard.iq.dataverse.FileMetadata)2 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)2 GuestUser (edu.harvard.iq.dataverse.authorization.users.GuestUser)2 User (edu.harvard.iq.dataverse.authorization.users.User)2 TestCommandContext (edu.harvard.iq.dataverse.engine.TestCommandContext)2