use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.
the class IdentityRestServiceImpl method getGroupInfo.
@Override
public GroupInfoDto getGroupInfo(String userId) {
if (userId == null) {
throw new InvalidRequestException(Status.BAD_REQUEST, "No user id was supplied");
}
IdentityService identityService = getProcessEngine().getIdentityService();
GroupQuery query = identityService.createGroupQuery();
List<Group> userGroups = query.groupMember(userId).orderByGroupName().asc().list();
Set<UserDto> allGroupUsers = new HashSet<UserDto>();
List<GroupDto> allGroups = new ArrayList<GroupDto>();
for (Group group : userGroups) {
List<User> groupUsers = identityService.createUserQuery().memberOfGroup(group.getId()).list();
for (User user : groupUsers) {
if (!user.getId().equals(userId)) {
allGroupUsers.add(new UserDto(user.getId(), user.getFirstName(), user.getLastName()));
}
}
allGroups.add(new GroupDto(group.getId(), group.getName()));
}
return new GroupInfoDto(allGroups, allGroupUsers);
}
use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.
the class GroupResourceImpl method getGroup.
public GroupDto getGroup(UriInfo context) {
Group dbGroup = findGroupObject();
if (dbGroup == null) {
throw new InvalidRequestException(Status.NOT_FOUND, "Group with id " + resourceId + " does not exist");
}
GroupDto group = GroupDto.fromGroup(dbGroup);
return group;
}
use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.
the class TenantQueryTest method setUp.
@Before
public void setUp() {
identityService = engineRule.getIdentityService();
createTenant(TENANT_ONE, "Tenant_1");
createTenant(TENANT_TWO, "Tenant_2");
User user = identityService.newUser(USER);
identityService.saveUser(user);
Group group = identityService.newGroup(GROUP);
identityService.saveGroup(group);
identityService.createMembership(USER, GROUP);
identityService.createTenantUserMembership(TENANT_ONE, USER);
identityService.createTenantGroupMembership(TENANT_TWO, GROUP);
}
use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testDeleteMembershipUnexistingUser.
@Test
public void testDeleteMembershipUnexistingUser() {
Group sales = identityService.newGroup("sales");
identityService.saveGroup(sales);
// No exception should be thrown when user doesn't exist
identityService.deleteMembership("unexistinguser", sales.getId());
identityService.deleteGroup(sales.getId());
}
use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testDeleteMembership.
@Test
public void testDeleteMembership() {
Group sales = identityService.newGroup("sales");
identityService.saveGroup(sales);
User johndoe = identityService.newUser("johndoe");
identityService.saveUser(johndoe);
// Add membership
identityService.createMembership(johndoe.getId(), sales.getId());
List<Group> groups = identityService.createGroupQuery().groupMember(johndoe.getId()).list();
assertTrue(groups.size() == 1);
assertEquals("sales", groups.get(0).getId());
// Delete the membership and check members of sales group
identityService.deleteMembership(johndoe.getId(), sales.getId());
groups = identityService.createGroupQuery().groupMember(johndoe.getId()).list();
assertTrue(groups.size() == 0);
identityService.deleteGroup("sales");
identityService.deleteUser("johndoe");
}
Aggregations