jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r656240 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/state/ test/java/org/apache/jackrabbit/core/version/
Date Wed, 14 May 2008 11:39:35 GMT
Author: mreutegg
Date: Wed May 14 04:39:34 2008
New Revision: 656240

URL: http://svn.apache.org/viewvc?rev=656240&view=rev
Log:
JCR-1587: When trying to reuse version label in transaction, exception is thrown

Added:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RemoveAndAddVersionLabelXATest.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java?rev=656240&r1=656239&r2=656240&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
Wed May 14 04:39:34 2008
@@ -126,6 +126,16 @@
         return state;
     }
 
+    /**
+     * Returns the change log that contains the current changes in this local
+     * item state manager.
+     *
+     * @return the change log with the current changes.
+     */
+    protected ChangeLog getChanges() {
+        return changeLog;
+    }
+
     //-----------------------------------------------------< ItemStateManager >
     /**
      * {@inheritDoc}

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java?rev=656240&r1=656239&r2=656240&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
Wed May 14 04:39:34 2008
@@ -203,6 +203,13 @@
         return changeLog;
     }
 
+    /**
+     * @throws UnsupportedOperationException always.
+     */
+    protected ChangeLog getChanges() {
+        throw new UnsupportedOperationException("getChanges");
+    }
+
     //-----------------------------------------------------< ItemStateManager >
     /**
      * {@inheritDoc}
@@ -218,13 +225,21 @@
         if (virtualProvider != null && virtualProvider.hasItemState(id)) {
             return virtualProvider.getItemState(id);
         }
-        ChangeLog changeLog = getChangeLog();
+        // 1) check local changes
+        ChangeLog changeLog = super.getChanges();
+        ItemState state = changeLog.get(id);
+        if (state != null) {
+            return state;
+        }
+        // 2) check tx log
+        changeLog = getChangeLog();
         if (changeLog != null) {
-            ItemState state = changeLog.get(id);
+            state = changeLog.get(id);
             if (state != null) {
                 return state;
             }
         }
+        // 3) fallback to base class
         return super.getItemState(id);
     }
 
@@ -240,7 +255,21 @@
         if (virtualProvider != null && virtualProvider.hasItemState(id)) {
             return true;
         }
-        ChangeLog changeLog = getChangeLog();
+        // 1) check local changes
+        ChangeLog changeLog = super.getChanges();
+        try {
+            ItemState state = changeLog.get(id);
+            if (state != null) {
+                return true;
+            }
+        } catch (NoSuchItemStateException e) {
+            // marked removed in local ism
+            return false;
+        }
+        // if we get here, then there is no item state with
+        // the given id known to the local ism
+        // 2) check tx log
+        changeLog = getChangeLog();
         if (changeLog != null) {
             try {
                 ItemState state = changeLog.get(id);
@@ -248,10 +277,12 @@
                     return true;
                 }
             } catch (NoSuchItemStateException e) {
+                // marked removed in tx log
                 return false;
             }
         }
-        return super.hasItemState(id);
+        // 3) fallback to shared ism
+        return sharedStateMgr.hasItemState(id);
     }
 
     /**

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RemoveAndAddVersionLabelXATest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RemoveAndAddVersionLabelXATest.java?rev=656240&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RemoveAndAddVersionLabelXATest.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RemoveAndAddVersionLabelXATest.java
Wed May 14 04:39:34 2008
@@ -0,0 +1,52 @@
+/*
+ * 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.version;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.core.UserTransactionImpl;
+
+import javax.jcr.Node;
+import javax.transaction.UserTransaction;
+
+/**
+ * <code>RemoveAndAddVersionLabelXATest</code> implements a test case for
+ * JCR-1587.
+ */
+public class RemoveAndAddVersionLabelXATest extends AbstractJCRTest {
+
+    public void testVersionLabel() throws Exception {
+        UserTransaction tx = new UserTransactionImpl(superuser);
+        tx.begin();
+        Node n = testRootNode.addNode(nodeName1);
+        n.addMixin(mixVersionable);
+        testRootNode.save();
+        String v1 = n.checkin().getName();
+        n.checkout();
+        String v2 = n.checkin().getName();
+        n.getVersionHistory().addVersionLabel(v2, "label", false);
+        tx.commit();
+
+        tx = new UserTransactionImpl(superuser);
+        tx.begin();
+        n.restore(v1, false);
+        n.getVersionHistory().removeVersion(v2);
+        n.checkout();
+        v2 = n.checkin().getName();
+        n.getVersionHistory().addVersionLabel(v2, "label", false);
+        tx.commit();
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RemoveAndAddVersionLabelXATest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message