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/09/04 15:53:16 UTC

svn commit: r1866397 - in /jackrabbit/branches/2.14: ./ 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: Wed Sep  4 15:53:15 2019
New Revision: 1866397

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

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

Propchange: jackrabbit/branches/2.14/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Sep  4 15:53:15 2019
@@ -1,3 +1,3 @@
 /jackrabbit/branches/JCR-2272:1173165-1176545
 /jackrabbit/sandbox/JCR-2415-lucene-3.0:1060860-1064038
-/jackrabbit/trunk:1776907,1776911-1776912,1776914,1776918,1779166,1779460,1779614,1779632,1780208,1780220,1780335-1780336,1780406,1785225,1786325,1786330,1787043,1787381,1792066,1792100,1792105,1792113,1792193,1793315,1793323,1793327,1793332,1793339,1796980,1797209,1797215,1797917,1798586,1799429,1799538,1799549,1799575,1800359,1800378,1800752,1802925,1802977,1807234,1807244,1808752,1808754,1809149,1809329,1809624,1810108,1811667,1812543,1812634,1812994,1814831,1817094,1817097-1817098,1817100,1817113,1817201,1817213,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,1826178,1826230,1826647,1826940,1826964,1828213,1830107,1830201,1830540,1830753,1830814,1830878,1830951,1831854,1831860,1832058,1832090,1833374,1833835,1833891,1834008,1834308,1834315,1834401,1834418,1834424,1834673,1834922,1835445,1835448,1835459,1836341,183
 6349,1836620,1836729,1836731,1836733,1836773,1836776,1836778,1836794,1836800,1839647,1839910,1839924,1839931,1839937,1839945,1839964,1839966,1840027,1841858,1841865,1841924,1843995,1844000,1844014,1844036,1844067,1844252,1846665,1846896,1847167,1851360,1851369,1851372,1851904,1851953,1851961,1852417,1853927,1854018,1856855,1856969,1857631,1857721,1859563,1859633,1860118,1860645,1861773,1861777-1861778,1861781,1861786
+/jackrabbit/trunk:1776907,1776911-1776912,1776914,1776918,1779166,1779460,1779614,1779632,1780208,1780220,1780335-1780336,1780406,1785225,1786325,1786330,1787043,1787381,1792066,1792100,1792105,1792113,1792193,1793315,1793323,1793327,1793332,1793339,1796980,1797209,1797215,1797917,1798586,1799429,1799538,1799549,1799575,1800359,1800378,1800752,1802925,1802977,1807234,1807244,1808752,1808754,1809149,1809329,1809624,1810108,1811667,1812543,1812634,1812994,1814831,1817094,1817097-1817098,1817100,1817113,1817201,1817213,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,1826178,1826230,1826647,1826940,1826964,1828213,1830107,1830201,1830540,1830753,1830814,1830878,1830951,1831854,1831860,1832058,1832090,1833374,1833835,1833891,1834008,1834308,1834315,1834401,1834418,1834424,1834673,1834922,1835445,1835448,1835459,1836341,183
 6349,1836620,1836729,1836731,1836733,1836773,1836776,1836778,1836794,1836800,1839647,1839910,1839924,1839931,1839937,1839945,1839964,1839966,1840027,1841858,1841865,1841924,1843995,1844000,1844014,1844036,1844067,1844252,1846665,1846896,1847167,1851360,1851369,1851372,1851904,1851953,1851961,1852417,1853927,1854018,1856855,1856969,1857631,1857721,1859563,1859633,1860118,1860645,1861773,1861777-1861778,1861781,1861786,1862783,1862805

Modified: jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java?rev=1866397&r1=1866396&r2=1866397&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java Wed Sep  4 15:53:15 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.14/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java?rev=1866397&r1=1866396&r2=1866397&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java Wed Sep  4 15:53:15 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.14/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml?rev=1866397&r1=1866396&r2=1866397&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml Wed Sep  4 15:53:15 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