use of org.apache.sling.caconfig.spi.ConfigurationPersistenceAccessDeniedException in project sling by apache.
the class DefaultConfigurationPersistenceStrategy method replaceProperties.
private void replaceProperties(Resource resource, Map<String, Object> properties) {
if (log.isTraceEnabled()) {
log.trace("! Store properties for resource {}: {}", resource.getPath(), MapUtil.traceOutput(properties));
}
ModifiableValueMap modValueMap = resource.adaptTo(ModifiableValueMap.class);
if (modValueMap == null) {
throw new ConfigurationPersistenceAccessDeniedException("No write access: Unable to store configuration data to " + resource.getPath() + ".");
}
// remove all existing properties that are not filterd
Set<String> propertyNamesToRemove = new HashSet<>(modValueMap.keySet());
PropertiesFilterUtil.removeIgnoredProperties(propertyNamesToRemove, configurationManagementSettings);
for (String propertyName : propertyNamesToRemove) {
modValueMap.remove(propertyName);
}
modValueMap.putAll(properties);
}
Aggregations