jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r523680 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle: BundleDbPersistenceManager.java OraclePersistenceManager.java
Date Thu, 29 Mar 2007 12:03:46 GMT
Author: tripod
Date: Thu Mar 29 05:03:43 2007
New Revision: 523680

URL: http://svn.apache.org/viewvc?view=rev&rev=523680
Log:
JCR-814 Oracle bundle PM fails checking schema if 2 users use the same database

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/OraclePersistenceManager.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java?view=diff&rev=523680&r1=523679&r2=523680
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
Thu Mar 29 05:03:43 2007
@@ -406,23 +406,7 @@
      * @throws RepositoryException if an error occurs.
      */
     protected void checkSchema() throws SQLException, RepositoryException {
-        DatabaseMetaData metaData = con.getMetaData();
-        String tableName = schemaObjectPrefix + "BUNDLE";
-        if (metaData.storesLowerCaseIdentifiers()) {
-            tableName = tableName.toLowerCase();
-        } else if (metaData.storesUpperCaseIdentifiers()) {
-            tableName = tableName.toUpperCase();
-        }
-        String userName = metaData.getUserName();
-        ResultSet rs = metaData.getTables(null, userName, tableName, null);
-        boolean schemaExists;
-        try {
-            schemaExists = rs.next();
-        } finally {
-            rs.close();
-        }
-
-        if (!schemaExists) {
+        if (!checkTablesExist()) {
             // read ddl from resources
             InputStream in = getClass().getResourceAsStream(schema + ".ddl");
             if (in == null) {
@@ -460,6 +444,44 @@
                 stmt.close();
             }
         }
+    }
+
+    /**
+     * Checks if the database table exist.
+     *
+     * @return <code>true</code> if the tables exist;
+     *         <code>false</code> otherwise.
+     *
+     * @throws SQLException if an SQL erro occurs.
+     */
+    protected boolean checkTablesExist() throws SQLException {
+        DatabaseMetaData metaData = con.getMetaData();
+        String tableName = schemaObjectPrefix + "BUNDLE";
+        if (metaData.storesLowerCaseIdentifiers()) {
+            tableName = tableName.toLowerCase();
+        } else if (metaData.storesUpperCaseIdentifiers()) {
+            tableName = tableName.toUpperCase();
+        }
+        String userName = checkTablesWithUser() ? metaData.getUserName() : null;
+        ResultSet rs = metaData.getTables(null, userName, tableName, null);
+        try {
+            return rs.next();
+        } finally {
+            rs.close();
+        }
+    }
+
+    /**
+     * Indicates if the username should be included when retrieving the tables
+     * during {@link #checkTablesExist()}.
+     * <p/>
+     * Please note that this currently only needs to be changed for oracle based
+     * persistence managers.
+     *
+     * @return <code>false</code>
+     */
+    protected boolean checkTablesWithUser() {
+        return false;
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/OraclePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/OraclePersistenceManager.java?view=diff&rev=523680&r1=523679&r2=523680
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/OraclePersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/OraclePersistenceManager.java
Thu Mar 29 05:03:43 2007
@@ -96,7 +96,16 @@
     protected DbNameIndex createDbNameIndex() throws SQLException {
         return new NGKDbNameIndex(con, schemaObjectPrefix);
     }
-    
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return <code>true</code>
+     */
+    protected boolean checkTablesWithUser() {
+        return true;
+    }
+
     /**
      * Since Oracle only supports table names up to 30 characters in
      * length illegal characters are simply replaced with "_" rather than



Mime
View raw message