Package snap.web
Class WebSite
java.lang.Object
snap.web.WebSite
- Direct Known Subclasses:
DirSite
,DropBoxSite
,FileSite
,HTTPSite
,JRTSite
,RecentFilesSite
,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.protected WebFile
createFile
(FileHeader fileHeader) Returns a new file for given file header, regardless of whether it exists on site.createFileForPath
(String aPath, boolean isDir) Returns a new file for given path, regardless of whether it exists on 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 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
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.protected FileContents
getContentsForFile
(WebFile aFile) Returns the contents for given file.boolean
Returns whether data source exists.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 individual file with the given path.Returns the host name.protected File
getJavaFile
(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
Creates a WebSite that can be used for storing persistent support files.getURL()
Returns the URL.Returns a URL for the given file path.Returns the URL root.Returns the user name.void
refresh()
Clears site caches.void
Removes a site file PropChangeListener.void
Resets all loaded site files.protected WebResponse
Save file.protected void
setModTimeForFile
(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. -
getURLString
Returns the URL root. -
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 individual file with the given path.- Throws:
ResponseException
-
createFileForPath
Returns a new file for given path, regardless of whether it exists on site. -
createFile
Returns a new file for given file header, regardless of whether it exists on site. -
getContentsForFile
Returns the contents for given file. -
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. -
setModTimeForFile
Saves the modified time for a file to underlying file system.- Throws:
Exception
-
resetFiles
public void resetFiles()Resets all loaded site files. -
getJavaFile
Returns a standard java.io.File, if available. -
getURL
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. -
getSandbox
Returns a WebSite that can be used for storing persistent support files. -
getSandboxName
Creates a WebSite that can be used for storing persistent support files. -
getLocalFile
Returns a local file for given file (with option to cache for future use). -
refresh
public void refresh()Clears site caches. -
flush
Flushes any unsaved changes to backing store.- Throws:
Exception
-
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.
-