jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r831900 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java test/java/org/apache/jackrabbit/core/query/XPathAxisTest.java
Date Mon, 02 Nov 2009 14:15:14 GMT
Author: mreutegg
Date: Mon Nov  2 14:15:13 2009
New Revision: 831900

URL: http://svn.apache.org/viewvc?rev=831900&view=rev
Log:
JCR-1987: Jackrabbit's lucene based query implementation does not check property constraints
on the root node.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/XPathAxisTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java?rev=831900&r1=831899&r2=831900&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
Mon Nov  2 14:15:13 2009
@@ -452,6 +452,17 @@
                     and.add(new NameQuery(nameTest, indexFormatVersion, nsMappings), Occur.MUST);
                     context = and;
                 }
+                // apply predicates
+                Object[] predicates = steps[0].acceptOperands(this, context);
+                BooleanQuery andQuery = new BooleanQuery();
+                for (Object predicate : predicates) {
+                    andQuery.add((Query) predicate, Occur.MUST);
+                }
+                if (andQuery.clauses().size() > 0) {
+                    andQuery.add(context, Occur.MUST);
+                    context = andQuery;
+                }
+
                 LocationStepQueryNode[] tmp = new LocationStepQueryNode[steps.length - 1];
                 System.arraycopy(steps, 1, tmp, 0, steps.length - 1);
                 steps = tmp;

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/XPathAxisTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/XPathAxisTest.java?rev=831900&r1=831899&r2=831900&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/XPathAxisTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/XPathAxisTest.java
Mon Nov  2 14:15:13 2009
@@ -198,4 +198,12 @@
         executeXPathQuery(xpath, new Node[0]);
     }
 
+    public void testRootQuery() throws RepositoryException {
+        // JCR-1987
+        executeXPathQuery("/jcr:root[@foo = 'does-not-exist']", new Node[0]);
+        Node rootNode = superuser.getRootNode();
+        executeXPathQuery("/jcr:root", new Node[]{rootNode});
+        executeXPathQuery("/jcr:root[@" + jcrPrimaryType + "='" +
+                rootNode.getPrimaryNodeType().getName() + "']", new Node[]{rootNode});
+    }
 }



Mime
View raw message