Search in sources :

Example 6 with FileDocumentFactory

use of org.olat.search.service.document.file.FileDocumentFactory in project openolat by klemens.

the class LeafIndexer method doIndexVFSLeafByMySelf.

protected void doIndexVFSLeafByMySelf(SearchResourceContext leafResourceContext, VFSLeaf leaf, OlatFullIndexer indexWriter, String filePath) throws InterruptedException {
    if (isLogDebugEnabled())
        logDebug("Analyse VFSLeaf=" + leaf.getName());
    try {
        FileDocumentFactory documentFactory = CoreSpringFactory.getImpl(FileDocumentFactory.class);
        if (documentFactory.isFileSupported(leaf)) {
            String myFilePath = "";
            if (filePath.endsWith("/")) {
                myFilePath = filePath + leaf.getName();
            } else {
                myFilePath = filePath + "/" + leaf.getName();
            }
            leafResourceContext.setFilePath(myFilePath);
            Document document = documentFactory.createDocument(leafResourceContext, leaf);
            indexWriter.addDocument(document);
        } else {
            if (isLogDebugEnabled())
                logDebug("Documenttype not supported. file=" + leaf.getName());
        }
    } catch (DocumentAccessException e) {
        if (isLogDebugEnabled())
            logDebug("Can not access document." + e.getMessage());
    } catch (IOException ioEx) {
        logWarn("IOException: Can not index leaf=" + leaf.getName(), ioEx);
    } catch (InterruptedException iex) {
        throw new InterruptedException(iex.getMessage());
    } catch (Exception ex) {
        logWarn("Exception: Can not index leaf=" + leaf.getName(), ex);
    }
}
Also used : IOException(java.io.IOException) Document(org.apache.lucene.document.Document) FileDocumentFactory(org.olat.search.service.document.file.FileDocumentFactory) IOException(java.io.IOException) DocumentAccessException(org.olat.search.service.document.file.DocumentAccessException) DocumentAccessException(org.olat.search.service.document.file.DocumentAccessException)

Aggregations

Document (org.apache.lucene.document.Document)6 FileDocumentFactory (org.olat.search.service.document.file.FileDocumentFactory)6 IOException (java.io.IOException)4 VFSItem (org.olat.core.util.vfs.VFSItem)4 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)4 AbstractOlatDocument (org.olat.search.model.AbstractOlatDocument)4 DocumentAccessException (org.olat.search.service.document.file.DocumentAccessException)4 IndexableField (org.apache.lucene.index.IndexableField)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 SearchResourceContext (org.olat.search.service.SearchResourceContext)2