jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1466878 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: core/ kernel/ plugins/commit/ plugins/segment/ spi/state/
Date Thu, 11 Apr 2013 13:21:05 GMT
Author: mduerig
Date: Thu Apr 11 13:21:04 2013
New Revision: 1466878

URL: http://svn.apache.org/r1466878
Log:
OAK-709: Consider moving permission evaluation to the node state level
implement rebasing of secure node state differences on top of non secure node state giving
transient changes precedence.

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/OurChangesRebaseDiff.java
  (contents, props changed)
      - copied, changed from r1466869, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/PurgeRebaseDiff.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ConflictAnnotatingRebaseDiff.java
  (contents, props changed)
      - copied, changed from r1466869, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/RebaseDiff.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/PurgeRebaseDiff.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/RebaseDiff.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/OurChangesRebaseDiff.java
(from r1466869, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/PurgeRebaseDiff.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/OurChangesRebaseDiff.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/OurChangesRebaseDiff.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/PurgeRebaseDiff.java&r1=1466869&r2=1466878&rev=1466878&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/PurgeRebaseDiff.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/OurChangesRebaseDiff.java
Thu Apr 11 13:21:04 2013
@@ -19,84 +19,75 @@
 
 package org.apache.jackrabbit.oak.core;
 
-import javax.jcr.UnsupportedRepositoryOperationException;
-
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.spi.state.AbstractRebaseDiff;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.util.TODO;
 
 /**
- * FIXME rename, document
+ * This implementation of {@code RebaseDiff} implements a
+ * {@link org.apache.jackrabbit.oak.spi.state.NodeStateDiff},
+ * which handled conflicts by giving precedence to our changes.
+ * I.e. the changes in the {@code after} node state.
  */
-class PurgeRebaseDiff extends AbstractRebaseDiff {
-    private PurgeRebaseDiff(NodeBuilder builder) {
+class OurChangesRebaseDiff extends AbstractRebaseDiff {
+    private OurChangesRebaseDiff(NodeBuilder builder) {
         super(builder);
     }
 
     public static NodeState rebase(NodeState before, NodeState after, NodeBuilder builder)
{
-        after.compareAgainstBaseState(before, new PurgeRebaseDiff(builder));
+        after.compareAgainstBaseState(before, new OurChangesRebaseDiff(builder));
         return builder.getNodeState();
     }
 
     @Override
-    protected PurgeRebaseDiff createDiff(NodeBuilder builder, String name) {
-        return new PurgeRebaseDiff(builder.child(name));
+    protected OurChangesRebaseDiff createDiff(NodeBuilder builder, String name) {
+        return new OurChangesRebaseDiff(builder.child(name));
     }
 
     @Override
     protected void addExistingProperty(NodeBuilder builder, PropertyState after) {
-        conflict();
+        builder.setProperty(after);
     }
 
     @Override
     protected void changeDeletedProperty(NodeBuilder builder, PropertyState after) {
-        conflict();
+        builder.setProperty(after);
     }
 
     @Override
     protected void changeChangedProperty(NodeBuilder builder, PropertyState before, PropertyState
after) {
-        conflict();
+        builder.setProperty(after);
     }
 
     @Override
     protected void deleteDeletedProperty(NodeBuilder builder, PropertyState before) {
-        conflict();
+        // ignore
     }
 
     @Override
     protected void deleteChangedProperty(NodeBuilder builder, PropertyState before) {
-        conflict();
+        builder.removeProperty(before.getName());
     }
 
     @Override
     protected void addExistingNode(NodeBuilder builder, String name, NodeState after) {
-        conflict();
+        builder.setNode(name, after);
     }
 
     @Override
     protected void changeDeletedNode(NodeBuilder builder, String name, NodeState after) {
-        conflict();
+        builder.setNode(name, after);
     }
 
     @Override
     protected void deleteDeletedNode(NodeBuilder builder, String name, NodeState before)
{
-        conflict();
+        // ignore
     }
 
     @Override
     protected void deleteChangedNode(NodeBuilder builder, String name, NodeState before)
{
-        conflict();
+        builder.removeNode(name);
     }
 
-    private static void conflict() {
-        // FIXME correctly handle conflict cases
-        try {
-            TODO.unimplemented().doNothing();
-        }
-        catch (UnsupportedRepositoryOperationException e) {
-            throw new IllegalStateException(e);
-        }
-    }
 }

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/OurChangesRebaseDiff.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/OurChangesRebaseDiff.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java?rev=1466878&r1=1466877&r2=1466878&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
Thu Apr 11 13:21:04 2013
@@ -432,7 +432,7 @@ public class RootImpl implements Root {
     @Nonnull
     private NodeState getRootState() {
         NodeBuilder builder = branch.getHead().builder();
-        return PurgeRebaseDiff.rebase(secureHead, getSecureRootState(), builder);
+        return OurChangesRebaseDiff.rebase(secureHead, getSecureRootState(), builder);
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java?rev=1466878&r1=1466877&r2=1466878&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
Thu Apr 11 13:21:04 2013
@@ -16,21 +16,21 @@
  */
 package org.apache.jackrabbit.oak.kernel;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
+import static org.apache.jackrabbit.oak.commons.PathUtils.getName;
+import static org.apache.jackrabbit.oak.commons.PathUtils.getParentPath;
+
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.api.MicroKernelException;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.state.AbstractNodeStoreBranch;
+import org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.spi.state.RebaseDiff;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
-import static org.apache.jackrabbit.oak.commons.PathUtils.getName;
-import static org.apache.jackrabbit.oak.commons.PathUtils.getParentPath;
 
 /**
  * {@code NodeStoreBranch} based on {@link MicroKernel} branching and merging.
@@ -190,7 +190,7 @@ class KernelNodeStoreBranch extends Abst
             // Nothing written to persistent branch yet
             // perform rebase in memory
             NodeBuilder builder = root.builder();
-            getHead().compareAgainstBaseState(getBase(), new RebaseDiff(builder));
+            getHead().compareAgainstBaseState(getBase(), new ConflictAnnotatingRebaseDiff(builder));
             head = builder.getNodeState();
             base = root;
             baseRevision = root.getRevision();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java?rev=1466878&r1=1466877&r2=1466878&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java
Thu Apr 11 13:21:04 2013
@@ -16,6 +16,17 @@
  */
 package org.apache.jackrabbit.oak.plugins.commit;
 
+import static org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff.ADD_EXISTING_NODE;
+import static org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff.ADD_EXISTING_PROPERTY;
+import static org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff.CHANGE_CHANGED_PROPERTY;
+import static org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff.CHANGE_DELETED_NODE;
+import static org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff.CHANGE_DELETED_PROPERTY;
+import static org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff.CONFLICT;
+import static org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff.DELETE_CHANGED_NODE;
+import static org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff.DELETE_CHANGED_PROPERTY;
+import static org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff.DELETE_DELETED_NODE;
+import static org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff.DELETE_DELETED_PROPERTY;
+
 import java.util.Map;
 
 import com.google.common.collect.ImmutableMap;
@@ -33,17 +44,6 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.jackrabbit.oak.spi.state.RebaseDiff.ADD_EXISTING_NODE;
-import static org.apache.jackrabbit.oak.spi.state.RebaseDiff.ADD_EXISTING_PROPERTY;
-import static org.apache.jackrabbit.oak.spi.state.RebaseDiff.CHANGE_CHANGED_PROPERTY;
-import static org.apache.jackrabbit.oak.spi.state.RebaseDiff.CHANGE_DELETED_NODE;
-import static org.apache.jackrabbit.oak.spi.state.RebaseDiff.CHANGE_DELETED_PROPERTY;
-import static org.apache.jackrabbit.oak.spi.state.RebaseDiff.CONFLICT;
-import static org.apache.jackrabbit.oak.spi.state.RebaseDiff.DELETE_CHANGED_NODE;
-import static org.apache.jackrabbit.oak.spi.state.RebaseDiff.DELETE_CHANGED_PROPERTY;
-import static org.apache.jackrabbit.oak.spi.state.RebaseDiff.DELETE_DELETED_NODE;
-import static org.apache.jackrabbit.oak.spi.state.RebaseDiff.DELETE_DELETED_PROPERTY;
-
 /**
  * MergingNodeStateDiff... TODO
  */

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java?rev=1466878&r1=1466877&r2=1466878&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
Thu Apr 11 13:21:04 2013
@@ -24,9 +24,9 @@ import org.apache.jackrabbit.oak.api.Com
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.state.AbstractNodeStoreBranch;
+import org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.spi.state.RebaseDiff;
 
 class SegmentNodeStoreBranch extends AbstractNodeStoreBranch {
 
@@ -72,7 +72,7 @@ class SegmentNodeStoreBranch extends Abs
         if (!baseId.equals(newBaseId)) {
             NodeBuilder builder =
                     new SegmentNodeState(store, newBaseId).builder();
-            getHead().compareAgainstBaseState(getBase(), new RebaseDiff(builder));
+            getHead().compareAgainstBaseState(getBase(), new ConflictAnnotatingRebaseDiff(builder));
             this.baseId = newBaseId;
             this.rootId = writer.writeNode(builder.getNodeState()).getRecordId();
             writer.flush();

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ConflictAnnotatingRebaseDiff.java
(from r1466869, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/RebaseDiff.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ConflictAnnotatingRebaseDiff.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ConflictAnnotatingRebaseDiff.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/RebaseDiff.java&r1=1466869&r2=1466878&rev=1466878&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/RebaseDiff.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ConflictAnnotatingRebaseDiff.java
Thu Apr 11 13:21:04 2013
@@ -20,12 +20,12 @@ import org.apache.jackrabbit.mk.api.Micr
 import org.apache.jackrabbit.oak.api.PropertyState;
 
 /**
- * {@code RebaseDiff} implements a {@link NodeStateDiff}, which performs
- * the conflict handling as defined in {@link MicroKernel#rebase(String, String)}
+ * This implementation of {@code AbstractRebaseDiff} implements a {@link NodeStateDiff},
+ * which performs the conflict handling as defined in {@link MicroKernel#rebase(String, String)}
  * on the Oak SPI state level by annotating conflicting items with conflict
  * markers.
  */
-public class RebaseDiff extends AbstractRebaseDiff {
+public class ConflictAnnotatingRebaseDiff extends AbstractRebaseDiff {
     public static final String CONFLICT = ":conflict";
     public static final String DELETE_CHANGED_PROPERTY = "deleteChangedProperty";
     public static final String DELETE_CHANGED_NODE = "deleteChangedNode";
@@ -37,13 +37,13 @@ public class RebaseDiff extends Abstract
     public static final String CHANGE_DELETED_NODE = "changeDeletedNode";
     public static final String DELETE_DELETED_NODE = "deleteDeletedNode";
 
-    public RebaseDiff(NodeBuilder builder) {
+    public ConflictAnnotatingRebaseDiff(NodeBuilder builder) {
         super(builder);
     }
 
     @Override
-    protected RebaseDiff createDiff(NodeBuilder builder, String name) {
-        return new RebaseDiff(builder.child(name));
+    protected ConflictAnnotatingRebaseDiff createDiff(NodeBuilder builder, String name) {
+        return new ConflictAnnotatingRebaseDiff(builder.child(name));
     }
 
     @Override

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ConflictAnnotatingRebaseDiff.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ConflictAnnotatingRebaseDiff.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL



Mime
View raw message