### Eclipse Workspace Patch 1.0
#P jackrabbit-core
Index: src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
===================================================================
--- src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java (revision 1836620)
+++ src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java (working copy)
@@ -41,6 +41,7 @@
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 @@
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));
}
Index: src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java (revision 1836620)
+++ src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java (working copy)
@@ -389,17 +389,20 @@
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,14 +814,14 @@
}
/**
- * Returns true if this rule applies to the given node
- * state.
+ * Returns true if the nodetype of this rule
+ * applies to the given node state.
*
* @param state the state to check.
* @return true the rule applies to the given node;
* false otherwise.
*/
- public boolean appliesTo(NodeState state) {
+ public boolean appliesToNodeType(NodeState state) {
if (state.getMixinTypeNames().contains(nodeTypeName)) {
return true;
}
@@ -825,9 +828,31 @@
if (!nodeTypeName.equals(state.getNodeTypeName())) {
return false;
}
- return condition == null || condition.evaluate(state);
+ return true;
}
+
+ /**
+ * Returns true if the condition of this rule
+ * applies to the given node state.
+ *
+ * @param state the state to check.
+ * @return true the rule applies to the given node;
+ * false otherwise.
+ */
+ public boolean appliesToCondition(NodeState state) {
+ return condition != null && condition.evaluate(state);
+ }
+ /**
+ * Returns true this rule contains a condition.
+ *
+ * @return true the rule contains a condition;
+ * false otherwise.
+ */
+ public boolean containsCondition() {
+ return condition != null;
+ }
+
//-------------------------< internal >---------------------------------
/**
Index: src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml
===================================================================
--- src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml (revision 1836620)
+++ src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml (working copy)
@@ -19,7 +19,12 @@
+
+ other
+
+
+ foo
\ No newline at end of file