Search in sources :

Example 1 with SimplePermission

use of io.lumeer.core.model.SimplePermission in project engine by Lumeer.

the class OrganizationFacade method createOrganization.

public Organization createOrganization(final Organization organization) {
    // TODO check system role for creating organizations
    Permission defaultUserPermission = new SimplePermission(authenticatedUser.getUserEmail(), Organization.ROLES);
    organization.getPermissions().updateUserPermissions(defaultUserPermission);
    Organization storedOrganization = organizationDao.createOrganization(organization);
    createOrganizationScopedRepositories(storedOrganization);
    return storedOrganization;
}
Also used : Organization(io.lumeer.api.model.Organization) Permission(io.lumeer.api.model.Permission) SimplePermission(io.lumeer.core.model.SimplePermission) SimplePermission(io.lumeer.core.model.SimplePermission)

Example 2 with SimplePermission

use of io.lumeer.core.model.SimplePermission in project engine by Lumeer.

the class ProjectFacade method createProject.

public Project createProject(Project project) {
    checkOrganizationWriteRole();
    Permission defaultUserPermission = new SimplePermission(authenticatedUser.getCurrentUsername(), Project.ROLES);
    project.getPermissions().updateUserPermissions(defaultUserPermission);
    Project storedProject = projectDao.createProject(project);
    createProjectScopedRepositories(storedProject);
    return storedProject;
}
Also used : Project(io.lumeer.api.model.Project) Permission(io.lumeer.api.model.Permission) SimplePermission(io.lumeer.core.model.SimplePermission) SimplePermission(io.lumeer.core.model.SimplePermission)

Example 3 with SimplePermission

use of io.lumeer.core.model.SimplePermission in project engine by Lumeer.

the class ViewFacade method createView.

public View createView(View view) {
    if (view.getCode() == null || view.getCode().isEmpty()) {
        view.setCode(this.generateViewCode(view.getName()));
    }
    Permission defaultUserPermission = new SimplePermission(authenticatedUser.getCurrentUsername(), View.ROLES);
    view.getPermissions().updateUserPermissions(defaultUserPermission);
    return viewDao.createView(view);
}
Also used : Permission(io.lumeer.api.model.Permission) SimplePermission(io.lumeer.core.model.SimplePermission) SimplePermission(io.lumeer.core.model.SimplePermission)

Example 4 with SimplePermission

use of io.lumeer.core.model.SimplePermission in project engine by Lumeer.

the class CollectionFacade method createCollectionMetadata.

private Collection createCollectionMetadata(Collection collection) {
    if (collection.getCode() == null || collection.getCode().isEmpty()) {
        collection.setCode(generateCollectionCode(collection.getName()));
    }
    Permission defaultUserPermission = new SimplePermission(authenticatedUser.getCurrentUsername(), Collection.ROLES);
    collection.getPermissions().updateUserPermissions(defaultUserPermission);
    return collectionDao.createCollection(collection);
}
Also used : Permission(io.lumeer.api.model.Permission) SimplePermission(io.lumeer.core.model.SimplePermission) SimplePermission(io.lumeer.core.model.SimplePermission)

Example 5 with SimplePermission

use of io.lumeer.core.model.SimplePermission in project engine by Lumeer.

the class CollectionFacadeIT method testUpdateGroupPermissions.

@Test
public void testUpdateGroupPermissions() {
    String collectionId = createCollection(CODE).getId();
    SimplePermission groupPermission = new SimplePermission(GROUP, new HashSet<>(Arrays.asList(Role.SHARE, Role.READ)));
    collectionFacade.updateGroupPermissions(collectionId, groupPermission);
    Permissions permissions = collectionDao.getCollectionByCode(CODE).getPermissions();
    assertThat(permissions).isNotNull();
    assertPermissions(permissions.getUserPermissions(), USER_PERMISSION);
    assertPermissions(permissions.getGroupPermissions(), groupPermission);
}
Also used : LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) JsonPermissions(io.lumeer.api.dto.JsonPermissions) Permissions(io.lumeer.api.model.Permissions) SimplePermission(io.lumeer.core.model.SimplePermission) Test(org.junit.Test)

Aggregations

SimplePermission (io.lumeer.core.model.SimplePermission)24 Permissions (io.lumeer.api.model.Permissions)16 LumeerAssertions.assertPermissions (io.lumeer.test.util.LumeerAssertions.assertPermissions)16 Test (org.junit.Test)16 JsonPermissions (io.lumeer.api.dto.JsonPermissions)10 JsonPermission (io.lumeer.api.dto.JsonPermission)8 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)8 HashSet (java.util.HashSet)8 Set (java.util.Set)8 Entity (javax.ws.rs.client.Entity)8 Response (javax.ws.rs.core.Response)8 Permission (io.lumeer.api.model.Permission)5 Project (io.lumeer.api.model.Project)3 JsonProject (io.lumeer.api.dto.JsonProject)2 Organization (io.lumeer.api.model.Organization)2 JsonOrganization (io.lumeer.api.dto.JsonOrganization)1 Role (io.lumeer.api.model.Role)1