Uploaded image for project: '[Read Only] - Hippo Repository'
  1. [Read Only] - Hippo Repository
  2. REPO-1487

RepositoryGroupManager - error adding users to an empty group

    XMLWordPrintable

    Details

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

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              smuco Saimir Muco
            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: