Author: thomasm
Date: Thu Jan 16 15:39:53 2014
New Revision: 1558839
URL: http://svn.apache.org/r1558839
Log:
OAK-1215 Relative property paths don't work in XPath search expressions
(improved documentation, related small bugfix)
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyInexistenceImpl.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/PropertyInexistenceImpl.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyInexistenceImpl.java?rev=1558839&r1=1558838&r2=1558839&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyInexistenceImpl.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyInexistenceImpl.java
Thu Jan 16 15:39:53 2014
@@ -59,7 +59,7 @@ public class PropertyInexistenceImpl ext
if (t == null) {
return true;
}
- String pn = normalizePath(propertyName);
+ String pn = normalizePropertyName(propertyName);
String relativePath = PathUtils.getParentPath(pn);
String name = PathUtils.getName(pn);
for (String p : PathUtils.elements(relativePath)) {
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=1558839&r1=1558838&r2=1558839&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
Thu Jan 16 15:39:53 2014
@@ -385,11 +385,18 @@ public class SelectorImpl extends Source
return currentOakProperty(pn);
}
- public PropertyValue currentOakProperty(String propertyName) {
- boolean relative = propertyName.indexOf('/') >= 0;
+ /**
+ * Get the property value. The property name may be relative. The special
+ * property names "jcr:path", "jcr:score" and "rep:excerpt" are supported.
+ *
+ * @param oakPropertyName (must already be normalized)
+ * @return the property value or null if not found
+ */
+ public PropertyValue currentOakProperty(String oakPropertyName) {
+ boolean relative = oakPropertyName.indexOf('/') >= 0;
Tree t = currentTree();
if (relative) {
- for (String p :
PathUtils.elements(PathUtils.getParentPath(propertyName))) {
+ for (String p :
PathUtils.elements(PathUtils.getParentPath(oakPropertyName))) {
if (t == null) {
return null;
}
@@ -401,12 +408,12 @@ public class SelectorImpl extends Source
t = t.getChild(p);
}
}
- propertyName = PathUtils.getName(propertyName);
+ oakPropertyName = PathUtils.getName(oakPropertyName);
}
if (t == null || !t.exists()) {
return null;
}
- if (propertyName.equals(QueryImpl.JCR_PATH)) {
+ if (oakPropertyName.equals(QueryImpl.JCR_PATH)) {
String path = currentPath();
String local = getLocalPath(path);
if (local == null) {
@@ -414,12 +421,12 @@ public class SelectorImpl extends Source
return null;
}
return PropertyValues.newString(local);
- } else if (propertyName.equals(QueryImpl.JCR_SCORE)) {
+ } else if (oakPropertyName.equals(QueryImpl.JCR_SCORE)) {
return currentRow.getValue(QueryImpl.JCR_SCORE);
- } else if (propertyName.equals(QueryImpl.REP_EXCERPT)) {
+ } else if (oakPropertyName.equals(QueryImpl.REP_EXCERPT)) {
return currentRow.getValue(QueryImpl.REP_EXCERPT);
}
- return PropertyValues.create(t.getProperty(propertyName));
+ return PropertyValues.create(t.getProperty(oakPropertyName));
}
@Override