Package org.apache.jackrabbit.core.fs.db
Class DatabaseFileSystem
- java.lang.Object
-
- org.apache.jackrabbit.core.fs.db.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 Summary
Fields Modifier and Type Field Description protected org.apache.jackrabbit.core.util.db.ConnectionHelper
conHelper
theConnectionHelper
set in theinit()
methodprotected String
copyFileSQL
protected String
copyFilesSQL
protected String
deleteFileSQL
protected String
deleteFolderSQL
protected static int
INITIAL_BUFFER_SIZE
protected boolean
initialized
protected String
insertFileSQL
protected String
insertFolderSQL
protected String
schema
protected String
schemaObjectPrefix
protected String
selectChildCountSQL
protected String
selectDataSQL
protected String
selectExistSQL
protected String
selectFileAndFolderNamesSQL
protected String
selectFileExistSQL
protected String
selectFileNamesSQL
protected String
selectFolderExistSQL
protected String
selectFolderNamesSQL
protected String
selectLastModifiedSQL
protected String
selectLengthSQL
protected String
updateDataSQL
protected String
updateLastModifiedSQL
-
Constructor Summary
Constructors Constructor Description DatabaseFileSystem()
Default constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
buildSQLStatements()
Builds the SQL statementsvoid
close()
protected org.apache.jackrabbit.core.util.db.CheckSchemaOperation
createCheckSchemaOperation()
This method is called frominit()
after thecreateConnectionHelper(DataSource)
method, and returns a defaultCheckSchemaOperation
.protected org.apache.jackrabbit.core.util.db.ConnectionHelper
createConnectionHelper(DataSource dataSrc)
This method is called from theinit()
method of this class and returns aConnectionHelper
instance which is assigned to theconHelper
field.protected void
createDeepFolder(String folderPath)
Creates the specified files system folder entry, recursively creating any non-existing intermediate folder entries.void
createFolder(String folderPath)
void
deleteFile(String filePath)
void
deleteFolder(String folderPath)
boolean
equals(Object obj)
boolean
exists(String path)
protected abstract DataSource
getDataSource()
InputStream
getInputStream(String filePath)
OutputStream
getOutputStream(String filePath)
String
getSchema()
String
getSchemaObjectPrefix()
boolean
hasChildren(String path)
int
hashCode()
Returns zero to satisfy the Object equals/hashCode contract.void
init()
boolean
isFile(String path)
boolean
isFolder(String path)
boolean
isSchemaCheckEnabled()
long
lastModified(String path)
long
length(String filePath)
String[]
list(String folderPath)
String[]
listFiles(String folderPath)
String[]
listFolders(String folderPath)
void
setSchema(String schema)
void
setSchemaCheckEnabled(boolean enabled)
void
setSchemaObjectPrefix(String schemaObjectPrefix)
protected void
verifyRootExists()
Verifies that the root file system entry exists.
-
-
-
Field Detail
-
initialized
protected boolean initialized
-
schema
protected String schema
-
schemaObjectPrefix
protected String schemaObjectPrefix
-
INITIAL_BUFFER_SIZE
protected static final int INITIAL_BUFFER_SIZE
- See Also:
- Constant Field Values
-
conHelper
protected org.apache.jackrabbit.core.util.db.ConnectionHelper conHelper
theConnectionHelper
set in theinit()
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
-
-
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 classObject
- Returns:
- always zero
- See Also:
Object.hashCode()
-
init
public void init() throws org.apache.jackrabbit.core.fs.FileSystemException
- Specified by:
init
in interfaceorg.apache.jackrabbit.core.fs.FileSystem
- Throws:
org.apache.jackrabbit.core.fs.FileSystemException
-
getDataSource
protected abstract DataSource getDataSource() throws Exception
- Returns:
- Throws:
Exception
-
createConnectionHelper
protected org.apache.jackrabbit.core.util.db.ConnectionHelper createConnectionHelper(DataSource dataSrc) throws Exception
This method is called from theinit()
method of this class and returns aConnectionHelper
instance which is assigned to theconHelper
field. Subclasses may override it to return a specialized connection helper.- Parameters:
dataSrc
- theDataSource
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 frominit()
after thecreateConnectionHelper(DataSource)
method, and returns a defaultCheckSchemaOperation
. 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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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
-
-