* is not met, a <code>IOException</code> is thrown.
*
* @throws IOException if an error occurs while initializing this handler.
*/
protected void doInit() throws IOException {
QueryHandlerContext context = getContext();
if (path == null) {
throw new IOException("SearchIndex requires 'path' parameter in configuration!");
}
Set<NodeId> excludedIDs = new HashSet<NodeId>();
if (context.getExcludedNodeId() != null) {
excludedIDs.add(context.getExcludedNodeId());
}
extractor = createTextExtractor();
synProvider = createSynonymProvider();
directoryManager = createDirectoryManager();
if (context.getParentHandler() instanceof SearchIndex) {
// use system namespace mappings
SearchIndex sysIndex = (SearchIndex) context.getParentHandler();
nsMappings = sysIndex.getNamespaceMappings();
} else {
// read local namespace mappings
File mapFile = new File(new File(path), NS_MAPPING_FILE);
if (mapFile.exists()) {
// be backward compatible and use ns_mappings.properties from
// index folder
nsMappings = new FileBasedNamespaceMappings(mapFile);
} else {
// otherwise use repository wide stable index prefix from
// namespace registry
nsMappings = new NSRegistryBasedNamespaceMappings(
context.getNamespaceRegistry());
}
}
scs = new SharedFieldSortComparator(
FieldNames.PROPERTIES, context.getItemStateManager(),
context.getHierarchyManager(), nsMappings);
indexingConfig = createIndexingConfiguration(nsMappings);
analyzer.setIndexingConfig(indexingConfig);
index = new MultiIndex(this, excludedIDs);
if (index.numDocs() == 0) {
Path rootPath;
if (excludedIDs.isEmpty()) {
// this is the index for jcr:system
rootPath = JCR_SYSTEM_PATH;
} else {
rootPath = ROOT_PATH;
}
index.createInitialIndex(context.getItemStateManager(),
context.getRootId(), rootPath);
}
if (consistencyCheckEnabled
&& (index.getRedoLogApplied() || forceConsistencyCheck)) {
log.info("Running consistency check...");
try {
ConsistencyCheck check = ConsistencyCheck.run(index,
context.getItemStateManager());
if (autoRepair) {
check.repair(true);
} else {
List<ConsistencyCheckError> errors = check.getErrors();
if (errors.size() == 0) {