jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r792175 - in /jackrabbit/trunk/jackrabbit-core/src/main: java/org/apache/jackrabbit/core/fs/db/ java/org/apache/jackrabbit/core/persistence/db/ resources/org/apache/jackrabbit/core/fs/db/ resources/org/apache/jackrabbit/core/persistence/db/
Date Wed, 08 Jul 2009 15:04:25 GMT
Author: jukka
Date: Wed Jul  8 15:04:25 2009
New Revision: 792175

URL: http://svn.apache.org/viewvc?rev=792175&view=rev
Log:
JCR-1924: ms-sql tablespace support for FileSystem and PersistenceManager

Patch contributed by Brian Whipple.

Added:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/MSSqlFileSystem.java
  (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/MSSqlPersistenceManager.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/fs/db/mssql.ddl
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/db/mssql.ddl

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java?rev=792175&r1=792174&r2=792175&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
Wed Jul  8 15:04:25 2009
@@ -1178,8 +1178,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
@@ -1193,6 +1192,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() {

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/MSSqlFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/MSSqlFileSystem.java?rev=792175&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/MSSqlFileSystem.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/MSSqlFileSystem.java
Wed Jul  8 15:04:25 2009
@@ -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;
+
+/**
+ * <code>MSSqlFileSystem</code> is a JDBC-based <code>FileSystem</code>
+ * implementation for Jackrabbit that persists file system entries in an
+ * MS SQL database.
+ * <p/>
+ * It is configured through the following properties:
+ * <ul>
+ * <li><code>driver</code>: the FQN name of the JDBC driver class
+ * (default: <code>"com.microsoft.sqlserver.jdbc.SQLServerDriver"</code>)</li>
+ * <li><code>schema</code>: type of schema to be used
+ * (default: <code>"mssql"</code>)</li>
+ * <li><code>url</code>: the database url (e.g.
+ * <code>"jdbc:sqlserver://[host]:[port];&lt;params&gt;"</code>)</li>
+ * <li><code>user</code>: the database user</li>
+ * <li><code>password</code>: the user's password</li>
+ * <li><code>schemaObjectPrefix</code>: prefix to be prepended to schema
objects</li>
+ * <li><code>tableSpace</code>: the tablespace to use</li>
+ * </ul>
+ * See also {@link DbFileSystem}.
+ * <p/>
+ * The following is a fragment from a sample configuration:
+ * <pre>
+ *   &lt;FileSystem class="org.apache.jackrabbit.core.fs.db.MSSqlFileSystem"&gt;
+ *       &lt;param name="url" value="jdbc:sqlserver://localhost:1433"/&gt;
+ *       &lt;param name="user" value="padv25"/&gt;
+ *       &lt;param name="password" value="padv25"/&gt;
+ *       &lt;param name="schemaObjectPrefix" value="rep_"/&gt;
+ *       &lt;param name="tableSpace" value="default"/&gt;
+ *  &lt;/FileSystem&gt;
+ * </pre>
+ */
+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 <code>MSSqlFileSystem</code> 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

Propchange: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/MSSqlFileSystem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java?rev=792175&r1=792174&r2=792175&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java
Wed Jul  8 15:04:25 2009
@@ -1018,7 +1018,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);
                     }
@@ -1035,6 +1035,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.
      */

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/MSSqlPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/MSSqlPersistenceManager.java?rev=792175&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/MSSqlPersistenceManager.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/MSSqlPersistenceManager.java
Wed Jul  8 15:04:25 2009
@@ -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;
+
+/**
+ * <code>MSSqlPersistenceManager</code> is a JDBC-based
+ * <code>PersistenceManager</code> for Jackrabbit that persists
+ * <code>ItemState</code> and <code>NodeReferences</code> 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).
+ * <p/>
+ * It is configured through the following properties:
+ * <ul>
+ * <li><code>driver</code>: the FQN name of the JDBC driver class
+ * (default: <code>"com.microsoft.sqlserver.jdbc.SQLServerDriver"</code>)</li>
+ * <li><code>schema</code>: type of schema to be used
+ * (default: <code>"mssql"</code>)</li>
+ * <li><code>url</code>: the database url (e.g.
+ * <code>"jdbc:microsoft:sqlserver://[host]:[port];databaseName=[dbname]"</code>)</li>
+ * <li><code>user</code>: the database user</li>
+ * <li><code>password</code>: the user's password</li>
+ * <li><code>schemaObjectPrefix</code>: prefix to be prepended to schema
objects</li>
+ * <li><code>tableSpace</code>: the tablespace to use</li>
+ * <li><code>externalBLOBs</code>: if <code>true</code> (the
default) BINARY
+ * values (BLOBs) are stored in the local file system;
+ * if <code>false</code> BLOBs are stored in the database</li>
+ * </ul>
+ * See also {@link SimpleDbPersistenceManager}.
+ * <p/>
+ * The following is a fragment from a sample configuration:
+ * <pre>
+ *   &lt;PersistenceManager class="org.apache.jackrabbit.core.persistence.db.MSSqlPersistenceManager"&gt;
+ *       &lt;param name="url" value="jdbc:microsoft:sqlserver://localhost:1433;mydb"/&gt;
+ *       &lt;param name="user" value="mydba"/&gt;
+ *       &lt;param name="password" value="mydba"/&gt;
+ *       &lt;param name="schemaObjectPrefix" value="${wsp.name}_"/&gt;
+ *       &lt;param name="tableSpace" value=""/&gt;
+ *       &lt;param name="externalBLOBs" value="false"/&gt;
+ *  &lt;/PersistenceManager&gt;
+ * </pre>
+ */
+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 <code>MSSqlPersistenceManager</code> 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

Propchange: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/MSSqlPersistenceManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/fs/db/mssql.ddl
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/fs/db/mssql.ddl?rev=792175&r1=792174&r2=792175&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/fs/db/mssql.ddl
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/fs/db/mssql.ddl
Wed Jul  8 15:04:25 2009
@@ -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}

Modified: jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/db/mssql.ddl
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/db/mssql.ddl?rev=792175&r1=792174&r2=792175&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/db/mssql.ddl
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/persistence/db/mssql.ddl
Wed Jul  8 15:04:25 2009
@@ -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}



Mime
View raw message