jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r267183 - in /incubator/jackrabbit/trunk/core/src: java/org/apache/jackrabbit/core/version/ test/org/apache/jackrabbit/test/api/version/
Date Fri, 02 Sep 2005 10:37:50 GMT
Author: tripod
Date: Fri Sep  2 03:37:27 2005
New Revision: 267183

URL: http://svn.apache.org/viewcvs?rev=267183&view=rev
Log:
[JCR-205] Version.merge() corrupts repository

Modified:
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/VersionImpl.java
    incubator/jackrabbit/trunk/core/src/test/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java
    incubator/jackrabbit/trunk/core/src/test/org/apache/jackrabbit/test/api/version/VersionTest.java

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java?rev=267183&r1=267182&r2=267183&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java
Fri Sep  2 03:37:27 2005
@@ -19,18 +19,21 @@
 import org.apache.jackrabbit.core.ItemLifeCycleListener;
 import org.apache.jackrabbit.core.ItemManager;
 import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.name.IllegalNameException;
 import org.apache.jackrabbit.name.NoPrefixDeclaredException;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.UnknownPrefixException;
+import org.apache.log4j.Logger;
 
 import javax.jcr.Item;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.NodeIterator;
 import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionException;
 import javax.jcr.version.VersionHistory;
@@ -42,6 +45,11 @@
 public class VersionHistoryImpl extends NodeImpl implements VersionHistory {
 
     /**
+     * the default logger.
+     */
+    private static Logger log = Logger.getLogger(VersionHistoryImpl.class);
+
+    /**
      * the internal version history
      */
     private final InternalVersionHistory history;
@@ -283,5 +291,33 @@
      */
     public InternalVersionHistory getInternalVersionHistory() {
         return history;
+    }
+
+    //--------------------------------------< Overwrite "protected" methods >---
+
+
+    /**
+     * Always throws a {@link javax.jcr.nodetype.ConstraintViolationException} since this
node
+     * is protected.
+     *
+     * @throws javax.jcr.nodetype.ConstraintViolationException
+     */
+    public void update(String srcWorkspaceName) throws ConstraintViolationException {
+        String msg = "update operation not allowed on a version history node: " + safeGetJCRPath();
+        log.debug(msg);
+        throw new ConstraintViolationException(msg);
+    }
+
+    /**
+     * Always throws a {@link javax.jcr.nodetype.ConstraintViolationException} since this
node
+     * is protected.
+     *
+     * @throws javax.jcr.nodetype.ConstraintViolationException
+     */
+    public NodeIterator merge(String srcWorkspace, boolean bestEffort)
+            throws ConstraintViolationException {
+        String msg = "merge operation not allowed on a version history node: " + safeGetJCRPath();
+        log.debug(msg);
+        throw new ConstraintViolationException(msg);
     }
 }

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/VersionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/VersionImpl.java?rev=267183&r1=267182&r2=267183&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/VersionImpl.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/VersionImpl.java
Fri Sep  2 03:37:27 2005
@@ -19,14 +19,17 @@
 import org.apache.jackrabbit.core.ItemLifeCycleListener;
 import org.apache.jackrabbit.core.ItemManager;
 import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.state.NodeState;
+import org.apache.log4j.Logger;
 
 import javax.jcr.Item;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.NodeIterator;
 import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
 import java.util.Calendar;
@@ -37,10 +40,14 @@
 public class VersionImpl extends NodeImpl implements Version {
 
     /**
+     * the default logger.
+     */
+    private static Logger log = Logger.getLogger(VersionImpl.class);
+
+    /**
      * the internal version
      */
     protected final InternalVersion version;
-
     /**
      * creates a new version node
      *
@@ -137,4 +144,33 @@
             return false;
         }
     }
+
+    //--------------------------------------< Overwrite "protected" methods >---
+
+
+    /**
+     * Always throws a {@link javax.jcr.nodetype.ConstraintViolationException} since this
node
+     * is protected.
+     *
+     * @throws javax.jcr.nodetype.ConstraintViolationException
+     */
+    public void update(String srcWorkspaceName) throws ConstraintViolationException {
+        String msg = "update operation not allowed on a version node: " + safeGetJCRPath();
+        log.debug(msg);
+        throw new ConstraintViolationException(msg);
+    }
+
+    /**
+     * Always throws a {@link javax.jcr.nodetype.ConstraintViolationException} since this
node
+     * is protected.
+     *
+     * @throws javax.jcr.nodetype.ConstraintViolationException
+     */
+    public NodeIterator merge(String srcWorkspace, boolean bestEffort)
+            throws ConstraintViolationException {
+        String msg = "merge operation not allowed on a version node: " + safeGetJCRPath();
+        log.debug(msg);
+        throw new ConstraintViolationException(msg);
+    }
+
 }

Modified: incubator/jackrabbit/trunk/core/src/test/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/test/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java?rev=267183&r1=267182&r2=267183&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/test/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java
(original)
+++ incubator/jackrabbit/trunk/core/src/test/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java
Fri Sep  2 03:37:27 2005
@@ -29,7 +29,6 @@
 import javax.jcr.PropertyIterator;
 import javax.jcr.Value;
 import javax.jcr.PropertyType;
-import javax.jcr.PathNotFoundException;
 import javax.jcr.lock.LockException;
 import javax.jcr.version.VersionHistory;
 import javax.jcr.version.VersionIterator;
@@ -602,13 +601,20 @@
     }
 
     /**
-     * Tests if <code>VersionHistory.merge(String, boolean)</code> works as
-     * expected (do nothing and return quietly)
+     * Tests if <code>VersionHistory.merge(String)</code> throws an
+     * {@link javax.jcr.nodetype.ConstraintViolationException}
      */
     public void testMerge() throws Exception {
-        // should do nothing and return quietly
-        vHistory.merge(workspaceName, true);
-        vHistory.merge(workspaceName, false);
+        try {
+            vHistory.merge(workspaceName, true);
+            fail("VersionHistory.merge(String, true) did not throw an ConstraintViolationException");
+        } catch (ConstraintViolationException success) {
+        }
+        try {
+            vHistory.merge(workspaceName, false);
+            fail("VersionHistory.merge(String, false) did not throw an ConstraintViolationException");
+        } catch (ConstraintViolationException success) {
+        }
     }
 
     /**
@@ -617,9 +623,10 @@
      */
     public void testOrderBefore() throws Exception {
         try {
-            vHistory.orderBefore(version.getName(), null);
-            fail("VersionHistory.orderBefore(String,String) did not throw an UnsupportedRepositoryOperationException");
+            vHistory.orderBefore(jcrFrozenNode, null);
+            fail("VersionHistory.orderBefore(String,String) did not throw an UnsupportedRepositoryOperationException
or a ConstraintViolationException");
         } catch (UnsupportedRepositoryOperationException success) {
+        } catch (ConstraintViolationException success) {
         }
     }
 
@@ -813,11 +820,15 @@
     }
 
     /**
-     * Tests if <code>VersionHistory.update(String)</code> works as expected
(do
-     * nothing and return quietly)
+     * Tests if <code>VersionHistory.update(String)</code> throws an
+     * {@link javax.jcr.nodetype.ConstraintViolationException}
      */
     public void testUpdate() throws Exception {
-        // should do nothing and return quietly
-        vHistory.update(workspaceName);
+        try {
+            vHistory.update(workspaceName);
+            fail("VersionHistory.update(String) did not throw an ConstraintViolationException");
+        } catch (ConstraintViolationException success) {
+        }
     }
+
 }

Modified: incubator/jackrabbit/trunk/core/src/test/org/apache/jackrabbit/test/api/version/VersionTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/test/org/apache/jackrabbit/test/api/version/VersionTest.java?rev=267183&r1=267182&r2=267183&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/test/org/apache/jackrabbit/test/api/version/VersionTest.java
(original)
+++ incubator/jackrabbit/trunk/core/src/test/org/apache/jackrabbit/test/api/version/VersionTest.java
Fri Sep  2 03:37:27 2005
@@ -478,13 +478,20 @@
     }
 
     /**
-     * Tests if <code>Version.merge(String, boolean)</code> works as expected
-     * (do nothing and return quietly)
+     * Tests if <code>Version.merge(String)</code> throws an
+     * {@link javax.jcr.nodetype.ConstraintViolationException}
      */
     public void testMerge() throws Exception {
-        // should do nothing and return quietly
-        version.merge(workspaceName, true);
-        version.merge(workspaceName, false);
+        try {
+            version.merge(workspaceName, true);
+            fail("Version.merge(String, true) did not throw an ConstraintViolationException");
+        } catch (ConstraintViolationException success) {
+        }
+        try {
+            version.merge(workspaceName, false);
+            fail("Version.merge(String, false) did not throw an ConstraintViolationException");
+        } catch (ConstraintViolationException success) {
+        }
     }
 
     /**
@@ -494,8 +501,9 @@
     public void testOrderBefore() throws Exception {
         try {
             version.orderBefore(jcrFrozenNode, null);
-            fail("Version.orderBefore(String,String) did not throw an UnsupportedRepositoryOperationException");
+            fail("Version.orderBefore(String,String) did not throw an UnsupportedRepositoryOperationException
or a ConstraintViolationException");
         } catch (UnsupportedRepositoryOperationException success) {
+        } catch (ConstraintViolationException success) {
         }
     }
 
@@ -690,11 +698,14 @@
     }
 
     /**
-     * Tests if <code>Version.update(String)</code> works as expected (do
-     * nothing and return quietly)
+     * Tests if <code>VersionHistory.update(String)</code> throws an
+     * {@link javax.jcr.nodetype.ConstraintViolationException}
      */
     public void testUpdate() throws Exception {
-        // should do nothing and return quietly
-        version.update(workspaceName);
+        try {
+            version.update(workspaceName);
+            fail("VersionHistory.update(String) did not throw an ConstraintViolationException");
+        } catch (ConstraintViolationException success) {
+        }
     }
 }



Mime
View raw message