Index: src/main/java/org/apache/jackrabbit/core/persistence/db/MSSqlPersistenceManager.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/persistence/db/MSSqlPersistenceManager.java (revision 0)
+++ src/main/java/org/apache/jackrabbit/core/persistence/db/MSSqlPersistenceManager.java (revision 0)
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.
+ */
+package org.apache.jackrabbit.core.persistence.db;
+
+import org.apache.jackrabbit.util.Text;
+
+/**
+ * MSSqlPersistenceManager is a JDBC-based
+ * PersistenceManager for Jackrabbit that persists
+ * ItemState and NodeReferences objects in MS SQL
+ * database using a simple custom serialization format and a
+ * very basic non-normalized database schema (in essence tables with one 'key'
+ * and one 'data' column).
+ *
driver: the FQN name of the JDBC driver class
+ * (default: "com.microsoft.sqlserver.jdbc.SQLServerDriver")schema: type of schema to be used
+ * (default: "mssql")url: the database url (e.g.
+ * "jdbc:microsoft:sqlserver://[host]:[port];databaseName=[dbname]")user: the database userpassword: the user's passwordschemaObjectPrefix: prefix to be prepended to schema objectstableSpace: the tablespace to useexternalBLOBs: if true (the default) BINARY
+ * values (BLOBs) are stored in the local file system;
+ * if false BLOBs are stored in the database
+ * <PersistenceManager class="org.apache.jackrabbit.core.persistence.db.MSSqlPersistenceManager">
+ * <param name="url" value="jdbc:microsoft:sqlserver://localhost:1433;mydb"/>
+ * <param name="user" value="mydba"/>
+ * <param name="password" value="mydba"/>
+ * <param name="schemaObjectPrefix" value="${wsp.name}_"/>
+ * <param name="tableSpace" value=""/>
+ * <param name="externalBLOBs" value="false"/>
+ * </PersistenceManager>
+ *
+ */
+public class MSSqlPersistenceManager extends SimpleDbPersistenceManager {
+
+ /** the variable for the MSSql table space */
+ public static final String TABLE_SPACE_VARIABLE = "${tableSpace}";
+
+ /** the MSSql table space to use */
+ protected String tableSpace;
+
+ /**
+ * Creates a new MSSqlPersistenceManager instance.
+ */
+ public MSSqlPersistenceManager() {
+ // preset some attributes to reasonable defaults
+ schema = "mssql";
+ driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
+ schemaObjectPrefix = "";
+ user = "";
+ password = "";
+ initialized = false;
+ tableSpace = "";
+ }
+
+ /**
+ * Returns the configured MSSql table space.
+ * @return the configured MSSql table space.
+ */
+ public String getTableSpace() {
+ return tableSpace;
+ }
+
+ /**
+ * Sets the MSSql table space.
+ * @param tableSpace the MSSql table space.
+ */
+ public void setTableSpace(String tableSpace) {
+ if (tableSpace != null && tableSpace.length() > 0) {
+ this.tableSpace = "on " + tableSpace.trim();
+ } else {
+ this.tableSpace = "";
+ }
+ }
+
+ protected String createSchemaSql(String sql) {
+ return Text.replace(
+ super.createSchemaSql(sql), TABLE_SPACE_VARIABLE, tableSpace);
+ }
+}
\ No newline at end of file
Index: src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java (revision 725364)
+++ src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java (working copy)
@@ -1021,7 +1021,7 @@
// Skip comments and empty lines
if (!sql.startsWith("#") && sql.length() > 0) {
// replace prefix variable
- sql = Text.replace(sql, SCHEMA_OBJECT_PREFIX_VARIABLE, schemaObjectPrefix);
+ sql = createSchemaSql(sql);
// execute sql stmt
stmt.executeUpdate(sql);
}
@@ -1038,6 +1038,17 @@
}
/**
+ * Replace wildcards and return the expanded SQL statement.
+ *
+ * @param sql The SQL with embedded wildcards.
+ * @return The SQL with no wildcards present.
+ */
+ protected String createSchemaSql(String sql) {
+ // replace prefix variable
+ return Text.replace(sql, SCHEMA_OBJECT_PREFIX_VARIABLE, schemaObjectPrefix);
+ }
+
+ /**
* Returns an input stream to the schema DDL resource.
* @return an input stream to the schema DDL resource.
*/
Index: src/main/java/org/apache/jackrabbit/core/fs/db/MSSqlFileSystem.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/fs/db/MSSqlFileSystem.java (revision 0)
+++ src/main/java/org/apache/jackrabbit/core/fs/db/MSSqlFileSystem.java (revision 0)
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.
+ */
+package org.apache.jackrabbit.core.fs.db;
+
+import org.apache.jackrabbit.util.Text;
+
+/**
+ * MSSqlFileSystem is a JDBC-based FileSystem
+ * implementation for Jackrabbit that persists file system entries in an
+ * MS SQL database.
+ *
+ * It is configured through the following properties:
+ * driver: the FQN name of the JDBC driver class
+ * (default: "com.microsoft.sqlserver.jdbc.SQLServerDriver")schema: type of schema to be used
+ * (default: "mssql")url: the database url (e.g.
+ * "jdbc:sqlserver://[host]:[port];<params>")user: the database userpassword: the user's passwordschemaObjectPrefix: prefix to be prepended to schema objectstableSpace: the tablespace to use+ * <FileSystem class="org.apache.jackrabbit.core.fs.db.MSSqlFileSystem"> + * <param name="url" value="jdbc:sqlserver://localhost:1433"/> + * <param name="user" value="padv25"/> + * <param name="password" value="padv25"/> + * <param name="schemaObjectPrefix" value="rep_"/> + * <param name="tableSpace" value="default"/> + * </FileSystem> + *+ */ +public class MSSqlFileSystem extends DbFileSystem { + + /** the variable for the MS SQL table space */ + public static final String TABLE_SPACE_VARIABLE = "${tableSpace}"; + + /** the MS SQL table space to use */ + protected String tableSpace; + + /** + * Returns the configured MS SQL table space. + * @return the configured MS SQL table space. + */ + public String getTableSpace() { + return tableSpace; + } + + /** + * Sets the MS SQL table space. + * @param tableSpace the MS SQL table space. + */ + public void setTableSpace(String tableSpace) { + if (tableSpace != null && tableSpace.length() > 0) { + this.tableSpace = "on " + tableSpace.trim(); + } else { + this.tableSpace = ""; + } + } + + /** + * Creates a new
MSSqlFileSystem instance.
+ */
+ public MSSqlFileSystem() {
+ // preset some attributes to reasonable defaults
+ schema = "mssql";
+ driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
+ schemaObjectPrefix = "";
+ user = "";
+ password = "";
+ tableSpace = null;
+ initialized = false;
+ }
+
+ protected String createSchemaSql(String sql) {
+ return Text.replace(
+ super.createSchemaSql(sql), TABLE_SPACE_VARIABLE, tableSpace);
+ }
+}
\ No newline at end of file
Index: src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java (revision 725364)
+++ src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java (working copy)
@@ -1175,8 +1175,7 @@
// Skip comments and empty lines
if (!sql.startsWith("#") && sql.length() > 0) {
// replace prefix variable
- sql = Text.replace(sql, SCHEMA_OBJECT_PREFIX_VARIABLE, schemaObjectPrefix);
- // execute sql stmt
+ sql = createSchemaSql(sql);
stmt.executeUpdate(sql);
}
// read next sql stmt
@@ -1190,6 +1189,14 @@
}
/**
+ * Replace wildcards.
+ */
+ protected String createSchemaSql(String sql) {
+ sql = Text.replace(sql, SCHEMA_OBJECT_PREFIX_VARIABLE, schemaObjectPrefix);
+ return sql;
+ }
+
+ /**
* Builds the SQL statements
*/
protected void buildSQLStatements() {
Index: src/main/resources/org/apache/jackrabbit/core/persistence/db/mssql.ddl
===================================================================
--- src/main/resources/org/apache/jackrabbit/core/persistence/db/mssql.ddl (revision 725364)
+++ src/main/resources/org/apache/jackrabbit/core/persistence/db/mssql.ddl (working copy)
@@ -12,11 +12,11 @@
# 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}NODE (NODE_ID char(36) not null, NODE_DATA image not null)
-create unique index ${schemaObjectPrefix}NODE_IDX on ${schemaObjectPrefix}NODE (NODE_ID)
-create table ${schemaObjectPrefix}PROP (PROP_ID varchar(1024) not null, PROP_DATA image not null)
-create unique index ${schemaObjectPrefix}PROP_IDX on ${schemaObjectPrefix}PROP (PROP_ID)
-create table ${schemaObjectPrefix}REFS (NODE_ID char(36) not null, REFS_DATA image not null)
-create unique index ${schemaObjectPrefix}REFS_IDX on ${schemaObjectPrefix}REFS (NODE_ID)
-create table ${schemaObjectPrefix}BINVAL (BINVAL_ID varchar(1024) not null, BINVAL_DATA image not null)
-create unique index ${schemaObjectPrefix}BINVAL_IDX on ${schemaObjectPrefix}BINVAL (BINVAL_ID)
+create table ${schemaObjectPrefix}NODE (NODE_ID char(36) not null, NODE_DATA image not null) ${tableSpace}
+create unique index ${schemaObjectPrefix}NODE_IDX on ${schemaObjectPrefix}NODE (NODE_ID) ${tableSpace}
+create table ${schemaObjectPrefix}PROP (PROP_ID varchar(1024) not null, PROP_DATA image not null) ${tableSpace}
+create unique index ${schemaObjectPrefix}PROP_IDX on ${schemaObjectPrefix}PROP (PROP_ID) ${tableSpace}
+create table ${schemaObjectPrefix}REFS (NODE_ID char(36) not null, REFS_DATA image not null) ${tableSpace}
+create unique index ${schemaObjectPrefix}REFS_IDX on ${schemaObjectPrefix}REFS (NODE_ID) ${tableSpace}
+create table ${schemaObjectPrefix}BINVAL (BINVAL_ID varchar(1024) not null, BINVAL_DATA image not null) ${tableSpace}
+create unique index ${schemaObjectPrefix}BINVAL_IDX on ${schemaObjectPrefix}BINVAL (BINVAL_ID) ${tableSpace}
Index: src/main/resources/org/apache/jackrabbit/core/fs/db/mssql.ddl
===================================================================
--- src/main/resources/org/apache/jackrabbit/core/fs/db/mssql.ddl (revision 725364)
+++ src/main/resources/org/apache/jackrabbit/core/fs/db/mssql.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 varchar(2048) not null, FSENTRY_NAME varchar(255) not null, FSENTRY_DATA image null, FSENTRY_LASTMOD bigint not null, FSENTRY_LENGTH bigint not null)
-create unique index ${schemaObjectPrefix}FSENTRY_IDX on ${schemaObjectPrefix}FSENTRY (FSENTRY_PATH, FSENTRY_NAME)
+create table ${schemaObjectPrefix}FSENTRY (FSENTRY_PATH varchar(2048) not null, FSENTRY_NAME varchar(255) not null, FSENTRY_DATA image null, FSENTRY_LASTMOD bigint not null, FSENTRY_LENGTH bigint not null) ${tableSpace}
+create unique index ${schemaObjectPrefix}FSENTRY_IDX on ${schemaObjectPrefix}FSENTRY (FSENTRY_PATH, FSENTRY_NAME) ${tableSpace}