org.apache.sling.api.resource
Interface ModifyingResourceProvider

All Superinterfaces:
ResourceProvider

public interface ModifyingResourceProvider
extends ResourceProvider

A modifying resource provider is an extension of a resource provider which is only supported if the resource provider has been created through a ResourceProviderFactory. A modifying resource provider allows to create, update, and delete resources. Update is handled through ModifiableValueMap. All changes should be kept in a transient store until commit(ResourceResolver) is called. revert(ResourceResolver) discards all transient changes. If the modifying resource provider needs to clean up resources when it is discarded like removing objects from the transient state which are not committed etc., it should also implement the DynamicResourceProvider interface.

Since:
2.2.0
See Also:
ResourceProviderFactory.getResourceProvider(java.util.Map), ResourceProviderFactory.getAdministrativeResourceProvider(java.util.Map)

Field Summary
 
Fields inherited from interface org.apache.sling.api.resource.ResourceProvider
OWNS_ROOTS, RESOURCE_TYPE_SYNTHETIC, ROOTS, SERVICE_NAME
 
Method Summary
 void commit(ResourceResolver resolver)
          Commit all transient changes: create, delete and updates
 Resource create(ResourceResolver resolver, java.lang.String path, java.util.Map<java.lang.String,java.lang.Object> properties)
          Create a new resource at the given path.
 void delete(ResourceResolver resolver, java.lang.String path)
          Delete the resource at the given path.
 boolean hasChanges(ResourceResolver resolver)
          Are there any transient changes?
 void revert(ResourceResolver resolver)
          Revert all transient changes: create, delete and updates.
 
Methods inherited from interface org.apache.sling.api.resource.ResourceProvider
getResource, getResource, listChildren
 

Method Detail

create

Resource create(ResourceResolver resolver,
                java.lang.String path,
                java.util.Map<java.lang.String,java.lang.Object> properties)
                throws PersistenceException
Create a new resource at the given path. The new resource is put into the transient space of this provider until commit(ResourceResolver) is called.

Parameters:
resolver - The current resource resolver.
path - The resource path.
properties - Optional properties
Returns:
The new resource.
Throws:
PersistenceException - If anything fails

delete

void delete(ResourceResolver resolver,
            java.lang.String path)
            throws PersistenceException
Delete the resource at the given path. This change is kept in the transient space of this provider until commit(ResourceResolver) is called.

Parameters:
resolver - The current resource resolver.
path - The resource path.
Throws:
PersistenceException - If anything fails

revert

void revert(ResourceResolver resolver)
Revert all transient changes: create, delete and updates.

Parameters:
resolver - The current resource resolver.

commit

void commit(ResourceResolver resolver)
            throws PersistenceException
Commit all transient changes: create, delete and updates

Parameters:
resolver - The current resource resolver.
Throws:
PersistenceException - If anything fails

hasChanges

boolean hasChanges(ResourceResolver resolver)
Are there any transient changes?

Parameters:
resolver - The current resource resolver.


Copyright © 2007-2012 The Apache Software Foundation. All Rights Reserved.