use of org.apache.jackrabbit.core.nodetype.xml.AdditionalNamespaceResolver in project jackrabbit by apache.
the class IndexingConfigurationImpl method init.
/**
* {@inheritDoc}
*/
public void init(Element config, QueryHandlerContext context, NamespaceMappings nsMappings) throws Exception {
configuration = config;
ism = context.getItemStateManager();
hmgr = new HierarchyManagerImpl(context.getRootId(), ism);
NamespaceResolver nsResolver = new AdditionalNamespaceResolver(getNamespaces(config));
resolver = new ParsingNameResolver(NameFactoryImpl.getInstance(), nsResolver);
ntReg = context.getNodeTypeRegistry();
ntReg.addListener(this);
refreshIndexRules();
List<AggregateRule> idxAggregates = new ArrayList<AggregateRule>();
NodeList indexingConfigs = config.getChildNodes();
for (int i = 0; i < indexingConfigs.getLength(); i++) {
Node configNode = indexingConfigs.item(i);
if (configNode.getNodeName().equals("aggregate")) {
idxAggregates.add(new AggregateRuleImpl(configNode, resolver, ism, hmgr));
} else if (configNode.getNodeName().equals("analyzers")) {
NodeList childNodes = configNode.getChildNodes();
for (int j = 0; j < childNodes.getLength(); j++) {
Node analyzerNode = childNodes.item(j);
if (analyzerNode.getNodeName().equals("analyzer")) {
Analyzer analyzer = JackrabbitAnalyzer.getAnalyzerInstance(analyzerNode.getAttributes().getNamedItem("class").getNodeValue());
NodeList propertyChildNodes = analyzerNode.getChildNodes();
for (int k = 0; k < propertyChildNodes.getLength(); k++) {
Node propertyNode = propertyChildNodes.item(k);
if (propertyNode.getNodeName().equals("property")) {
// get property name
Name propName = resolver.getQName(getTextContent(propertyNode));
String fieldName = nsMappings.translateName(propName);
// set analyzer for the fulltext property fieldname
int idx = fieldName.indexOf(':');
fieldName = fieldName.substring(0, idx + 1) + FieldNames.FULLTEXT_PREFIX + fieldName.substring(idx + 1);
Object prevAnalyzer = analyzers.put(fieldName, analyzer);
if (prevAnalyzer != null) {
log.warn("Property " + propName.getLocalName() + " has been configured for multiple analyzers. " + " Last configured analyzer is used");
}
}
}
}
}
}
}
if (idxAggregates.isEmpty()) {
aggregateRules = null;
} else {
aggregateRules = idxAggregates.toArray(new AggregateRule[idxAggregates.size()]);
}
}
Aggregations