예제 #1
0
  @RequestMapping(value = "/account/groups", method = RequestMethod.POST)
  public ModelAndView addNewGroup(@ModelAttribute("group") Group group) {

    group.setName(group.getName().replace("<", " "));
    group.setDescription(group.getDescription().replace("<", " "));
    if (group.getName() != null && !group.getName().equals("")) {
      groupService.createGroup(group.getName(), group.getDescription(), group.isPublicGroup());
      return new ModelAndView("redirect:/tatami/account/groups?success=true");
    }
    return reinitializePage();
  }
예제 #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;
 }
예제 #3
0
  @RequestMapping(value = "/account/groups/edit", method = RequestMethod.POST)
  public ModelAndView doEditGroup(@ModelAttribute("group") Group group) {

    if (group.getGroupId() == null) {
      return new ModelAndView("redirect:/tatami/account/groups");
    }
    Collection<Group> groups = groupService.getGroupsWhereCurrentUserIsAdmin();
    boolean isGroupManagedByCurrentUser = false;
    for (Group testGroup : groups) {
      if (testGroup.getGroupId().equals(group.getGroupId())) {
        isGroupManagedByCurrentUser = true;
        break;
      }
    }
    if (!isGroupManagedByCurrentUser) {
      return new ModelAndView("redirect:/tatami/account/groups");
    }
    group.setDomain(authenticationService.getCurrentUser().getDomain());
    group.setName(group.getName().replace("<", " "));
    group.setDescription(group.getDescription().replace("<", " "));
    groupService.editGroup(group);
    return new ModelAndView(
        "redirect:/tatami/account/groups/edit?editGroup=true&groupId=" + group.getGroupId());
  }