Search in sources :

Example 1 with ConfigurationPersistenceException

use of org.apache.sling.caconfig.spi.ConfigurationPersistenceException in project sling by apache.

the class CustomConfigurationPersistenceStrategy method getOrCreateResource.

private Resource getOrCreateResource(ResourceResolver resourceResolver, String path, Map<String, Object> properties) {
    try {
        Resource resource = ResourceUtil.getOrCreateResource(resourceResolver, path, DEFAULT_RESOURCE_TYPE, DEFAULT_RESOURCE_TYPE, false);
        replaceProperties(resource, properties);
        return resource;
    } catch (PersistenceException ex) {
        throw new ConfigurationPersistenceException("Unable to persist configuration to " + path, ex);
    }
}
Also used : Resource(org.apache.sling.api.resource.Resource) ConfigurationPersistenceException(org.apache.sling.caconfig.spi.ConfigurationPersistenceException) PersistenceException(org.apache.sling.api.resource.PersistenceException) ConfigurationPersistenceException(org.apache.sling.caconfig.spi.ConfigurationPersistenceException)

Example 2 with ConfigurationPersistenceException

use of org.apache.sling.caconfig.spi.ConfigurationPersistenceException in project sling by apache.

the class CustomConfigurationPersistenceStrategy2 method deleteConfiguration.

@Override
public boolean deleteConfiguration(ResourceResolver resourceResolver, String configResourcePath) {
    Resource resource = resourceResolver.getResource(configResourcePath);
    if (resource != null) {
        try {
            resourceResolver.delete(resource);
        } catch (PersistenceException ex) {
            throw new ConfigurationPersistenceException("Unable to delete configuration at " + configResourcePath, ex);
        }
    }
    commit(resourceResolver);
    return true;
}
Also used : Resource(org.apache.sling.api.resource.Resource) ConfigurationPersistenceException(org.apache.sling.caconfig.spi.ConfigurationPersistenceException) PersistenceException(org.apache.sling.api.resource.PersistenceException) ConfigurationPersistenceException(org.apache.sling.caconfig.spi.ConfigurationPersistenceException)

Example 3 with ConfigurationPersistenceException

use of org.apache.sling.caconfig.spi.ConfigurationPersistenceException in project sling by apache.

the class CustomConfigurationPersistenceStrategy method deleteConfiguration.

@Override
public boolean deleteConfiguration(ResourceResolver resourceResolver, String configResourcePath) {
    Resource resource = resourceResolver.getResource(configResourcePath);
    if (resource != null) {
        try {
            resourceResolver.delete(resource);
        } catch (PersistenceException ex) {
            throw new ConfigurationPersistenceException("Unable to delete configuration at " + configResourcePath, ex);
        }
    }
    commit(resourceResolver);
    return true;
}
Also used : Resource(org.apache.sling.api.resource.Resource) ConfigurationPersistenceException(org.apache.sling.caconfig.spi.ConfigurationPersistenceException) PersistenceException(org.apache.sling.api.resource.PersistenceException) ConfigurationPersistenceException(org.apache.sling.caconfig.spi.ConfigurationPersistenceException)

Example 4 with ConfigurationPersistenceException

use of org.apache.sling.caconfig.spi.ConfigurationPersistenceException in project sling by apache.

the class CustomConfigurationPersistenceStrategy2 method getOrCreateResource.

private Resource getOrCreateResource(ResourceResolver resourceResolver, String path, Map<String, Object> properties) {
    try {
        Resource resource = ResourceUtil.getOrCreateResource(resourceResolver, path, DEFAULT_RESOURCE_TYPE, DEFAULT_RESOURCE_TYPE, false);
        replaceProperties(resource, properties);
        return resource;
    } catch (PersistenceException ex) {
        throw new ConfigurationPersistenceException("Unable to persist configuration to " + path, ex);
    }
}
Also used : Resource(org.apache.sling.api.resource.Resource) ConfigurationPersistenceException(org.apache.sling.caconfig.spi.ConfigurationPersistenceException) PersistenceException(org.apache.sling.api.resource.PersistenceException) ConfigurationPersistenceException(org.apache.sling.caconfig.spi.ConfigurationPersistenceException)

Aggregations

PersistenceException (org.apache.sling.api.resource.PersistenceException)4 Resource (org.apache.sling.api.resource.Resource)4 ConfigurationPersistenceException (org.apache.sling.caconfig.spi.ConfigurationPersistenceException)4