private static LocalRestrictions createLocalRestrictions()

in src/main/java/org/apache/sling/jcr/repoinit/impl/AclUtil.java [99:132]


    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 {0}",
                            restrictionName);
                    restrictions.put(restrictionName, values[0]);
                }
            }
        }
        return new LocalRestrictions(restrictions, mvrestrictions);
    }