jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r478645 - /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
Date Thu, 23 Nov 2006 19:12:25 GMT
Author: jukka
Date: Thu Nov 23 11:12:24 2006
New Revision: 478645

URL: http://svn.apache.org/viewvc?view=rev&rev=478645
Log:
JCR-546: Guard the entire checkin() method with the write lock

Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java?view=diff&rev=478645&r1=478644&r2=478645
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
Thu Nov 23 11:12:24 2006
@@ -367,9 +367,7 @@
      */
     protected InternalVersion checkin(InternalVersionHistoryImpl history, NodeImpl node)
             throws RepositoryException {
-
-        acquireReadLock();
-        String versionName;
+        WriteOperation operation = startWriteOperation();
         try {
             // 1. search a predecessor, suitable for generating the new name
             Value[] values = node.getProperty(QName.JCR_PREDECESSORS).getValues();
@@ -382,7 +380,7 @@
             }
 
             // 2. generate version name (assume no namespaces in version names)
-            versionName = best.getName().getLocalName();
+            String versionName = best.getName().getLocalName();
             int pos = versionName.lastIndexOf('.');
             if (pos > 0) {
                 versionName = versionName.substring(0, pos + 1)
@@ -396,31 +394,13 @@
                 versionName += ".1";
             }
 
-            stateMgr.edit();
-        } catch (IllegalStateException e) {
-            releaseReadLock();
-            throw new RepositoryException("Unable to start edit operation.");
-        }
-
-        boolean succeeded = false;
-
-        try {
-            acquireWriteLock();
-            releaseReadLock();
-
             InternalVersionImpl v = history.checkin(new QName("", versionName), node);
-            stateMgr.update();
-            succeeded = true;
-
+            operation.save();
             return v;
         } catch (ItemStateException e) {
             throw new RepositoryException(e);
         } finally {
-            if (!succeeded) {
-                // update operation failed, cancel all modifications
-                stateMgr.cancel();
-            }
-            releaseWriteLock();
+            operation.close();
         }
     }
 



Mime
View raw message