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); }