org.apache.sling.jcr.resource.internal.helper.jcr
Class JcrResourceProvider

java.lang.Object
  extended by org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider
All Implemented Interfaces:
ResourceProvider

public class JcrResourceProvider
extends Object
implements ResourceProvider

The JcrResourceProvider is the main resource provider of this bundle providing access to JCR resources. This resoure provider is created for each JcrResourceResolver instance and is bound to the JCR session for a single request.


Field Summary
 
Fields inherited from interface org.apache.sling.api.resource.ResourceProvider
RESOURCE_TYPE_SYNTHETIC, ROOTS, SERVICE_NAME
 
Constructor Summary
JcrResourceProvider(javax.jcr.Session session, ClassLoader dynamicClassLoader, boolean useMultiWorkspaces)
           
 
Method Summary
 Resource getResource(ResourceResolver resourceResolver, javax.servlet.http.HttpServletRequest request, String path)
          Returns a resource from this resource provider or null if the resource provider cannot find it.
 Resource getResource(ResourceResolver resourceResolver, String path)
          Returns a resource from this resource provider or null if the resource provider cannot find it.
 String[] getRoots()
           
 javax.jcr.Session getSession()
           
 boolean itemExists(String path)
          Checks whether the item exists and this content manager's session has read access to the item.
 Iterator<Resource> listChildren(Resource parent)
          Returns an Iterator of Resource objects loaded from the children of the given Resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JcrResourceProvider

public JcrResourceProvider(javax.jcr.Session session,
                           ClassLoader dynamicClassLoader,
                           boolean useMultiWorkspaces)
Method Detail

getRoots

public String[] getRoots()

getResource

public Resource getResource(ResourceResolver resourceResolver,
                            javax.servlet.http.HttpServletRequest request,
                            String path)
                     throws SlingException
Description copied from interface: ResourceProvider
Returns a resource from this resource provider or null if the resource provider cannot find it. The path should have one of the ResourceProvider.ROOTS strings as its prefix.

This method is called to resolve a resource for the given request. The properties of the request, such as request parameters, may be use to parametrize the resource resolution. An example of such parametrization is support for a JSR-311 style resource provider to support the parametrized URL patterns.

Specified by:
getResource in interface ResourceProvider
Parameters:
resourceResolver - The ResourceResolver to which the returned Resource is attached.
Returns:
null If this provider does not have a resource for the path.
Throws:
SlingException - may be thrown in case of any problem creating the Resource instance.

getResource

public Resource getResource(ResourceResolver resourceResolver,
                            String path)
                     throws SlingException
Description copied from interface: ResourceProvider
Returns a resource from this resource provider or null if the resource provider cannot find it. The path should have one of the ResourceProvider.ROOTS strings as its prefix.

Specified by:
getResource in interface ResourceProvider
Parameters:
resourceResolver - The ResourceResolver to which the returned Resource is attached.
Returns:
null If this provider does not have a resource for the path.
Throws:
SlingException - may be thrown in case of any problem creating the Resource instance.

listChildren

public Iterator<Resource> listChildren(Resource parent)
Description copied from interface: ResourceProvider
Returns an Iterator of Resource objects loaded from the children of the given Resource. The returned Resource instances are attached to the same ResourceResolver as the given parent resource.

This method may be called for resource providers whose root path list contains a path such that the resource path is a prefix of the list entry. This allows for the enumeration of deeply nested provided resources for which no actual parent hierarchy exists.

The returned iterator may in turn contain resources which do not actually exist but are required to traverse the resource tree. Such resources SHOULD be SyntheticResource objects whose resource type MUST be set to ResourceProvider.RESOURCE_TYPE_SYNTHETIC.

Specified by:
listChildren in interface ResourceProvider
Parameters:
parent - The Resource whose children are requested.
Returns:
An Iterator of Resource objects or null if the resource provider has no children for the given resource.

getSession

public javax.jcr.Session getSession()

itemExists

public boolean itemExists(String path)
Checks whether the item exists and this content manager's session has read access to the item. If the item does not exist, access control is ignored by this method and false is returned.

Parameters:
path - The path to the item to check
Returns:
true if the item exists and this content manager's session has read access. If the item does not exist, false is returned ignoring access control.


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