@RequestMapping(method = RequestMethod.GET, value = "/member/")
 public List<UserGroupDTO> loadUserGroupsWhereUserIsMember(
     @PathVariable("userId") final int userId, final Principal principal) {
   return dtoService.transformUserGroups(
       userGroupService.loadUserGroupsWhereUserIsMember(userService.load(userId)),
       getUser(principal));
 }
 @ResponseStatus(HttpStatus.OK)
 @ResponseBody
 @RequestMapping(method = RequestMethod.DELETE, value = "/{userGroupId}")
 public void delete(
     @PathVariable("userId") final int userId,
     @PathVariable("userGroupId") final int userGroupId) {
   userGroupService.delete(userGroupId);
 }
 @RequestMapping(method = RequestMethod.GET, value = "/")
 public List<UserGroupEditDTO> userGroupList(final @PathVariable("userId") int userId) {
   final List<UserGroup> userGroups =
       userGroupService.loadUserGroupsWhereUserIsOwner(userService.load(userId));
   final Function<UserGroup, UserGroupEditDTO> mapper =
       userGroup -> {
         final UserGroupEditDTO dto = new UserGroupEditDTO();
         dto.setUserGroupId(userGroup.getId());
         dto.setUserGroupName(userGroup.getGroupName());
         dto.setCupIds(
             userGroupService
                 .loadCups(userGroup)
                 .stream()
                 .map(AbstractEntity::getId)
                 .collect(Collectors.toList()));
         return dto;
       };
   return userGroups.stream().map(mapper).collect(Collectors.toList());
 }
 @ResponseStatus(HttpStatus.OK)
 @ResponseBody
 @RequestMapping(
     method = RequestMethod.PUT,
     value = "/{userGroupId}",
     produces = APPLICATION_JSON_VALUE)
 public UserGroupEditDTO save(
     @RequestBody final UserGroupEditDTO dto,
     @PathVariable("userId") final int userId,
     @PathVariable("userGroupId") final int userGroupId) {
   // TODO: validate!
   save(userId, dto, userGroupService.load(userGroupId));
   return dto;
 }
 private UserGroup save(final int userId, final UserGroupEditDTO dto, final UserGroup userGroup) {
   final User groupOwner = userService.load(userId);
   userGroup.setOwner(groupOwner);
   userGroup.setGroupName(dto.getUserGroupName());
   return userGroupService.save(userGroup, dto.getCupIds());
 }