org.springframework.extensions.webscripts
Class ClassPathStore

java.lang.Object
  extended by org.springframework.extensions.webscripts.AbstractStore
      extended by org.springframework.extensions.webscripts.ClassPathStore
All Implemented Interfaces:
org.springframework.context.ApplicationContextAware, Store

public class ClassPathStore
extends AbstractStore
implements org.springframework.context.ApplicationContextAware, Store

ClassPath based Web Script Store

Author:
davidc

Field Summary
protected  String classPath
           
protected  boolean mustExist
           
protected  File storeDir
           
protected  org.springframework.core.io.Resource storeResource
           
protected  String storeResourcePath
           
protected  int storeResourcePathLength
           
 
Constructor Summary
ClassPathStore()
           
 
Method Summary
 void createDocument(String documentPath, String content)
          Creates a document.
static String createPath(String path, String relativePath)
          Helper method for creating relative paths
 boolean exists()
          Determines whether the store actually exists
 String[] getAllDocumentPaths()
          Gets the paths of all documents in this store
 String getBasePath()
          Gets the base path of the store
 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[] getScriptDocumentPaths(WebScript script)
          Gets the paths of all implementation files for a given Web Script
 ScriptLoader getScriptLoader()
          Gets the script loader for this store
 freemarker.cache.TemplateLoader getTemplateLoader()
          Gets the template loader for this store
 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 setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
           
 void setClassPath(String classPath)
          Sets the class path
 void setMustExist(boolean mustExist)
          Sets whether the class path must exist If it must exist, but it doesn't exist, an exception is thrown on initialisation of the store
 String toString()
           
 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, wait, wait, wait
 
Methods inherited from interface org.springframework.extensions.webscripts.Store
getDocumentPaths
 

Field Detail

mustExist

protected boolean mustExist

classPath

protected String classPath

storeResource

protected org.springframework.core.io.Resource storeResource

storeResourcePath

protected String storeResourcePath

storeResourcePathLength

protected int storeResourcePathLength

storeDir

protected File storeDir
Constructor Detail

ClassPathStore

public ClassPathStore()
Method Detail

setMustExist

public void setMustExist(boolean mustExist)
Sets whether the class path must exist If it must exist, but it doesn't exist, an exception is thrown on initialisation of the store

Parameters:
mustExist -

setClassPath

public void setClassPath(String classPath)
Sets the class path

Parameters:
classPath - classpath

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException
Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Throws:
org.springframework.beans.BeansException

init

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

Specified by:
init in interface Store

exists

public boolean exists()
Description copied from interface: Store
Determines whether the store actually exists

Specified by:
exists in interface Store
Returns:
true => it does exist

getBasePath

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

Specified by:
getBasePath in interface Store
Returns:
base path

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.

Specified by:
isSecure in interface Store
Returns:
true if this store is considered secure

getAllDocumentPaths

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

Specified by:
getAllDocumentPaths in interface Store
Returns:
array of all document paths

getDocumentPaths

public String[] getDocumentPaths(String path,
                                 boolean includeSubPaths,
                                 String documentPattern)
                          throws IOException
Description copied from interface: Store
Gets the paths of given document pattern within given path/sub-paths in this store

Specified by:
getDocumentPaths in interface 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
Throws:
IOException

getDescriptionDocumentPaths

public String[] getDescriptionDocumentPaths()
                                     throws IOException
Description copied from interface: Store
Gets the paths of all Web Script description documents in this store

Specified by:
getDescriptionDocumentPaths in interface Store
Returns:
array of description document paths
Throws:
IOException

getScriptDocumentPaths

public String[] getScriptDocumentPaths(WebScript script)
                                throws IOException
Description copied from interface: Store
Gets the paths of all implementation files for a given Web Script

Specified by:
getScriptDocumentPaths in interface Store
Parameters:
script - web script
Returns:
array of implementation document paths
Throws:
IOException

lastModified

public long lastModified(String documentPath)
                  throws IOException
Description copied from interface: Store
Gets the last modified timestamp for the document.

Specified by:
lastModified in interface Store
Parameters:
documentPath - document path to an existing document
Returns:
last modified timestamp
Throws:
IOException - if the document does not exist in the store

hasDocument

public boolean hasDocument(String documentPath)
Description copied from interface: Store
Determines if the document exists.

Specified by:
hasDocument in interface Store
Parameters:
documentPath - document path
Returns:
true => exists, false => does not exist

getDocument

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

Specified by:
getDocument in interface Store
Parameters:
documentPath - document path
Returns:
input stream onto document
Throws:
IOException - if the document does not exist in the store

createDocument

public void createDocument(String documentPath,
                           String content)
                    throws IOException
Description copied from interface: Store
Creates a document.

Specified by:
createDocument in interface Store
Parameters:
documentPath - document path
content - content of the document to write
Throws:
IOException - if the document already exists or the create fails

updateDocument

public void updateDocument(String documentPath,
                           String content)
                    throws IOException
Description copied from interface: Store
Updates an existing document.

Specified by:
updateDocument in interface Store
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.

Specified by:
removeDocument in interface Store
Parameters:
documentPath - document path
Returns:
whether the operation succeeded
Throws:
IOException - if the document does not exist or the remove fails

getTemplateLoader

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

Specified by:
getTemplateLoader in interface Store
Returns:
template loader

getScriptLoader

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

Specified by:
getScriptLoader in interface Store
Returns:
script loader

createPath

public static String createPath(String path,
                                String relativePath)
Helper method for creating relative paths

Parameters:
path -
relativePath -
Returns:

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009 SpringSource, Inc. All Rights Reserved.