jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1513124 - 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/delegate/
Date Mon, 12 Aug 2013 12:56:47 GMT
Author: mreutegg
Date: Mon Aug 12 12:56:47 2013
New Revision: 1513124

URL: http://svn.apache.org/r1513124
Log:
OAK-168: Basic JCR VersionManager support
- Fix restore to base version and enable more tests

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionConstants.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditor.java
    jackrabbit/oak/trunk/oak-jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/VersionManagerDelegate.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionConstants.java?rev=1513124&r1=1513123&r2=1513124&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionConstants.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionConstants.java
Mon Aug 12 12:56:47 2013
@@ -66,6 +66,11 @@ public interface VersionConstants extend
     String REP_REMOVE_VERSION_LABELS = "rep:removeVersionLabels";
 
     /**
+     * Prefix of the jcr:baseVersion value for a restore.
+     */
+    String RESTORE_PREFIX = "restore-";
+
+    /**
      * Quote from JSR 283 Section "15.12.3 Activity Storage"<p/>
      * <p/>
      * Activities are persisted as nodes of type nt:activity under system-generated

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditor.java?rev=1513124&r1=1513123&r2=1513124&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditor.java
Mon Aug 12 12:56:47 2013
@@ -32,7 +32,9 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.JcrConstants.JCR_BASEVERSION;
 import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.MISSING_NODE;
+import static org.apache.jackrabbit.oak.plugins.version.VersionConstants.RESTORE_PREFIX;
 
 /**
  * TODO document
@@ -86,7 +88,7 @@ class VersionEditor implements Editor {
     @Override
     public void propertyAdded(PropertyState after)
             throws CommitFailedException {
-        if (after.getName().equals(JcrConstants.JCR_BASEVERSION)
+        if (after.getName().equals(JCR_BASEVERSION)
                 && this.after.hasProperty(JcrConstants.JCR_VERSIONHISTORY)
                 && !this.after.hasProperty(JcrConstants.JCR_ISCHECKEDOUT)
                 && !this.before.exists()) {
@@ -123,8 +125,13 @@ class VersionEditor implements Editor {
             } else {
                 vMgr.checkin(node);
             }
-        } else if (propName.equals(VersionConstants.JCR_BASEVERSION)) {
-            vMgr.restore(node, after.getValue(Type.REFERENCE), null);
+        } else if (propName.equals(JCR_BASEVERSION)) {
+            String baseVersion = after.getValue(Type.REFERENCE);
+            if (baseVersion.startsWith(RESTORE_PREFIX)) {
+                baseVersion = baseVersion.substring(RESTORE_PREFIX.length());
+                node.setProperty(JCR_BASEVERSION, baseVersion, Type.REFERENCE);
+            }
+            vMgr.restore(node, baseVersion, null);
         } else if (isVersionProperty(after)) {
             throwProtected(after.getName());
         } else if (wasReadOnly) {

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1513124&r1=1513123&r2=1513124&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Mon Aug 12 12:56:47 2013
@@ -230,10 +230,6 @@
       org.apache.jackrabbit.test.api.version.RestoreTest#testRestoreLabel
       org.apache.jackrabbit.test.api.version.RestoreTest#testRestoreLabelJcr2
       org.apache.jackrabbit.test.api.version.WorkspaceRestoreTest
-      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.GetReferencesNodeTest#testGetReferencesNeverFromVersions
<!-- Node.getReferences must not return references from version storage -->
       org.apache.jackrabbit.test.api.version.MergeCancelMergeTest

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/VersionManagerDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/VersionManagerDelegate.java?rev=1513124&r1=1513123&r2=1513124&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/VersionManagerDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/VersionManagerDelegate.java
Mon Aug 12 12:56:47 2013
@@ -25,6 +25,7 @@ import static org.apache.jackrabbit.JcrC
 import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
 import static org.apache.jackrabbit.JcrConstants.JCR_UUID;
 import static org.apache.jackrabbit.JcrConstants.JCR_VERSIONHISTORY;
+import static org.apache.jackrabbit.oak.plugins.version.VersionConstants.RESTORE_PREFIX;
 
 import javax.annotation.Nonnull;
 import javax.jcr.InvalidItemStateException;
@@ -41,6 +42,7 @@ import org.apache.jackrabbit.oak.api.Typ
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.jcr.version.ReadWriteVersionManager;
 import org.apache.jackrabbit.oak.jcr.version.VersionStorage;
+import org.apache.jackrabbit.oak.plugins.version.VersionConstants;
 
 /**
  * {@code VersionManagerDelegate}...
@@ -163,9 +165,7 @@ public class VersionManagerDelegate {
             t.setProperty(JCR_VERSIONHISTORY, vd.getParent().getIdentifier(), Type.REFERENCE);
         } else {
             Tree t = parent.getChild(oakName).getTree();
-            t.setProperty(JCR_BASEVERSION, vd.getIdentifier(), Type.REFERENCE);
-            // TODO: what if node was checked-out and restore is for current
-            //       base version? -> will not trigger VersionEditor
+            t.setProperty(JCR_BASEVERSION, RESTORE_PREFIX + vd.getIdentifier(), Type.REFERENCE);
         }
     }
 



Mime
View raw message