|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.sling.api.adapter.SlingAdaptable
org.apache.sling.adapter.SlingAdaptable
org.apache.sling.jcr.resource.internal.JcrResourceResolver
public class JcrResourceResolver
Field Summary | |
---|---|
static String |
PROP_ALIAS
|
static String |
PROP_REDIRECT_EXTERNAL
|
static String |
PROP_REDIRECT_EXTERNAL_STATUS
|
static String |
PROP_REDIRECT_INTERNAL
|
static String |
PROP_REG_EXP
|
Fields inherited from interface org.apache.sling.api.resource.ResourceResolver |
---|
REQUEST_ATTR_WORKSPACE_INFO, USER_IMPERSONATOR |
Constructor Summary | |
---|---|
JcrResourceResolver(JcrResourceProviderEntry rootProvider,
JcrResourceResolverFactoryImpl factory,
boolean isAdmin,
Map<String,Object> originalAuthInfo,
boolean useMultiWorkspaces)
|
Method Summary | ||
---|---|---|
|
adaptTo(Class<AdapterType> type)
Adapts the adaptable to another type. |
|
ResourceResolver |
clone(Map<String,Object> authenticationInfo)
Returns a new ResourceResolver instance based on the given
authenticationInfo map and the original authentication info
used to create this instance. |
|
void |
close()
Close this resource resolver. |
|
protected void |
closeCreatedResolvers()
Closes any helper resource resolver created while this resource resolver was used. |
|
protected void |
closeSession()
Closes the session underlying this resource resolver. |
|
protected void |
finalize()
Calls the close() method to ensure the resolver is properly
cleaned up before it is being collected by the garbage collector because
it is not referred to any more. |
|
Iterator<Resource> |
findResources(String query,
String language)
Searches for resources using the given query formulated in the given language. |
|
Object |
getAttribute(String name)
Returns the value of the given resource resolver attribute or null if the attribute is not set (or not visible as is the
case of the ResourceResolverFactory.PASSWORD or other security
sensitive attributes). |
|
Iterator<String> |
getAttributeNames()
Returns an iterator of attribute names whose value can be retrieved calling the ResourceResolver.getAttribute(String) method. |
|
static String |
getMapPath(String scheme,
String host,
int port,
String path)
Returns a string used for matching map entries against the given request or URI parts. |
|
String |
getProperty(Resource res,
String propName)
|
|
|
getProperty(Resource res,
String propName,
Class<Type> type)
|
|
Resource |
getResource(Resource base,
String path)
Returns a Resource object for data located at the given path. |
|
Resource |
getResource(String path)
Returns a Resource object for data located at the given path. |
|
protected Resource |
getResourceInternal(String path)
Creates a JcrNodeResource with the given path if existing |
|
String[] |
getSearchPath()
Returns the search path used by the ResourceResolver.getResource(String) method
to search for resources by relative path. |
|
String |
getUserID()
Get the user ID, if any, associated with this resource resolver. |
|
boolean |
isLive()
Returns true if this resource resolver has not been closed
yet. |
|
Iterator<Resource> |
listChildren(Resource parent)
Returns an Iterator of Resource objects loaded from
the children of the given Resource . |
|
String |
map(javax.servlet.http.HttpServletRequest request,
String resourcePath)
full implementation - apply sling:alias from the resource path - apply /etc/map mappings (inkl. |
|
String |
map(String resourcePath)
calls map(HttpServletRequest, String) as map(null, resourcePath) |
|
Iterator<Map<String,Object>> |
queryResources(String query,
String language)
Queries the storage using the given query formulated in the given language. |
|
Resource |
resolve(javax.servlet.http.HttpServletRequest request)
Resolves the resource from the given HttpServletRequest . |
|
Resource |
resolve(javax.servlet.http.HttpServletRequest request,
String absPath)
Resolves the resource from the given absPath optionally
taking HttpServletRequest into account, such as the value of
the Host request header. |
|
Resource |
resolve(String absPath)
Resolves the resource from the given absolute path. |
Methods inherited from class org.apache.sling.api.adapter.SlingAdaptable |
---|
setAdapterManager, unsetAdapterManager |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PROP_REG_EXP
public static final String PROP_REDIRECT_INTERNAL
public static final String PROP_ALIAS
public static final String PROP_REDIRECT_EXTERNAL
public static final String PROP_REDIRECT_EXTERNAL_STATUS
Constructor Detail |
---|
public JcrResourceResolver(JcrResourceProviderEntry rootProvider, JcrResourceResolverFactoryImpl factory, boolean isAdmin, Map<String,Object> originalAuthInfo, boolean useMultiWorkspaces)
Method Detail |
---|
public ResourceResolver clone(Map<String,Object> authenticationInfo) throws LoginException
ResourceResolver
ResourceResolver
instance based on the given
authenticationInfo
map and the original authentication info
used to create this instance.
The new resource resolver is created according to the following algorithm:
Map<String, Object> newAuthenticationInfo = new HashMap( authenticationInfoOfThisInstance); newAuthenticationInfo.addAll(authenticationInfo); return resourceResolverFactory.getResourceResolver(newAuthenticationInfo);
clone
in interface ResourceResolver
authenticationInfo
- The map or credential data to overlay the
orignal credential data with for the creation of a new
resource resolver. This may be null
in which case
the same credential data is used as was used to create this
instance.
ResourceResolver
LoginException
- If an error occurrs creating the new
ResourceResolver
with the provided credential
data.ResourceResolver.clone(Map)
public boolean isLive()
ResourceResolver
true
if this resource resolver has not been closed
yet.
Unlike the other methods defined in this interface, this method will
never throw an exception even after the resource resolver has been
closed
.
isLive
in interface ResourceResolver
true
if the resource resolver has not been closed
yet. Once the resource resolver has been closed, this method
returns false
.ResourceResolver.isLive()
public void close()
ResourceResolver
close
in interface ResourceResolver
ResourceResolver.close()
protected void closeSession()
close()
method.
Extensions can overwrite this method to do other work (or not close the session at all). Handle with care !
protected void closeCreatedResolvers()
Extensions can overwrite this method to do other work (or not close the created resource resovlers at all). Handle with care !
protected void finalize()
close()
method to ensure the resolver is properly
cleaned up before it is being collected by the garbage collector because
it is not referred to any more.
finalize
in class Object
public Iterator<String> getAttributeNames()
ResourceResolver
ResourceResolver.getAttribute(String)
method. This iterator will not
include any attributes which are not accessible.
getAttributeNames
in interface ResourceResolver
ResourceResolver.getAttributeNames()
public Object getAttribute(String name)
ResourceResolver
null
if the attribute is not set (or not visible as is the
case of the ResourceResolverFactory.PASSWORD
or other security
sensitive attributes).
getAttribute
in interface ResourceResolver
name
- The name of the attribute to access
null
if the attribute
is not set or not accessible.ResourceResolver.getAttribute(String)
public Resource resolve(String absPath)
ResourceResolver
NonExistingResource
if the path cannot be resolved to an existing
and accessible resource.
This method is intended to apply the same algorithm to the absolute path
as is used by the ResourceResolver.resolve(HttpServletRequest)
method except for
cases where the latter uses request property such as request headers or
request parameters to resolve a resource.
It is ok for the implementation of this method to just call the
ResourceResolver.resolve(HttpServletRequest, String)
method with
null
as the request argument.
resolve
in interface ResourceResolver
absPath
- The absolute path to be resolved to a resource. If this
parameter is null
, it is assumed to address the
root of the resource tree. If the path is relative it is
assumed relative to the root, that is a slash is prepended to
the path before resolving it.
Resource
addressed by the absPath
or a
NonExistingResource
if no such resource can be resolved.ResourceResolver.resolve(java.lang.String)
public Resource resolve(javax.servlet.http.HttpServletRequest request)
ResourceResolver
HttpServletRequest
.
Returns a NonExistingResource
if the path cannot be resolved to
an existing and accessible resource.
This method is deprecated as of API version 2.0.4 and should not be used
anymore. Implementations are expected to implement this method calling
the ResourceResolver.resolve(HttpServletRequest, String)
where the
absPath
argument is the result of calling the
getPathInfo()
on the request
object. If the
ResourceResolver.REQUEST_ATTR_WORKSPACE_INFO
attribute is set, the given
workspace is used to resolve the resource.
resolve
in interface ResourceResolver
request
- The http servlet request object used to resolve the
resource for. This must not be null
.
Resource
addressed by
HttpServletRequest.getPathInfo()
or a
NonExistingResource
if no such resource can be resolved.ResourceResolver.resolve(javax.servlet.http.HttpServletRequest)
public Resource resolve(javax.servlet.http.HttpServletRequest request, String absPath)
ResourceResolver
absPath
optionally
taking HttpServletRequest
into account, such as the value of
the Host
request header. Returns a
NonExistingResource
if the path cannot be resolved to an existing
and accessible resource.
The difference between this method and the ResourceResolver.resolve(String)
method is, that this method may take request properties like the scheme,
the host header or request parameters into account to resolve the
resource. If the ResourceResolver.REQUEST_ATTR_WORKSPACE_INFO
attribute is set,
the given workspace is used to resolve the resource.
resolve
in interface ResourceResolver
request
- The http servlet request object providing more hints at
how to resolve the absPath
. This parameter may be
null
in which case the implementation should use
reasonable defaults.absPath
- The absolute path to be resolved to a resource. If this
parameter is null
, it is assumed to address the
root of the resource tree. If the path is relative it is
assumed relative to the root, that is a slash is prepended to
the path before resolving it.
Resource
addressed by the absPath
or a
NonExistingResource
if no such resource can be resolved.ResourceResolver.resolve(javax.servlet.http.HttpServletRequest, java.lang.String)
public String map(String resourcePath)
map
in interface ResourceResolver
resourcePath
- The path for which to return a mapped path.
ResourceResolver.map(java.lang.String)
public String map(javax.servlet.http.HttpServletRequest request, String resourcePath)
map
in interface ResourceResolver
request
- The http servlet request object which may be used to apply
more mapping functionality.resourcePath
- The path for which to return a mapped path.
ResourceResolver.map(javax.servlet.http.HttpServletRequest, java.lang.String)
public String[] getSearchPath()
ResourceResolver
ResourceResolver.getResource(String)
method
to search for resources by relative path. If no search path is set an
empty array is returned.
The returns array of Strings is a copy of the internal value, so modifications to this array have no influence on the operation of the ResourceResolver.
Each entry in the array is an absolute path terminated with a slash character. Thus to create an absolute path from a search path entry and a relative path, the search path entry and relative path may just be concatenated.
getSearchPath
in interface ResourceResolver
ResourceResolver.getSearchPath()
public Resource getResource(String path)
ResourceResolver
Resource
object for data located at the given path.
This specification does not define the location for resources or the
semantics for resource paths. For an implementation reading content from
a Java Content Repository, the path could be a
javax.jcr.Item
path from which the resource object is
loaded. In contrast to the ResourceResolver.resolve(String)
method, this method
does not apply any logic to the path, so the path is used as-is to fetch
the content.
getResource
in interface ResourceResolver
path
- The absolute path to the resource object to be loaded. The
path may contain relative path specifiers like .
(current location) and ..
(parent location),
which are resolved by this method. If the path is relative,
that is the first character is not a slash, implementations
are expected to apply a search path algorithm to resolve the
relative path to a resource.
Resource
object loaded from the path or
null
if the path does not resolve to a resource.ResourceResolver.getResource(java.lang.String)
public Resource getResource(Resource base, String path)
ResourceResolver
Resource
object for data located at the given path.
This specification does not define the location for resources or the
semantics for resource paths. For an implementation reading content from
a Java Content Repository, the path could be a
javax.jcr.Item
path from which the resource object is
loaded.
getResource
in interface ResourceResolver
base
- The base Resource
against which a relative path
argument given by path
is resolved. This
parameter may be null
if the path
is
known to be absolute.path
- The path to the resource object to be loaded. If the path is
relative, i.e. does not start with a slash (/
),
the resource relative to the given base
resource
is returned. The path may contain relative path specifiers
like .
(current location) and ..
(parent location), which are resolved by this method.
Resource
object loaded from the path or
null
if the path does not resolve to a resource.ResourceResolver.getResource(org.apache.sling.api.resource.Resource, java.lang.String)
public Iterator<Resource> listChildren(Resource parent)
ResourceResolver
Iterator
of Resource
objects loaded from
the children of the given Resource
.
This specification does not define what the term "child" means. This is
left to the implementation to define. For example an implementation
reading content from a Java Content Repository, the children could be the
Resource
objects loaded from child items of the Item
of the given Resource
.
listChildren
in interface ResourceResolver
parent
- The Resource
whose children are requested.
Iterator
of Resource
objects.ResourceResolver.listChildren(org.apache.sling.api.resource.Resource)
public Iterator<Resource> findResources(String query, String language) throws SlingException
ResourceResolver
The semantic meaning of the query and language depend on the actual
implementation and storage used for the resources. For JCR repository
being used as storage, the query and lanuage parameters are used to
create a JCR Query
through the QueryManager
.
The result returned is then based on the NodeIterator
provided by the query result.
findResources
in interface ResourceResolver
query
- The query string to use to find the resources.language
- The language in which the query is formulated.
Iterator
of Resource
objects matching the
query.
QuerySyntaxException
- If the query is not syntactically correct
according to the query language indicator of if the query
language is not supported.
SlingException
- If an error occurrs querying
for the resources.ResourceResolver.findResources(java.lang.String, java.lang.String)
public Iterator<Map<String,Object>> queryResources(String query, String language) throws SlingException
ResourceResolver
The semantic meaning of the query and language depend on the actual
implementation and storage used for the resources. For JCR repository
being used as storage, the query and lanuage parameters are used to
create a JCR Query
through the QueryManager
.
The result returned is then based on the RowIterator
provided by the query result. The map returned for each row is indexed by
the column name and the column value is the JCR Value
object
converted into the respective Java object, such as Boolean
for a value of property type Boolean.
queryResources
in interface ResourceResolver
query
- The query string to use to find the resources.language
- The language in which the query is formulated.
Iterator
of Map
instances providing
access to the query result.
QuerySyntaxException
- If the query is not syntactically correct
according to the query language indicator of if the query
language is not supported.
SlingException
- If an error occurrs querying
for the resources.ResourceResolver.queryResources(java.lang.String, java.lang.String)
public String getUserID()
ResourceResolver
getUserID
in interface ResourceResolver
ResourceResolver.getUserID()
public <AdapterType> AdapterType adaptTo(Class<AdapterType> type)
Adaptable
adaptTo
in interface Adaptable
adaptTo
in class SlingAdaptable
AdapterType
- The generic type to which this resource is adapted
totype
- The Class object of the target type, such as
Node.class
null
if the resource cannot
adapt to the requested typeSlingAdaptable.adaptTo(java.lang.Class)
public static String getMapPath(String scheme, String host, int port, String path)
scheme
- The URI schemehost
- The host nameport
- The port number. If this is negative, the default value used
is 80 unless the scheme is "https" in which case the default
value is 443.path
- The (absolute) path
protected Resource getResourceInternal(String path)
public String getProperty(Resource res, String propName)
public <Type> Type getProperty(Resource res, String propName, Class<Type> type)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |