Class DatabaseFileSystem

  • All Implemented Interfaces:
    org.apache.jackrabbit.core.fs.FileSystem
    Direct Known Subclasses:
    DbFileSystem, JNDIDatabaseFileSystem

    public abstract class DatabaseFileSystem
    extends Object
    implements org.apache.jackrabbit.core.fs.FileSystem
    Base class for database file systems. This class contains common functionality for database file system subclasses that normally differ only in the way the database connection is acquired.

    See the DbFileSystem for a detailed description of the available configuration options and database behaviour.

    • Field Detail

      • initialized

        protected boolean initialized
      • schema

        protected String schema
      • schemaObjectPrefix

        protected String schemaObjectPrefix
      • conHelper

        protected org.apache.jackrabbit.core.util.db.ConnectionHelper conHelper
        the ConnectionHelper set in the init() method
      • selectExistSQL

        protected String selectExistSQL
      • selectFileExistSQL

        protected String selectFileExistSQL
      • selectFolderExistSQL

        protected String selectFolderExistSQL
      • selectChildCountSQL

        protected String selectChildCountSQL
      • selectDataSQL

        protected String selectDataSQL
      • selectLastModifiedSQL

        protected String selectLastModifiedSQL
      • selectLengthSQL

        protected String selectLengthSQL
      • selectFileNamesSQL

        protected String selectFileNamesSQL
      • selectFolderNamesSQL

        protected String selectFolderNamesSQL
      • selectFileAndFolderNamesSQL

        protected String selectFileAndFolderNamesSQL
      • deleteFileSQL

        protected String deleteFileSQL
      • deleteFolderSQL

        protected String deleteFolderSQL
      • insertFileSQL

        protected String insertFileSQL
      • insertFolderSQL

        protected String insertFolderSQL
      • updateDataSQL

        protected String updateDataSQL
      • updateLastModifiedSQL

        protected String updateLastModifiedSQL
      • copyFileSQL

        protected String copyFileSQL
      • copyFilesSQL

        protected String copyFilesSQL
    • Constructor Detail

      • DatabaseFileSystem

        public DatabaseFileSystem()
        Default constructor
    • Method Detail

      • getSchemaObjectPrefix

        public String getSchemaObjectPrefix()
      • setSchemaObjectPrefix

        public void setSchemaObjectPrefix​(String schemaObjectPrefix)
      • getSchema

        public String getSchema()
      • setSchema

        public void setSchema​(String schema)
      • isSchemaCheckEnabled

        public final boolean isSchemaCheckEnabled()
        Returns:
        whether the schema check is enabled
      • setSchemaCheckEnabled

        public final void setSchemaCheckEnabled​(boolean enabled)
        Parameters:
        enabled - set whether the schema check is enabled
      • hashCode

        public int hashCode()
        Returns zero to satisfy the Object equals/hashCode contract. This class is mutable and not meant to be used as a hash key.
        Overrides:
        hashCode in class Object
        Returns:
        always zero
        See Also:
        Object.hashCode()
      • init

        public void init()
                  throws org.apache.jackrabbit.core.fs.FileSystemException
        Specified by:
        init in interface org.apache.jackrabbit.core.fs.FileSystem
        Throws:
        org.apache.jackrabbit.core.fs.FileSystemException
      • createConnectionHelper

        protected org.apache.jackrabbit.core.util.db.ConnectionHelper createConnectionHelper​(DataSource dataSrc)
                                                                                      throws Exception
        This method is called from the init() method of this class and returns a ConnectionHelper instance which is assigned to the conHelper field. Subclasses may override it to return a specialized connection helper.
        Parameters:
        dataSrc - the DataSource of this persistence manager
        Returns:
        a ConnectionHelper
        Throws:
        Exception - on error
      • createCheckSchemaOperation

        protected org.apache.jackrabbit.core.util.db.CheckSchemaOperation createCheckSchemaOperation()
        This method is called from init() after the createConnectionHelper(DataSource) method, and returns a default CheckSchemaOperation. Subclasses can overrride this implementation to get a customized implementation.
        Returns:
        a new CheckSchemaOperation instance
      • close

        public void close()
                   throws org.apache.jackrabbit.core.fs.FileSystemException
        Specified by:
        close in interface org.apache.jackrabbit.core.fs.FileSystem
        Throws:
        org.apache.jackrabbit.core.fs.FileSystemException
      • createFolder

        public void createFolder​(String folderPath)
                          throws org.apache.jackrabbit.core.fs.FileSystemException
        Specified by:
        createFolder in interface org.apache.jackrabbit.core.fs.FileSystem
        Throws:
        org.apache.jackrabbit.core.fs.FileSystemException
      • deleteFile

        public void deleteFile​(String filePath)
                        throws org.apache.jackrabbit.core.fs.FileSystemException
        Specified by:
        deleteFile in interface org.apache.jackrabbit.core.fs.FileSystem
        Throws:
        org.apache.jackrabbit.core.fs.FileSystemException
      • deleteFolder

        public void deleteFolder​(String folderPath)
                          throws org.apache.jackrabbit.core.fs.FileSystemException
        Specified by:
        deleteFolder in interface org.apache.jackrabbit.core.fs.FileSystem
        Throws:
        org.apache.jackrabbit.core.fs.FileSystemException
      • exists

        public boolean exists​(String path)
                       throws org.apache.jackrabbit.core.fs.FileSystemException
        Specified by:
        exists in interface org.apache.jackrabbit.core.fs.FileSystem
        Throws:
        org.apache.jackrabbit.core.fs.FileSystemException
      • isFile

        public boolean isFile​(String path)
                       throws org.apache.jackrabbit.core.fs.FileSystemException
        Specified by:
        isFile in interface org.apache.jackrabbit.core.fs.FileSystem
        Throws:
        org.apache.jackrabbit.core.fs.FileSystemException
      • isFolder

        public boolean isFolder​(String path)
                         throws org.apache.jackrabbit.core.fs.FileSystemException
        Specified by:
        isFolder in interface org.apache.jackrabbit.core.fs.FileSystem
        Throws:
        org.apache.jackrabbit.core.fs.FileSystemException
      • lastModified

        public long lastModified​(String path)
                          throws org.apache.jackrabbit.core.fs.FileSystemException
        Specified by:
        lastModified in interface org.apache.jackrabbit.core.fs.FileSystem
        Throws:
        org.apache.jackrabbit.core.fs.FileSystemException
      • length

        public long length​(String filePath)
                    throws org.apache.jackrabbit.core.fs.FileSystemException
        Specified by:
        length in interface org.apache.jackrabbit.core.fs.FileSystem
        Throws:
        org.apache.jackrabbit.core.fs.FileSystemException
      • hasChildren

        public boolean hasChildren​(String path)
                            throws org.apache.jackrabbit.core.fs.FileSystemException
        Specified by:
        hasChildren in interface org.apache.jackrabbit.core.fs.FileSystem
        Throws:
        org.apache.jackrabbit.core.fs.FileSystemException
      • list

        public String[] list​(String folderPath)
                      throws org.apache.jackrabbit.core.fs.FileSystemException
        Specified by:
        list in interface org.apache.jackrabbit.core.fs.FileSystem
        Throws:
        org.apache.jackrabbit.core.fs.FileSystemException
      • listFiles

        public String[] listFiles​(String folderPath)
                           throws org.apache.jackrabbit.core.fs.FileSystemException
        Specified by:
        listFiles in interface org.apache.jackrabbit.core.fs.FileSystem
        Throws:
        org.apache.jackrabbit.core.fs.FileSystemException
      • listFolders

        public String[] listFolders​(String folderPath)
                             throws org.apache.jackrabbit.core.fs.FileSystemException
        Specified by:
        listFolders in interface org.apache.jackrabbit.core.fs.FileSystem
        Throws:
        org.apache.jackrabbit.core.fs.FileSystemException
      • getInputStream

        public InputStream getInputStream​(String filePath)
                                   throws org.apache.jackrabbit.core.fs.FileSystemException
        Specified by:
        getInputStream in interface org.apache.jackrabbit.core.fs.FileSystem
        Throws:
        org.apache.jackrabbit.core.fs.FileSystemException
      • getOutputStream

        public OutputStream getOutputStream​(String filePath)
                                     throws org.apache.jackrabbit.core.fs.FileSystemException
        Specified by:
        getOutputStream in interface org.apache.jackrabbit.core.fs.FileSystem
        Throws:
        org.apache.jackrabbit.core.fs.FileSystemException
      • buildSQLStatements

        protected void buildSQLStatements()
        Builds the SQL statements
      • verifyRootExists

        protected void verifyRootExists()
                                 throws Exception
        Verifies that the root file system entry exists. If it doesn't exist yet it will be automatically created.
        Throws:
        Exception - if an error occurs
      • createDeepFolder

        protected void createDeepFolder​(String folderPath)
                                 throws org.apache.jackrabbit.core.fs.FileSystemException
        Creates the specified files system folder entry, recursively creating any non-existing intermediate folder entries.
        Parameters:
        folderPath - folder entry to create
        Throws:
        org.apache.jackrabbit.core.fs.FileSystemException - if an error occurs