Search in sources :

Example 1 with ResourceNotFoundException

use of io.lumeer.storage.api.exception.ResourceNotFoundException in project engine by Lumeer.

the class CollectionFacade method checkProjectWriteRole.

private void checkProjectWriteRole() {
    if (!workspaceKeeper.getProject().isPresent()) {
        throw new ResourceNotFoundException(ResourceType.PROJECT);
    }
    Project project = workspaceKeeper.getProject().get();
    permissionsChecker.checkRole(project, Role.WRITE);
}
Also used : Project(io.lumeer.api.model.Project) ResourceNotFoundException(io.lumeer.storage.api.exception.ResourceNotFoundException)

Example 2 with ResourceNotFoundException

use of io.lumeer.storage.api.exception.ResourceNotFoundException in project engine by Lumeer.

the class GroupFacade method checkPermissions.

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

Example 3 with ResourceNotFoundException

use of io.lumeer.storage.api.exception.ResourceNotFoundException in project engine by Lumeer.

the class AuthenticatedUser method getCurrentUserGroups.

public Set<String> getCurrentUserGroups() {
    Optional<Organization> organizationOptional = workspaceKeeper.getOrganization();
    if (!organizationOptional.isPresent()) {
        throw new ResourceNotFoundException(ResourceType.ORGANIZATION);
    }
    Organization organization = organizationOptional.get();
    Map<String, Set<String>> userGroups = userCache.getUser(getCurrentUsername()).getGroups();
    return userGroups != null && userGroups.containsKey(organization.getId()) ? userGroups.get(organization.getId()) : Collections.emptySet();
}
Also used : Organization(io.lumeer.api.model.Organization) Set(java.util.Set) ResourceNotFoundException(io.lumeer.storage.api.exception.ResourceNotFoundException)

Example 4 with ResourceNotFoundException

use of io.lumeer.storage.api.exception.ResourceNotFoundException 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 5 with ResourceNotFoundException

use of io.lumeer.storage.api.exception.ResourceNotFoundException 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

ResourceNotFoundException (io.lumeer.storage.api.exception.ResourceNotFoundException)5 Organization (io.lumeer.api.model.Organization)4 Project (io.lumeer.api.model.Project)1 Set (java.util.Set)1