Search in sources :

Example 16 with SearchResourceContext

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);
}
Also used : OlatFullIndexer(org.olat.search.service.indexer.OlatFullIndexer) Indexer(org.olat.search.service.indexer.Indexer) AbstractHierarchicalIndexer(org.olat.search.service.indexer.AbstractHierarchicalIndexer) SearchResourceContext(org.olat.search.service.SearchResourceContext) Identity(org.olat.core.id.Identity) IOException(java.io.IOException) BaseSecurity(org.olat.basesecurity.BaseSecurity)

Example 17 with SearchResourceContext

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);
        }
    }
}
Also used : SearchResourceContext(org.olat.search.service.SearchResourceContext) FolderIndexerWorker(org.olat.search.service.indexer.FolderIndexerWorker) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) VFSContainer(org.olat.core.util.vfs.VFSContainer)

Example 18 with SearchResourceContext

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);
    }
}
Also used : SearchResourceContext(org.olat.search.service.SearchResourceContext) IndexWriter(org.apache.lucene.index.IndexWriter) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryDocument(org.olat.search.service.document.RepositoryEntryDocument) Document(org.apache.lucene.document.Document)

Example 19 with SearchResourceContext

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);
        }
    }
}
Also used : SearchResourceContext(org.olat.search.service.SearchResourceContext) FolderIndexerWorker(org.olat.search.service.indexer.FolderIndexerWorker) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) VFSContainer(org.olat.core.util.vfs.VFSContainer)

Example 20 with SearchResourceContext

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);
    }
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) SearchResourceContext(org.olat.search.service.SearchResourceContext) OLATResourceable(org.olat.core.id.OLATResourceable) FolderIndexerWorker(org.olat.search.service.indexer.FolderIndexerWorker) VFSContainer(org.olat.core.util.vfs.VFSContainer)

Aggregations

SearchResourceContext (org.olat.search.service.SearchResourceContext)92 Document (org.apache.lucene.document.Document)60 CourseNodeDocument (org.olat.search.service.document.CourseNodeDocument)32 RepositoryEntry (org.olat.repository.RepositoryEntry)26 IOException (java.io.IOException)18 VFSContainer (org.olat.core.util.vfs.VFSContainer)18 File (java.io.File)12 OLATResourceable (org.olat.core.id.OLATResourceable)12 BusinessGroup (org.olat.group.BusinessGroup)12 AssertException (org.olat.core.logging.AssertException)10 OlatDocument (org.olat.search.model.OlatDocument)10 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)8 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)8 IndexWriter (org.apache.lucene.index.IndexWriter)6 Identity (org.olat.core.id.Identity)6 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)6 VFSItem (org.olat.core.util.vfs.VFSItem)6 OLATResource (org.olat.resource.OLATResource)6 InfoMessageDocument (org.olat.search.service.document.InfoMessageDocument)6 PortfolioMapDocument (org.olat.search.service.document.PortfolioMapDocument)6