public Group getGroup(String groupId) { return identityService.createGroupQuery().groupId(groupId).singleResult(); }
public void deleteGroup(String groupId) { Group group = identityService.createGroupQuery().groupId(groupId).singleResult(); if (group == null) { throw new NotFoundException(); } identityService.deleteGroup(groupId); }
protected Group getGroupFromRequest(String groupId) { Group group = identityService.createGroupQuery().groupId(groupId).singleResult(); if (group == null) { throw new FlowableObjectNotFoundException("Could not find a group with id '" + groupId + "'.", Group.class); } if (restApiInterceptor != null) { restApiInterceptor.accessGroupInfoById(group); } return group; }
public Group updateGroupName(String groupId, String name) { if (StringUtils.isBlank(name)) { throw new BadRequestException("Group name required"); } Group group = identityService.createGroupQuery().groupId(groupId).singleResult(); if (group == null) { throw new NotFoundException(); } group.setName(name); identityService.saveGroup(group); return group; }
protected boolean isGroupPrivilege(String privilegeId, String groupId) { Group group = identityService.createGroupQuery().groupId(groupId).singleResult(); if (group == null) { throw new IllegalArgumentException("Invalid group id"); } return identityService.createPrivilegeQuery().privilegeId(privilegeId).groupId(groupId).count() > 0; }
protected void verifyGroupMemberExists(String groupId, String userId) { // Check existence Group group = identityService.createGroupQuery().groupId(groupId).singleResult(); User user = identityService.createUserQuery().userId(userId).singleResult(); for (User groupMember : identityService.createUserQuery().memberOfGroup(groupId).list()) { if (groupMember.getId().equals(userId)) { user = groupMember; } } if (group == null || user == null) { throw new NotFoundException(); } }
public void addGroupMember(String groupId, String userId) { verifyGroupMemberExists(groupId, userId); Group group = identityService.createGroupQuery().groupId(groupId).singleResult(); if (group == null) { throw new NotFoundException(); } User user = identityService.createUserQuery().userId(userId).singleResult(); if (user == null) { throw new NotFoundException(); } identityService.createMembership(userId, groupId); }
public void deleteGroupMember(String groupId, String userId) { verifyGroupMemberExists(groupId, userId); Group group = identityService.createGroupQuery().groupId(groupId).singleResult(); if (group == null) { throw new NotFoundException(); } User user = identityService.createUserQuery().userId(userId).singleResult(); if (user == null) { throw new NotFoundException(); } identityService.deleteMembership(userId, groupId); }