use of org.apache.sling.api.resource.PersistenceException in project sling by apache.
the class MongoDBNoSqlResourceProviderTransactionalIT method testRoot.
@Override
protected Resource testRoot() {
if (this.testRoot == null) {
try {
Resource root = context.resourceResolver().getResource("/");
Resource providerRoot = root.getChild("test");
if (providerRoot == null) {
providerRoot = context.resourceResolver().create(root, "test", ImmutableMap.<String, Object>of(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED));
}
this.testRoot = context.resourceResolver().create(providerRoot, UUID.randomUUID().toString(), ImmutableMap.<String, Object>of(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED));
} catch (PersistenceException ex) {
throw new RuntimeException(ex);
}
}
return this.testRoot;
}
use of org.apache.sling.api.resource.PersistenceException in project sling by apache.
the class SimpleNoSqlResourceProviderTransactionalTest method testRoot.
@Override
protected Resource testRoot() {
if (this.testRoot == null) {
try {
Map<String, Object> props = new HashMap<String, Object>();
props.put(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED);
final Resource root = context.resourceResolver().getResource("/");
Resource noSqlRoot = context.resourceResolver().create(root, "nosql-simple", props);
this.testRoot = context.resourceResolver().create(noSqlRoot, "test", props);
context.resourceResolver().commit();
} catch (PersistenceException ex) {
throw new RuntimeException(ex);
}
}
return this.testRoot;
}
use of org.apache.sling.api.resource.PersistenceException in project sling by apache.
the class SimpleNoSqlResourceProviderTest method testRoot.
@Override
protected Resource testRoot() {
if (this.testRoot == null) {
try {
Map<String, Object> props = new HashMap<String, Object>();
props.put(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED);
final Resource root = context.resourceResolver().getResource("/");
Resource noSqlRoot = context.resourceResolver().create(root, "nosql-simple", props);
this.testRoot = context.resourceResolver().create(noSqlRoot, "test", props);
} catch (PersistenceException ex) {
throw new RuntimeException(ex);
}
}
return this.testRoot;
}
use of org.apache.sling.api.resource.PersistenceException 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;
}
use of org.apache.sling.api.resource.PersistenceException 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);
}
}
Aggregations