Details
-
Bug
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
3.2.0
-
None
-
Platform Sprint 132
Description
Try to add a new user to a group programatically by using the following method:
org.hippoecm.repository.security.group.AbstractGroupManager#addMember(Node group, String rawUserId) { .. Set<String> members = getMembers(group); if (!members.contains(userId)) { members.add(userId); setMembers(group, members); } ... }
Internally it calls the method
getMembers(Node group) { final Property membersProperty = JcrUtils.getPropertyIfExists(group, HippoNodeType.HIPPO_MEMBERS); if (membersProperty != null) { Value[] values = membersProperty.getValues(); final Set<String> members = new HashSet<>(values.length); for (final Value value : values) { members.add(value.getString()); } return members; } return Collections.emptySet(); }
to check if the user is already part of the group. In case there is no property hipposys:members , it returns an empty set. The problem is that Set is immutable and therefore the addMember fails to add the new user members.add(userId);