@Override
public void validateRestrictions(String oakPath, 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 {
// supported path -> validate restrictions and test if mandatory
// restrictions are present.
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 + "'. Expected " + def.getRequiredType());
}
}
for (RestrictionDefinition def : supported.values()) {
if (def.isMandatory() && !restrictionProperties.containsKey(def.getName())) {
throw new AccessControlException("Mandatory restriction " + def.getName() + " is missing.");
}
}
}
}