Class AbstractResourceResolver
- java.lang.Object
-
- org.onehippo.cms7.crisp.api.resource.AbstractResourceCacheResolvable
-
- org.onehippo.cms7.crisp.api.resource.AbstractResourceResolver
-
- All Implemented Interfaces:
ResourceCacheResolvable
,ResourceResolver
public abstract class AbstractResourceResolver extends AbstractResourceCacheResolvable implements ResourceResolver
AbstractResourceResolver
base class.
-
-
Constructor Summary
Constructors Constructor Description AbstractResourceResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes any resources used in thisResourceResolver
instance with the backend.Resource
findResources(String baseAbsPath)
Resource
findResources(String baseAbsPath, Map<String,Object> pathVariables)
Resource
findResources(String baseAbsPath, ExchangeHint exchangeHint)
ResourceBeanMapper
getResourceBeanMapper()
Returns aResourceBeanMapper
.ResourceLinkResolver
getResourceLinkResolver()
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.Resource
resolve(String absPath)
Resolves singleResource
representation byabsPath
.Resource
resolve(String absPath, Map<String,Object> pathVariables)
Resolves singleResource
representation byabsPath
.Resource
resolve(String absPath, ExchangeHint exchangeHint)
Binary
resolveBinary(String absPath)
Resolves singleBinary
representation byabsPath
.Binary
resolveBinary(String absPath, Map<String,Object> pathVariables)
Resolves singleBinary
representation byabsPath
.Binary
resolveBinary(String absPath, ExchangeHint exchangeHint)
Resolves singleBinary
representation byabsPath
.Resource
resolveBinaryAsResource(String absPath)
Resource
resolveBinaryAsResource(String absPath, Map<String,Object> pathVariables)
Resource
resolveBinaryAsResource(String absPath, ExchangeHint exchangeHint)
URI
resolveFullURI(String absPath)
Resolves a full URI determined and resolved for theabsPath
.URI
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
-
-
-
-
Method Detail
-
resolve
public Resource resolve(String absPath) throws ResourceException
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
public Resource resolve(String absPath, ExchangeHint exchangeHint) throws ResourceException
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
public Resource resolve(String absPath, Map<String,Object> pathVariables) throws ResourceException
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
public Binary resolveBinary(String absPath) throws ResourceException
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
public Binary resolveBinary(String absPath, ExchangeHint exchangeHint) throws ResourceException
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 ResourceException
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.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
public Resource resolveBinaryAsResource(String absPath) 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.- 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 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.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
public Resource findResources(String baseAbsPath) 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.- 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 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.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
public boolean isLive() throws ResourceException
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
public void refresh() throws ResourceException
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
public void close() throws ResourceException
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
public ResourceLinkResolver 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
public void setResourceLinkResolver(ResourceLinkResolver resourceLinkResolver)
SetsResourceLinkResolver
.- Parameters:
resourceLinkResolver
-ResourceLinkResolver
that resolves a link for aResource
representation
-
getResourceBeanMapper
public ResourceBeanMapper getResourceBeanMapper() throws ResourceException
Returns aResourceBeanMapper
.- Specified by:
getResourceBeanMapper
in interfaceResourceResolver
- Returns:
- a
ResourceBeanMapper
- Throws:
ResourceException
-
resolveFullURI
public URI resolveFullURI(String absPath) throws ResourceException
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 ResourceException
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.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
-
-