Package snap.web
Class WebSite
java.lang.Object
snap.web.WebSite
- Direct Known Subclasses:
DirSite
,DropBoxSite
,FileSite
,HTTPSite
,RecentFilesSite
,WebSiteX
,ZipFileSite
This is an abstract class to provide data management (create, get, put, delete) and file management.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a PropChangeListener to listen for any site file PropChange.createFileForPath
(String aPath, boolean isDir) Creates a file for given path, regardless of whether it is known to actually exist in site.protected WebResponse
deleteFile
(WebFile aFile) Delete file.void
Deletes this data site, assuming it corresponds to something that can be deleted, like a database.protected void
doDelete
(WebRequest aReq, WebResponse aResp) Handle a DELETE request.protected abstract void
doGetOrHead
(WebRequest aReq, WebResponse aResp, boolean isHead) Handles a get or head request.protected void
doPost
(WebRequest aReq, WebResponse aResp) Handle a get request.protected void
doPut
(WebRequest aReq, WebResponse aResp) Handle a PUT request.protected void
Called when any site file changes.protected void
fileDidReset
(WebFile aFile) Called to notify site when file is reset.protected void
firePropChange
(String aProp, Object oldVal, Object newVal) Fires a property change for given property name, old value, new value and index.void
flush()
Flushes any unsaved changes to backing store.boolean
Returns whether data source exists.protected WebFile
getFileForFileHeader
(FileHeader fileHeader) Returns the file for given file header.getFileForPath
(String aPath) Returns the unique file instance with the given path (or null if it doesn't exist).protected WebFile
getFileForPathImpl
(String filePath) Returns the file for given path (null if not found).Returns the host name.protected File
getJavaFileForUrl
(WebURL aURL) Returns a standard java.io.File, if available.getLocalFile
(WebFile aFile, boolean doCache) Returns a local file for given file (with option to cache for future use).getName()
Returns the name for this data source.Returns the password.getPath()
Returns the data source name-space and name in standard path form.Returns a file property for key.getResponse
(WebRequest aReq) Returns a response instance for a request.Returns the root directory.Returns a WebSite that can be used for storing persistent support files.protected String
Returns a unique name for the Sandbox site.getURL()
Returns the URL.Returns the site URL address string.getUrlForPath
(String aFilePath) Returns a URL for the given file path.Returns the user name.void
Removes a site file PropChangeListener.void
Resets all loaded site files.protected WebResponse
Save file.protected void
saveLastModTimeForFile
(WebFile aFile, long aTime) Saves the modified time for a file to underlying file system.void
setPassword
(String aPassword) Sets the password.void
Sets a property for a key.void
Sets the URL.void
setUserName
(String aName) Sets the user name.toString()
Standard toString implementation.
-
Constructor Details
-
WebSite
public WebSite()Constructor.
-
-
Method Details
-
getURL
Returns the URL. -
setURL
Sets the URL. -
getUrlAddress
Returns the site URL address string. -
getName
Returns the name for this data source. -
getHostName
Returns the host name. -
getPath
Returns the data source name-space and name in standard path form. -
getUserName
Returns the user name. -
setUserName
Sets the user name. -
getPassword
Returns the password. -
setPassword
Sets the password. -
getExists
public boolean getExists()Returns whether data source exists. -
getRootDir
Returns the root directory. -
getFileForPath
Returns the unique file instance with the given path (or null if it doesn't exist).- Throws:
ResponseException
-
getFileForPathImpl
Returns the file for given path (null if not found).- Throws:
ResponseException
-
getFileForFileHeader
Returns the file for given file header. -
createFileForPath
Creates a file for given path, regardless of whether it is known to actually exist in site. -
saveFile
Save file. -
deleteFile
Delete file. -
getResponse
Returns a response instance for a request. -
doGetOrHead
Handles a get or head request. -
doPost
Handle a get request. -
doPut
Handle a PUT request. -
doDelete
Handle a DELETE request. -
saveLastModTimeForFile
Saves the modified time for a file to underlying file system.- Throws:
Exception
-
resetFiles
public void resetFiles()Resets all loaded site files. -
getJavaFileForUrl
Returns a standard java.io.File, if available. -
getUrlForPath
Returns a URL for the given file path. -
deleteSite
Deletes this data site, assuming it corresponds to something that can be deleted, like a database.- Throws:
Exception
-
getProp
Returns a file property for key. -
setProp
Sets a property for a key. -
getSandboxSite
Returns a WebSite that can be used for storing persistent support files. -
getSandboxSiteName
Returns a unique name for the Sandbox site. -
getLocalFile
Returns a local file for given file (with option to cache for future use). -
flush
Flushes any unsaved changes to backing store.- Throws:
Exception
-
fileDidReset
Called to notify site when file is reset. -
firePropChange
Fires a property change for given property name, old value, new value and index. -
addFileChangeListener
Adds a PropChangeListener to listen for any site file PropChange. -
removeFileChangeListener
Removes a site file PropChangeListener. -
fileDidPropChange
Called when any site file changes. -
toString
Standard toString implementation.
-