Search in sources :

Example 1 with Permission

use of io.lumeer.api.model.Permission 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 Permission

use of io.lumeer.api.model.Permission 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 Permission

use of io.lumeer.api.model.Permission 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 Permission

use of io.lumeer.api.model.Permission 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 Permission

use of io.lumeer.api.model.Permission in project engine by Lumeer.

the class PermissionsCheckerTest method prepareResource.

private Resource prepareResource(Set<Role> userRoles, Set<Role> groupRoles) {
    Permission userPermission = Mockito.mock(Permission.class);
    Mockito.when(userPermission.getName()).thenReturn(USER);
    Mockito.when(userPermission.getRoles()).thenReturn(userRoles);
    Permission groupPermission = Mockito.mock(Permission.class);
    Mockito.when(groupPermission.getName()).thenReturn(GROUP);
    Mockito.when(groupPermission.getRoles()).thenReturn(groupRoles);
    Permissions permissions = Mockito.mock(Permissions.class);
    Mockito.when(permissions.getUserPermissions()).thenReturn(Collections.singleton(userPermission));
    Mockito.when(permissions.getGroupPermissions()).thenReturn(Collections.singleton(groupPermission));
    Resource resource = Mockito.mock(Resource.class);
    Mockito.when(resource.getPermissions()).thenReturn(permissions);
    Mockito.when(resource.getType()).thenReturn(ResourceType.PROJECT);
    return resource;
}
Also used : Permission(io.lumeer.api.model.Permission) Permissions(io.lumeer.api.model.Permissions) Resource(io.lumeer.api.model.Resource)

Aggregations

Permission (io.lumeer.api.model.Permission)23 Test (org.junit.Test)15 MorphiaPermission (io.lumeer.storage.mongodb.model.embedded.MorphiaPermission)10 JsonPermission (io.lumeer.api.dto.JsonPermission)9 SimplePermission (io.lumeer.core.model.SimplePermission)9 Response (javax.ws.rs.core.Response)9 Organization (io.lumeer.api.model.Organization)7 JsonOrganization (io.lumeer.api.dto.JsonOrganization)5 HashSet (java.util.HashSet)5 SearchQuery (io.lumeer.storage.api.query.SearchQuery)4 Collection (io.lumeer.api.model.Collection)2 Project (io.lumeer.api.model.Project)2 View (io.lumeer.api.model.View)2 DatabaseQuery (io.lumeer.storage.api.query.DatabaseQuery)2 MorphiaCollection (io.lumeer.storage.mongodb.model.MorphiaCollection)2 Document (org.bson.Document)2 JsonPermissions (io.lumeer.api.dto.JsonPermissions)1 JsonView (io.lumeer.api.dto.JsonView)1 Permissions (io.lumeer.api.model.Permissions)1 Resource (io.lumeer.api.model.Resource)1