jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1528472 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
Date Wed, 02 Oct 2013 13:46:41 GMT
Author: jukka
Date: Wed Oct  2 13:46:41 2013
New Revision: 1528472

URL: http://svn.apache.org/r1528472
Log:
OAK-1063: MutableTree.enter() simplification

Make exists() and a few other public methods call enter() so that the move tracking code is
just in one place.
Inline the super.getPath() call in getPathInternal() so we can replace the getParent() call
with direct parent access.

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java?rev=1528472&r1=1528471&r2=1528472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
Wed Oct  2 13:46:41 2013
@@ -40,6 +40,7 @@ import javax.annotation.Nonnull;
 import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Sets;
+
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.Type;
@@ -157,11 +158,9 @@ public class MutableTree extends Abstrac
 
     @Override
     public boolean exists() {
-        root.checkLive();
+        enter();
         if (isHidden(name)) {
             return false;
-        } else if (applyPendingMoves()) {
-            return reconnect();
         } else {
             return nodeBuilder.exists();
         }
@@ -169,8 +168,8 @@ public class MutableTree extends Abstrac
 
     @Override
     public MutableTree getParent() {
+        enter();
         checkState(parent != null, "root tree does not have a parent");
-        root.checkLive();
         return parent;
     }
 
@@ -194,10 +193,13 @@ public class MutableTree extends Abstrac
 
     @Override
     public Status getPropertyStatus(String name) {
+        enter();
+
         // make sure we don't expose information about a non-accessible property
         if (!hasProperty(name)) {
             return null;
         }
+
         // get status of this tree without checking for it's existence
         Status nodeStatus = super.getStatus();
         if (nodeStatus == NEW) {
@@ -209,7 +211,6 @@ public class MutableTree extends Abstrac
         }
 
         PropertyState base = getSecureBase().getProperty(name);
-
         if (base == null) {
             return NEW;
         } else if (head.equals(base)) {
@@ -452,7 +453,20 @@ public class MutableTree extends Abstrac
     }
 
     String getPathInternal() {
-        return super.getPath();
+        if (parent == null) {
+            return "/";
+        } else {
+            StringBuilder sb = new StringBuilder();
+            buildPath(sb);
+            return sb.toString();
+        }
+    }
+
+    private void buildPath(StringBuilder sb) {
+        if (parent != null) {
+            parent.buildPath(sb);
+            sb.append('/').append(name);
+        }
     }
 
     //------------------------------------------------------------< private >---



Mime
View raw message