Search in sources :

Example 1 with Organization

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

the class OrganizationFacade method updateGroupPermissions.

public Set<Permission> updateGroupPermissions(final String organizationCode, final Permission... groupPermissions) {
    Organization organization = checkRoleAndGetOrganization(organizationCode, Role.MANAGE);
    organization.getPermissions().updateGroupPermissions(groupPermissions);
    organizationDao.updateOrganization(organization.getId(), organization);
    return organization.getPermissions().getGroupPermissions();
}
Also used : Organization(io.lumeer.api.model.Organization)

Example 2 with Organization

use of io.lumeer.api.model.Organization 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 3 with Organization

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

the class OrganizationFacade method updateUserPermissions.

public Set<Permission> updateUserPermissions(final String organizationCode, final Permission... userPermissions) {
    Organization organization = checkRoleAndGetOrganization(organizationCode, Role.MANAGE);
    organization.getPermissions().updateUserPermissions(userPermissions);
    organizationDao.updateOrganization(organization.getId(), organization);
    return organization.getPermissions().getUserPermissions();
}
Also used : Organization(io.lumeer.api.model.Organization)

Example 4 with Organization

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

the class OrganizationFacade method removeGroupPermission.

public void removeGroupPermission(final String organizationCode, final String group) {
    Organization organization = checkRoleAndGetOrganization(organizationCode, Role.MANAGE);
    organization.getPermissions().removeGroupPermission(group);
    organizationDao.updateOrganization(organization.getId(), organization);
}
Also used : Organization(io.lumeer.api.model.Organization)

Example 5 with Organization

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

the class UserFacade method checkPermissions.

private void checkPermissions(String organizationId) {
    Organization organization = organizationDao.getOrganizationById(organizationId);
    permissionsChecker.checkRole(organization, Role.MANAGE);
}
Also used : Organization(io.lumeer.api.model.Organization)

Aggregations

Organization (io.lumeer.api.model.Organization)69 JsonOrganization (io.lumeer.api.dto.JsonOrganization)42 Test (org.junit.Test)31 JsonPermission (io.lumeer.api.dto.JsonPermission)22 Response (javax.ws.rs.core.Response)20 Before (org.junit.Before)18 User (io.lumeer.api.model.User)17 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)17 Project (io.lumeer.api.model.Project)15 JsonProject (io.lumeer.api.dto.JsonProject)14 JsonPermissions (io.lumeer.api.dto.JsonPermissions)13 MorphiaOrganization (io.lumeer.storage.mongodb.model.MorphiaOrganization)13 JsonCollection (io.lumeer.api.dto.JsonCollection)8 Permission (io.lumeer.api.model.Permission)7 SoftAssertions (org.assertj.core.api.SoftAssertions)6 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)5 ResourceNotFoundException (io.lumeer.storage.api.exception.ResourceNotFoundException)4 MorphiaPermission (io.lumeer.storage.mongodb.model.embedded.MorphiaPermission)4 Role (io.lumeer.api.model.Role)3 DatabaseQuery (io.lumeer.storage.api.query.DatabaseQuery)3