You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2008/08/04 16:44:15 UTC
svn commit: r682409 - in /jackrabbit/trunk/jackrabbit-core/src:
main/java/org/apache/jackrabbit/core/query/lucene/
test/java/org/apache/jackrabbit/core/query/
test/repository/workspaces/indexing-test/
Author: mreutegg
Date: Mon Aug 4 07:44:14 2008
New Revision: 682409
URL: http://svn.apache.org/viewvc?rev=682409&view=rev
Log:
JCR-1704: Indexing rules inheritance doesn't work
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/IndexingRuleTest.java
jackrabbit/trunk/jackrabbit-core/src/test/repository/workspaces/indexing-test/indexing-configuration.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=682409&r1=682408&r2=682409&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 Mon Aug 4 07:44:14 2008
@@ -126,15 +126,16 @@
if (configNode.getNodeName().equals("index-rule")) {
IndexingRule element = new IndexingRule(configNode);
// register under node type and all its sub types
+ log.debug("Found rule '{}' for NodeType '{}'", element, element.getNodeTypeName());
for (int n = 0; n < ntNames.length; n++) {
- if (ntReg.getEffectiveNodeType(ntNames[n]).includesNodeType(
- element.getNodeTypeName())) {
+ if (ntReg.getEffectiveNodeType(ntNames[n]).includesNodeType(element.getNodeTypeName())) {
List perNtConfig = (List) configElements.get(ntNames[n]);
if (perNtConfig == null) {
perNtConfig = new ArrayList();
configElements.put(ntNames[n], perNtConfig);
}
- perNtConfig.add(element);
+ log.debug("Registering it for name '{}'", ntNames[n]);
+ perNtConfig.add(new IndexingRule(element, ntNames[n]));
}
}
} else if (configNode.getNodeName().equals("aggregate")) {
@@ -578,12 +579,12 @@
/**
* Map of {@link PropertyConfig}. Key=Name of property.
*/
- private final Map propConfigs = new HashMap();
+ private final Map propConfigs;
/**
* List of {@link NamePattern}s.
*/
- private final List namePatterns = new ArrayList();
+ private final List namePatterns;
/**
* An expression based on a relative path.
@@ -596,6 +597,21 @@
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.
+ */
+ IndexingRule(IndexingRule original, Name nodeTypeName) {
+ this.nodeTypeName = nodeTypeName;
+ this.propConfigs = original.propConfigs;
+ this.namePatterns = original.namePatterns;
+ this.condition = original.condition;
+ this.boost = original.boost;
+ }
+
+ /**
*
* @param config the configuration for this rule.
* @throws MalformedPathException if the condition expression is malformed.
@@ -607,6 +623,8 @@
this.nodeTypeName = getNodeTypeName(config);
this.condition = getCondition(config);
this.boost = getNodeBoost(config);
+ this.propConfigs = new HashMap();
+ this.namePatterns = new ArrayList();
createPropertyConfigs(config, propConfigs, namePatterns);
}
Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexingRuleTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexingRuleTest.java?rev=682409&r1=682408&r2=682409&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexingRuleTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexingRuleTest.java Mon Aug 4 07:44:14 2008
@@ -82,4 +82,15 @@
"/*[jcr:contains(., 'quick')]";
checkResult(executeQuery(stmt), new Node[]{node1});
}
+
+ public void testNodeType() throws RepositoryException {
+ // assumes there is an index-rule for nt:hierarchyNode that
+ // does not include the property jcr:created
+ Node node1 = testRootNode.addNode(nodeName1, "nt:folder");
+ testRootNode.save();
+ String stmt = "/jcr:root" + testRootNode.getPath() +
+ "/*[@" + jcrCreated + " = xs:dateTime('" +
+ node1.getProperty(jcrCreated).getString() + "')]";
+ checkResult(executeQuery(stmt), new Node[]{});
+ }
}
Modified: jackrabbit/trunk/jackrabbit-core/src/test/repository/workspaces/indexing-test/indexing-configuration.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/repository/workspaces/indexing-test/indexing-configuration.xml?rev=682409&r1=682408&r2=682409&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/repository/workspaces/indexing-test/indexing-configuration.xml (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/repository/workspaces/indexing-test/indexing-configuration.xml Mon Aug 4 07:44:14 2008
@@ -32,6 +32,10 @@
<property isRegexp="true">.*Text</property>
</index-rule>
+ <index-rule nodeType="nt:hierarchyNode">
+ <!-- do not index any properties -->
+ </index-rule>
+
<aggregate primaryType="nt:file">
<include>jcr:content</include>
<include>jcr:content/*</include>