-
Type:
Bug
-
Status: Closed
-
Priority:
Normal
-
Resolution: Fixed
-
Affects Version/s: 3.2.0
-
Fix Version/s: 4.0.0
-
Component/s: None
-
Labels:
-
Similar issues:
-
Processed by team:Pulsar
-
Sprint:Platform Sprint 132
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);