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;
}
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;
}
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);
}
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);
}
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;
}
Aggregations