private UserGroupRestRep update() {
      UserGroupUpdateParam param = new UserGroupUpdateParam();
      UserGroupRestRep userGroupRestRep = UserGroupUtils.getUserGroup(this.id);

      param.setLabel(userGroupRestRep.getName());
      param.setDomain(this.domain);

      Set<UserAttributeParam> oldAttributes = userGroupRestRep.getAttributes();
      Set<UserAttributeParam> newAttributes = new HashSet<UserAttributeParam>();
      for (AttributeMapping mapping : this.attributes) {
        if (mapping != null) {
          newAttributes.add(mapping.createUserAttributeParam());
        }
      }

      param.getAddAttributes().addAll(newAttributes);
      param.getAddAttributes().removeAll(oldAttributes);

      for (UserAttributeParam oldAttribute : oldAttributes) {
        param.getRemoveAttributes().add(oldAttribute.getKey());
      }

      for (UserAttributeParam newAttribute : newAttributes) {
        param.getRemoveAttributes().remove(newAttribute.getKey());
      }

      return UserGroupUtils.update(this.id, param);
    }
  @FlashException("list")
  @Restrictions({@Restrict("SECURITY_ADMIN")})
  public static void edit(String id) {
    UserGroupRestRep userGroup = UserGroupUtils.getUserGroup(id);
    if (userGroup == null) {
      flash.error(MessagesUtils.get(UNKNOWN, id));
      list();
    }

    edit(new UserGroupForm(userGroup));
  }
    private UserGroupRestRep create() {
      UserGroupCreateParam param = new UserGroupCreateParam();
      param.setLabel(this.name);
      param.setDomain(this.domain);
      for (AttributeMapping mapping : this.attributes) {
        if (mapping != null) {
          param.getAttributes().add(mapping.createUserAttributeParam());
        }
      }

      return UserGroupUtils.create(param);
    }
 public static void listJson() {
   performListJson(UserGroupUtils.getUserGroups(), new JsonItemOperation());
 }
 @Override
 public Void performOperation(URI id) throws Exception {
   UserGroupUtils.delete(id);
   return null;
 }