jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1430313 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast: PropertyValueImpl.java SelectorImpl.java
Date Tue, 08 Jan 2013 15:01:26 GMT
Author: thomasm
Date: Tue Jan  8 15:01:26 2013
New Revision: 1430313

URL: http://svn.apache.org/viewvc?rev=1430313&view=rev
Log:
OAK-309 ParentNodeTest fails (XPath parent node navigation using "..")

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java?rev=1430313&r1=1430312&r2=1430313&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
Tue Jan  8 15:01:26 2013
@@ -92,9 +92,8 @@ public class PropertyValueImpl extends D
 
     @Override
     public PropertyValue currentProperty() {
-        boolean relative = propertyName.indexOf('/') >= 0;
-        boolean asterisk = propertyName.equals("*");
-        if (!relative && !asterisk) {
+        boolean asterisk = PathUtils.getName(propertyName).equals("*");
+        if (!asterisk) {
             PropertyValue p = selector.currentProperty(propertyName);
             return matchesPropertyType(p) ? p : null;
         }
@@ -102,20 +101,6 @@ public class PropertyValueImpl extends D
         if (tree == null) {
             return null;
         }
-        if (relative) {
-            for (String p : PathUtils.elements(PathUtils.getParentPath(propertyName))) {
-                if (tree == null) {
-                    return null;
-                }
-                if (!tree.hasChild(p)) {
-                    return null;
-                }
-                tree = tree.getChild(p);
-            }
-            if (tree == null) {
-                return null;
-            }
-        }
         if (!asterisk) {
             String name = PathUtils.getName(propertyName);
             if (!tree.hasProperty(name)) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java?rev=1430313&r1=1430312&r2=1430313&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
Tue Jan  8 15:01:26 2013
@@ -34,6 +34,7 @@ import org.apache.jackrabbit.JcrConstant
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.PropertyValue;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants;
 import org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager;
 import org.apache.jackrabbit.oak.query.Query;
@@ -230,18 +231,7 @@ public class SelectorImpl extends Source
     }
 
     public PropertyValue currentProperty(String propertyName) {
-        if (propertyName.equals(Query.JCR_PATH)) {
-            String p = currentPath();
-            if (p == null) {
-                return null;
-            }
-            String local = getLocalPath(p);
-            if (local == null) {
-                // not a local path
-                return null;
-            }
-            return PropertyValues.newString(local);
-        }
+        boolean relative = propertyName.indexOf('/') >= 0;
         if (cursor == null) {
             return null;
         }
@@ -256,7 +246,31 @@ public class SelectorImpl extends Source
             return null;
         }
         Tree t = getTree(path);
-        return t == null ? null : PropertyValues.create(t.getProperty(propertyName));
+        if (relative) {
+            for (String p : PathUtils.elements(PathUtils.getParentPath(propertyName))) {
+                if (t == null) {
+                    return null;
+                }
+                if (p.equals("..")) {
+                    t = t.getParent();
+                } else {
+                    t = t.getChild(p);
+                }
+            }
+            propertyName = PathUtils.getName(propertyName);
+        }
+        if (t == null) {
+            return null;
+        }
+        if (propertyName.equals(Query.JCR_PATH)) {
+            String local = getLocalPath(path);
+            if (local == null) {
+                // not a local path
+                return null;
+            }
+            return PropertyValues.newString(local);
+        }
+        return PropertyValues.create(t.getProperty(propertyName));
     }
 
     @Override



Mime
View raw message