jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1532339 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/VersionManagementTest.java
Date Tue, 15 Oct 2013 13:57:15 GMT
Author: angela
Date: Tue Oct 15 13:57:15 2013
New Revision: 1532339

URL: http://svn.apache.org/r1532339
Log:
OAK-1097 : VersionablePathHook ignores "modified" version histories

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/VersionManagementTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java?rev=1532339&r1=1532338&r2=1532339&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java
Tue Oct 15 13:57:15 2013
@@ -18,11 +18,9 @@ package org.apache.jackrabbit.oak.plugin
 
 import java.util.ArrayList;
 import java.util.List;
-
-import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
-
 import javax.annotation.Nonnull;
 
+import com.google.common.collect.ImmutableSet;
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
@@ -36,7 +34,7 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
-import com.google.common.collect.ImmutableSet;
+import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
 
 /**
  * Commit hook which is responsible for storing the path of the versionable
@@ -83,8 +81,29 @@ public class VersionablePathHook impleme
 
         @Override
         public boolean propertyAdded(PropertyState after) {
-            if (VersionConstants.JCR_VERSIONHISTORY.equals(after.getName())
-                    && nodeAfter.isVersionable(versionManager)) {
+            return setVersionablePath(after);
+        }
+
+        @Override
+        public boolean propertyChanged(PropertyState before, PropertyState after) {
+            return setVersionablePath(after);
+        }
+
+        @Override
+        public boolean childNodeAdded(String name, NodeState after) {
+            return childNodeChanged(name, EMPTY_NODE, after);
+        }
+
+        @Override
+        public boolean childNodeChanged(
+                String name, NodeState before, NodeState after) {
+            Node node = new Node(nodeAfter, name);
+            return after.compareAgainstBaseState(
+                    before, new Diff(versionManager, node, exceptions));
+        }
+
+        private boolean setVersionablePath(PropertyState after) {
+            if (JcrConstants.JCR_VERSIONHISTORY.equals(after.getName()) && nodeAfter.isVersionable(versionManager))
{
                 NodeBuilder vhBuilder;
                 try {
                     vhBuilder = versionManager.getOrCreateVersionHistory(nodeAfter.builder);
@@ -106,19 +125,6 @@ public class VersionablePathHook impleme
             }
             return true;
         }
-
-        @Override
-        public boolean childNodeAdded(String name, NodeState after) {
-            return childNodeChanged(name, EMPTY_NODE, after);
-        }
-
-        @Override
-        public boolean childNodeChanged(
-                String name, NodeState before, NodeState after) {
-            Node node = new Node(nodeAfter, name);
-            return after.compareAgainstBaseState(
-                    before, new Diff(versionManager, node, exceptions));
-        }
     }
 
     private static final class Node {

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/VersionManagementTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/VersionManagementTest.java?rev=1532339&r1=1532338&r2=1532339&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/VersionManagementTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/VersionManagementTest.java
Tue Oct 15 13:57:15 2013
@@ -351,6 +351,10 @@ public class VersionManagementTest exten
         history.addVersionLabel(v.getName(), "testLabel", true);
     }
 
+    /**
+     * @since oak
+     */
+    @Test
     public void testVersionablePath() throws Exception {
         Node n = createVersionableNode(superuser.getNode(path));
 
@@ -358,4 +362,53 @@ public class VersionManagementTest exten
         Property versionablePath = vh.getProperty(superuser.getWorkspace().getName());
         assertEquals(n.getPath(), versionablePath.getString());
     }
+
+    @Test
+    public void testAddNewVersionableNode() throws Exception {
+        modify(path, REP_WRITE, true);
+        modify(path, Privilege.JCR_VERSION_MANAGEMENT, true);
+
+        Node testNode = testSession.getNode(path);
+        Node newNode = testNode.addNode("versionable");
+        newNode.addMixin("mix:versionable");
+        testSession.save();
+    }
+
+    /**
+     * @since oak
+     */
+    @Test
+    public void testVersionableChildNode() throws Exception {
+        Node testNode = superuser.getNode(path).addNode("n1").addNode("n2").addNode("n3").addNode("jcr:content");
+        superuser.save();
+
+        testNode.addMixin("mix:versionable");
+        superuser.save();
+
+        assertTrue(testNode.isNodeType("mix:versionable"));
+        VersionHistory vh = testNode.getVersionHistory();
+        Property versionablePath = vh.getProperty(superuser.getWorkspace().getName());
+        assertEquals(testNode.getPath(), versionablePath.getString());
+    }
+
+    /**
+     * @since oak
+     */
+    @Test
+    public void testVersionableChildNode2() throws Exception {
+        Node testNode = superuser.getNode(path).addNode("n1").addNode("n2").addNode("n3").addNode("jcr:content");
+        testNode.addMixin("mix:versionable");
+        superuser.save();
+
+
+        testNode.remove();
+        testNode = superuser.getNode(path).getNode("n1").getNode("n2").getNode("n3").addNode("jcr:content");
+        testNode.addMixin("mix:versionable");
+        superuser.save();
+
+        assertTrue(testNode.isNodeType("mix:versionable"));
+        VersionHistory vh = testNode.getVersionHistory();
+        Property versionablePath = vh.getProperty(superuser.getWorkspace().getName());
+        assertEquals(testNode.getPath(), versionablePath.getString());
+    }
 }
\ No newline at end of file



Mime
View raw message