jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1453789 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core: IdentifierManager.java ReadOnlyTree.java TreeImpl.java
Date Thu, 07 Mar 2013 11:52:43 GMT
Author: mduerig
Date: Thu Mar  7 11:52:42 2013
New Revision: 1453789

URL: http://svn.apache.org/r1453789
Log:
OAK-101: implement identifier handling (byUUID, byIdentifier, etc)
avoid referring to inaccessible parents / properties

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/IdentifierManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.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/IdentifierManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/IdentifierManager.java?rev=1453789&r1=1453788&r2=1453789&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/IdentifierManager.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/IdentifierManager.java
Thu Mar  7 11:52:42 2013
@@ -95,14 +95,12 @@ public class IdentifierManager {
      */
     @Nonnull
     public String getIdentifier(Tree tree) {
-        PropertyState property = tree.getProperty(JcrConstants.JCR_UUID);
-        if (property != null) {
-            return property.getValue(STRING);
-        } else if (tree.isRoot()) {
-            return tree.getPath();
+        if (tree instanceof TreeImpl) {
+            return ((TreeImpl) tree).getIdentifier();
+        } else if (tree instanceof ReadOnlyTree) {
+            return ((ReadOnlyTree) tree).getIdentifier();
         } else {
-            // FIXME parent might not be accessible
-            return PathUtils.concat(getIdentifier(tree.getParent()), tree.getName());
+            return tree.getPath();
         }
     }
 

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=1453789&r1=1453788&r2=1453789&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 Mar  7 11:52:42 2013
@@ -23,16 +23,19 @@ import java.util.Iterator;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.TreeLocation;
 import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
 
 public class ReadOnlyTree implements Tree {
 
@@ -243,6 +246,20 @@ public class ReadOnlyTree implements Tre
         throw new UnsupportedOperationException();
     }
 
+    //------------------------------------------------------------< internal >---
+
+    @Nonnull
+    String getIdentifier() {
+        PropertyState property = state.getProperty(JcrConstants.JCR_UUID);
+        if (property != null) {
+            return property.getValue(STRING);
+        } else if (parent == null) {
+            return "/";
+        } else {
+            return PathUtils.concat(parent.getIdentifier(), name);
+        }
+    }
+
     //-------------------------------------------------------< TreeLocation >---
 
     private final class NodeLocation extends AbstractNodeLocation<ReadOnlyTree> {

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=1453789&r1=1453788&r2=1453789&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
Thu Mar  7 11:52:42 2013
@@ -30,10 +30,12 @@ import com.google.common.base.Function;
 import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Sets;
+import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.TreeLocation;
 import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryPropertyBuilder;
 import org.apache.jackrabbit.oak.plugins.memory.MultiStringPropertyState;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -43,6 +45,7 @@ import org.apache.jackrabbit.oak.spi.sta
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
 import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
 
 public class TreeImpl implements Tree {
@@ -489,6 +492,18 @@ public class TreeImpl implements Tree {
         nodeBuilder.setProperty(builder.getPropertyState());
     }
 
+    @Nonnull
+    String getIdentifier() {
+        PropertyState property = internalGetProperty(JcrConstants.JCR_UUID);
+        if (property != null) {
+            return property.getValue(STRING);
+        } else if (parent == null) {
+            return "/";
+        } else {
+            return PathUtils.concat(parent.getIdentifier(), name);
+        }
+    }
+
     //------------------------------------------------------------< private >---
 
     private TreeImpl internalGetChild(String childName) {



Mime
View raw message