org.apache.jackrabbit.core.fs.db
Class OracleFileSystem

java.lang.Object
  extended by org.apache.jackrabbit.core.fs.db.DatabaseFileSystem
      extended by org.apache.jackrabbit.core.fs.db.DbFileSystem
          extended by org.apache.jackrabbit.core.fs.db.OracleFileSystem
All Implemented Interfaces:
FileSystem

public class OracleFileSystem
extends DbFileSystem

OracleFileSystem is a JDBC-based FileSystem implementation for Jackrabbit that persists file system entries in an Oracle database.

It is configured through the following properties:

See also DbFileSystem.

The following is a fragment from a sample configuration:

   <FileSystem class="org.apache.jackrabbit.core.fs.db.OracleFileSystem">
       <param name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:orcl"/>
       <param name="user" value="scott"/>
       <param name="password" value="tiger"/>
       <param name="schemaObjectPrefix" value="rep_"/>
       <param name="tableSpace" value="default"/>
  </FileSystem>
 


Field Summary
static String TABLE_SPACE_VARIABLE
          the variable for the Oracle table space
protected  String tableSpace
          the Oracle table space to use
 
Fields inherited from class org.apache.jackrabbit.core.fs.db.DbFileSystem
driver, password, url, user
 
Fields inherited from class org.apache.jackrabbit.core.fs.db.DatabaseFileSystem
con, copyFileSQL, copyFilesSQL, deleteFileSQL, deleteFolderSQL, INITIAL_BUFFER_SIZE, initialized, insertFileSQL, insertFolderSQL, schema, SCHEMA_OBJECT_PREFIX_VARIABLE, schemaObjectPrefix, selectChildCountSQL, selectDataSQL, selectExistSQL, selectFileAndFolderNamesSQL, selectFileExistSQL, selectFileNamesSQL, selectFolderExistSQL, selectFolderNamesSQL, selectLastModifiedSQL, selectLengthSQL, SLEEP_BEFORE_RECONNECT, updateDataSQL, updateLastModifiedSQL
 
Fields inherited from interface org.apache.jackrabbit.core.fs.FileSystem
SEPARATOR, SEPARATOR_CHAR
 
Constructor Summary
OracleFileSystem()
          Creates a new OracleFileSystem instance.
 
Method Summary
protected  void buildSQLStatements()
          Builds the SQL statements

Since Oracle treats emtpy strings and BLOBs as null values the SQL statements had to be adapated accordingly.

protected  void checkSchema()
          Checks if the required schema objects exist and creates them if they don't exist yet.

Overridden in order to support multiple oracle schemas.

protected  Blob createTemporaryBlob(InputStream in)
          Creates a temporary oracle.sql.BLOB instance via reflection and spools the contents of the specified stream.
protected  void freeTemporaryBlob(Object blob)
          Frees a temporary oracle.sql.BLOB instance via reflection.
 OutputStream getOutputStream(String filePath)
          Returns an output stream for writing bytes to the file denoted by this path. The file will be created if it doesn't exist. If the file exists, its contents will be overwritten.

Overridden because we need to use oracle.sql.BLOB and PreparedStatement#setBlob instead of just PreparedStatement#setBinaryStream.

 RandomAccessOutputStream getRandomAccessOutputStream(String filePath)
          Returns an output stream for writing bytes to the file denoted by this path. The file will be created if it doesn't exist. The current position of the file pointer is set to 0. See also RandomAccessOutputStream.seek(long);
 String getTableSpace()
          Returns the configured Oracle table space.
 void init()
          Initialize the file system

Retrieve the oracle.sql.BLOB class via reflection, and initialize the values for the DURATION_SESSION and MODE_READWRITE constants defined there.

 void setTableSpace(String tableSpace)
          Sets the Oracle table space.
 
Methods inherited from class org.apache.jackrabbit.core.fs.db.DbFileSystem
equals, getConnection, getDriver, getPassword, getUrl, getUser, hashCode, setDriver, setPassword, setUrl, setUser
 
Methods inherited from class org.apache.jackrabbit.core.fs.db.DatabaseFileSystem
close, closeConnection, closeResultSet, closeStatement, closeStream, copy, copyDeepFolder, copyFile, createDeepFolder, createFolder, deleteFile, deleteFolder, executeStmt, exists, getInputStream, getSchema, getSchemaObjectPrefix, hasChildren, initConnection, initPreparedStatements, isFile, isFolder, lastModified, length, list, listFiles, listFolders, move, prepareSchemaObjectPrefix, reestablishConnection, resetStatement, setSchema, setSchemaObjectPrefix, touch, verifyRootExists
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TABLE_SPACE_VARIABLE

public static final String TABLE_SPACE_VARIABLE
the variable for the Oracle table space

See Also:
Constant Field Values

tableSpace

protected String tableSpace
the Oracle table space to use

Constructor Detail

OracleFileSystem

public OracleFileSystem()
Creates a new OracleFileSystem instance.

Method Detail

getTableSpace

public String getTableSpace()
Returns the configured Oracle table space.

Returns:
the configured Oracle table space.

setTableSpace

public void setTableSpace(String tableSpace)
Sets the Oracle table space.

Parameters:
tableSpace - the Oracle table space.

init

public void init()
          throws FileSystemException
Initialize the file system

Retrieve the oracle.sql.BLOB class via reflection, and initialize the values for the DURATION_SESSION and MODE_READWRITE constants defined there.

Specified by:
init in interface FileSystem
Overrides:
init in class DatabaseFileSystem
Throws:
FileSystemException - if the file system initialization fails
See Also:
oracle.sql.BLOB#DURATION_SESSION, oracle.sql.BLOB#MODE_READWRITE

checkSchema

protected void checkSchema()
                    throws Exception
Checks if the required schema objects exist and creates them if they don't exist yet.

Overridden in order to support multiple oracle schemas. Note that schema names in Oracle correspond to the username of the connection. See http://issues.apache.org/jira/browse/JCR-582

Overrides:
checkSchema in class DatabaseFileSystem
Throws:
Exception - if an error occurs

buildSQLStatements

protected void buildSQLStatements()
Builds the SQL statements

Since Oracle treats emtpy strings and BLOBs as null values the SQL statements had to be adapated accordingly. The following changes were necessary:

Overrides:
buildSQLStatements in class DatabaseFileSystem

getOutputStream

public OutputStream getOutputStream(String filePath)
                             throws FileSystemException
Returns an output stream for writing bytes to the file denoted by this path. The file will be created if it doesn't exist. If the file exists, its contents will be overwritten.

Overridden because we need to use oracle.sql.BLOB and PreparedStatement#setBlob instead of just PreparedStatement#setBinaryStream.

Specified by:
getOutputStream in interface FileSystem
Overrides:
getOutputStream in class DatabaseFileSystem
Parameters:
filePath - the path of the file.
Returns:
an output stream for writing bytes to the file.
Throws:
FileSystemException - if the file cannot be written to or created

getRandomAccessOutputStream

public RandomAccessOutputStream getRandomAccessOutputStream(String filePath)
                                                     throws FileSystemException,
                                                            UnsupportedOperationException
Returns an output stream for writing bytes to the file denoted by this path. The file will be created if it doesn't exist. The current position of the file pointer is set to 0. See also RandomAccessOutputStream.seek(long);

Specified by:
getRandomAccessOutputStream in interface FileSystem
Overrides:
getRandomAccessOutputStream in class DatabaseFileSystem
Parameters:
filePath - the path of the file.
Returns:
an random access output stream for writing bytes to the file.
Throws:
FileSystemException - if the file could not be created or if the output stream cannot be obtained.
UnsupportedOperationException - if the implementation does not support file access through a RandomAccessOutputStream.

createTemporaryBlob

protected Blob createTemporaryBlob(InputStream in)
                            throws Exception
Creates a temporary oracle.sql.BLOB instance via reflection and spools the contents of the specified stream.

Throws:
Exception

freeTemporaryBlob

protected void freeTemporaryBlob(Object blob)
                          throws Exception
Frees a temporary oracle.sql.BLOB instance via reflection.

Throws:
Exception


Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.