org.apache.sling.resourceresolver.impl.helper
Class ResourceResolverContext

java.lang.Object
  extended by org.apache.sling.resourceresolver.impl.helper.ResourceResolverContext

public class ResourceResolverContext
extends Object

This class keeps track of the used resource providers for a resource resolver. Like a resource resolver itself, this class is not thread safe.


Constructor Summary
ResourceResolverContext(boolean isAdmin, Map<String,Object> originalAuthInfo, ResourceAccessSecurityTracker resourceAccessSecurityTracker)
          Create a new resource resolver context.
 
Method Summary
 void addFactoryResourceProvider(Long key, org.apache.sling.api.resource.ResourceProvider provider)
          Add a new resource provider
 void close()
          Close all dynamic resource providers.
 void commit(org.apache.sling.api.resource.ResourceResolver resolver)
          Commit all transient changes
 Map<String,Object> getAuthenticationInfo()
          Return the authentication info.
 org.apache.sling.api.resource.ResourceProvider getFactoryResourceProvider(Long key)
          Return a resource provider for a given key
 String getParentResourceType(org.apache.sling.api.resource.ResourceResolverFactory factory, org.apache.sling.api.resource.ResourceResolver resolver, String resourceType)
          Get the parent resource type
static String getProperty(org.apache.sling.api.resource.Resource res, String propName)
          Returns getProperty(res, propName, String.class)
static
<Type> Type
getProperty(org.apache.sling.api.resource.Resource res, String propName, Class<Type> type)
          Returns the value of the name property of the resource converted to the requested type.
 ResourceAccessSecurityTracker getResourceAccessSecurityTracker()
          get's the ServiceTracker of the ResourceAccessSecurity service
 boolean hasChanges(org.apache.sling.api.resource.ResourceResolver resolver)
          Do we have changes?
 boolean isAdmin()
          Is this an admin resource resolver.
 boolean isLive()
          Check all active dynamic resource providers.
 void refresh()
          Refresh
 void revert(org.apache.sling.api.resource.ResourceResolver resolver)
          Revert all transient changes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceResolverContext

public ResourceResolverContext(boolean isAdmin,
                               Map<String,Object> originalAuthInfo,
                               ResourceAccessSecurityTracker resourceAccessSecurityTracker)
Create a new resource resolver context.

Method Detail

isAdmin

public boolean isAdmin()
Is this an admin resource resolver.


getAuthenticationInfo

public Map<String,Object> getAuthenticationInfo()
Return the authentication info.


addFactoryResourceProvider

public void addFactoryResourceProvider(Long key,
                                       org.apache.sling.api.resource.ResourceProvider provider)
Add a new resource provider

Parameters:
key - The unique key of the provider
provider - The provider.

getFactoryResourceProvider

public org.apache.sling.api.resource.ResourceProvider getFactoryResourceProvider(Long key)
Return a resource provider for a given key

Parameters:
key - The unique key of a provider
Returns:
The resource provider or null

isLive

public boolean isLive()
Check all active dynamic resource providers.


close

public void close()
Close all dynamic resource providers.


revert

public void revert(org.apache.sling.api.resource.ResourceResolver resolver)
Revert all transient changes.


commit

public void commit(org.apache.sling.api.resource.ResourceResolver resolver)
            throws org.apache.sling.api.resource.PersistenceException
Commit all transient changes

Throws:
org.apache.sling.api.resource.PersistenceException

hasChanges

public boolean hasChanges(org.apache.sling.api.resource.ResourceResolver resolver)
Do we have changes?


refresh

public void refresh()
Refresh


getResourceAccessSecurityTracker

public ResourceAccessSecurityTracker getResourceAccessSecurityTracker()
get's the ServiceTracker of the ResourceAccessSecurity service


getParentResourceType

public String getParentResourceType(org.apache.sling.api.resource.ResourceResolverFactory factory,
                                    org.apache.sling.api.resource.ResourceResolver resolver,
                                    String resourceType)
Get the parent resource type

See Also:
ResourceResolver.getParentResourceType(java.lang.String)

getProperty

public static String getProperty(org.apache.sling.api.resource.Resource res,
                                 String propName)
Returns getProperty(res, propName, String.class)

Parameters:
res - The resource to access the property from
propName - The name of the property to access
Returns:
The property as a String or null if the property does not exist or cannot be converted into a String

getProperty

public static <Type> Type getProperty(org.apache.sling.api.resource.Resource res,
                                      String propName,
                                      Class<Type> type)
Returns the value of the name property of the resource converted to the requested type.

If the resource itself does not have the property, the property is looked up in the jcr:content child node. This access is done through the same ValueMap as is used to access the property directly. This generally only works for JCR based ValueMap instances which provide access to relative path property names. This may not work in non JCR ValueMap, however in non JCR envs there is usually no "jcr:content" child node anyway

Parameters:
res - The resource to access the property from
propName - The name of the property to access
type - The type into which to convert the property
Returns:
The property converted to the requested type or null if the property does not exist or cannot be converted into the requested type


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