Class ClassPathStore

java.lang.Object
org.springframework.extensions.webscripts.AbstractStore
org.springframework.extensions.webscripts.ClassPathStore
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, Store

public class ClassPathStore extends AbstractStore implements org.springframework.context.ApplicationContextAware, Store
ClassPath based Web Script Store
Author:
davidc, kevinr, muzquiano
  • Field Details

  • Constructor Details

    • ClassPathStore

      public ClassPathStore()
  • Method Details

    • 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 - boolean
    • 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
    • isReadOnly

      public boolean isReadOnly()
      Description copied from class: AbstractStore
      Whether the store is in read-only mode
      Specified by:
      isReadOnly in interface Store
      Overrides:
      isReadOnly in class AbstractStore
      Returns:
      boolean
    • 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. Note a raw InputStream to the content is returned and must be closed by the accessing method.
      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 fully qualified paths
      Parameters:
      path - String
      relativePath - String
      Returns:
      full qualified path
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isJarURL

      protected static boolean isJarURL(URL url)
      Determine whether the given URL points to a resource in a jar file, that is, has protocol "jar", "zip", "vfszip", "wsjar" or "code-source".

      "zip" and "wsjar" and "vfszip" are used by BEA WebLogic Server and IBM WebSphere and JBoss, respectively, but can be treated like jar files. The same applies to "code-source" URLs on Oracle OC4J, provided that the path contains a jar separator.

      Parameters:
      url - the URL to check
      Returns:
      whether the URL has been identified as a JAR URL
    • extractJarFileURL

      protected static URL extractJarFileURL(URL jarUrl) throws MalformedURLException
      Extract the URL for the actual jar file from the given URL (which may point to a resource in a jar file or to a jar file itself).
      Parameters:
      jarUrl - the original URL
      Returns:
      the URL for the actual jar file
      Throws:
      MalformedURLException - if no valid jar file URL could be extracted