jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cko...@apache.org
Subject svn commit: r1862783 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/query/lucene/ test/java/org/apache/jackrabbit/core/query/lucene/ test/resources/org/apache/jackrabbit/core/query/lucene/
Date Tue, 09 Jul 2019 06:30:07 GMT
Author: ckoell
Date: Tue Jul  9 06:30:06 2019
New Revision: 1862783

URL: http://svn.apache.org/viewvc?rev=1862783&view=rev
Log:
JCR-4455 condition index-rule handling more broken after JCR-4339

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java?rev=1862783&r1=1862782&r2=1862783&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
Tue Jul  9 06:30:06 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 = 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/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java?rev=1862783&r1=1862782&r2=1862783&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
Tue Jul  9 06:30:06 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/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml?rev=1862783&r1=1862782&r2=1862783&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml
Tue Jul  9 06:30:06 2019
@@ -19,7 +19,12 @@
 <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" condition="@foo = 'high'">
+		<property>foo</property>
 	</index-rule>
 
 </configuration>
\ No newline at end of file



Mime
View raw message