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; }
query.groupId(allRequestParams.get("id"));
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; }
@ApiOperation(value = "Create a group", tags = { "Groups" }) @ApiResponses(value = { @ApiResponse(code = 201, message = "Indicates the group was created."), @ApiResponse(code = 400, message = "Indicates the id of the group was missing.") }) @PostMapping(value = "/groups", produces = "application/json") public GroupResponse createGroup(@RequestBody GroupRequest groupRequest, HttpServletRequest httpRequest, HttpServletResponse response) { if (groupRequest.getId() == null) { throw new FlowableIllegalArgumentException("Id cannot be null."); } // Check if a user with the given ID already exists so we return a CONFLICT if (identityService.createGroupQuery().groupId(groupRequest.getId()).count() > 0) { throw new FlowableConflictException("A group with id '" + groupRequest.getId() + "' already exists."); } Group created = identityService.newGroup(groupRequest.getId()); created.setId(groupRequest.getId()); created.setName(groupRequest.getName()); created.setType(groupRequest.getType()); if (restApiInterceptor != null) { restApiInterceptor.createNewGroup(created); } identityService.saveGroup(created); response.setStatus(HttpStatus.CREATED.value()); return restResponseFactory.createGroupResponse(created); }
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); }