use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.
the class IdentityIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext parentResourceContext, Object parentObject, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
int counter = 0;
BaseSecurity secMgr = BaseSecurityManager.getInstance();
List<Long> identityKeys = secMgr.loadVisibleIdentityKeys();
if (isLogDebugEnabled())
logDebug("Found " + identityKeys.size() + " active identities to index");
DBFactory.getInstance().commitAndCloseSession();
for (Long identityKey : identityKeys) {
try {
// reload the identity here before indexing it to make sure it has not been deleted in the meantime
Identity identity = secMgr.loadIdentityByKey(identityKey);
if (identity == null || (identity.getStatus() >= Identity.STATUS_VISIBLE_LIMIT)) {
logInfo("doIndex: identity was deleted while we were indexing. The deleted identity was: " + identity);
continue;
}
if (isLogDebugEnabled())
logDebug("Indexing identity::" + identity.getName() + " and counter::" + counter);
// Create a search context for this identity. The search context will open the users visiting card in a new tab
SearchResourceContext searchResourceContext = new SearchResourceContext(parentResourceContext);
searchResourceContext.setBusinessControlFor(OresHelper.createOLATResourceableInstance(Identity.class, identity.getKey()));
searchResourceContext.setParentContextType(TYPE);
// delegate indexing work to all configured indexers
for (Indexer indexer : getChildIndexers()) {
indexer.doIndex(searchResourceContext, identity, indexWriter);
}
counter++;
} catch (Exception ex) {
logWarn("Exception while indexing identity::" + identityKey + ". Skipping this user, try next one.", ex);
DBFactory.getInstance().rollbackAndCloseSession();
}
DBFactory.getInstance().commitAndCloseSession();
}
if (isLogDebugEnabled())
logDebug("IdentityIndexer finished with counter::" + counter);
}
use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.
the class TaxonomyLevelLibraryIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext parentResourceContext, Object object, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
if (object instanceof TaxonomyLevel) {
TaxonomyLevel level = (TaxonomyLevel) object;
VFSContainer library = taxonomyService.getDocumentsLibrary(level);
if (library != null) {
SearchResourceContext searchResourceContext = new SearchResourceContext(parentResourceContext);
searchResourceContext.setBusinessControlFor(level);
searchResourceContext.setTitle(level.getDisplayName());
searchResourceContext.setDescription(level.getDescription());
searchResourceContext.setLastModified(level.getLastModified());
searchResourceContext.setCreatedDate(level.getCreationDate());
FolderIndexerWorker runnableFolderIndexer = new FolderIndexerWorker();
runnableFolderIndexer.setAccessRule(FolderIndexerAccess.FULL_ACCESS);
runnableFolderIndexer.setParentResourceContext(searchResourceContext);
runnableFolderIndexer.setContainer(library);
runnableFolderIndexer.setIndexWriter(indexerWriter);
runnableFolderIndexer.setFilePath("");
indexerWriter.submit(runnableFolderIndexer);
}
}
}
use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.
the class RepositoryEntryLifeIndexer method fullIndex.
@Override
public void fullIndex(LifeFullIndexer indexWriter) {
SearchResourceContext ctxt = new SearchResourceContext();
IndexWriter writer = null;
try {
writer = indexWriter.getAndLockWriter();
int counter = 0;
List<RepositoryEntry> items;
do {
items = repositoryEntryDAO.getAllRepositoryEntries(counter, BATCH_SIZE);
for (RepositoryEntry item : items) {
Document doc = documentFactory.createDocument(ctxt, item);
indexWriter.addDocument(doc, writer);
}
counter += items.size();
} while (items.size() == BATCH_SIZE);
} catch (Exception e) {
log.error("", e);
} finally {
indexWriter.releaseWriter(writer);
}
}
use of org.olat.search.service.SearchResourceContext in project openolat by klemens.
the class TaxonomyLevelLibraryIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext parentResourceContext, Object object, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
if (object instanceof TaxonomyLevel) {
TaxonomyLevel level = (TaxonomyLevel) object;
VFSContainer library = taxonomyService.getDocumentsLibrary(level);
if (library != null) {
SearchResourceContext searchResourceContext = new SearchResourceContext(parentResourceContext);
searchResourceContext.setBusinessControlFor(level);
searchResourceContext.setTitle(level.getDisplayName());
searchResourceContext.setDescription(level.getDescription());
searchResourceContext.setLastModified(level.getLastModified());
searchResourceContext.setCreatedDate(level.getCreationDate());
FolderIndexerWorker runnableFolderIndexer = new FolderIndexerWorker();
runnableFolderIndexer.setAccessRule(FolderIndexerAccess.FULL_ACCESS);
runnableFolderIndexer.setParentResourceContext(searchResourceContext);
runnableFolderIndexer.setContainer(library);
runnableFolderIndexer.setIndexWriter(indexerWriter);
runnableFolderIndexer.setFilePath("");
indexerWriter.submit(runnableFolderIndexer);
}
}
}
use of org.olat.search.service.SearchResourceContext in project openolat by klemens.
the class TaxonomyTemplatesLibraryIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext parentResourceContext, Object parentObject, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
Taxonomy taxonomy = (Taxonomy) parentObject;
VFSContainer templatesContainer = taxonomyService.getDocumentsLibrary(taxonomy);
if (templatesContainer != null) {
SearchResourceContext searchResourceContext = new SearchResourceContext(parentResourceContext);
OLATResourceable templateOres = OresHelper.createOLATResourceableInstance(getSupportedTypeName(), 0l);
searchResourceContext.setBusinessControlFor(templateOres);
FolderIndexerWorker runnableFolderIndexer = new FolderIndexerWorker();
runnableFolderIndexer.setAccessRule(FolderIndexerAccess.FULL_ACCESS);
runnableFolderIndexer.setParentResourceContext(searchResourceContext);
runnableFolderIndexer.setContainer(templatesContainer);
runnableFolderIndexer.setIndexWriter(indexerWriter);
runnableFolderIndexer.setFilePath("");
indexerWriter.submit(runnableFolderIndexer);
}
}
Aggregations