Class RemoteStore
java.lang.Object
org.springframework.extensions.webscripts.AbstractStore
org.springframework.extensions.webscripts.RemoteStore
- All Implemented Interfaces:
Store
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
Nested ClassesModifier and TypeClassDescriptionprotected classRemote Store implementation of a Script Loader -
Field Summary
FieldsFields inherited from class org.springframework.extensions.webscripts.AbstractStore
DESC_PATH_PATTERN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Stringprotected ResponsecallDelete(String uri) Perform a DELETE call to the given URI.protected ResponsePerform a GET call to the given URI.protected ResponsecallPost(String uri, InputStream in) Perform a POST call to the given URI with the supplied input.voidcreateDocument(String documentPath, String content) Creates a document.voidcreateDocuments(List<org.springframework.extensions.surf.util.Pair<String, org.dom4j.Document>> pathContents) Creates multiple XML documents at the specified paths.booleanexists()Determines whether the store actually existsString[]Gets the paths of all documents in this storegetApi()Gets the api.Gets the base path of the storeprotected ConnectorGet a Connector for access to the endpoint.Gets the connector service.String[]Gets the paths of all Web Script description documents in this storegetDocument(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 storeGets the endpoint.String[]getScriptDocumentPaths(WebScript script) Gets the paths of all implementation files for a given Web ScriptGets the script loader for this storeGets the store id.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.TemplateLoaderGets the template loader for this storeGets the store's web application id binding This is meaningful for WCM Web Project stores.booleanhasDocument(String documentPath) Determines if the document exists.voidinit()Initialise Store (called once)booleanisSecure()Returns true if this store is considered secure - i.e.longlastModified(String documentPath) Gets the last modified timestamp for the document.booleanremoveDocument(String documentPath) Removes an existing document.voidvoidsetConnectorProvider(ConnectorProvider connectorProvider) Sets the connector providervoidsetConnectorService(ConnectorService service) voidsetEndpoint(String endpoint) voidSets the base path to send to the remote storevoidsetStoreId(String storeId) Allows for specification of default or fallback store id to use when binding to a remote store.voidsetWebappId(String webappId) Sets the store's web application id to bind to within the designated store This is meaningful for WCM Web Project stores.voidsetWebappPathPrefix(String webappPathPrefix) voidupdateDocument(String documentPath, String content) Updates an existing document.Methods inherited from class org.springframework.extensions.webscripts.AbstractStore
getDocumentPaths, getPreviewContext, isReadOnly, setPreviewContextProvider, setReadOnly
-
Field Details
-
DEFAULT_API
- See Also:
-
DEFAULT_ENDPOINT_ID
- See Also:
-
-
Constructor Details
-
RemoteStore
public RemoteStore()
-
-
Method Details
-
setConnectorService
- Parameters:
service- The ConnectorService bean
-
getConnectorService
Gets the connector service.- Returns:
- the connector service
-
setConnectorProvider
Sets the connector provider -
getConnectorProvider
- Returns:
- the connector provider
-
setApi
- Parameters:
api- the WebScript API path to set for the remote store i.e. "/remotestore"
-
getApi
Gets the api.- Returns:
- the api
-
setPath
Sets the base path to send to the remote store- Parameters:
path- String
-
setEndpoint
- Parameters:
endpoint- the endpoint ID to use when calling the remote API
-
getEndpoint
Gets the endpoint.- Returns:
- the endpoint
-
setWebappId
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
-
setWebappPathPrefix
-
getWebappId
Gets the store's web application id binding This is meaningful for WCM Web Project stores.- Returns:
- String
-
setStoreId
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
Gets the store id.- Returns:
- the store id
-
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:StoreInitialise Store (called once) -
isSecure
public boolean isSecure()Description copied from interface:StoreReturns 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:StoreDetermines whether the store actually exists- Returns:
- true => it does exist
-
hasDocument
Description copied from interface:StoreDetermines 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
Description copied from interface:StoreGets 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
Description copied from interface:StoreUpdates an existing document.- Parameters:
documentPath- document pathcontent- content to update the document with- Throws:
IOException- if the document does not exist or the update fails
-
removeDocument
Description copied from interface:StoreRemoves 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
Description copied from interface:StoreCreates a document.- Parameters:
documentPath- document pathcontent- 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 IOExceptionDescription copied from interface:StoreCreates multiple XML documents at the specified paths.- Specified by:
createDocumentsin interfaceStore- Overrides:
createDocumentsin classAbstractStore- Parameters:
pathContents- list of path, document pairs- Throws:
IOException- if a document already exists or a create fails
-
getDocument
Description copied from interface:StoreGets 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
Description copied from interface:StoreGets the paths of all documents in this store- Returns:
- array of all document paths
-
getDocumentPaths
Description copied from interface:StoreGets the paths of given document pattern within given path/sub-paths in this store- Parameters:
path- start pathincludeSubPaths- if true, include sub-pathsdocumentPattern- document name, allows wildcards, eg. *.ftl or my*.ftl- Returns:
- array of document paths
-
getDescriptionDocumentPaths
Description copied from interface:StoreGets the paths of all Web Script description documents in this store- Returns:
- array of description document paths
-
getScriptDocumentPaths
Description copied from interface:StoreGets the paths of all implementation files for a given Web Script- Parameters:
script- web script- Returns:
- array of implementation document paths
-
getScriptLoader
Description copied from interface:StoreGets the script loader for this store- Returns:
- script loader
-
getTemplateLoader
public freemarker.cache.TemplateLoader getTemplateLoader()Description copied from interface:StoreGets the template loader for this store- Returns:
- template loader
-
getBasePath
Description copied from interface:StoreGets the base path of the store- Returns:
- base path
-
buildUri
-
callPost
Perform a POST call to the given URI with the supplied input. -
callGet
Perform a GET call to the given URI. -
callDelete
Perform a DELETE call to the given URI. -
getConnector
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
-