jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r638430 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/version/ test/java/org/apache/jackrabbit/core/version/
Date Tue, 18 Mar 2008 16:17:13 GMT
Author: mreutegg
Date: Tue Mar 18 09:17:07 2008
New Revision: 638430

URL: http://svn.apache.org/viewvc?rev=638430&view=rev
Log:
JCR-1481: VersionHistory.removeVersion() does not throw ReferentialIntegrityException

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/CheckinRemoveVersionTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/TestAll.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java?rev=638430&r1=638429&r2=638430&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
Tue Mar 18 09:17:07 2008
@@ -32,8 +32,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.List;
-
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Value;
@@ -287,16 +285,20 @@
     protected abstract boolean hasItem(NodeId id);
 
     /**
-     * Returns the item references that reference the given version item.
-     * Subclass responsiblity.
+     * Checks if there are item references (from outside the version storage)
+     * that reference the given version item. Subclass responsiblity.
      * <p/>
      * Please note, that the overridden method must aquire the readlock before
      * reading the state manager.
      *
      * @param item version item
-     * @return list of item references, may be empty.
+     * @return <code>true</code> if there are item references from outside the
+     *         version storage; <code>false</code> otherwise.
+     * @throws RepositoryException if an error occurs while reading from the
+     *                             repository.
      */
-    protected abstract List getItemReferences(InternalVersionItem item);
+    protected abstract boolean hasItemReferences(InternalVersionItem item)
+            throws RepositoryException;
 
     /**
      * Creates a new Version History.

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java?rev=638430&r1=638429&r2=638430&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
Tue Mar 18 09:17:07 2008
@@ -37,7 +37,6 @@
 import java.util.Calendar;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Set;
 
 /**
@@ -361,8 +360,7 @@
             throw new VersionException(msg);
         }
         // check if any references (from outside the version storage) exist on this version
-        List refs = vMgr.getItemReferences(v);
-        if (!refs.isEmpty()) {
+        if (vMgr.hasItemReferences(v)) {
             throw new ReferentialIntegrityException("Unable to remove version. At least once
referenced.");
         }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java?rev=638430&r1=638429&r2=638430&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Tue Mar 18 09:17:07 2008
@@ -41,6 +41,7 @@
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.state.SharedItemStateManager;
 import org.apache.jackrabbit.core.state.ISMLocking;
+import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
 import org.apache.jackrabbit.spi.Path;
@@ -52,7 +53,6 @@
 import org.slf4j.LoggerFactory;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
@@ -398,13 +398,16 @@
     /**
      * {@inheritDoc}
      */
-    protected List getItemReferences(InternalVersionItem item) {
+    protected boolean hasItemReferences(InternalVersionItem item)
+            throws RepositoryException {
         try {
             NodeReferences refs = stateMgr.getNodeReferences(
                     new NodeReferencesId(item.getId()));
-            return refs.getReferences();
+            return refs.hasReferences();
+        } catch (NoSuchItemStateException e) {
+            return false;
         } catch (ItemStateException e) {
-            return Collections.EMPTY_LIST;
+            throw new RepositoryException(e);
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java?rev=638430&r1=638429&r2=638430&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
Tue Mar 18 09:17:07 2008
@@ -48,7 +48,6 @@
 import javax.jcr.version.VersionException;
 import javax.jcr.version.VersionHistory;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -343,8 +342,9 @@
     /**
      * {@inheritDoc}
      */
-    protected List getItemReferences(InternalVersionItem item) {
-        return vMgr.getItemReferences(item);
+    protected boolean hasItemReferences(InternalVersionItem item)
+            throws RepositoryException {
+        return session.getNodeById(item.getId()).getReferences().hasNext();
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/CheckinRemoveVersionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/CheckinRemoveVersionTest.java?rev=638430&r1=638429&r2=638430&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/CheckinRemoveVersionTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/CheckinRemoveVersionTest.java
Tue Mar 18 09:17:07 2008
@@ -36,6 +36,7 @@
         tx.begin();
         try {
             Version v10 = n.checkin();
+            assertTrue("Version.getReferences() must return base version", v10.getReferences().hasNext());
             try {
                 n.getVersionHistory().removeVersion(v10.getName());
                 fail("VersionHistory.removeVersion() must throw ReferentialIntegrityException
when" +

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/TestAll.java?rev=638430&r1=638429&r2=638430&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/TestAll.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/TestAll.java
Tue Mar 18 09:17:07 2008
@@ -32,8 +32,7 @@
      */
     public static Test suite() {
         TestSuite suite = new TestSuite("Version tests");
-        // disabled because JCR-1481 is not yet fixed
-        //suite.addTestSuite(CheckinRemoveVersionTest.class);
+        suite.addTestSuite(CheckinRemoveVersionTest.class);
         suite.addTestSuite(RemoveVersionLabelTest.class);
         suite.addTestSuite(RestoreTest.class);
         suite.addTestSuite(VersionIteratorImplTest.class);



Mime
View raw message