jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1479831 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ oak-jcr/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/ oak-jcr/src/te...
Date Tue, 07 May 2013 09:39:13 GMT
Author: mreutegg
Date: Tue May  7 09:39:12 2013
New Revision: 1479831

URL: http://svn.apache.org/r1479831
Log:
OAK-168: Basic JCR VersionManager support
OAK-601: Node#getVersionHistory fails with UnsupportedRepositoryOperationException
OAK-602: VersionManager is never updated
- Resume work on JCR versioning
- Enable tests for OAK-601 and OAK-602 again and remove workarounds in tests
- Take protected status into account in Node.canAddMixin()

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
    jackrabbit/oak/trunk/oak-jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/Descriptors.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionablePathsTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java?rev=1479831&r1=1479830&r2=1479831&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
Tue May  7 09:39:12 2013
@@ -66,6 +66,7 @@ class ReadWriteVersionManager extends Re
 
     private final NodeBuilder versionStorageNode;
     private final NodeBuilder workspaceRoot;
+    private ReadOnlyNodeTypeManager ntMgr;
 
     ReadWriteVersionManager(NodeBuilder versionStorageNode,
                             NodeBuilder workspaceRoot) {
@@ -88,8 +89,11 @@ class ReadWriteVersionManager extends Re
     @Nonnull
     @Override
     protected ReadOnlyNodeTypeManager getNodeTypeManager() {
-        return ReadOnlyNodeTypeManager.getInstance(
-                getWorkspaceRoot(), NamePathMapper.DEFAULT);
+        if (ntMgr == null) {
+            ntMgr = ReadOnlyNodeTypeManager.getInstance(
+                    getWorkspaceRoot(), NamePathMapper.DEFAULT);
+        }
+        return ntMgr;
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1479831&r1=1479830&r2=1479831&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Tue May  7 09:39:12 2013
@@ -237,6 +237,43 @@
       org.apache.jackrabbit.test.api.observation.AddEventListenerTest#testUUID
       org.apache.jackrabbit.test.api.observation.LockingTest#testAddLockToNode
       org.apache.jackrabbit.test.api.observation.LockingTest#testRemoveLockFromNode
+      <!-- Versioning -->
+      org.apache.jackrabbit.test.api.version.VersionTest#testGetUUID
+      org.apache.jackrabbit.test.api.version.VersionTest#testRestore
+      org.apache.jackrabbit.test.api.version.VersionTest#testUnlock
+      org.apache.jackrabbit.test.api.version.VersionTest#testUnlockJcr2
+      org.apache.jackrabbit.test.api.version.VersionTest#testUpdate
+      org.apache.jackrabbit.test.api.version.VersionTest#testGetCorrespondingNodePath
+      org.apache.jackrabbit.test.api.version.VersionTest#testGetLock
+      org.apache.jackrabbit.test.api.version.VersionTest#testGetLockJcr2
+      org.apache.jackrabbit.test.api.version.VersionTest#testLock
+      org.apache.jackrabbit.test.api.version.VersionTest#testLockJcr2
+      org.apache.jackrabbit.test.api.version.VersionTest#testMerge
+      org.apache.jackrabbit.test.api.version.VersionHistoryTest
+      org.apache.jackrabbit.test.api.version.VersionLabelTest
+      org.apache.jackrabbit.test.api.version.CheckinTest
+      org.apache.jackrabbit.test.api.version.CopyTest
+      org.apache.jackrabbit.test.api.version.RestoreTest
+      org.apache.jackrabbit.test.api.version.WorkspaceRestoreTest
+      org.apache.jackrabbit.test.api.version.OnParentVersionAbortTest
+      org.apache.jackrabbit.test.api.version.OnParentVersionComputeTest
+      org.apache.jackrabbit.test.api.version.OnParentVersionCopyTest
+      org.apache.jackrabbit.test.api.version.OnParentVersionIgnoreTest
+      org.apache.jackrabbit.test.api.version.OnParentVersionInitializeTest
+      org.apache.jackrabbit.test.api.version.GetPredecessorsTest
+      org.apache.jackrabbit.test.api.version.GetContainingHistoryTest
+      org.apache.jackrabbit.test.api.version.GetVersionableUUIDTest
+      org.apache.jackrabbit.test.api.version.SessionMoveVersionExceptionTest
+      org.apache.jackrabbit.test.api.version.WorkspaceMoveVersionExceptionTest
+      org.apache.jackrabbit.test.api.version.MergeCancelMergeTest
+      org.apache.jackrabbit.test.api.version.MergeCheckedoutSubNodeTest
+      org.apache.jackrabbit.test.api.version.MergeDoneMergeTest
+      org.apache.jackrabbit.test.api.version.MergeNodeIteratorTest
+      org.apache.jackrabbit.test.api.version.MergeNodeTest
+      org.apache.jackrabbit.test.api.version.MergeShallowTest
+      org.apache.jackrabbit.test.api.version.MergeNonVersionableSubNodeTest
+      org.apache.jackrabbit.test.api.version.MergeSubNodeTest
+
       org.apache.jackrabbit.oak.jcr.security.user.GroupTest#testCyclicGroups2           
                   <!-- OAK-615 -->
       org.apache.jackrabbit.oak.jcr.security.authorization.AccessControlImporterTest#testImportACLRemoveACE
<!-- OAK-414 -->
       org.apache.jackrabbit.oak.jcr.security.authorization.AccessControlImporterTest#testImportACLUnknown
  <!-- OAK-414 -->
@@ -253,9 +290,6 @@
       org.apache.jackrabbit.oak.jcr.security.user.UserImportTest#testImportInvalidImpersonationAbort
       <!-- OAK-414 -->
       org.apache.jackrabbit.oak.jcr.security.user.UserImportTest#testImportGroupMembersFromNodesBestEffort
 <!-- OAK-414 -->
       org.apache.jackrabbit.oak.jcr.security.user.MemberNodeImportTest                  
                   <!-- OAK-414, OAK-482 -->
-      org.apache.jackrabbit.oak.jcr.version.VersionHistoryTest#testGetVersionHistoryFromNode
            <!-- OAK-601 -->
-      org.apache.jackrabbit.oak.jcr.version.VersionHistoryTest#testGetVersionHistory    
                <!-- OAK-602 -->
-      org.apache.jackrabbit.oak.jcr.version.VersionHistoryTest#testGetVersionHistoryAfterMove
           <!-- OAK-602 -->
 
       org.apache.jackrabbit.oak.jcr.security.authorization.AccessControlManagementTest#testRemoveMixin
             <!-- OAK-767 -->
       org.apache.jackrabbit.oak.jcr.security.authorization.WriteTest#testRemoveNodeWithInvisibleNonRemovableChild
  <!-- OAK-51 -->

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/Descriptors.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/Descriptors.java?rev=1479831&r1=1479830&r2=1479831&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/Descriptors.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/Descriptors.java
Tue May  7 09:39:12 2013
@@ -195,7 +195,7 @@ public class Descriptors {
                 trueValue, true, true));
         put(new Descriptor(
                 OPTION_VERSIONING_SUPPORTED,
-                falseValue, true, true));
+                trueValue, true, true));
         put(new Descriptor(
                 OPTION_WORKSPACE_MANAGEMENT_SUPPORTED,
                 trueValue, true, true));

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1479831&r1=1479830&r2=1479831&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Tue May  7 09:39:12 2013
@@ -881,7 +881,10 @@ public class NodeImpl<T extends NodeDele
             @Override
             public Boolean perform() throws RepositoryException {
                 PropertyState prop = PropertyStates.createProperty(JCR_MIXINTYPES, singleton(oakTypeName),
NAMES);
-                return sessionContext.getAccessManager().hasPermissions(dlg.getTree(), prop,
Permissions.NODE_TYPE_MANAGEMENT) && dlg.canAddMixin(oakTypeName);
+                return sessionContext.getAccessManager().hasPermissions(
+                    dlg.getTree(), prop, Permissions.NODE_TYPE_MANAGEMENT)
+                        && !dlg.isProtected()
+                        && dlg.canAddMixin(oakTypeName);
             }
         });
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java?rev=1479831&r1=1479830&r2=1479831&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java
Tue May  7 09:39:12 2013
@@ -203,9 +203,6 @@ public class VersionManagerImpl implemen
 
     @Override
     public void checkout(final String absPath) throws RepositoryException {
-        if (true) {
-            TODO.unimplemented().doNothing();
-        }
         final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
         sessionDelegate.perform(new SessionOperation<Void>() {
             @Override
@@ -226,9 +223,6 @@ public class VersionManagerImpl implemen
 
     @Override
     public Version checkin(final String absPath) throws RepositoryException {
-        if (true) {
-            return TODO.dummyImplementation().returnValue(getBaseVersion(absPath));
-        }
         final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
         return sessionDelegate.perform(new SessionOperation<Version>() {
             @Override

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryTest.java?rev=1479831&r1=1479830&r2=1479831&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryTest.java
Tue May  7 09:39:12 2013
@@ -23,11 +23,9 @@ import javax.jcr.version.VersionManager;
 
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.test.AbstractJCRTest;
-import org.junit.Ignore;
-import org.junit.Test;
 
 /**
- * VersionHistoryTest... TODO
+ * Contains {@link VersionHistory} related tests.
  */
 public class VersionHistoryTest extends AbstractJCRTest {
 
@@ -40,55 +38,56 @@ public class VersionHistoryTest extends 
         versionManager = superuser.getWorkspace().getVersionManager();
     }
 
-    @Test
     public void testJcrVersionHistoryProperty() throws Exception {
-        testRootNode.addMixin(JcrConstants.MIX_VERSIONABLE);
+        Node n = testRootNode.addNode(nodeName1, testNodeType);
+        n.addMixin(JcrConstants.MIX_VERSIONABLE);
         superuser.save();
 
-        assertTrue(testRootNode.hasProperty(JcrConstants.JCR_VERSIONHISTORY));
+        assertTrue(n.hasProperty(JcrConstants.JCR_VERSIONHISTORY));
     }
 
-    @Ignore("OAK-601")
-    @Test
     public void testGetVersionHistoryFromNode() throws Exception {
-        testRootNode.addMixin(JcrConstants.MIX_VERSIONABLE);
+        Node n = testRootNode.addNode(nodeName1, testNodeType);
+        n.addMixin(JcrConstants.MIX_VERSIONABLE);
         superuser.save();
 
-        VersionHistory vh = testRootNode.getVersionHistory();
+        VersionHistory vh = n.getVersionHistory();
+        assertNotNull(vh);
     }
 
-    @Ignore("OAK-602")
-    @Test
     public void testGetVersionHistory() throws Exception {
-        testRootNode.addMixin(JcrConstants.MIX_VERSIONABLE);
+        Node n = testRootNode.addNode(nodeName1, testNodeType);
+        n.addMixin(JcrConstants.MIX_VERSIONABLE);
         superuser.save();
 
-        VersionHistory vh = versionManager.getVersionHistory(testRoot);
+        VersionHistory vh = versionManager.getVersionHistory(n.getPath());
+        assertNotNull(vh);
     }
 
-    @Test
     public void testGetVersionHistory2() throws Exception {
-        testRootNode.addMixin(JcrConstants.MIX_VERSIONABLE);
+        Node n = testRootNode.addNode(nodeName1, testNodeType);
+        n.addMixin(JcrConstants.MIX_VERSIONABLE);
         superuser.save();
 
         Session s = getHelper().getSuperuserSession();
         try {
-            VersionHistory vh = s.getWorkspace().getVersionManager().getVersionHistory(testRoot);
+            VersionHistory vh = s.getWorkspace().getVersionManager().getVersionHistory(n.getPath());
+            assertNotNull(vh);
         } finally {
             s.logout();
         }
     }
 
-    @Test
     public void testGetVersionHistoryNodeByUUID() throws Exception {
-        testRootNode.addMixin(JcrConstants.MIX_VERSIONABLE);
+        Node n = testRootNode.addNode(nodeName1, testNodeType);
+        n.addMixin(JcrConstants.MIX_VERSIONABLE);
         superuser.save();
 
-        Node vh = superuser.getNodeByUUID(testRootNode.getProperty(JcrConstants.JCR_VERSIONHISTORY).getString());
+        Node vh = superuser.getNodeByUUID(n.getProperty(
+                JcrConstants.JCR_VERSIONHISTORY).getString());
+        assertNotNull(vh);
     }
 
-    @Ignore("OAK-602")
-    @Test
     public void testGetVersionHistoryAfterMove() throws Exception {
         Node node1 = testRootNode.addNode(nodeName1);
         node1.addMixin(JcrConstants.MIX_VERSIONABLE);

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionablePathsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionablePathsTest.java?rev=1479831&r1=1479830&r2=1479831&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionablePathsTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionablePathsTest.java
Tue May  7 09:39:12 2013
@@ -18,37 +18,20 @@ package org.apache.jackrabbit.oak.jcr.ve
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
-import javax.jcr.Session;
 import javax.jcr.version.VersionManager;
 
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.test.AbstractJCRTest;
-import org.junit.Test;
 
 /**
  * VersionablePathsTest... TODO
- * <p/>
- * FIXME: versionablePath only adjusted AFTER move/rename has been persisted.
  */
 public class VersionablePathsTest extends AbstractJCRTest {
 
-    // FIXME: shouldn't be needed (OAK-602)
-    private Session tmpSession;
-
-    @Override
-    protected void tearDown() throws Exception {
-        if (tmpSession != null) {
-            tmpSession.logout();
-        }
-        super.tearDown();
-    }
-
     private VersionManager getVersionManager() throws RepositoryException {
-        tmpSession = getHelper().getSuperuserSession();
-        return tmpSession.getWorkspace().getVersionManager();
+        return superuser.getWorkspace().getVersionManager();
     }
 
-    @Test
     public void testVersionablePaths() throws Exception {
         testRootNode.addMixin(JcrConstants.MIX_VERSIONABLE);
         superuser.save();
@@ -61,7 +44,6 @@ public class VersionablePathsTest extend
         assertEquals(testRootNode.getPath(), vh.getProperty(workspaceName).getString());
     }
 
-    @Test
     public void testVersionablePathsAfterRename() throws Exception {
         Node node1 = testRootNode.addNode(nodeName1);
         node1.addMixin(JcrConstants.MIX_VERSIONABLE);
@@ -71,8 +53,6 @@ public class VersionablePathsTest extend
         superuser.move(node1.getPath(), destPath);
         superuser.save();
 
-        // FIXME: test node is stale after move
-        node1 = testRootNode.getNode(nodeName2);
         Node vh = getVersionManager().getVersionHistory(node1.getPath());
         assertTrue(vh.isNodeType("rep:VersionablePaths"));
         String workspaceName = superuser.getWorkspace().getName();
@@ -80,7 +60,6 @@ public class VersionablePathsTest extend
         assertEquals(node1.getPath(), vh.getProperty(workspaceName).getString());
     }
 
-    @Test
     public void testVersionablePathsAfterMove() throws Exception {
         Node node1 = testRootNode.addNode(nodeName1);
         Node node2 = testRootNode.addNode(nodeName2);
@@ -91,8 +70,6 @@ public class VersionablePathsTest extend
         superuser.move(node1.getPath(), destPath);
         superuser.save();
 
-        // FIXME: node1 is stale after move
-        node1 = node2.getNode(nodeName1);
         assertEquals(destPath, node1.getPath());
 
         Node vh = getVersionManager().getVersionHistory(node1.getPath());
@@ -102,7 +79,6 @@ public class VersionablePathsTest extend
         assertEquals(node1.getPath(), vh.getProperty(workspaceName).getString());
     }
 
-    @Test
     public void testVersionablePathsAfterParentMove() throws Exception {
         Node node1 = testRootNode.addNode(nodeName1);
         Node node3 = node1.addNode(nodeName3);
@@ -114,8 +90,6 @@ public class VersionablePathsTest extend
         superuser.move(node1.getPath(), destPath);
         superuser.save();
 
-        // FIXME: node3 is stale after move
-        node3 = node2.getNode(nodeName1 + '/' + nodeName3);
         assertEquals(destPath + '/' + nodeName3, node3.getPath());
 
         Node vh = getVersionManager().getVersionHistory(node3.getPath());



Mime
View raw message