@Override
protected ContentRepositoryIndex loadIndex() throws IOException,
ContentRepositoryException {
logger.debug("Trying to load site index");
ContentRepositoryIndex idx = null;
logger.debug("Loading site index '{}'", site.getIdentifier());
// Add content if there is any
idx = new ContentRepositoryIndex(site, searchIndex);
// Create the idx if there is nothing in place so far
if (idx.getResourceCount() <= 0) {
logger.info("Index of '{}' is empty, triggering reindex", site.getIdentifier());
buildIndex(idx);
}
// Make sure the version matches the implementation
else if (idx.getIndexVersion() < SearchIndex.INDEX_VERSION) {
logger.info("Index of '{}' needs to be updated, triggering reindex", site.getIdentifier());
buildIndex(idx);
} else if (idx.getIndexVersion() != SearchIndex.INDEX_VERSION) {
logger.warn("Index '{}' needs to be downgraded, triggering reindex", site.getIdentifier());
buildIndex(idx);
}
// Is there an existing idex?
long resourceCount = idx.getResourceCount();
long resourceVersionCount = idx.getRevisionCount();
logger.info("Loaded site idx with {} resources and {} revisions", resourceCount, resourceVersionCount - resourceCount);
return idx;
}