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/26 08:14:32 UTC
svn commit: r1865913 - in /jackrabbit/branches/2.18: ./
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: Mon Aug 26 08:14:31 2019
New Revision: 1865913
URL: http://svn.apache.org/viewvc?rev=1865913&view=rev
Log:
JCR-4455 condition index-rule handling more broken after JCR-4339 (merged r1862783 and r1862805 into 2.18)
Modified:
jackrabbit/branches/2.18/ (props changed)
jackrabbit/branches/2.18/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
jackrabbit/branches/2.18/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
jackrabbit/branches/2.18/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml
Propchange: jackrabbit/branches/2.18/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug 26 08:14:31 2019
@@ -1,3 +1,3 @@
/jackrabbit/branches/JCR-2272:1173165-1176545
/jackrabbit/sandbox/JCR-2415-lucene-3.0:1060860-1064038
-/jackrabbit/trunk:1850224,1851360,1851369,1851372,1851380,1851384,1851904,1851946,1851953,1851961,1852417,1853927,1854018,1856855,1856969,1857631,1857721,1858564,1858566,1859534,1859563,1859633,1860118,1860123,1860645,1861773,1861777-1861778,1861781,1861786,1862283,1863196,1863222,1863384
+/jackrabbit/trunk:1850224,1851360,1851369,1851372,1851380,1851384,1851904,1851946,1851953,1851961,1852417,1853927,1854018,1856855,1856969,1857631,1857721,1858564,1858566,1859534,1859563,1859633,1860118,1860123,1860645,1861773,1861777-1861778,1861781,1861786,1862283,1862783,1862805,1863196,1863222,1863384
Modified: jackrabbit/branches/2.18/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.18/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java?rev=1865913&r1=1865912&r2=1865913&view=diff
==============================================================================
--- jackrabbit/branches/2.18/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java (original)
+++ jackrabbit/branches/2.18/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java Mon Aug 26 08:14:31 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.18/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.18/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java?rev=1865913&r1=1865912&r2=1865913&view=diff
==============================================================================
--- jackrabbit/branches/2.18/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java (original)
+++ jackrabbit/branches/2.18/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java Mon Aug 26 08:14:31 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.18/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.18/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml?rev=1865913&r1=1865912&r2=1865913&view=diff
==============================================================================
--- jackrabbit/branches/2.18/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml (original)
+++ jackrabbit/branches/2.18/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml Mon Aug 26 08:14:31 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