### 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 1776413)
+++ src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java (working copy)
@@ -43,12 +43,14 @@
private static final Name FOO = NameFactoryImpl.getInstance().create("", "foo");
private NodeState nState;
+ private Node n;
@Override
protected void setUp() throws Exception {
super.setUp();
- Node n = testRootNode.addNode(nodeName1, ntUnstructured);
+ n = testRootNode.addNode(nodeName1, ntUnstructured);
n.addMixin(mixReferenceable);
+ n.addMixin(mixTitle);
session.save();
nState = (NodeState) getSearchIndex().getContext().getItemStateManager().getItemState(
new NodeId(n.getIdentifier()));
@@ -97,6 +99,13 @@
assertFalse(config.isIncludedInNodeScopeIndex(state, FOO));
}
+ public void testIndexRuleMixin() throws Exception{
+ IndexingConfiguration config = createConfig("config5");
+ assertTrue(config.isIndexed(nState, NameConstants.JCR_TITLE));
+ assertFalse(config.isIndexed(nState, NameConstants.JCR_DESCRIPTION));
+ assertTrue(config.isIndexed(nState, NameConstants.JCR_UUID)); // from mixReferenceable ... should be indexed
+ }
+
//----------------------------< internal >----------------------------------
protected IndexingConfiguration createConfig(String name) throws Exception {
IndexingConfiguration config = new IndexingConfigurationImpl();
Index: src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java (revision 1776407)
+++ src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java (working copy)
@@ -28,6 +28,7 @@
import javax.jcr.NamespaceException;
import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
import org.apache.commons.collections.iterators.AbstractIteratorDecorator;
import org.apache.jackrabbit.core.HierarchyManager;
@@ -46,6 +47,8 @@
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.Path;
import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;
import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
import org.apache.jackrabbit.spi.commons.conversion.NameResolver;
@@ -212,7 +215,7 @@
* false otherwise.
*/
public boolean isIndexed(NodeState state, Name propertyName) {
- IndexingRule rule = getApplicableIndexingRule(state);
+ IndexingRule rule = getApplicableIndexingRule(state, propertyName);
if (rule != null) {
return rule.isIndexed(propertyName);
}
@@ -230,7 +233,7 @@
* @return the boost value for the property.
*/
public float getPropertyBoost(NodeState state, Name propertyName) {
- IndexingRule rule = getApplicableIndexingRule(state);
+ IndexingRule rule = getApplicableIndexingRule(state, propertyName);
if (rule != null) {
return rule.getBoost(propertyName);
}
@@ -244,7 +247,7 @@
* @return the boost for the node scope fulltext index field.
*/
public float getNodeBoost(NodeState state) {
- IndexingRule rule = getApplicableIndexingRule(state);
+ IndexingRule rule = getApplicableIndexingRule(state, null);
if (rule != null) {
return rule.getNodeBoost();
}
@@ -263,7 +266,7 @@
*/
public boolean isIncludedInNodeScopeIndex(NodeState state,
Name propertyName) {
- IndexingRule rule = getApplicableIndexingRule(state);
+ IndexingRule rule = getApplicableIndexingRule(state, propertyName);
if (rule != null) {
return rule.isIncludedInNodeScopeIndex(propertyName);
}
@@ -282,7 +285,7 @@
* included in an excerpt; false otherwise.
*/
public boolean useInExcerpt(NodeState state, Name propertyName) {
- IndexingRule rule = getApplicableIndexingRule(state);
+ IndexingRule rule = getApplicableIndexingRule(state, propertyName);
if (rule != null) {
return rule.useInExcerpt(propertyName);
}
@@ -353,7 +356,7 @@
nt2rules.put(ntName, perNtConfig);
}
log.debug("Registering it for name '{}'", ntName);
- perNtConfig.add(new IndexingRule(element, ntName));
+ perNtConfig.add(new IndexingRule(element, ntReg.getNodeTypeDef(ntName)));
}
}
}
@@ -361,15 +364,15 @@
configElements = nt2rules;
}
-
/**
* Returns the first indexing rule that applies to the given node
* state.
*
* @param state a node state.
+ * @param propertyName the property name to check.
* @return the indexing rule or null if none applies.
*/
- private IndexingRule getApplicableIndexingRule(NodeState state) {
+ private IndexingRule getApplicableIndexingRule(NodeState state, Name propertyName) {
List rules = null;
List r = configElements.get(state.getNodeTypeName());
if (r != null) {
@@ -389,7 +392,7 @@
if (rules != null) {
for (IndexingRule rule : rules) {
- if (rule.appliesTo(state)) {
+ if (rule.appliesTo(state, propertyName)) {
return rule;
}
}
@@ -654,9 +657,9 @@
private class IndexingRule {
/**
- * The node type of this fulltext indexing rule.
+ * The NodeTypeDefinition of this fulltext indexing rule.
*/
- private final Name nodeTypeName;
+ private final QNodeTypeDefinition nodeTypeDefinition;
/**
* Map of {@link PropertyConfig}. Key=Name of property.
@@ -677,16 +680,16 @@
* The boost value for this config element.
*/
private final float boost;
-
+
/**
* Creates a new indexing rule base on an existing one, but for a
* different node type name.
*
* @param original the existing rule.
- * @param nodeTypeName the node type name for the rule.
+ * @param qNodeTypeDefinition the node type for the rule.
*/
- IndexingRule(IndexingRule original, Name nodeTypeName) {
- this.nodeTypeName = nodeTypeName;
+ IndexingRule(IndexingRule original, QNodeTypeDefinition qNodeTypeDefinition) {
+ this.nodeTypeDefinition = qNodeTypeDefinition;
this.propConfigs = original.propConfigs;
this.namePatterns = original.namePatterns;
this.condition = original.condition;
@@ -699,10 +702,11 @@
* @throws MalformedPathException if the condition expression is malformed.
* @throws IllegalNameException if a name contains illegal characters.
* @throws NamespaceException if a name contains an unknown prefix.
+ * @throws NoSuchNodeTypeException if the nodeType could not be evaluated
*/
IndexingRule(Node config)
- throws MalformedPathException, IllegalNameException, NamespaceException {
- this.nodeTypeName = getNodeTypeName(config);
+ throws MalformedPathException, IllegalNameException, NamespaceException, NoSuchNodeTypeException {
+ this.nodeTypeDefinition = getNodeTypeDefinition(config);
this.condition = getCondition(config);
this.boost = getNodeBoost(config);
this.propConfigs = new HashMap();
@@ -716,7 +720,7 @@
* @return name of the node type.
*/
public Name getNodeTypeName() {
- return nodeTypeName;
+ return nodeTypeDefinition.getName();
}
/**
@@ -788,10 +792,19 @@
* state.
*
* @param state the state to check.
+ * @param propertyName the property name to check.
* @return true the rule applies to the given node;
* false otherwise.
*/
- public boolean appliesTo(NodeState state) {
+ public boolean appliesTo(NodeState state, Name propertyName) {
+ Name nodeTypeName = getNodeTypeName();
+ if (propertyName != null) {
+ for (QPropertyDefinition propertyDefinition : nodeTypeDefinition.getPropertyDefs()) {
+ if (propertyDefinition.getName().equals(propertyName)) {
+ return true;
+ }
+ }
+ }
if (!nodeTypeName.equals(state.getNodeTypeName())) {
return false;
}
@@ -831,11 +844,12 @@
* characters.
* @throws NamespaceException if the node type contains an unknown
* prefix.
+ * @throws NoSuchNodeTypeException if the node type could not be evaluated
*/
- private Name getNodeTypeName(Node config)
- throws IllegalNameException, NamespaceException {
+ private QNodeTypeDefinition getNodeTypeDefinition(Node config)
+ throws IllegalNameException, NamespaceException, NoSuchNodeTypeException {
String ntString = config.getAttributes().getNamedItem("nodeType").getNodeValue();
- return resolver.getQName(ntString);
+ return ntReg.getNodeTypeDef(resolver.getQName(ntString));
}
/**
Index: src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config5.xml
===================================================================
--- src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config5.xml (revision 0)
+++ src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config5.xml (working copy)
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+ jcr:title
+
+
+
+
\ No newline at end of file
Property changes on: src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config5.xml
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property