Class WebSite

All Implemented Interfaces:
RMJSONArchiver.GetKeys, RMPropertyChanger, PropertyChangeListener, Cloneable, EventListener
Direct Known Subclasses:
ClassSite, DirSite, FileSite, HTTPSite, SnapSite, ZipFileSite

public abstract class WebSite extends RMObject implements PropertyChangeListener, RMJSONArchiver.GetKeys
This is an abstract class to provide data management (create, get, put, delete) and file management.
  • Field Details

  • Constructor Details

    • WebSite

      public WebSite()
  • Method Details

    • getURL

      public WebURL getURL()
      Returns the URL.
    • setURL

      protected 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.
    • getRootDirectory

      public WebFile getRootDirectory()
      Returns the root directory.
    • getRequest

      public Request getRequest(WebURL aURL)
      Returns a request object for a URL.
    • getResponse

      public Response getResponse(Request aRequest)
      Returns a response instance for a request.
    • handleHead

      protected Response handleHead(Request aRequest)
      Handles a head request.
    • handleGet

      protected Response handleGet(Request aRequest)
      Handle a get request.
    • handlePut

      protected Response handlePut(Request aRequest)
      Handle a PUT request.
    • handleDelete

      protected Response handleDelete(Request aRequest)
      Handle a DELETE request.
    • createFile

      public WebFile createFile(String aPath, boolean isDirectory)
      Returns a new file at the given path, regardless of whether it exists in the data source.
    • getFile

      public WebFile getFile(String aPath)
      Returns the individual file with the given path.
    • saveFile

      protected void saveFile(WebFile aFile) throws ResponseException
      Save file.
      Throws:
      ResponseException
    • deleteFile

      protected void deleteFile(WebFile aFile) throws ResponseException
      Delete file.
      Throws:
      ResponseException
    • createFileImpl

      protected WebFile createFileImpl(String aPath, boolean isDirectory)
      Creates a new file.
    • getFileImpl

      protected WebFile getFileImpl(String aPath) throws Exception
      Returns a data source file for given path (if file exists).
      Throws:
      Exception
    • getFilesImpl

      @Nullable protected List<WebFile> getFilesImpl(WebFile aFile) throws Exception
      Returns a list of files at path.
      Throws:
      Exception
    • getFileBytesImpl

      protected byte[] getFileBytesImpl(WebFile aFile) throws Exception
      Returns file bytes.
      Throws:
      Exception
    • saveFileImpl

      protected void saveFileImpl(WebFile aFile) throws Exception
      Saves a file.
      Throws:
      Exception
    • deleteFileImpl

      protected void deleteFileImpl(WebFile aFile) throws Exception
      Deletes a file.
      Throws:
      Exception
    • refreshFile

      public void refreshFile(WebFile aFile)
      Revert file from saved version.
    • refreshFileImpl

      protected void refreshFileImpl(WebFile aFile) throws Exception
      Reverts a file.
      Throws:
      Exception
    • getModifiedTime

      public long getModifiedTime(WebFile aFile)
      Returns the modified time for a file to underlying file system.
    • setModifiedTime

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

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

      protected void setExists(WebFile aFile, boolean aValue)
      Sets whether a file exists.
    • getStandardFile

      protected File getStandardFile(WebFile aFile)
      Returns a standard java.io.File, if available.
    • getURL

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

      protected WebURL createURL(String aURL)
      Creates a URL for string.
    • createSite

      public void createSite() throws Exception
      Creates the data site remote site (database, directory file, etc.).
      Throws:
      Exception
    • deleteSite

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

      public Schema getSchema()
      Returns the schema of represented WebSite as a hierarchy of RMEntity and RMProperty objects.
    • createSchema

      protected Schema createSchema()
      Creates the schema.
    • createEntity

      public Entity createEntity(String aName)
      Creates an entity for given name.
    • createEntityImpl

      protected Entity createEntityImpl(String aName)
      Returns the entity for given name.
    • getEntity

      public Entity getEntity(String aName)
      Returns the entity for given name.
    • getEntityImpl

      protected Entity getEntityImpl(String aName) throws Exception
      Returns the entity for given name.
      Throws:
      Exception
    • saveEntity

      public void saveEntity(Entity anEntity) throws Exception
      Saves the given entity.
      Throws:
      Exception
    • saveEntityImpl

      protected void saveEntityImpl(Entity anEntity) throws Exception
      Saves the given entity.
      Throws:
      Exception
    • deleteEntity

      public void deleteEntity(Entity anEntity) throws Exception
      Saves the given entity.
      Throws:
      Exception
    • deleteEntityImpl

      protected void deleteEntityImpl(Entity anEntity) throws Exception
      Saves the given entity.
      Throws:
      Exception
    • getDataTables

      public List<DataTable> getDataTables()
      Returns the list of known data tables.
    • getDataTable

      public DataTable getDataTable(String aName)
      Returns the DataTable for given name
    • createDataTable

      protected DataTable createDataTable(String aName)
      Returns the DataTable for given name.
    • createDataTableImpl

      @Nonnull protected DataTable createDataTableImpl()
      Creates an instance of DataTable.
    • createRow

      @Nonnull public Row createRow(@Nonnull Entity anEntity, @Nullable Object aPrimaryValue)
      Returns a row for an entity and primary value that is guaranteed to be unique for this data source.
    • createRow

      @Nonnull public Row createRow(@Nonnull Entity anEntity, @Nullable Object aPrimaryValue, Map aMap)
      Returns a row for an entity and primary value that is guaranteed to be unique for this data source.
    • createRowImpl

      @Nonnull protected Row createRowImpl(Entity anEntity, Object aPrimaryValue)
      Creates a new row for source.
    • getRow

      @Nullable public Row getRow(Entity anEntity, Object aPrimaryValue)
      Returns a row for a given entity and primary value.
    • getRowImpl

      @Nullable protected Row getRowImpl(Entity anEntity, Object aPrimaryValue)
      Returns a row for a given entity and primary value.
    • getRow

      @Nullable public Row getRow(Query aQuery)
      Returns a row for given query.
    • getRows

      @Nonnull public List<Row> getRows(Query aQuery)
      Returns a set of rows for the given properties and condition.
    • getRowsImpl

      @Nonnull protected abstract List<Row> getRowsImpl(Entity anEntity, Query aQuery)
      Returns a set of rows for the given properties and condition.
    • saveRow

      public void saveRow(Row aRow) throws Exception
      Inserts or updates a given row.
      Throws:
      Exception
    • saveRowImpl

      protected abstract void saveRowImpl(Row aRow) throws Exception
      Inserts or updates a given row.
      Throws:
      Exception
    • deleteRow

      public void deleteRow(Row aRow) throws Exception
      Deletes a given row.
      Throws:
      Exception
    • deleteRowImpl

      protected abstract void deleteRowImpl(Row aRow) throws Exception
      Deletes a given row.
      Throws:
      Exception
    • bulkImport

      public void bulkImport(Map<String,List<Map>> theMaps) throws Exception
      Bulk import.
      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

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

      public void setSandbox(WebSite aSandbox)
      Sets a WebSite that can be used for storing persistent support files.
    • createSandbox

      @Nonnull protected WebSite createSandbox()
      Creates a WebSite that can be used for storing persistent support files.
    • createSandboxURL

      @Nonnull protected WebURL createSandboxURL()
      Creates a WebSite that can be used for storing persistent support files.
    • createSandboxURLS

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

      public WebSite.Servlet getServlet(WebURL aUrl)
      Returns the Servlet for URL.
    • setServlet

      public void setServlet(WebURL aUrl, WebSite.Servlet aServlet)
      Sets a Servlet for URL.
    • getClassLoader

      public WebClassLoader getClassLoader()
      Returns the DataClassLoader.
    • setClassLoader

      public void setClassLoader(WebClassLoader aClassLoader)
      Sets the DataClassLoader.
    • createClassLoader

      protected WebClassLoader createClassLoader()
      Creates the DataClassLoader.
    • isRunning

      public boolean isRunning()
      Returns whether this data source is running background processes.
    • addDeepChangeListener

      public void addDeepChangeListener(DeepChangeListener aListener)
      Adds a deep (property) change listener to get notified when this WebSite sees changes (to files).
    • removeDeepChangeListener

      public void removeDeepChangeListener(DeepChangeListener aListener)
      Removes a deep (property) change listener to get notified when this WebSite sees changes (to files).
    • propertyChange

      public void propertyChange(PropertyChangeEvent anEvent)
      Handle property changes on row objects by forwarding to listener.
      Specified by:
      propertyChange in interface PropertyChangeListener
    • refresh

      public void refresh()
      Clears all cached data in the data source, forcing everything to reload.
    • flush

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

      protected void flushImpl() throws Exception
      Flushes any unsaved changes to backing store.
      Throws:
      Exception
    • getJSONKeys

      public List<String> getJSONKeys()
      RMJSONArchiver GetKeys method.
      Specified by:
      getJSONKeys in interface RMJSONArchiver.GetKeys
    • toString

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