Class AbstractResourceResolver
- All Implemented Interfaces:
ResourceCacheResolvable
,ResourceResolver
ResourceResolver
base class.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes any resources used in thisResourceResolver
instance with the backend.findResources
(String baseAbsPath) findResources
(String baseAbsPath, Map<String, Object> pathVariables) findResources
(String baseAbsPath, ExchangeHint exchangeHint) Returns aResourceBeanMapper
.Returns a domain-specificResourceLinkResolver
for aResource
representation generated by thisResourceResolver
implementation.boolean
isLive()
Returns true if theResourceResolver
service for a backend is still alive.void
refresh()
Refreshes any local state changes, if any.Resolves singleResource
representation byabsPath
.Resolves singleResource
representation byabsPath
.resolve
(String absPath, ExchangeHint exchangeHint) resolveBinary
(String absPath) Resolves singleBinary
representation byabsPath
.resolveBinary
(String absPath, Map<String, Object> pathVariables) Resolves singleBinary
representation byabsPath
.resolveBinary
(String absPath, ExchangeHint exchangeHint) Resolves singleBinary
representation byabsPath
.resolveBinaryAsResource
(String absPath) resolveBinaryAsResource
(String absPath, Map<String, Object> pathVariables) resolveBinaryAsResource
(String absPath, ExchangeHint exchangeHint) resolveFullURI
(String absPath) Resolves a full URI determined and resolved for theabsPath
.resolveFullURI
(String absPath, Map<String, Object> pathVariables) Resolves a full URI determined and resolved for theabsPath
.void
setResourceLinkResolver
(ResourceLinkResolver resourceLinkResolver) SetsResourceLinkResolver
.Methods inherited from class org.onehippo.cms7.crisp.api.resource.AbstractResourceCacheResolvable
createCacheKey, fromCacheData, getResourceDataCache, isCacheable, isCacheEnabled, setCacheEnabled, setResourceDataCache, toCacheData
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.onehippo.cms7.crisp.api.resource.ResourceCacheResolvable
createCacheKey, fromCacheData, getResourceDataCache, isCacheable, isCacheEnabled, toCacheData
Methods inherited from interface org.onehippo.cms7.crisp.api.resource.ResourceResolver
findResources, resolve, resolveBinary, resolveBinaryAsResource
-
Constructor Details
-
AbstractResourceResolver
public AbstractResourceResolver()
-
-
Method Details
-
resolve
Resolves singleResource
representation byabsPath
.absPath
is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, thenabsPath
can be a URI path or part of URL. Or, as an example, theabsPath
can be an index name of a search index, table name of databases or node path in JCR, totally depending onResourceResolver
implementations.- Specified by:
resolve
in interfaceResourceResolver
- Parameters:
absPath
- absolute path of aResource
- Returns:
- single
Resource
representation byabsPath
- Throws:
ResourceException
- if resource resolution operation fails
-
resolve
Resolves singleResource
representation byabsPath
with the optionalexchangeHint
.absPath
is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, thenabsPath
can be a URI path or part of URL. Or, as an example, theabsPath
can be an index name of a search index, table name of databases or node path in JCR, totally depending onResourceResolver
implementations.If a non-null
exchangeHint
is given, then it can be understood by the specificResourceResolver
implementation for its specific backend.- Specified by:
resolve
in interfaceResourceResolver
- Parameters:
absPath
- absolute path of aResource
exchangeHint
- a message exchange hint for the backend- Returns:
- single
Resource
representation byabsPath
- Throws:
ResourceException
- if resource resolution operation fails
-
resolve
Resolves singleResource
representation byabsPath
.absPath
is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, thenabsPath
can be a URI path or part of URL. Or, as an example, theabsPath
can be an index name of a search index, table name of databases or node path in JCR, totally depending onResourceResolver
implementations.The
absPath
template is expanded using the given path variables (pathVariables
), if any. For example, ifpathVariables
looks like{"var1":"hello","var2":"world"}
andabsPath
is".../some/path/{var1}/{var2}/overview"
, then it is expanded to".../some/path/hello/world/overview"
by thepathVariables
when making a real request to the backend.- Specified by:
resolve
in interfaceResourceResolver
- Parameters:
absPath
- absolute path of aResource
pathVariables
- the variables to expand the template given byabsPath
- Returns:
- single
Resource
representation byabsPath
- Throws:
ResourceException
- if resource resolution operation fails
-
resolveBinary
Resolves singleBinary
representation byabsPath
.absPath
is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, thenabsPath
can be a URI path or part of URL. Or, as an example, theabsPath
can be an index name of a search index, table name of databases or node path in JCR, totally depending onResourceResolver
implementations.- Specified by:
resolveBinary
in interfaceResourceResolver
- Parameters:
absPath
- absolute path of aBinary
- Returns:
- single
Binary
representation byabsPath
- Throws:
ResourceException
- if resource resolution operation fails
-
resolveBinary
Resolves singleBinary
representation byabsPath
.absPath
is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, thenabsPath
can be a URI path or part of URL. Or, as an example, theabsPath
can be an index name of a search index, table name of databases or node path in JCR, totally depending onResourceResolver
implementations.If a non-null
exchangeHint
is given, then it can be understood by the specificResourceResolver
implementation for its specific backend.- Specified by:
resolveBinary
in interfaceResourceResolver
- Parameters:
absPath
- absolute path of aBinary
exchangeHint
- a message exchange hint for the backend- Returns:
- single
Binary
representation byabsPath
- Throws:
ResourceException
- if resource resolution operation fails
-
resolveBinary
public Binary resolveBinary(String absPath, Map<String, Object> pathVariables) throws ResourceExceptionResolves singleBinary
representation byabsPath
.absPath
is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, thenabsPath
can be a URI path or part of URL. Or, as an example, theabsPath
can be an index name of a search index, table name of databases or node path in JCR, totally depending onResourceResolver
implementations.The
absPath
template is expanded using the given path variables (pathVariables
), if any. For example, ifpathVariables
looks like{"var1":"hello","var2":"world"}
andabsPath
is".../some/path/{var1}/{var2}/overview"
, then it is expanded to".../some/path/hello/world/overview"
by thepathVariables
when making a real request to the backend.- Specified by:
resolveBinary
in interfaceResourceResolver
- Parameters:
absPath
- absolute path of aBinary
pathVariables
- the variables to expand the template given byabsPath
- Returns:
- single
Binary
representation byabsPath
- Throws:
ResourceException
- if resource resolution operation fails
-
resolveBinaryAsResource
Description copied from interface:ResourceResolver
Resolves singleBinary
representation byabsPath
, and convert it to aResource
.absPath
is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, thenabsPath
can be a URI path or part of URL. Or, as an example, theabsPath
can be an index name of a search index, table name of databases or node path in JCR, totally depending onResourceResolver
implementations.- Specified by:
resolveBinaryAsResource
in interfaceResourceResolver
- Parameters:
absPath
- absolute path of aBinary
- Returns:
- a
Resource
object converted from the singleBinary
representation byabsPath
- Throws:
ResourceException
- if resource resolution operation fails
-
resolveBinaryAsResource
public Resource resolveBinaryAsResource(String absPath, ExchangeHint exchangeHint) throws ResourceException Description copied from interface:ResourceResolver
Resolves singleBinary
representation byabsPath
, and convert it to aResource
.absPath
is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, thenabsPath
can be a URI path or part of URL. Or, as an example, theabsPath
can be an index name of a search index, table name of databases or node path in JCR, totally depending onResourceResolver
implementations.If a non-null
exchangeHint
is given, then it can be understood by the specificResourceResolver
implementation for its specific backend.- Specified by:
resolveBinaryAsResource
in interfaceResourceResolver
- Parameters:
absPath
- absolute path of aBinary
exchangeHint
- a message exchange hint for the backend- Returns:
- a
Resource
object converted from the singleBinary
representation byabsPath
- Throws:
ResourceException
- if resource resolution operation fails
-
resolveBinaryAsResource
public Resource resolveBinaryAsResource(String absPath, Map<String, Object> pathVariables) throws ResourceExceptionDescription copied from interface:ResourceResolver
Resolves singleBinary
representation byabsPath
, and convert it to aResource
.absPath
is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, thenabsPath
can be a URI path or part of URL. Or, as an example, theabsPath
can be an index name of a search index, table name of databases or node path in JCR, totally depending onResourceResolver
implementations.The
absPath
template is expanded using the given path variables (pathVariables
), if any. For example, ifpathVariables
looks like{"var1":"hello","var2":"world"}
andabsPath
is".../some/path/{var1}/{var2}/overview"
, then it is expanded to".../some/path/hello/world/overview"
by thepathVariables
when making a real request to the backend.- Specified by:
resolveBinaryAsResource
in interfaceResourceResolver
- Parameters:
absPath
- absolute path of aBinary
pathVariables
- the variables to expand the template given byabsPath
- Returns:
- a
Resource
object converted from the singleBinary
representation byabsPath
- Throws:
ResourceException
- if resource resolution operation fails
-
findResources
SearchResource
representations frombaseAbsPath
and returns a parentResource
representation which contains a collection of childResource
representations.baseAbsPath
is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, thenbaseAbsPath
can be a URI path or part of URL. Or, as an example, thebaseAbsPath
can be an index name of a search index, table name of databases or node path in JCR, totally depending onResourceResolver
implementations.- Specified by:
findResources
in interfaceResourceResolver
- Parameters:
baseAbsPath
- base absolute path of aResource
- Returns:
- a parent
Resource
representation which contains a collection of childResource
representations - Throws:
ResourceException
- if resource resolution operation fails
-
findResources
public Resource findResources(String baseAbsPath, ExchangeHint exchangeHint) throws ResourceException SearchResource
representations frombaseAbsPath
and returns a parentResource
representation which contains a collection of childResource
representations.baseAbsPath
is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, thenbaseAbsPath
can be a URI path or part of URL. Or, as an example, thebaseAbsPath
can be an index name of a search index, table name of databases or node path in JCR, totally depending onResourceResolver
implementations.If a non-null
exchangeHint
is given, then it can be understood by the specificResourceResolver
implementation for its specific backend.- Specified by:
findResources
in interfaceResourceResolver
- Parameters:
baseAbsPath
- base absolute path of aResource
exchangeHint
- a message exchange hint for the backend- Returns:
- a parent
Resource
representation which contains a collection of childResource
representations - Throws:
ResourceException
- if resource resolution operation fails
-
findResources
public Resource findResources(String baseAbsPath, Map<String, Object> pathVariables) throws ResourceExceptionSearchResource
representations frombaseAbsPath
and returns a parentResource
representation which contains a collection of childResource
representations.baseAbsPath
is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, thenbaseAbsPath
can be a URI path or part of URL. Or, as an example, thebaseAbsPath
can be an index name of a search index, table name of databases or node path in JCR, totally depending onResourceResolver
implementations.The
baseAbsPath
template is expanded using the given path variables (pathVariables
), if any. For example, ifpathVariables
looks like{"var1":"hello","var2":"world"}
andbaseAbsPath
is".../some/path/{var1}/{var2}/overview"
, then it is expanded to".../some/path/hello/world/overview"
by thepathVariables
when making a real request to the backend.- Specified by:
findResources
in interfaceResourceResolver
- Parameters:
baseAbsPath
- base absolute path of aResource
pathVariables
- the variables to expand the template given byabsPath
- Returns:
- a parent
Resource
representation which contains a collection of childResource
representations - Throws:
ResourceException
- if resource resolution operation fails
-
isLive
Returns true if theResourceResolver
service for a backend is still alive. Returns true by default.An implementation may choose to implement this method to check if the underlying connection with the backend is still alive in this method. In REST API based implementation, it is likely to simply return true in this method. However, for example, an implementation with JCR backend may use
javax.jcr.Session#isLive()
method in its implementation.- Specified by:
isLive
in interfaceResourceResolver
- Returns:
- true if the
ResourceResolver
service for a backend is still alive. true by default - Throws:
ResourceException
- if resource resolution operation fails
-
refresh
Refreshes any local state changes, if any.An implementation may choose to implement this method to give a chance to refresh local states. In REST API based implementation, it is likely to simply do nothing in this method. However, for example, an implementation with JCR backend may use
javax.jcr.Session#refresh(boolean)
method in its implementation.- Specified by:
refresh
in interfaceResourceResolver
- Throws:
ResourceException
- if resource resolution operation fails
-
close
Closes any resources used in thisResourceResolver
instance with the backend.An implementation may choose to implement this method to give a chance to close any resources used in this implementation. In REST API based implementation, it is likely to simply do nothing in this method if the REST API is stateless. However, for example, an implementation with a stateful connection may close its connection to the backend in this method.
- Specified by:
close
in interfaceResourceResolver
- Throws:
ResourceException
- if resource resolution operation fails
-
getResourceLinkResolver
Returns a domain-specificResourceLinkResolver
for aResource
representation generated by thisResourceResolver
implementation.- Specified by:
getResourceLinkResolver
in interfaceResourceResolver
- Returns:
- a domain-specific
ResourceLinkResolver
for aResource
representation generated by thisResourceResolver
implementation
-
setResourceLinkResolver
SetsResourceLinkResolver
.- Parameters:
resourceLinkResolver
-ResourceLinkResolver
that resolves a link for aResource
representation
-
getResourceBeanMapper
Returns aResourceBeanMapper
.- Specified by:
getResourceBeanMapper
in interfaceResourceResolver
- Returns:
- a
ResourceBeanMapper
- Throws:
ResourceException
-
resolveFullURI
Description copied from interface:ResourceResolver
Resolves a full URI determined and resolved for theabsPath
. Or returns null if the backend cannot support a full URI access.absPath
is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, thenabsPath
can be a URI path or part of URL. Or, as an example, theabsPath
can be an index name of a search index, table name of databases or node path in JCR, totally depending onResourceResolver
implementations.- Specified by:
resolveFullURI
in interfaceResourceResolver
- Parameters:
absPath
- absolute path of aResource
- Returns:
- URI representation by
absPath
- Throws:
ResourceException
- if resource resolution operation fails
-
resolveFullURI
public URI resolveFullURI(String absPath, Map<String, Object> pathVariables) throws ResourceExceptionDescription copied from interface:ResourceResolver
Resolves a full URI determined and resolved for theabsPath
. Or returns null if the backend cannot support a full URI access.absPath
is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, thenabsPath
can be a URI path or part of URL. Or, as an example, theabsPath
can be an index name of a search index, table name of databases or node path in JCR, totally depending onResourceResolver
implementations.The
absPath
template is expanded using the given path variables (pathVariables
), if any. For example, ifpathVariables
looks like{"var1":"hello","var2":"world"}
andabsPath
is".../some/path/{var1}/{var2}/overview"
, then it is expanded to".../some/path/hello/world/overview"
by thepathVariables
.- Specified by:
resolveFullURI
in interfaceResourceResolver
- Parameters:
absPath
- absolute path of aResource
pathVariables
- the variables to expand the template given byabsPath
- Returns:
- URI representation by
absPath
- Throws:
ResourceException
- if resource resolution operation fails
-