public void removeMemberFromGroup(User user, Group group) { String groupId = group.getGroupId(); Collection<String> userCurrentGroupIds = userGroupRepository.findGroups(user.getLogin()); boolean userIsAlreadyAMember = false; for (String testGroupId : userCurrentGroupIds) { if (testGroupId.equals(groupId)) { userIsAlreadyAMember = true; } } if (userIsAlreadyAMember) { groupMembersRepository.removeMember(groupId, user.getLogin()); groupCounterRepository.decrementGroupCounter(user.getDomain(), groupId); userGroupRepository.removeGroup(user.getLogin(), groupId); } else { if (log.isDebugEnabled()) { log.debug("User " + user.getLogin() + " is not a member of group " + group.getName()); } } }
public Collection<Group> getGroupsForCurrentUser() { User currentUser = authenticationService.getCurrentUser(); Collection<String> groupIds = userGroupRepository.findGroups(currentUser.getLogin()); return getGroupDetails(currentUser, groupIds); }