Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-8605

AclUtil.createLocalRestrictions should use JackrabbitAccessControlList.isMultiValueRestriction(String)



    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Repoinit JCR 1.1.14
    • Component/s: Repoinit
    • Labels:


      today the AclUtil.createLocalRestrictions looks at the length of the value array to determine if a given restriction is intended to be multivalued or not. this may lead to an unexpected exception in cases where a single value is defined for a restriction that is defined to be multivalued. instead of looking at the length of the array, the code should make use of JackrabbitAccessControlList.isMultiValueRestriction in order to find out if a given restriction is multivalued or not.

      here the proposed change (also using the 'checkState' method that is part of the patch for SLING-8604:

          private static LocalRestrictions createLocalRestrictions(List<RestrictionClause> list, JackrabbitAccessControlList jacl, Session s) throws RepositoryException {
              Map<String,Value> restrictions = new HashMap<>();
              Map<String,Value[]> mvrestrictions = new HashMap<>();
              if(list != null && !list.isEmpty()){
                  ValueFactory vf = s.getValueFactory();
                 for(RestrictionClause rc : list){
                     String restrictionName = rc.getName();
                     int type = jacl.getRestrictionType(restrictionName);
                     boolean isMvRestriction = jacl.isMultiValueRestriction(restrictionName);
                     Value[] values = new Value[rc.getValues().size()];
                     for(int i=0;i<values.length;i++) {
                         values[i] = vf.createValue(rc.getValues().get(i),type);
                     if("rep:glob".equals(restrictionName) && values.length == 0) {
                         // SLING-7280 - special case for rep:glob which supports an empty string
                         // to mean "no values"
                         restrictions.put(restrictionName, vf.createValue(""));
                     } else if (isMvRestriction) {
                         mvrestrictions.put(restrictionName, values);
                     } else {
                         checkState(values.length == 1, "Expected just one value for single valued restriction with name " + restrictionName);
                         restrictions.put(restrictionName, values[0]);
              return new LocalRestrictions(restrictions,mvrestrictions);


          Issue Links



              • Assignee:
                rombert Robert Munteanu
                angela Angela Schreiber
              • Votes:
                0 Vote for this issue
                1 Start watching this issue


                • Created: