Index: src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java (revision 1176665)
+++ src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java (working copy)
@@ -16,12 +16,12 @@
*/
package org.apache.jackrabbit.core.fs.db;
+import javax.sql.DataSource;
+
import org.apache.jackrabbit.core.util.db.CheckSchemaOperation;
import org.apache.jackrabbit.core.util.db.ConnectionHelper;
import org.apache.jackrabbit.core.util.db.OracleConnectionHelper;
-import javax.sql.DataSource;
-
/**
* OracleFileSystem is a JDBC-based FileSystem
* implementation for Jackrabbit that persists file system entries in an
@@ -38,7 +38,8 @@
*
user: the database userpassword: the user's passwordschemaObjectPrefix: prefix to be prepended to schema objectstableSpace: the tablespace to usetablespace: the tablespace to use for tables (also used for indexes if indexTablespace is omitted)indexTablespace: the tablespace to use for indexesOracleFileSystem instance.
*/
@@ -66,26 +86,57 @@
schema = "oracle";
driver = "oracle.jdbc.OracleDriver";
schemaObjectPrefix = "";
+ tablespace = DEFAULT_TABLESPACE_CLAUSE;
+ indexTablespace = DEFAULT_TABLESPACE_CLAUSE;
initialized = false;
}
/**
- * Returns the configured Oracle table space.
- * @return the configured Oracle table space.
+ * Returns the configured Oracle tablespace for tables.
+ * @return the configured Oracle tablespace for tables.
*/
- public String getTableSpace() {
- return tableSpace;
+ public String getTablespace() {
+ return tablespace;
}
/**
- * Sets the Oracle table space.
- * @param tableSpace the Oracle table space.
+ * Sets the Oracle tablespace for tables.
+ * @param tablespaceName the Oracle tablespace for tables.
*/
- public void setTableSpace(String tableSpace) {
- if (tableSpace != null && tableSpace.trim().length() > 0) {
- this.tableSpace = "tablespace " + tableSpace.trim();
+ public void setTablespace(String tablespaceName) {
+ this.tablespace = this.buildTablespaceClause(tablespaceName);
+ }
+
+ /**
+ * Returns the configured Oracle tablespace for indexes.
+ * @return the configured Oracle tablespace for indexes.
+ */
+ public String getIndexTablespace() {
+ return indexTablespace;
+ }
+
+ /**
+ * Sets the Oracle tablespace for indexes.
+ * @param tablespace the Oracle tablespace for indexes.
+ */
+ public void setIndexTablespace(String tablespaceName) {
+ this.indexTablespace = this.buildTablespaceClause(tablespaceName);
+ }
+
+ /**
+ * Constructs the tablespace <tbs name> clause from
+ * the supplied tablespace name. If the name is empty, {@link #DEFAULT_TABLESPACE_CLAUSE}
+ * is returned instead.
+ *
+ * @param tablespaceName A tablespace name
+ * @return A tablespace clause using the supplied name or
+ * {@value #DEFAULT_TABLESPACE_CLAUSE} if the name is empty
+ */
+ private String buildTablespaceClause(String tablespaceName) {
+ if (tablespaceName == null || tablespaceName.trim().length() == 0) {
+ return DEFAULT_TABLESPACE_CLAUSE;
} else {
- this.tableSpace = "";
+ return "tablespace " + tablespaceName.trim();
}
}
@@ -106,8 +157,13 @@
*/
@Override
protected CheckSchemaOperation createCheckSchemaOperation() {
- return super.createCheckSchemaOperation().addVariableReplacement(
- CheckSchemaOperation.TABLE_SPACE_VARIABLE, tableSpace);
+ if (DEFAULT_TABLESPACE_CLAUSE.equals(indexTablespace) && !DEFAULT_TABLESPACE_CLAUSE.equals(tablespace)) {
+ // tablespace was set but not indexTablespace : use the same for both
+ indexTablespace = tablespace;
+ }
+ return super.createCheckSchemaOperation()
+ .addVariableReplacement(TABLESPACE_VARIABLE, tablespace)
+ .addVariableReplacement(INDEX_TABLESPACE_VARIABLE, indexTablespace);
}
//-----------------------------------------< DatabaseFileSystem overrides >
Index: src/main/java/org/apache/jackrabbit/core/journal/OracleDatabaseJournal.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/journal/OracleDatabaseJournal.java (revision 1176665)
+++ src/main/java/org/apache/jackrabbit/core/journal/OracleDatabaseJournal.java (working copy)
@@ -25,25 +25,91 @@
/**
* It has the following property in addition to those of the DatabaseJournal:
* tableSpace: the Oracle tablespace to usetablespace: the tablespace to use for tablesindexTablespace: the tablespace to use for indexestablespace <tbs name> clause from
+ * the supplied tablespace name. If the name is empty, {@link #DEFAULT_TABLESPACE_CLAUSE}
+ * is returned instead.
+ *
+ * @param tablespaceName A tablespace name
+ * @return A tablespace clause using the supplied name or
+ * {@value #DEFAULT_TABLESPACE_CLAUSE} if the name is empty
+ */
+ private String buildTablespaceClause(String tablespaceName) {
+ if (tablespaceName == null || tablespaceName.trim().length() == 0) {
+ return DEFAULT_TABLESPACE_CLAUSE;
+ } else {
+ return "tablespace " + tablespaceName.trim();
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -58,27 +124,12 @@
*/
@Override
protected CheckSchemaOperation createCheckSchemaOperation() {
- return super.createCheckSchemaOperation().addVariableReplacement(
- CheckSchemaOperation.TABLE_SPACE_VARIABLE, tableSpace);
- }
-
- /**
- * Returns the configured Oracle table space.
- * @return the configured Oracle table space.
- */
- public String getTableSpace() {
- return tableSpace;
- }
-
- /**
- * Sets the Oracle table space.
- * @param tableSpace the Oracle table space.
- */
- public void setTableSpace(String tableSpace) {
- if (tableSpace != null && tableSpace.trim().length() > 0) {
- this.tableSpace = "tablespace " + tableSpace.trim();
- } else {
- this.tableSpace = "";
+ if (DEFAULT_TABLESPACE_CLAUSE.equals(indexTablespace) && !DEFAULT_TABLESPACE_CLAUSE.equals(tablespace)) {
+ // tablespace was set but not indexTablespace : use the same for both
+ indexTablespace = tablespace;
}
+ return super.createCheckSchemaOperation()
+ .addVariableReplacement(TABLESPACE_VARIABLE, tablespace)
+ .addVariableReplacement(INDEX_TABLESPACE_VARIABLE, indexTablespace);
}
}
Index: src/main/java/org/apache/jackrabbit/core/persistence/pool/OraclePersistenceManager.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/persistence/pool/OraclePersistenceManager.java (revision 1176665)
+++ src/main/java/org/apache/jackrabbit/core/persistence/pool/OraclePersistenceManager.java (working copy)
@@ -38,42 +38,90 @@
* tablespace <tbs name> clause from
+ * the supplied tablespace name. If the name is empty, {@link #DEFAULT_TABLESPACE_CLAUSE}
+ * is returned instead.
*
- * @param tableSpace the Oracle table space.
+ * @param tablespaceName A tablespace name
+ * @return A tablespace clause using the supplied name or
+ * {@value #DEFAULT_TABLESPACE_CLAUSE} if the name is empty
*/
- public void setTableSpace(String tableSpace) {
- if (tableSpace != null && tableSpace.trim().length() > 0) {
- this.tableSpace = "tablespace " + tableSpace.trim();
+ private String buildTablespaceClause(String tablespaceName) {
+ if (tablespaceName == null || tablespaceName.trim().length() == 0) {
+ return DEFAULT_TABLESPACE_CLAUSE;
} else {
- this.tableSpace = "";
+ return "tablespace " + tablespaceName.trim();
}
}
@@ -119,7 +167,12 @@
*/
@Override
protected CheckSchemaOperation createCheckSchemaOperation() {
- return super.createCheckSchemaOperation().addVariableReplacement(
- CheckSchemaOperation.TABLE_SPACE_VARIABLE, tableSpace);
+ if (DEFAULT_TABLESPACE_CLAUSE.equals(indexTablespace) && !DEFAULT_TABLESPACE_CLAUSE.equals(tablespace)) {
+ // tablespace was set but not indexTablespace : use the same for both
+ indexTablespace = tablespace;
+ }
+ return super.createCheckSchemaOperation()
+ .addVariableReplacement(TABLESPACE_VARIABLE, tablespace)
+ .addVariableReplacement(INDEX_TABLESPACE_VARIABLE, indexTablespace);
}
}
Index: src/main/resources/org/apache/jackrabbit/core/fs/db/oracle.ddl
===================================================================
--- src/main/resources/org/apache/jackrabbit/core/fs/db/oracle.ddl (revision 1176665)
+++ src/main/resources/org/apache/jackrabbit/core/fs/db/oracle.ddl (working copy)
@@ -12,5 +12,5 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-create table ${schemaObjectPrefix}FSENTRY (FSENTRY_PATH varchar2(2048) not null, FSENTRY_NAME varchar2(255) not null, FSENTRY_DATA blob null, FSENTRY_LASTMOD number(38,0) not null, FSENTRY_LENGTH number(38,0) null) ${tableSpace}
-create unique index ${schemaObjectPrefix}FSENTRY_IDX on ${schemaObjectPrefix}FSENTRY (FSENTRY_PATH, FSENTRY_NAME) ${tableSpace}
+create table ${schemaObjectPrefix}FSENTRY (FSENTRY_PATH varchar2(2048) not null, FSENTRY_NAME varchar2(255) not null, FSENTRY_DATA blob null, FSENTRY_LASTMOD number(38,0) not null, FSENTRY_LENGTH number(38,0) null) ${tablespace}
+create unique index ${schemaObjectPrefix}FSENTRY_IDX on ${schemaObjectPrefix}FSENTRY (FSENTRY_PATH, FSENTRY_NAME) ${indexTablespace}
Index: src/main/resources/org/apache/jackrabbit/core/journal/oracle.ddl
===================================================================
--- src/main/resources/org/apache/jackrabbit/core/journal/oracle.ddl (revision 1176665)
+++ src/main/resources/org/apache/jackrabbit/core/journal/oracle.ddl (working copy)
@@ -12,11 +12,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-create table ${schemaObjectPrefix}JOURNAL (REVISION_ID number(20,0) NOT NULL, JOURNAL_ID varchar(255), PRODUCER_ID varchar(255), REVISION_DATA blob) ${tableSpace}
-create unique index ${schemaObjectPrefix}JOURNAL_IDX on ${schemaObjectPrefix}JOURNAL (REVISION_ID) ${tableSpace}
-create table ${schemaObjectPrefix}GLOBAL_REVISION (REVISION_ID number(20,0) NOT NULL) ${tableSpace}
-create unique index ${schemaObjectPrefix}GLOBAL_REVISION_IDX on ${schemaObjectPrefix}GLOBAL_REVISION (REVISION_ID) ${tableSpace}
-create table ${schemaObjectPrefix}LOCAL_REVISIONS (JOURNAL_ID varchar(255) NOT NULL, REVISION_ID number(20,0) NOT NULL)
+create table ${schemaObjectPrefix}JOURNAL (REVISION_ID number(20,0) NOT NULL, JOURNAL_ID varchar(255), PRODUCER_ID varchar(255), REVISION_DATA blob) ${tablespace}
+create unique index ${schemaObjectPrefix}JOURNAL_IDX on ${schemaObjectPrefix}JOURNAL (REVISION_ID) ${indexTablespace}
+create table ${schemaObjectPrefix}GLOBAL_REVISION (REVISION_ID number(20,0) NOT NULL) ${tablespace}
+create unique index ${schemaObjectPrefix}GLOBAL_REVISION_IDX on ${schemaObjectPrefix}GLOBAL_REVISION (REVISION_ID) ${indexTablespace}
+
+create table ${schemaObjectPrefix}LOCAL_REVISIONS (JOURNAL_ID varchar(255) NOT NULL, REVISION_ID number(20,0) NOT NULL) ${tablespace}
+
# Inserting the one and only revision counter record now helps avoiding race conditions
insert into ${schemaObjectPrefix}GLOBAL_REVISION VALUES(0)
Index: src/main/resources/org/apache/jackrabbit/core/persistence/bundle/oracle.ddl
===================================================================
--- src/main/resources/org/apache/jackrabbit/core/persistence/bundle/oracle.ddl (revision 1176665)
+++ src/main/resources/org/apache/jackrabbit/core/persistence/bundle/oracle.ddl (working copy)
@@ -12,16 +12,17 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-create table ${schemaObjectPrefix}BUNDLE (NODE_ID raw(16) not null, BUNDLE_DATA blob not null) ${tableSpace}
-create unique index ${schemaObjectPrefix}BUNDLE_IDX on ${schemaObjectPrefix}BUNDLE (NODE_ID) ${tableSpace}
+create table ${schemaObjectPrefix}BUNDLE (NODE_ID raw(16) not null, BUNDLE_DATA blob not null) ${tablespace}
+create unique index ${schemaObjectPrefix}BUNDLE_IDX on ${schemaObjectPrefix}BUNDLE (NODE_ID) ${indexTablespace}
-create table ${schemaObjectPrefix}REFS (NODE_ID raw(16) not null, REFS_DATA blob not null) ${tableSpace}
-create unique index ${schemaObjectPrefix}REFS_IDX on ${schemaObjectPrefix}REFS (NODE_ID) ${tableSpace}
+create table ${schemaObjectPrefix}REFS (NODE_ID raw(16) not null, REFS_DATA blob not null) ${tablespace}
+create unique index ${schemaObjectPrefix}REFS_IDX on ${schemaObjectPrefix}REFS (NODE_ID) ${indexTablespace}
-create table ${schemaObjectPrefix}BINVAL (BINVAL_ID varchar2(64) not null, BINVAL_DATA blob null) ${tableSpace}
-create unique index ${schemaObjectPrefix}BINVAL_IDX on ${schemaObjectPrefix}BINVAL (BINVAL_ID) ${tableSpace}
+create table ${schemaObjectPrefix}BINVAL (BINVAL_ID varchar2(64) not null, BINVAL_DATA blob null) ${tablespace}
+create unique index ${schemaObjectPrefix}BINVAL_IDX on ${schemaObjectPrefix}BINVAL (BINVAL_ID) ${indexTablespace}
-create table ${schemaObjectPrefix}NAMES (ID INTEGER primary key, NAME varchar2(255) not null) ${tableSpace}
-create unique index ${schemaObjectPrefix}NAMES_IDX on ${schemaObjectPrefix}NAMES (NAME) ${tableSpace}
+create table ${schemaObjectPrefix}NAMES (ID INTEGER primary key using index ${indexTablespace}, NAME varchar2(255) not null) ${tablespace}
+create unique index ${schemaObjectPrefix}NAMES_IDX on ${schemaObjectPrefix}NAMES (NAME) ${indexTablespace}
+
create sequence ${schemaObjectPrefix}seq_names_id
create trigger ${schemaObjectPrefix}t1 before insert on ${schemaObjectPrefix}NAMES for each row begin select ${schemaObjectPrefix}seq_names_id.nextval into :new.id from dual; end;
\ No newline at end of file
Index: src/test/java/org/apache/jackrabbit/core/OracleRepositoryTest.java
===================================================================
--- src/test/java/org/apache/jackrabbit/core/OracleRepositoryTest.java (revision 0)
+++ src/test/java/org/apache/jackrabbit/core/OracleRepositoryTest.java (revision 0)
@@ -0,0 +1,60 @@
+package org.apache.jackrabbit.core;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Properties;
+
+import javax.jcr.Session;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.jackrabbit.core.config.RepositoryConfig;
+
+/**
+ * Tests the creation of a repository using Oracle persistence and different table and index tablespaces.
+ *
+ * @author Edouard Hue