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
Abstract ResourceResolver base class.
  • Constructor Details

    • AbstractResourceResolver

      public AbstractResourceResolver()
  • Method Details

    • resolve

      public Resource resolve(String absPath) throws ResourceException
      Resolves single Resource representation by absPath.

      absPath is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, then absPath can be a URI path or part of URL. Or, as an example, the absPath can be an index name of a search index, table name of databases or node path in JCR, totally depending on ResourceResolver implementations.

      Specified by:
      resolve in interface ResourceResolver
      Parameters:
      absPath - absolute path of a Resource
      Returns:
      single Resource representation by absPath
      Throws:
      ResourceException - if resource resolution operation fails
    • resolve

      public Resource resolve(String absPath, ExchangeHint exchangeHint) throws ResourceException
      Resolves single Resource representation by absPath with the optional exchangeHint.

      absPath is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, then absPath can be a URI path or part of URL. Or, as an example, the absPath can be an index name of a search index, table name of databases or node path in JCR, totally depending on ResourceResolver implementations.

      If a non-null exchangeHint is given, then it can be understood by the specific ResourceResolver implementation for its specific backend.

      Specified by:
      resolve in interface ResourceResolver
      Parameters:
      absPath - absolute path of a Resource
      exchangeHint - a message exchange hint for the backend
      Returns:
      single Resource representation by absPath
      Throws:
      ResourceException - if resource resolution operation fails
    • resolve

      public Resource resolve(String absPath, Map<String,Object> pathVariables) throws ResourceException
      Resolves single Resource representation by absPath.

      absPath is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, then absPath can be a URI path or part of URL. Or, as an example, the absPath can be an index name of a search index, table name of databases or node path in JCR, totally depending on ResourceResolver implementations.

      The absPath template is expanded using the given path variables (pathVariables), if any. For example, if pathVariables looks like {"var1":"hello","var2":"world"} and absPath is ".../some/path/{var1}/{var2}/overview", then it is expanded to ".../some/path/hello/world/overview" by the pathVariables when making a real request to the backend.

      Specified by:
      resolve in interface ResourceResolver
      Parameters:
      absPath - absolute path of a Resource
      pathVariables - the variables to expand the template given by absPath
      Returns:
      single Resource representation by absPath
      Throws:
      ResourceException - if resource resolution operation fails
    • resolveBinary

      public Binary resolveBinary(String absPath) throws ResourceException
      Resolves single Binary representation by absPath.

      absPath is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, then absPath can be a URI path or part of URL. Or, as an example, the absPath can be an index name of a search index, table name of databases or node path in JCR, totally depending on ResourceResolver implementations.

      Specified by:
      resolveBinary in interface ResourceResolver
      Parameters:
      absPath - absolute path of a Binary
      Returns:
      single Binary representation by absPath
      Throws:
      ResourceException - if resource resolution operation fails
    • resolveBinary

      public Binary resolveBinary(String absPath, ExchangeHint exchangeHint) throws ResourceException
      Resolves single Binary representation by absPath.

      absPath is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, then absPath can be a URI path or part of URL. Or, as an example, the absPath can be an index name of a search index, table name of databases or node path in JCR, totally depending on ResourceResolver implementations.

      If a non-null exchangeHint is given, then it can be understood by the specific ResourceResolver implementation for its specific backend.

      Specified by:
      resolveBinary in interface ResourceResolver
      Parameters:
      absPath - absolute path of a Binary
      exchangeHint - a message exchange hint for the backend
      Returns:
      single Binary representation by absPath
      Throws:
      ResourceException - if resource resolution operation fails
    • resolveBinary

      public Binary resolveBinary(String absPath, Map<String,Object> pathVariables) throws ResourceException
      Resolves single Binary representation by absPath.

      absPath is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, then absPath can be a URI path or part of URL. Or, as an example, the absPath can be an index name of a search index, table name of databases or node path in JCR, totally depending on ResourceResolver implementations.

      The absPath template is expanded using the given path variables (pathVariables), if any. For example, if pathVariables looks like {"var1":"hello","var2":"world"} and absPath is ".../some/path/{var1}/{var2}/overview", then it is expanded to ".../some/path/hello/world/overview" by the pathVariables when making a real request to the backend.

      Specified by:
      resolveBinary in interface ResourceResolver
      Parameters:
      absPath - absolute path of a Binary
      pathVariables - the variables to expand the template given by absPath
      Returns:
      single Binary representation by absPath
      Throws:
      ResourceException - if resource resolution operation fails
    • resolveBinaryAsResource

      public Resource resolveBinaryAsResource(String absPath) throws ResourceException
      Description copied from interface: ResourceResolver
      Resolves single Binary representation by absPath, and convert it to a Resource.

      absPath is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, then absPath can be a URI path or part of URL. Or, as an example, the absPath can be an index name of a search index, table name of databases or node path in JCR, totally depending on ResourceResolver implementations.

      Specified by:
      resolveBinaryAsResource in interface ResourceResolver
      Parameters:
      absPath - absolute path of a Binary
      Returns:
      a Resource object converted from the single Binary representation by absPath
      Throws:
      ResourceException - if resource resolution operation fails
    • resolveBinaryAsResource

      public Resource resolveBinaryAsResource(String absPath, ExchangeHint exchangeHint) throws ResourceException
      Description copied from interface: ResourceResolver
      Resolves single Binary representation by absPath, and convert it to a Resource.

      absPath is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, then absPath can be a URI path or part of URL. Or, as an example, the absPath can be an index name of a search index, table name of databases or node path in JCR, totally depending on ResourceResolver implementations.

      If a non-null exchangeHint is given, then it can be understood by the specific ResourceResolver implementation for its specific backend.

      Specified by:
      resolveBinaryAsResource in interface ResourceResolver
      Parameters:
      absPath - absolute path of a Binary
      exchangeHint - a message exchange hint for the backend
      Returns:
      a Resource object converted from the single Binary representation by absPath
      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 single Binary representation by absPath, and convert it to a Resource.

      absPath is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, then absPath can be a URI path or part of URL. Or, as an example, the absPath can be an index name of a search index, table name of databases or node path in JCR, totally depending on ResourceResolver implementations.

      The absPath template is expanded using the given path variables (pathVariables), if any. For example, if pathVariables looks like {"var1":"hello","var2":"world"} and absPath is ".../some/path/{var1}/{var2}/overview", then it is expanded to ".../some/path/hello/world/overview" by the pathVariables when making a real request to the backend.

      Specified by:
      resolveBinaryAsResource in interface ResourceResolver
      Parameters:
      absPath - absolute path of a Binary
      pathVariables - the variables to expand the template given by absPath
      Returns:
      a Resource object converted from the single Binary representation by absPath
      Throws:
      ResourceException - if resource resolution operation fails
    • findResources

      public Resource findResources(String baseAbsPath) throws ResourceException
      Search Resource representations from baseAbsPath and returns a parent Resource representation which contains a collection of child Resource representations.

      baseAbsPath is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, then baseAbsPath can be a URI path or part of URL. Or, as an example, the baseAbsPath can be an index name of a search index, table name of databases or node path in JCR, totally depending on ResourceResolver implementations.

      Specified by:
      findResources in interface ResourceResolver
      Parameters:
      baseAbsPath - base absolute path of a Resource
      Returns:
      a parent Resource representation which contains a collection of child Resource representations
      Throws:
      ResourceException - if resource resolution operation fails
    • findResources

      public Resource findResources(String baseAbsPath, ExchangeHint exchangeHint) throws ResourceException
      Search Resource representations from baseAbsPath and returns a parent Resource representation which contains a collection of child Resource representations.

      baseAbsPath is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, then baseAbsPath can be a URI path or part of URL. Or, as an example, the baseAbsPath can be an index name of a search index, table name of databases or node path in JCR, totally depending on ResourceResolver implementations.

      If a non-null exchangeHint is given, then it can be understood by the specific ResourceResolver implementation for its specific backend.

      Specified by:
      findResources in interface ResourceResolver
      Parameters:
      baseAbsPath - base absolute path of a Resource
      exchangeHint - a message exchange hint for the backend
      Returns:
      a parent Resource representation which contains a collection of child Resource representations
      Throws:
      ResourceException - if resource resolution operation fails
    • findResources

      public Resource findResources(String baseAbsPath, Map<String,Object> pathVariables) throws ResourceException
      Search Resource representations from baseAbsPath and returns a parent Resource representation which contains a collection of child Resource representations.

      baseAbsPath is a domain-specific path template that should be meaningful to the backend. For example, if the backend is a REST API, then baseAbsPath can be a URI path or part of URL. Or, as an example, the baseAbsPath can be an index name of a search index, table name of databases or node path in JCR, totally depending on ResourceResolver implementations.

      The baseAbsPath template is expanded using the given path variables (pathVariables), if any. For example, if pathVariables looks like {"var1":"hello","var2":"world"} and baseAbsPath is ".../some/path/{var1}/{var2}/overview", then it is expanded to ".../some/path/hello/world/overview" by the pathVariables when making a real request to the backend.

      Specified by:
      findResources in interface ResourceResolver
      Parameters:
      baseAbsPath - base absolute path of a Resource
      pathVariables - the variables to expand the template given by absPath
      Returns:
      a parent Resource representation which contains a collection of child Resource representations
      Throws:
      ResourceException - if resource resolution operation fails
    • isLive

      public boolean isLive() throws ResourceException
      Returns true if the ResourceResolver 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 interface ResourceResolver
      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 interface ResourceResolver
      Throws:
      ResourceException - if resource resolution operation fails
    • close

      public void close() throws ResourceException
      Closes any resources used in this ResourceResolver 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 interface ResourceResolver
      Throws:
      ResourceException - if resource resolution operation fails
    • getResourceLinkResolver

      public ResourceLinkResolver getResourceLinkResolver()
      Returns a domain-specific ResourceLinkResolver for a Resource representation generated by this ResourceResolver implementation.
      Specified by:
      getResourceLinkResolver in interface ResourceResolver
      Returns:
      a domain-specific ResourceLinkResolver for a Resource representation generated by this ResourceResolver implementation
    • setResourceLinkResolver

      public void setResourceLinkResolver(ResourceLinkResolver resourceLinkResolver)
      Parameters:
      resourceLinkResolver - ResourceLinkResolver that resolves a link for a Resource representation
    • getResourceBeanMapper

      public ResourceBeanMapper getResourceBeanMapper() throws ResourceException
      Specified by:
      getResourceBeanMapper in interface ResourceResolver
      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 the absPath. 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, then absPath can be a URI path or part of URL. Or, as an example, the absPath can be an index name of a search index, table name of databases or node path in JCR, totally depending on ResourceResolver implementations.

      Specified by:
      resolveFullURI in interface ResourceResolver
      Parameters:
      absPath - absolute path of a Resource
      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 the absPath. 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, then absPath can be a URI path or part of URL. Or, as an example, the absPath can be an index name of a search index, table name of databases or node path in JCR, totally depending on ResourceResolver implementations.

      The absPath template is expanded using the given path variables (pathVariables), if any. For example, if pathVariables looks like {"var1":"hello","var2":"world"} and absPath is ".../some/path/{var1}/{var2}/overview", then it is expanded to ".../some/path/hello/world/overview" by the pathVariables.

      Specified by:
      resolveFullURI in interface ResourceResolver
      Parameters:
      absPath - absolute path of a Resource
      pathVariables - the variables to expand the template given by absPath
      Returns:
      URI representation by absPath
      Throws:
      ResourceException - if resource resolution operation fails