@RequestMapping(value = "/account/groups/edit/removeMember", method = RequestMethod.POST)
  public ModelAndView removeMembership(
      @RequestParam String groupId, @RequestParam String username) {

    Collection<Group> groups = groupService.getGroupsWhereCurrentUserIsAdmin();
    Group currentGroup = null;
    for (Group group : groups) {
      if (group.getGroupId().equals(groupId)) {
        currentGroup = group;
        break;
      }
    }
    if (currentGroup == null) {
      return reinitializePage();
    }
    User memberToRemove = userService.getUserByUsername(username);
    if (memberToRemove == null) {
      return new ModelAndView(
          "redirect:/tatami/account/groups/edit?wrongUser=true&groupId="
              + currentGroup.getGroupId());
    }
    groupService.removeMemberFromGroup(memberToRemove, currentGroup);
    return new ModelAndView(
        "redirect:/tatami/account/groups/edit?memberRemove=true&groupId="
            + currentGroup.getGroupId());
  }
  @RequestMapping(value = "/account/groups/edit/addMember", method = RequestMethod.POST)
  public ModelAndView addMembership(
      @ModelAttribute("userGroupMembership") UserGroupMembership userGroupMembership) {

    if (log.isDebugEnabled()) {
      log.debug("Managing group membership for : " + userGroupMembership);
    }
    String groupId = userGroupMembership.getGroupId();
    if (groupId == null || groupId.equals("")) {
      return reinitializePage();
    }
    Collection<Group> groups = groupService.getGroupsWhereCurrentUserIsAdmin();
    Group currentGroup = null;
    for (Group group : groups) {
      if (group.getGroupId().equals(groupId)) {
        currentGroup = group;
        break;
      }
    }
    if (currentGroup == null) {
      return reinitializePage();
    }
    String username = userGroupMembership.getUsername();
    if (username == null || username.equals("")) {
      return new ModelAndView(
          "redirect:/tatami/account/groups/edit?noUser=true&groupId=" + currentGroup.getGroupId());
    }
    User newMember = userService.getUserByUsername(username);
    if (newMember == null) {
      return new ModelAndView(
          "redirect:/tatami/account/groups/edit?wrongUser=true&groupId="
              + currentGroup.getGroupId());
    }
    groupService.addMemberToGroup(newMember, currentGroup);
    return new ModelAndView(
        "redirect:/tatami/account/groups/edit?memberAdd=true&groupId=" + currentGroup.getGroupId());
  }