Search in sources :

Example 31 with Organization

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

the class OrganizationFacade method removeUserPermission.

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

Example 32 with Organization

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

the class OrganizationFacade method getOrganization.

public Organization getOrganization(final String organizationCode) {
    Organization organization = organizationDao.getOrganizationByCode(organizationCode);
    permissionsChecker.checkRole(organization, Role.READ);
    return keepOnlyActualUserRoles(organization);
}
Also used : Organization(io.lumeer.api.model.Organization)

Example 33 with Organization

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

the class OrganizationFacade method updateOrganization.

public Organization updateOrganization(final String organizationCode, final Organization organization) {
    Organization storedOrganization = organizationDao.getOrganizationByCode(organizationCode);
    permissionsChecker.checkRole(storedOrganization, Role.MANAGE);
    keepStoredPermissions(organization, storedOrganization.getPermissions());
    Organization updatedOrganization = organizationDao.updateOrganization(storedOrganization.getId(), organization);
    return keepOnlyActualUserRoles(updatedOrganization);
}
Also used : Organization(io.lumeer.api.model.Organization)

Example 34 with Organization

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

the class ProjectFacade method checkOrganizationWriteRole.

private void checkOrganizationWriteRole() {
    if (!workspaceKeeper.getOrganization().isPresent()) {
        throw new ResourceNotFoundException(ResourceType.ORGANIZATION);
    }
    Organization organization = workspaceKeeper.getOrganization().get();
    permissionsChecker.checkRole(organization, Role.WRITE);
}
Also used : Organization(io.lumeer.api.model.Organization) ResourceNotFoundException(io.lumeer.storage.api.exception.ResourceNotFoundException)

Example 35 with Organization

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

the class GroupFacade method deleteGroupFromUsers.

private void deleteGroupFromUsers(String groupId) {
    if (!workspaceKeeper.getOrganization().isPresent()) {
        throw new ResourceNotFoundException(ResourceType.ORGANIZATION);
    }
    Organization organization = workspaceKeeper.getOrganization().get();
    userDao.deleteGroupFromUsers(organization.getId(), groupId);
}
Also used : Organization(io.lumeer.api.model.Organization) ResourceNotFoundException(io.lumeer.storage.api.exception.ResourceNotFoundException)

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