use of io.lumeer.api.model.Organization 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);
}
use of io.lumeer.api.model.Organization 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();
}
use of io.lumeer.api.model.Organization in project engine by Lumeer.
the class MorphiaProjectDaoTest method initProjectDao.
@Before
public void initProjectDao() {
Organization organization = Mockito.mock(Organization.class);
Mockito.when(organization.getId()).thenReturn(ORGANIZATION_ID);
projectDao = new MorphiaProjectDao();
projectDao.setDatabase(database);
projectDao.setDatastore(datastore);
projectDao.setOrganization(organization);
projectDao.ensureIndexes();
}
use of io.lumeer.api.model.Organization in project engine by Lumeer.
the class MorphiaOrganizationDaoTest method testGetOrganizationsNoReadRole.
@Test
public void testGetOrganizationsNoReadRole() {
Organization organization = prepareOrganization(CODE1);
Permission userPermission = new MorphiaPermission(USER2, Collections.singleton(Role.CLONE.toString()));
organization.getPermissions().updateUserPermissions(userPermission);
datastore.save(organization);
Organization organization2 = prepareOrganization(CODE2);
Permission groupPermission = new MorphiaPermission(GROUP2, Collections.singleton(Role.SHARE.toString()));
organization2.getPermissions().updateGroupPermissions(groupPermission);
datastore.save(organization2);
DatabaseQuery query = DatabaseQuery.createBuilder(USER2).groups(Collections.singleton(GROUP2)).build();
List<Organization> organizations = organizationDao.getOrganizations(query);
assertThat(organizations).isEmpty();
}
use of io.lumeer.api.model.Organization in project engine by Lumeer.
the class MorphiaOrganizationDaoTest method testGetOrganizations.
@Test
public void testGetOrganizations() {
Organization organization = prepareOrganization(CODE1);
datastore.save(organization);
Organization organization2 = prepareOrganization(CODE2);
datastore.save(organization2);
DatabaseQuery query = DatabaseQuery.createBuilder(USER).build();
List<Organization> organizations = organizationDao.getOrganizations(query);
assertThat(organizations).extracting(Organization::getCode).containsOnly(CODE1, CODE2);
}
Aggregations