### 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 1780335) +++ src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java (working copy) @@ -106,6 +106,17 @@ assertTrue(config.isIndexed(nState, NameConstants.JCR_UUID)); // from mixReferenceable ... should be indexed } + public void testMatchCondition() throws Exception{ + IndexingConfiguration config = createConfig("config6"); + Node n = testRootNode.addNode(nodeName1, ntUnstructured); + n.addMixin(mixReferenceable); + n.setProperty(FOO.getLocalName(), "high"); + session.save(); + nState = (NodeState) getSearchIndex().getContext().getItemStateManager().getItemState( + new NodeId(n.getIdentifier())); + assertFalse(config.isIndexed(nState, FOO)); + } + //----------------------------< 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 1780335) +++ src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java (working copy) @@ -28,12 +28,12 @@ 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; import org.apache.jackrabbit.core.HierarchyManagerImpl; import org.apache.jackrabbit.core.id.PropertyId; +import org.apache.jackrabbit.core.nodetype.EffectiveNodeType; import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry; import org.apache.jackrabbit.core.nodetype.NodeTypeRegistryListener; import org.apache.jackrabbit.core.nodetype.xml.AdditionalNamespaceResolver; @@ -215,9 +215,9 @@ * false otherwise. */ public boolean isIndexed(NodeState state, Name propertyName) { - IndexingRule rule = getApplicableIndexingRule(state, propertyName); + IndexingRule rule = getApplicableIndexingRule(state); if (rule != null) { - return rule.isIndexed(propertyName); + return rule.isIndexed(state, propertyName); } // none of the configs matches -> index property return true; @@ -233,7 +233,7 @@ * @return the boost value for the property. */ public float getPropertyBoost(NodeState state, Name propertyName) { - IndexingRule rule = getApplicableIndexingRule(state, propertyName); + IndexingRule rule = getApplicableIndexingRule(state); if (rule != null) { return rule.getBoost(propertyName); } @@ -247,7 +247,7 @@ * @return the boost for the node scope fulltext index field. */ public float getNodeBoost(NodeState state) { - IndexingRule rule = getApplicableIndexingRule(state, null); + IndexingRule rule = getApplicableIndexingRule(state); if (rule != null) { return rule.getNodeBoost(); } @@ -266,7 +266,7 @@ */ public boolean isIncludedInNodeScopeIndex(NodeState state, Name propertyName) { - IndexingRule rule = getApplicableIndexingRule(state, propertyName); + IndexingRule rule = getApplicableIndexingRule(state); if (rule != null) { return rule.isIncludedInNodeScopeIndex(propertyName); } @@ -285,7 +285,7 @@ * included in an excerpt; false otherwise. */ public boolean useInExcerpt(NodeState state, Name propertyName) { - IndexingRule rule = getApplicableIndexingRule(state, propertyName); + IndexingRule rule = getApplicableIndexingRule(state); if (rule != null) { return rule.useInExcerpt(propertyName); } @@ -356,7 +356,7 @@ nt2rules.put(ntName, perNtConfig); } log.debug("Registering it for name '{}'", ntName); - perNtConfig.add(new IndexingRule(element, ntReg.getNodeTypeDef(ntName))); + perNtConfig.add(new IndexingRule(element, ntReg.getNodeTypeDef(ntName), ntReg.getEffectiveNodeType(ntName))); } } } @@ -370,10 +370,9 @@ * 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, Name propertyName) { + private IndexingRule getApplicableIndexingRule(NodeState state) { List rules = null; List r = configElements.get(state.getNodeTypeName()); if (r != null) { @@ -393,7 +392,7 @@ if (rules != null) { for (IndexingRule rule : rules) { - if (rule.appliesTo(state, propertyName)) { + if (rule.appliesTo(state)) { return rule; } } @@ -658,11 +657,21 @@ private class IndexingRule { /** - * The NodeTypeDefinition of this fulltext indexing rule. + * The node type of this fulltext indexing rule. */ - private final QNodeTypeDefinition nodeTypeDefinition; + private final Name nodeTypeName; /** + * Indicates if nodetype is a mixin + */ + private boolean mixinNodeType = false; + + /** + * The effective node type of this fulltext indexing rule. + */ + private EffectiveNodeType effectiveNodeType; + + /** * Map of {@link PropertyConfig}. Key=Name of property. */ private final Map propConfigs; @@ -687,10 +696,13 @@ * different node type name. * * @param original the existing rule. - * @param qNodeTypeDefinition the node type for the rule. + * @param nodeTypeDef the node type definition for the rule. + * @param effectiveNodeType the EffectiveNodeType of the rule */ - IndexingRule(IndexingRule original, QNodeTypeDefinition qNodeTypeDefinition) { - this.nodeTypeDefinition = qNodeTypeDefinition; + IndexingRule(IndexingRule original, QNodeTypeDefinition nodeTypeDef, EffectiveNodeType effectiveNodeType) { + this.nodeTypeName = nodeTypeDef.getName(); + this.mixinNodeType = nodeTypeDef.isMixin(); + this.effectiveNodeType = effectiveNodeType; this.propConfigs = original.propConfigs; this.namePatterns = original.namePatterns; this.condition = original.condition; @@ -703,11 +715,10 @@ * @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, NoSuchNodeTypeException { - this.nodeTypeDefinition = getNodeTypeDefinition(config); + throws MalformedPathException, IllegalNameException, NamespaceException { + this.nodeTypeName = getNodeTypeName(config); this.condition = getCondition(config); this.boost = getNodeBoost(config); this.propConfigs = new HashMap(); @@ -721,7 +732,7 @@ * @return name of the node type. */ public Name getNodeTypeName() { - return nodeTypeDefinition.getName(); + return nodeTypeName; } /** @@ -735,12 +746,23 @@ * Returns true if the property with the given name is * indexed according to this rule. * + * @param state the node state. * @param propertyName the name of a property. * @return true if the property is indexed; * false otherwise. */ - public boolean isIndexed(Name propertyName) { - return getConfig(propertyName) != null; + public boolean isIndexed(NodeState state, Name propertyName) { + if (mixinNodeType && effectiveNodeType != null) { + QPropertyDefinition[] allPropDefs = effectiveNodeType.getAllPropDefs(); + for (QPropertyDefinition propertyDefinition : allPropDefs) { + if (propertyDefinition.getName().equals(propertyName)) { + return getConfig(propertyName) != null; + } + } + return true; + } else { + return getConfig(propertyName) != null; + } } /** @@ -793,19 +815,13 @@ * 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, Name propertyName) { - Name nodeTypeName = getNodeTypeName(); - if (propertyName != null) { - for (QPropertyDefinition propertyDefinition : nodeTypeDefinition.getPropertyDefs()) { - if (propertyDefinition.getName().equals(propertyName)) { - return true; - } - } - } + public boolean appliesTo(NodeState state) { + if (state.getMixinTypeNames().contains(nodeTypeName)) { + return true; + } if (!nodeTypeName.equals(state.getNodeTypeName())) { return false; } @@ -845,12 +861,11 @@ * characters. * @throws NamespaceException if the node type contains an unknown * prefix. - * @throws NoSuchNodeTypeException if the node type could not be evaluated */ - private QNodeTypeDefinition getNodeTypeDefinition(Node config) - throws IllegalNameException, NamespaceException, NoSuchNodeTypeException { + private Name getNodeTypeName(Node config) + throws IllegalNameException, NamespaceException { String ntString = config.getAttributes().getNamedItem("nodeType").getNodeValue(); - return ntReg.getNodeTypeDef(resolver.getQName(ntString)); + return resolver.getQName(ntString); } /** 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 (nonexistent) +++ src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml (working copy) @@ -0,0 +1,25 @@ + + + + + + + + + \ No newline at end of file Property changes on: src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config6.xml ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property