org.springframework.extensions.webscripts
Class RemoteStore

java.lang.Object
  extended by org.springframework.extensions.webscripts.AbstractStore
      extended by 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

Nested Class Summary
protected  class RemoteStore.RemoteStoreScriptLoader
          Remote Store implementation of a Script Loader
 
Field Summary
static String DEFAULT_API
           
static String DEFAULT_ENDPOINT_ID
           
 
Constructor Summary
RemoteStore()
           
 
Method Summary
 void createDocument(String documentPath, String content)
          Creates a document.
 boolean exists()
          Determines whether the store actually exists
 String[] getAllDocumentPaths()
          Gets the paths of all documents in this store
 String getApi()
          Gets the api.
 String getBasePath()
          Gets the base path of the store
 ConnectorProvider getConnectorProvider()
           
 ConnectorService getConnectorService()
          Gets the connector service.
 String[] getDescriptionDocumentPaths()
          Gets the paths of all Web Script description documents in this store
 InputStream getDocument(String documentPath)
          Gets a document
 String[] getDocumentPaths(String path, boolean includeSubPaths, String documentPattern)
          Gets the paths of given document pattern within given path/sub-paths in this store
 String getEndpoint()
          Gets the endpoint.
 String[] getScriptDocumentPaths(WebScript script)
          Gets the paths of all implementation files for a given Web Script
 ScriptLoader getScriptLoader()
          Gets the script loader for this store
 String getStoreId()
          Gets the store id.
 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.
 freemarker.cache.TemplateLoader getTemplateLoader()
          Gets the template loader for this store
 String getWebappId()
          Gets the store's web application id binding This is meaningful for WCM Web Project stores.
 String getWebappPathPrefix()
           
 boolean hasDocument(String documentPath)
          Determines if the document exists.
 void init()
          Initialise Store (called once)
 boolean isSecure()
          Returns true if this store is considered secure - i.e.
 long lastModified(String documentPath)
          Gets the last modified timestamp for the document.
 boolean removeDocument(String documentPath)
          Removes an existing document.
 void setApi(String api)
           
 void setConnectorProvider(ConnectorProvider connectorProvider)
          Sets the connector provider
 void setConnectorService(ConnectorService service)
           
 void setEndpoint(String endpoint)
           
 void setPath(String path)
          Sets the base path to send to the remote store
 void setStoreId(String storeId)
          Allows for specification of default or fallback store id to use when binding to a remote store.
 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.
 void setWebappPathPrefix(String webappPathPrefix)
           
 void updateDocument(String documentPath, String content)
          Updates an existing document.
 
Methods inherited from class org.springframework.extensions.webscripts.AbstractStore
getDocumentPaths, getPreviewContext, setPreviewContextProvider
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_API

public static final String DEFAULT_API
See Also:
Constant Field Values

DEFAULT_ENDPOINT_ID

public static final String DEFAULT_ENDPOINT_ID
See Also:
Constant Field Values
Constructor Detail

RemoteStore

public RemoteStore()
Method Detail

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 -

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 -

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:

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:

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

getDocument

public InputStream getDocument(String documentPath)
                        throws IOException
Description copied from interface: Store
Gets a document

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


Copyright © 2009 SpringSource, Inc. All Rights Reserved.