Esempio 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);
 }
Esempio n. 2
0
 private Collection<Group> getGroupDetails(User currentUser, Collection<String> groupIds) {
   String domain = DomainUtil.getDomainFromLogin(currentUser.getLogin());
   Collection<Group> groups = new TreeSet<Group>();
   for (String groupId : groupIds) {
     Group group = groupRepository.getGroupById(domain, groupId);
     Group groupDetails = groupDetailsRepository.getGroupDetails(groupId);
     group.setName(groupDetails.getName());
     group.setPublicGroup(groupDetails.isPublicGroup());
     group.setDescription(groupDetails.getDescription());
     long counter = groupCounterRepository.getGroupCounter(domain, groupId);
     group.setCounter(counter);
     groups.add(group);
   }
   return groups;
 }
Esempio 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());
     }
   }
 }