You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by re...@apache.org on 2019/08/29 19:32:36 UTC

svn commit: r1866101 - in /jackrabbit/branches/2.16: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/ jackrabbit-core/src/test/resources/org/apache/jackrabb...

Author: reschke
Date: Thu Aug 29 19:32:36 2019
New Revision: 1866101

URL: http://svn.apache.org/viewvc?rev=1866101&view=rev
Log:
JCR-4455 condition index-rule handling more broken after JCR-4339 (merged r1862783 and r1862805 into 2.16)

Modified:
    jackrabbit/branches/2.16/   (props changed)
    jackrabbit/branches/2.16/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
    jackrabbit/branches/2.16/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
    jackrabbit/branches/2.16/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml

Propchange: jackrabbit/branches/2.16/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug 29 19:32:36 2019
@@ -1,3 +1,3 @@
 /jackrabbit/branches/JCR-2272:1173165-1176545
 /jackrabbit/sandbox/JCR-2415-lucene-3.0:1060860-1064038
-/jackrabbit/trunk:1816227,1817094,1817097-1817098,1817100,1817113,1817201,1817213,1817341,1817373,1817377,1818586,1819269,1819271,1819839,1819849,1820119,1820133,1820294,1820573,1820675,1820753,1821247,1821475,1821597,1821705,1821880,1822643,1822863,1822947,1822950,1824756,1824763-1824764,1824771,1824876,1826154,1826178,1826230,1826647,1826940,1826964,1828213,1830107,1830201,1830540,1830753,1830814,1830878,1830951,1831182,1831854,1831860,1832058,1832090,1832177,1833374,1833835,1833891,1834008,1834308,1834315,1834401,1834418,1834424,1834673,1834922,1835445,1835448,1835459,1836341,1836349,1836620,1836722,1836729,1836731,1836733,1836773,1836776,1836778,1836794,1836800,1839647,1839910,1839924,1839931,1839937,1839945,1839964,1839966,1840007,1840027,1841459,1841858,1841865,1841916-1841917,1841924,1843392,1843995,1844000,1844014,1844030,1844036,1844067,1844252,1846665,1846896,1847167,1850224,1851360,1851369,1851372,1851380,1851384,1851904,1851946,1851953,1851961,1852417,1853927,1854018,185
 6855,1856969,1857631,1857721,1859534,1859563,1859633,1860118,1860123,1860645,1861773,1861777-1861778,1861781,1861786
+/jackrabbit/trunk:1816227,1817094,1817097-1817098,1817100,1817113,1817201,1817213,1817341,1817373,1817377,1818586,1819269,1819271,1819839,1819849,1820119,1820133,1820294,1820573,1820675,1820753,1821247,1821475,1821597,1821705,1821880,1822643,1822863,1822947,1822950,1824756,1824763-1824764,1824771,1824876,1826154,1826178,1826230,1826647,1826940,1826964,1828213,1830107,1830201,1830540,1830753,1830814,1830878,1830951,1831182,1831854,1831860,1832058,1832090,1832177,1833374,1833835,1833891,1834008,1834308,1834315,1834401,1834418,1834424,1834673,1834922,1835445,1835448,1835459,1836341,1836349,1836620,1836722,1836729,1836731,1836733,1836773,1836776,1836778,1836794,1836800,1839647,1839910,1839924,1839931,1839937,1839945,1839964,1839966,1840007,1840027,1841459,1841858,1841865,1841916-1841917,1841924,1843392,1843995,1844000,1844014,1844030,1844036,1844067,1844252,1846665,1846896,1847167,1850224,1851360,1851369,1851372,1851380,1851384,1851904,1851946,1851953,1851961,1852417,1853927,1854018,185
 6855,1856969,1857631,1857721,1859534,1859563,1859633,1860118,1860123,1860645,1861773,1861777-1861778,1861781,1861786,1862783,1862805

Modified: jackrabbit/branches/2.16/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.16/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java?rev=1866101&r1=1866100&r2=1866101&view=diff
==============================================================================
--- jackrabbit/branches/2.16/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java (original)
+++ jackrabbit/branches/2.16/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java Thu Aug 29 19:32:36 2019
@@ -389,17 +389,20 @@ public class IndexingConfigurationImpl
                 rules.addAll(r);
             }
         }
-
+        IndexingRule matchingNodeTypeRule = null;
         if (rules != null) {
             for (IndexingRule rule : rules) {
-                if (rule.appliesTo(state)) {
-                    return rule;
+                if (rule.appliesToNodeType(state)) {
+                    if (!rule.containsCondition() && matchingNodeTypeRule == null) {
+                        matchingNodeTypeRule = rule;
+                    } else if (rule.appliesToCondition(state)) {
+                        return rule; 
+                    }
                 }
             }
         }
 
-        // no applicable rule
-        return null;
+        return matchingNodeTypeRule;
     }
 
     /**
@@ -811,21 +814,43 @@ public class IndexingConfigurationImpl
         }
 
         /**
-         * Returns <code>true</code> if this rule applies to the given node
-         * <code>state</code>.
+         * Returns <code>true</code> if the nodetype of this rule 
+         * applies to the given node <code>state</code>.
          *
          * @param state the state to check.
          * @return <code>true</code> the rule applies to the given node;
          *         <code>false</code> otherwise.
          */
-        public boolean appliesTo(NodeState state) {
+        public boolean appliesToNodeType(NodeState state) {
             if (state.getMixinTypeNames().contains(nodeTypeName)) {
                 return true;
             }
             if (!nodeTypeName.equals(state.getNodeTypeName())) {
                 return false;
             }
-            return condition == null || condition.evaluate(state);
+            return true;
+        }
+        
+        /**
+         * Returns <code>true</code> if the condition of this rule 
+         * applies to the given node <code>state</code>.
+         *
+         * @param state the state to check.
+         * @return <code>true</code> the rule applies to the given node;
+         *         <code>false</code> otherwise.
+         */
+        public boolean appliesToCondition(NodeState state) {
+            return condition != null && condition.evaluate(state);
+        }
+
+        /**
+         * Returns <code>true</code> this rule contains a condition. 
+         *
+         * @return <code>true</code> the rule contains a condition;
+         *         <code>false</code> otherwise.
+         */
+        public boolean containsCondition() {
+            return condition != null;
         }
 
         //-------------------------< internal >---------------------------------

Modified: jackrabbit/branches/2.16/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.16/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java?rev=1866101&r1=1866100&r2=1866101&view=diff
==============================================================================
--- jackrabbit/branches/2.16/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java (original)
+++ jackrabbit/branches/2.16/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java Thu Aug 29 19:32:36 2019
@@ -41,6 +41,7 @@ import org.xml.sax.SAXException;
 public class IndexingConfigurationImplTest extends AbstractIndexingTest {
 
     private static final Name FOO = NameFactoryImpl.getInstance().create("", "foo");
+    private static final Name OTHER = NameFactoryImpl.getInstance().create("", "other");
 
     private NodeState nState;
     private Node n;
@@ -114,6 +115,15 @@ public class IndexingConfigurationImplTe
         session.save();
         nState = (NodeState) getSearchIndex().getContext().getItemStateManager().getItemState(
                 new NodeId(n.getIdentifier()));        
+        assertTrue(config.isIndexed(nState, FOO));
+        assertFalse(config.isIndexed(nState, OTHER));
+        
+        n = testRootNode.addNode(nodeName2, ntUnstructured);
+        n.addMixin(mixReferenceable);
+        session.save();
+        nState = (NodeState) getSearchIndex().getContext().getItemStateManager().getItemState(
+                new NodeId(n.getIdentifier()));        
+        assertTrue(config.isIndexed(nState, OTHER));
         assertFalse(config.isIndexed(nState, FOO));
     }
 

Modified: jackrabbit/branches/2.16/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.16/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml?rev=1866101&r1=1866100&r2=1866101&view=diff
==============================================================================
--- jackrabbit/branches/2.16/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml (original)
+++ jackrabbit/branches/2.16/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml Thu Aug 29 19:32:36 2019
@@ -19,7 +19,16 @@
 <configuration xmlns:jcr="http://www.jcp.org/jcr/1.0"
                xmlns:nt="http://www.jcp.org/jcr/nt/1.0">
 
+ 	<index-rule nodeType="nt:unstructured">
+		<property>other</property>
+	</index-rule>
+
+ 	<index-rule nodeType="nt:unstructured">
+		<property>other_</property>
+	</index-rule>
+
 	<index-rule nodeType="nt:unstructured" condition="@foo = 'high'">
+		<property>foo</property>
 	</index-rule>
 
 </configuration>
\ No newline at end of file