Search in sources :

Example 1 with ConfigurationPersistenceAccessDeniedException

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);
}
Also used : ConfigurationPersistenceAccessDeniedException(org.apache.sling.caconfig.spi.ConfigurationPersistenceAccessDeniedException) ModifiableValueMap(org.apache.sling.api.resource.ModifiableValueMap) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 ModifiableValueMap (org.apache.sling.api.resource.ModifiableValueMap)1 ConfigurationPersistenceAccessDeniedException (org.apache.sling.caconfig.spi.ConfigurationPersistenceAccessDeniedException)1