Package snap.web

Class WebSite

java.lang.Object
snap.web.WebSite
Direct Known Subclasses:
DirSite, DropBoxSite, FileSite, HTTPSite, RecentFilesSite, WebSiteX, 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.
    • getUrlAddress

      public String getUrlAddress()
      Returns the site URL address string.
    • 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 file for given path (null if not found).
      Throws:
      ResponseException
    • getFileForFileHeader

      protected WebFile getFileForFileHeader(FileHeader fileHeader)
      Returns the file for given file header.
    • createFileForPath

      public WebFile createFileForPath(String aPath, boolean isDir)
      Creates a file for given path, regardless of whether it is known to actually exist in site.
    • 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 abstract 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.
    • saveLastModTimeForFile

      protected void saveLastModTimeForFile(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.
    • getJavaFileForUrl

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

      public WebURL getUrlForPath(String aFilePath)
      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.
    • getSandboxSite

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

      protected String getSandboxSiteName()
      Returns a unique name for the Sandbox site.
    • getLocalFile

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

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

      protected void fileDidReset(WebFile aFile)
      Called to notify site when file is reset.
    • 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