Search in sources :

Example 6 with Permission

use of edu.harvard.iq.dataverse.authorization.Permission in project dataverse by IQSS.

the class RolePermissionFragment method setRole.

public void setRole(DataverseRole role) {
    this.role = role;
    selectedPermissions = new LinkedList<>();
    if (role != null) {
        for (Permission p : role.permissions()) {
            selectedPermissions.add(p.name());
        }
    }
}
Also used : Permission(edu.harvard.iq.dataverse.authorization.Permission)

Example 7 with Permission

use of edu.harvard.iq.dataverse.authorization.Permission in project dataverse by IQSS.

the class SubmitDatasetForReviewCommandTest method setUp.

@Before
public void setUp() {
    dataset = new Dataset();
    HttpServletRequest aHttpServletRequest = null;
    dataverseRequest = new DataverseRequest(MocksFactory.makeAuthenticatedUser("First", "Last"), aHttpServletRequest);
    testEngine = new TestDataverseEngine(new TestCommandContext() {

        @Override
        public AuthenticationServiceBean authentication() {
            return new AuthenticationServiceBean() {

                @Override
                public AuthenticatedUser getAuthenticatedUser(String id) {
                    return MocksFactory.makeAuthenticatedUser("First", "Last");
                }
            };
        }

        @Override
        public IndexServiceBean index() {
            return new IndexServiceBean() {

                @Override
                public Future<String> indexDataset(Dataset dataset, boolean doNormalSolrDocCleanUp) {
                    return null;
                }
            };
        }

        @Override
        public EntityManager em() {
            return new TestEntityManager() {

                @Override
                public <T> T merge(T entity) {
                    return entity;
                }

                @Override
                public void flush() {
                // nothing to do here
                }
            };
        }

        @Override
        public DatasetServiceBean datasets() {
            return new DatasetServiceBean() {

                {
                    em = new NoOpTestEntityManager();
                }

                @Override
                public DatasetVersionUser getDatasetVersionUser(DatasetVersion version, User user) {
                    return null;
                }

                @Override
                public DatasetLock addDatasetLock(Long datasetId, DatasetLock.Reason reason, Long userId, String info) {
                    return null;
                }
            };
        }

        @Override
        public DataverseRoleServiceBean roles() {
            return new DataverseRoleServiceBean() {

                @Override
                public DataverseRole findBuiltinRoleByAlias(String alias) {
                    return new DataverseRole();
                }

                @Override
                public RoleAssignment save(RoleAssignment assignment) {
                    // no-op
                    return assignment;
                }
            };
        }

        @Override
        public PermissionServiceBean permissions() {
            return new PermissionServiceBean() {

                @Override
                public List<AuthenticatedUser> getUsersWithPermissionOn(Permission permission, DvObject dvo) {
                    // We only need permissions for notifications, which we are testing in InReviewWorkflowIT.
                    return Collections.emptyList();
                }
            };
        }
    });
}
Also used : DataverseRoleServiceBean(edu.harvard.iq.dataverse.DataverseRoleServiceBean) TestCommandContext(edu.harvard.iq.dataverse.engine.TestCommandContext) AuthenticatedUser(edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser) User(edu.harvard.iq.dataverse.authorization.users.User) DatasetVersionUser(edu.harvard.iq.dataverse.DatasetVersionUser) PermissionServiceBean(edu.harvard.iq.dataverse.PermissionServiceBean) DvObject(edu.harvard.iq.dataverse.DvObject) Dataset(edu.harvard.iq.dataverse.Dataset) RoleAssignment(edu.harvard.iq.dataverse.RoleAssignment) TestEntityManager(edu.harvard.iq.dataverse.engine.TestEntityManager) NoOpTestEntityManager(edu.harvard.iq.dataverse.engine.NoOpTestEntityManager) NoOpTestEntityManager(edu.harvard.iq.dataverse.engine.NoOpTestEntityManager) DatasetVersion(edu.harvard.iq.dataverse.DatasetVersion) AuthenticatedUser(edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser) AuthenticationServiceBean(edu.harvard.iq.dataverse.authorization.AuthenticationServiceBean) TestDataverseEngine(edu.harvard.iq.dataverse.engine.TestDataverseEngine) DataverseRole(edu.harvard.iq.dataverse.authorization.DataverseRole) HttpServletRequest(javax.servlet.http.HttpServletRequest) DataverseRequest(edu.harvard.iq.dataverse.engine.command.DataverseRequest) DatasetServiceBean(edu.harvard.iq.dataverse.DatasetServiceBean) Permission(edu.harvard.iq.dataverse.authorization.Permission) IndexServiceBean(edu.harvard.iq.dataverse.search.IndexServiceBean) Before(org.junit.Before)

Aggregations

Permission (edu.harvard.iq.dataverse.authorization.Permission)7 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)3 User (edu.harvard.iq.dataverse.authorization.users.User)3 DataverseRequest (edu.harvard.iq.dataverse.engine.command.DataverseRequest)3 Dataset (edu.harvard.iq.dataverse.Dataset)2 DatasetServiceBean (edu.harvard.iq.dataverse.DatasetServiceBean)2 DatasetVersion (edu.harvard.iq.dataverse.DatasetVersion)2 DatasetVersionUser (edu.harvard.iq.dataverse.DatasetVersionUser)2 DataverseRoleServiceBean (edu.harvard.iq.dataverse.DataverseRoleServiceBean)2 DvObject (edu.harvard.iq.dataverse.DvObject)2 PermissionServiceBean (edu.harvard.iq.dataverse.PermissionServiceBean)2 RoleAssignment (edu.harvard.iq.dataverse.RoleAssignment)2 AuthenticationServiceBean (edu.harvard.iq.dataverse.authorization.AuthenticationServiceBean)2 DataverseRole (edu.harvard.iq.dataverse.authorization.DataverseRole)2 Group (edu.harvard.iq.dataverse.authorization.groups.Group)2 NoOpTestEntityManager (edu.harvard.iq.dataverse.engine.NoOpTestEntityManager)2 TestCommandContext (edu.harvard.iq.dataverse.engine.TestCommandContext)2 TestDataverseEngine (edu.harvard.iq.dataverse.engine.TestDataverseEngine)2 IndexServiceBean (edu.harvard.iq.dataverse.search.IndexServiceBean)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2