Exemplo n.º 1
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);
 }
Exemplo n.º 2
0
 public Collection<UserGroupDTO> getMembersForGroup(String groupId) {
   Map<String, String> membersMap = groupMembersRepository.findMembers(groupId);
   Collection<UserGroupDTO> userGroupDTOs = new TreeSet<UserGroupDTO>();
   for (Map.Entry<String, String> member : membersMap.entrySet()) {
     UserGroupDTO dto = new UserGroupDTO();
     User user = userRepository.findUserByLogin(member.getKey());
     dto.setLogin(user.getLogin());
     dto.setUsername(user.getUsername());
     dto.setGravatar(user.getGravatar());
     dto.setFirstName(user.getFirstName());
     dto.setLastName(user.getLastName());
     dto.setRole(member.getValue());
     userGroupDTOs.add(dto);
   }
   return userGroupDTOs;
 }
Exemplo n.º 3
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());
     }
   }
 }