jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1440952 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java
Date Thu, 31 Jan 2013 13:20:30 GMT
Author: mduerig
Date: Thu Jan 31 13:20:29 2013
New Revision: 1440952

URL: http://svn.apache.org/viewvc?rev=1440952&view=rev
Log:
OAK-51 : Access Control Management (WIP)
partially revert changes from revision 1440540 as discussed

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

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java?rev=1440952&r1=1440951&r2=1440952&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java
Thu Jan 31 13:20:29 2013
@@ -47,11 +47,6 @@ public class ReadOnlyTree implements Tre
     private final String name;
 
     /**
-     * Path of this tree
-     */
-    private final String path;
-
-    /**
      * Underlying node state
      */
     private final NodeState state;
@@ -63,23 +58,10 @@ public class ReadOnlyTree implements Tre
     public ReadOnlyTree(@Nullable ReadOnlyTree parent, @Nonnull String name, @Nonnull NodeState
state) {
         this.parent = parent;
         this.name = checkNotNull(name);
-        this.path = buildPath(parent, name);
         this.state = checkNotNull(state);
         checkArgument(!name.isEmpty() || parent == null);
     }
 
-    private static String buildPath(ReadOnlyTree parent, String name) {
-        if (parent == null) {
-            return "/";
-        } else if (parent.isRoot()) {
-            return parent.path + name;
-        } else {
-            StringBuilder sb = new StringBuilder();
-            sb.append(parent.path).append('/').append(name);
-            return sb.toString();
-        }
-    }
-
     public static ReadOnlyTree createFromRoot(Root root) {
         if (root instanceof RootImpl) {
             return new ReadOnlyTree(((RootImpl) root).getBaseState());
@@ -102,7 +84,21 @@ public class ReadOnlyTree implements Tre
 
     @Override
     public String getPath() {
-        return path;
+        if (isRoot()) {
+            // shortcut
+            return "/";
+        }
+
+        StringBuilder sb = new StringBuilder();
+        buildPath(sb);
+        return sb.toString();
+    }
+
+    private void buildPath(StringBuilder sb) {
+        if (parent != null) {
+            parent.buildPath(sb);
+            sb.append('/').append(name);
+        }
     }
 
     @Override



Mime
View raw message