jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1465609 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core: RootImpl.java TreeImpl.java
Date Mon, 08 Apr 2013 12:16:59 GMT
Author: jukka
Date: Mon Apr  8 12:16:59 2013
New Revision: 1465609

URL: http://svn.apache.org/r1465609
Log:
OAK-709: Consider moving permission evaluation to the node state level

Rebase changes from SecureNodeState to the raw underlying state before committing

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/core/TreeImpl.java

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=1465609&r1=1465608&r2=1465609&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
Mon Apr  8 12:16:59 2013
@@ -58,6 +58,7 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
+import org.apache.jackrabbit.oak.spi.state.RebaseDiff;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
@@ -97,6 +98,8 @@ public class RootImpl implements Root {
      */
     private NodeStoreBranch branch;
 
+    private NodeState secureHead;
+
     /** Sentinel for the next move operation to take place on the this root */
     private Move lastMove = new Move();
 
@@ -132,6 +135,8 @@ public class RootImpl implements Root {
         this.indexProvider = indexProvider;
 
         branch = this.store.branch();
+        secureHead = new SecureNodeState(
+                branch.getHead(), getPermissionProvider(), getTypeProvider());
         rootTree = new TreeImpl(this, lastMove);
     }
 
@@ -241,7 +246,7 @@ public class RootImpl implements Root {
         if (!store.getRoot().equals(rootTree.getBaseState())) {
             purgePendingChanges();
             branch.rebase();
-            rootTree.reset(getSecureHead());
+            reset();
             permissionProvider = null;
         }
     }
@@ -250,7 +255,7 @@ public class RootImpl implements Root {
     public final void refresh() {
         checkLive();
         branch = store.branch();
-        rootTree.reset(getSecureHead());
+        reset();
         modCount = 0;
         if (permissionProvider != null) {
             permissionProvider.refresh();
@@ -396,7 +401,7 @@ public class RootImpl implements Root {
 
     @Nonnull
     NodeBuilder createRootBuilder() {
-        return getSecureHead().builder();
+        return secureHead.builder();
     }
 
     // TODO better way to determine purge limit. See OAK-175
@@ -426,7 +431,12 @@ public class RootImpl implements Root {
      * Purge all pending changes to the underlying {@link NodeStoreBranch}.
      */
     private void purgePendingChanges() {
-        branch.setRoot(getRootState());
+        NodeState before = secureHead;
+        NodeState after = getRootState();
+        NodeBuilder builder = branch.getHead().builder();
+        // FIXME: This rebase should fail on conflicts
+        after.compareAgainstBaseState(before, new RebaseDiff(builder));
+        branch.setRoot(builder.getNodeState());
         reset();
     }
 
@@ -434,7 +444,9 @@ public class RootImpl implements Root {
      * Reset the root builder to the branch's current root state
      */
     private void reset() {
-        rootTree.getNodeBuilder().reset(getSecureHead());
+        secureHead = new SecureNodeState(
+                branch.getHead(), getPermissionProvider(), getTypeProvider());
+        rootTree.reset(secureHead);
     }
 
     @Nonnull
@@ -448,11 +460,6 @@ public class RootImpl implements Root {
     }
 
     @Nonnull
-    private NodeState getSecureHead() {
-        return new SecureNodeState(branch.getHead(), getPermissionProvider(), getTypeProvider());
-    }
-
-    @Nonnull
     private NodeState getRootState() {
         // FIXME: should not return a state being (based on) SecureNodeState (see OAK-709)
         return rootTree.getNodeState();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java?rev=1465609&r1=1465608&r2=1465609&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
Mon Apr  8 12:16:59 2013
@@ -90,7 +90,7 @@ public class TreeImpl implements Tree {
         this.root = checkNotNull(root);
         this.parent = checkNotNull(parent);
         this.name = checkNotNull(name);
-        this.nodeBuilder = parent.getNodeBuilder().child(name);
+        this.nodeBuilder = parent.nodeBuilder.child(name);
         this.pendingMoves = checkNotNull(pendingMoves);
     }
 
@@ -406,11 +406,6 @@ public class TreeImpl implements Tree {
 
     //-----------------------------------------------------------< internal >---
 
-    @Nonnull
-    NodeBuilder getNodeBuilder() {
-        return nodeBuilder;
-    }
-
     /**
      * The (possibly non-existent) node state this tree is based on.
      * @return the base node state of this tree



Mime
View raw message