Package snap.web

Class WebSite

java.lang.Object
snap.web.WebSite
Direct Known Subclasses:
DirSite, DropBoxSite, FileSite, HTTPSite, JRTSite, RecentFilesSite, ZipFileSite

public abstract class WebSite extends Object
This is an abstract class to provide data management (create, get, put, delete) and file management.
  • Constructor Details

    • WebSite

      public WebSite()
      Constructor.
  • Method Details

    • getURL

      public WebURL getURL()
      Returns the URL.
    • setURL

      public void setURL(WebURL aURL)
      Sets the URL.
    • getURLString

      public String getURLString()
      Returns the URL root.
    • getName

      public String getName()
      Returns the name for this data source.
    • getHostName

      public String getHostName()
      Returns the host name.
    • getPath

      public String getPath()
      Returns the data source name-space and name in standard path form.
    • getUserName

      public String getUserName()
      Returns the user name.
    • setUserName

      public void setUserName(String aName)
      Sets the user name.
    • getPassword

      public String getPassword()
      Returns the password.
    • setPassword

      public void setPassword(String aPassword)
      Sets the password.
    • getExists

      public boolean getExists()
      Returns whether data source exists.
    • getRootDir

      public WebFile getRootDir()
      Returns the root directory.
    • getFileForPath

      public WebFile getFileForPath(String aPath) throws ResponseException
      Returns the unique file instance with the given path (or null if it doesn't exist).
      Throws:
      ResponseException
    • getFileForPathImpl

      protected WebFile getFileForPathImpl(String filePath) throws ResponseException
      Returns the individual file with the given path.
      Throws:
      ResponseException
    • createFileForPath

      public WebFile createFileForPath(String aPath, boolean isDir)
      Returns a new file for given path, regardless of whether it exists on site.
    • createFile

      protected WebFile createFile(FileHeader fileHeader)
      Returns a new file for given file header, regardless of whether it exists on site.
    • getContentsForFile

      protected FileContents getContentsForFile(WebFile aFile)
      Returns the contents for given file.
    • saveFile

      protected WebResponse saveFile(WebFile aFile)
      Save file.
    • deleteFile

      protected WebResponse deleteFile(WebFile aFile)
      Delete file.
    • getResponse

      public WebResponse getResponse(WebRequest aReq)
      Returns a response instance for a request.
    • doGetOrHead

      protected void doGetOrHead(WebRequest aReq, WebResponse aResp, boolean isHead)
      Handles a get or head request.
    • doPost

      protected void doPost(WebRequest aReq, WebResponse aResp)
      Handle a get request.
    • doPut

      protected void doPut(WebRequest aReq, WebResponse aResp)
      Handle a PUT request.
    • doDelete

      protected void doDelete(WebRequest aReq, WebResponse aResp)
      Handle a DELETE request.
    • setModTimeForFile

      protected void setModTimeForFile(WebFile aFile, long aTime) throws Exception
      Saves the modified time for a file to underlying file system.
      Throws:
      Exception
    • resetFiles

      public void resetFiles()
      Resets all loaded site files.
    • getJavaFile

      protected File getJavaFile(WebURL aURL)
      Returns a standard java.io.File, if available.
    • getURL

      public WebURL getURL(String aPath)
      Returns a URL for the given file path.
    • deleteSite

      public void deleteSite() throws Exception
      Deletes this data site, assuming it corresponds to something that can be deleted, like a database.
      Throws:
      Exception
    • getProp

      public Object getProp(String aKey)
      Returns a file property for key.
    • setProp

      public void setProp(String aKey, Object aValue)
      Sets a property for a key.
    • getSandbox

      public WebSite getSandbox()
      Returns a WebSite that can be used for storing persistent support files.
    • getSandboxName

      protected String getSandboxName()
      Creates a WebSite that can be used for storing persistent support files.
    • getLocalFile

      public WebFile getLocalFile(WebFile aFile, boolean doCache)
      Returns a local file for given file (with option to cache for future use).
    • refresh

      public void refresh()
      Clears site caches.
    • flush

      public void flush() throws Exception
      Flushes any unsaved changes to backing store.
      Throws:
      Exception
    • firePropChange

      protected void firePropChange(String aProp, Object oldVal, Object newVal)
      Fires a property change for given property name, old value, new value and index.
    • addFileChangeListener

      public void addFileChangeListener(PropChangeListener aLsnr)
      Adds a PropChangeListener to listen for any site file PropChange.
    • removeFileChangeListener

      public void removeFileChangeListener(PropChangeListener aLsnr)
      Removes a site file PropChangeListener.
    • fileDidPropChange

      protected void fileDidPropChange(PropChange aPC)
      Called when any site file changes.
    • toString

      public String toString()
      Standard toString implementation.
      Overrides:
      toString in class Object