AbstractRestrictionProvider implements RestrictionProvider, AccessControlConstants { @Override public void validateRestrictions(String oakPath, @NotNull Tree aceTree) throws AccessControlException { Map<String, PropertyState> restrictionProperties = getRestrictionProperties(aceTree); if (isUnsupportedPath(oakPath)) { if (!restrictionProperties.isEmpty()) { throw new AccessControlException("Restrictions not supported with 'null' path."); } } else { for (Map.Entry<String, PropertyState> entry : restrictionProperties.entrySet()) { String restrName = entry.getKey(); RestrictionDefinition def = supported.get(restrName); if (def == null) { throw new AccessControlException("Unsupported restriction: " + restrName); } Type<?> type = entry.getValue().getType(); if (type != def.getRequiredType()) { throw new AccessControlException("Invalid restriction type '" + type + "' for " + restrName + ". Expected " + def.getRequiredType()); } } for (RestrictionDefinition def : supported.values()) { if (def.isMandatory() && !restrictionProperties.containsKey(def.getName())) { throw new AccessControlException("Mandatory restriction " + def.getName() + " is missing."); } } } } AbstractRestrictionProvider(@NotNull Map<String, ? extends RestrictionDefinition> definitions); @NotNull @Override Set<RestrictionDefinition> getSupportedRestrictions(String oakPath); @NotNull @Override Restriction createRestriction(String oakPath, @NotNull String oakName, @NotNull Value value); @NotNull @Override Restriction createRestriction(String oakPath, @NotNull String oakName, @NotNull Value... values); @NotNull @Override Set<Restriction> readRestrictions(String oakPath, @NotNull Tree aceTree); @Override void writeRestrictions(String oakPath, Tree aceTree, Set<Restriction> restrictions); @Override void validateRestrictions(String oakPath, @NotNull Tree aceTree);  }
@Test public void testValidateRestrictionsUnsupportedPathEmptyRestrictions() throws Exception { restrictionProvider.validateRestrictions(null, getAceTree()); }
@Test public void testValidateRestrictions() throws Exception { Restriction glob = restrictionProvider.createRestriction(testPath, REP_GLOB, globValue); Restriction ntNames = restrictionProvider.createRestriction(testPath, REP_NT_NAMES, nameValues); Restriction mand = restrictionProvider.createRestriction(testPath, "mandatory", valueFactory.createValue(true)); restrictionProvider.validateRestrictions(testPath, getAceTree(mand)); restrictionProvider.validateRestrictions(testPath, getAceTree(mand, glob)); restrictionProvider.validateRestrictions(testPath, getAceTree(mand, ntNames)); restrictionProvider.validateRestrictions(testPath, getAceTree(mand, glob, ntNames)); }