Class RemoteStore

java.lang.Object
org.springframework.extensions.webscripts.AbstractStore
org.springframework.extensions.webscripts.RemoteStore
All Implemented Interfaces:
Store

public class RemoteStore extends AbstractStore
Store implementation that queries and retrieves documents from a remote HTTP endpoint.

The endpoint is assumed to support a WebScript Remote Store implementation (such as AVMRemoteStore) that mirrors the required Store API.

Author:
Kevin Roast
  • Field Details

  • Constructor Details

    • RemoteStore

      public RemoteStore()
  • Method Details

    • setConnectorService

      public void setConnectorService(ConnectorService service)
      Parameters:
      service - The ConnectorService bean
    • getConnectorService

      public ConnectorService getConnectorService()
      Gets the connector service.
      Returns:
      the connector service
    • setConnectorProvider

      public void setConnectorProvider(ConnectorProvider connectorProvider)
      Sets the connector provider
    • getConnectorProvider

      public ConnectorProvider getConnectorProvider()
      Returns:
      the connector provider
    • setApi

      public void setApi(String api)
      Parameters:
      api - the WebScript API path to set for the remote store i.e. "/remotestore"
    • getApi

      public String getApi()
      Gets the api.
      Returns:
      the api
    • setPath

      public void setPath(String path)
      Sets the base path to send to the remote store
      Parameters:
      path - String
    • setEndpoint

      public void setEndpoint(String endpoint)
      Parameters:
      endpoint - the endpoint ID to use when calling the remote API
    • getEndpoint

      public String getEndpoint()
      Gets the endpoint.
      Returns:
      the endpoint
    • setWebappId

      public void setWebappId(String webappId)
      Sets the store's web application id to bind to within the designated store This is meaningful for WCM Web Project stores.
      Parameters:
      webappId - String
    • getWebappPathPrefix

      public String getWebappPathPrefix()
    • setWebappPathPrefix

      public void setWebappPathPrefix(String webappPathPrefix)
    • getWebappId

      public String getWebappId()
      Gets the store's web application id binding This is meaningful for WCM Web Project stores.
      Returns:
      String
    • setStoreId

      public void setStoreId(String storeId)
      Allows for specification of default or fallback store id to use when binding to a remote store. This can be overridden by providing an implementation of a RemoteStoreContextProvider in the Spring Bean configuration.
      Parameters:
      storeId - the default store id
    • getStoreId

      public String getStoreId()
      Gets the store id.
      Returns:
      the store id
    • getStorePath

      public String getStorePath()
      Store path calculation If we have a store context, then we can check to see if a base path should be inserted ahead of the path that we believe we're directing to. Use case - consider writing a file /alfresco/site-data/components/component.xml If we're writing to sitestore, then the file is stored relative to the store root. In the case of a WCM web project, however, we may want to persist to one of several web applications. If we have a webappId (retrieved from the context), then we prepend: /WEB-INF/classes The new location is: /WEB-INF/classes/alfresco/site-data/components/component.xml This allows us to operate against both straight up AVM stores as well as WCM Web Project AVM stores.
      Returns:
      String
    • init

      public void init()
      Description copied from interface: Store
      Initialise Store (called once)
    • isSecure

      public boolean isSecure()
      Description copied from interface: Store
      Returns true if this store is considered secure - i.e. on the app-server classpath. Scripts in secure stores can be run under the identity of a declared user (via the runas attribute) rather than the authenticated user.
      Returns:
      true if this store is considered secure
    • exists

      public boolean exists()
      Description copied from interface: Store
      Determines whether the store actually exists
      Returns:
      true => it does exist
    • hasDocument

      public boolean hasDocument(String documentPath) throws IOException
      Description copied from interface: Store
      Determines if the document exists.
      Parameters:
      documentPath - document path
      Returns:
      true => exists, false => does not exist
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • lastModified

      public long lastModified(String documentPath) throws IOException
      Description copied from interface: Store
      Gets the last modified timestamp for the document.
      Parameters:
      documentPath - document path to an existing document
      Returns:
      last modified timestamp
      Throws:
      IOException - if the document does not exist in the store
    • updateDocument

      public void updateDocument(String documentPath, String content) throws IOException
      Description copied from interface: Store
      Updates an existing document.
      Parameters:
      documentPath - document path
      content - content to update the document with
      Throws:
      IOException - if the document does not exist or the update fails
    • removeDocument

      public boolean removeDocument(String documentPath) throws IOException
      Description copied from interface: Store
      Removes an existing document.
      Parameters:
      documentPath - document path
      Returns:
      whether the operation succeeded
      Throws:
      IOException - if the document does not exist or the remove fails
    • createDocument

      public void createDocument(String documentPath, String content) throws IOException
      Description copied from interface: Store
      Creates a document.
      Parameters:
      documentPath - document path
      content - content of the document to write
      Throws:
      IOException - if the document already exists or the create fails
    • createDocuments

      public void createDocuments(List<org.springframework.extensions.surf.util.Pair<String,org.dom4j.Document>> pathContents) throws IOException
      Description copied from interface: Store
      Creates multiple XML documents at the specified paths.
      Specified by:
      createDocuments in interface Store
      Overrides:
      createDocuments in class AbstractStore
      Parameters:
      pathContents - list of path, document pairs
      Throws:
      IOException - if a document already exists or a create fails
    • getDocument

      public InputStream getDocument(String documentPath) throws IOException
      Description copied from interface: Store
      Gets a document. Note a raw InputStream to the content is returned and must be closed by the accessing method.
      Parameters:
      documentPath - document path
      Returns:
      input stream onto document
      Throws:
      IOException - if the document does not exist in the store
    • getAllDocumentPaths

      public String[] getAllDocumentPaths()
      Description copied from interface: Store
      Gets the paths of all documents in this store
      Returns:
      array of all document paths
    • getDocumentPaths

      public String[] getDocumentPaths(String path, boolean includeSubPaths, String documentPattern)
      Description copied from interface: Store
      Gets the paths of given document pattern within given path/sub-paths in this store
      Parameters:
      path - start path
      includeSubPaths - if true, include sub-paths
      documentPattern - document name, allows wildcards, eg. *.ftl or my*.ftl
      Returns:
      array of document paths
    • getDescriptionDocumentPaths

      public String[] getDescriptionDocumentPaths()
      Description copied from interface: Store
      Gets the paths of all Web Script description documents in this store
      Returns:
      array of description document paths
    • getScriptDocumentPaths

      public String[] getScriptDocumentPaths(WebScript script)
      Description copied from interface: Store
      Gets the paths of all implementation files for a given Web Script
      Parameters:
      script - web script
      Returns:
      array of implementation document paths
    • getScriptLoader

      public ScriptLoader getScriptLoader()
      Description copied from interface: Store
      Gets the script loader for this store
      Returns:
      script loader
    • getTemplateLoader

      public freemarker.cache.TemplateLoader getTemplateLoader()
      Description copied from interface: Store
      Gets the template loader for this store
      Returns:
      template loader
    • getBasePath

      public String getBasePath()
      Description copied from interface: Store
      Gets the base path of the store
      Returns:
      base path
    • buildUri

      protected String buildUri(String uri)
    • callPost

      protected Response callPost(String uri, InputStream in)
      Perform a POST call to the given URI with the supplied input.
    • callGet

      protected Response callGet(String uri)
      Perform a GET call to the given URI.
    • callDelete

      protected Response callDelete(String uri)
      Perform a DELETE call to the given URI.
    • getConnector

      protected Connector getConnector() throws ConnectorProviderException
      Get a Connector for access to the endpoint. If a connector has been bound to the current thread then use it, else retrieve a transient connector instance from the ConnectorService.
      Returns:
      Connector
      Throws:
      ConnectorProviderException