Example #1
0
 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());
     }
   }
 }
Example #2
0
 public void createGroup(String name, String description, boolean publicGroup) {
   if (log.isDebugEnabled()) {
     log.debug("Creating group : " + name);
   }
   User currentUser = authenticationService.getCurrentUser();
   String domain = DomainUtil.getDomainFromLogin(currentUser.getLogin());
   String groupId = groupRepository.createGroup(domain);
   groupDetailsRepository.createGroupDetails(groupId, name, description, publicGroup);
   groupMembersRepository.addAdmin(groupId, currentUser.getLogin());
   groupCounterRepository.incrementGroupCounter(domain, groupId);
   userGroupRepository.addGroupAsAdmin(currentUser.getLogin(), groupId);
 }
Example #3
0
 public Collection<Group> getGroupsWhereCurrentUserIsAdmin() {
   User currentUser = authenticationService.getCurrentUser();
   Collection<String> groupIds = userGroupRepository.findGroupsAsAdmin(currentUser.getLogin());
   return getGroupDetails(currentUser, groupIds);
 }