Class AbstractResourceServiceBroker

java.lang.Object
org.onehippo.cms7.crisp.api.broker.AbstractResourceServiceBroker
All Implemented Interfaces:
ResourceServiceBroker

public abstract class AbstractResourceServiceBroker extends Object implements ResourceServiceBroker
Abstract CRISP Resource Service Broker base class.
  • Field Details

    • OPERATION_KEY

      public static final String OPERATION_KEY
      Key name for an invoked operation name, which can be used in cache key generation as an attribute name.
      See Also:
    • RESOURCE_SPACE

      public static final String RESOURCE_SPACE
      Key name for the resource space name in an invocation, which can be used in cache key generation as an attribute name.
      See Also:
    • RESOURCE_PATH

      public static final String RESOURCE_PATH
      Key name for the relative resource path in an invocation, which can be used in cache key generation as an attribute name.
      See Also:
    • PATH_VARIABLES

      public static final String PATH_VARIABLES
      Key name for the path variables to be used in the physical invocation path (or URI) expansion, which can be used in cache key generation as an attribute name.
      See Also:
    • EXCHANGE_HINT

      public static final String EXCHANGE_HINT
      Key name for the exchange hint, which can be used in cache key generation as an attribute name.
      See Also:
    • OPERATION_KEY_RESOLVE

      public static final String OPERATION_KEY_RESOLVE
      Key name of OPERATION_KEY in resolve(String, String, Map) operation invocation, which can be used in cache key generation as an attribute name.
    • OPERATION_KEY_FIND_RESOURCES

      public static final String OPERATION_KEY_FIND_RESOURCES
      Key name of OPERATION_KEY in findResources(String, String, Map) operation invocation, which can be used in cache key generation as an attribute name.
  • Constructor Details

    • AbstractResourceServiceBroker

      public AbstractResourceServiceBroker()
      Default constructor.
  • Method Details

    • getResourceResolverProvider

      public ResourceResolverProvider getResourceResolverProvider()
      Returns ResourceResolverProvider that finds and returns a proper ResourceResolver.
      Returns:
      ResourceResolverProvider that finds and returns a proper ResourceResolver
    • setResourceResolverProvider

      public void setResourceResolverProvider(ResourceResolverProvider resourceResolverProvider)
      Sets ResourceResolverProvider that finds and returns a proper ResourceResolver.
      Parameters:
      resourceResolverProvider - ResourceResolverProvider that finds and returns a proper ResourceResolver
    • resolve

      public Resource resolve(String resourceSpace, String absResourcePath) throws ResourceException
      Resolves a proper ResourceResolver by the specified resourceSpace and 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 ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      absResourcePath - absolute path of a Resource
      Returns:
      single Resource representation by absPath
      Throws:
      ResourceException - if resource resolution operation fails
    • resolve

      public Resource resolve(String resourceSpace, String absResourcePath, ExchangeHint exchangeHint) throws ResourceException
      Resolves a proper ResourceResolver by the specified resourceSpace and 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.

      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 ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      absResourcePath - 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 resourceSpace, String absResourcePath, Map<String,Object> pathVariables) throws ResourceException
      Resolves a proper ResourceResolver by the specified resourceSpace and 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 ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      absResourcePath - 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 resourceSpace, String absResourcePath) throws ResourceException
      Resolves a proper ResourceResolver by the specified resourceSpace and 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 ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      absResourcePath - absolute path of a Binary
      Returns:
      single Binary representation by absPath
      Throws:
      ResourceException - if resource resolution operation fails
    • resolveBinary

      public Binary resolveBinary(String resourceSpace, String absResourcePath, ExchangeHint exchangeHint) throws ResourceException
      Resolves a proper ResourceResolver by the specified resourceSpace and 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 ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      absResourcePath - 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 resourceSpace, String absResourcePath, Map<String,Object> pathVariables) throws ResourceException
      Resolves a proper ResourceResolver by the specified resourceSpace and 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 ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      absResourcePath - 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 resourceSpace, String absResourcePath) throws ResourceException
      Description copied from interface: ResourceServiceBroker
      Resolves a proper ResourceResolver by the specified resourceSpace, resolves single Binary representation by absPath, and converts the Binary representation into 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 ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      absResourcePath - 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 resourceSpace, String absResourcePath, ExchangeHint exchangeHint) throws ResourceException
      Description copied from interface: ResourceServiceBroker
      Resolves a proper ResourceResolver by the specified resourceSpace, resolves single Binary representation by absPath, and converts the Binary representation into 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 ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      absResourcePath - 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 resourceSpace, String absResourcePath, Map<String,Object> pathVariables) throws ResourceException
      Description copied from interface: ResourceServiceBroker
      Resolves a proper ResourceResolver by the specified resourceSpace, resolves single Binary representation by absPath, and converts the Binary representation into 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 ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      absResourcePath - 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 resourceSpace, String baseAbsPath) throws ResourceException
      Resolves a proper ResourceResolver by the specified resourceSpace and 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 ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      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 resourceSpace, String baseAbsPath, ExchangeHint exchangeHint) throws ResourceException
      Resolves a proper ResourceResolver by the specified resourceSpace and 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 ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      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 resourceSpace, String baseAbsPath, Map<String,Object> pathVariables) throws ResourceException
      Resolves a proper ResourceResolver by the specified resourceSpace and 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 ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      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
    • resolveLink

      public ResourceLink resolveLink(String resourceSpace, Resource resource) throws ResourceException
      Resolves a proper ResourceResolver by the specified resourceSpace and resolves a ResourceLink for the given resource.
      Specified by:
      resolveLink in interface ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      resource - resource representation
      Returns:
      a ResourceLink for the given resource
      Throws:
      ResourceException - if resource resolution operation fails
    • resolveLink

      public ResourceLink resolveLink(String resourceSpace, Resource resource, Map<String,Object> linkVariables) throws ResourceException
      Resolves a proper ResourceResolver by the specified resourceSpace and resolves a ResourceLink for the given resource with passing linkVariables that can be used by implementation to expand its internal link generation template.

      How the linkVariables is used in link generation template expansion is totally up to an implementation.

      Specified by:
      resolveLink in interface ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      resource - resource representation
      linkVariables - the variables to expand the internal link generation template
      Returns:
      a ResourceLink for the given resource
      Throws:
      ResourceException - if resource resolution operation fails
    • getResourceDataCache

      public ResourceDataCache getResourceDataCache(String resourceSpace) throws ResourceException
      Returns a proper resource cache store representation (ResourceDataCache) for the specified resourceSpace, or null if caching is disabled.

      An implementation may return a default resource cache store representation (ResourceDataCache) as a fallback if the resolved ResourceResolver doesn't have its own ResourceDataCache instance (in other words, if the resolved ResourceCacheResolvable.getResourceDataCache() return null).

      If an underlying resource resolver is explicitly disabled on caching (in other words, if the resolved ResourceCacheResolvable.isCacheEnabled() returns false), it should return null.

      Specified by:
      getResourceDataCache in interface ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      Returns:
      a proper resource cache store representation (ResourceDataCache) for the specified resourceSpace, or a fallback ResourceDataCache if the resolved ResourceResolver doesn't have its own ResourceDataCache instance
      Throws:
      ResourceException - if resource space is not found
    • getResourceBeanMapper

      public ResourceBeanMapper getResourceBeanMapper(String resourceSpace) throws ResourceException
      Returns a proper ResourceBeanMapper for the given resourceSpace.
      Specified by:
      getResourceBeanMapper in interface ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      Returns:
      a proper ResourceBeanMapper for the given resourceSpace
      Throws:
      ResourceException - if resource space is not found
    • resolveFullURI

      public URI resolveFullURI(String resourceSpace, String absPath) throws ResourceException
      Description copied from interface: ResourceServiceBroker
      Resolves a full URI determined and resolved for the specific resourceSpace and 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 ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      absPath - absolute path of a Resource
      Returns:
      URI representation by absPath
      Throws:
      ResourceException - if resource resolution operation fails
    • resolveFullURI

      public URI resolveFullURI(String resourceSpace, String absPath, Map<String,Object> pathVariables) throws ResourceException
      Description copied from interface: ResourceServiceBroker
      Resolves a full URI determined and resolved for the specific resourceSpace and 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 ResourceServiceBroker
      Parameters:
      resourceSpace - Resource space name to resolve a proper ResourceResolver
      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
    • getResourceResolver

      protected ResourceResolver getResourceResolver(String resourceSpace) throws ResourceException
      Finds and returns a ResourceResolver by the specified resourceSpace.
      Parameters:
      resourceSpace - resource space name
      Returns:
      a ResourceResolver by the specified resourceSpace
      Throws:
      ResourceException - if resource resolve is not found