Search in sources :

Example 1 with WikiPage

use of org.olat.modules.wiki.WikiPage in project OpenOLAT by OpenOLAT.

the class GroupWikiIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext parentResourceContext, Object businessObj, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    if (!(businessObj instanceof BusinessGroup))
        throw new AssertException("businessObj must be BusinessGroup");
    BusinessGroup businessGroup = (BusinessGroup) businessObj;
    // Index Group Wiki
    if (isLogDebugEnabled())
        logDebug("Analyse Wiki for Group=" + businessGroup);
    CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(businessGroup);
    if (collabTools.isToolEnabled(CollaborationTools.TOOL_WIKI)) {
        try {
            Wiki wiki = WikiManager.getInstance().getOrLoadWiki(businessGroup);
            // loop over all wiki pages
            List<WikiPage> wikiPageList = wiki.getAllPagesWithContent();
            for (WikiPage wikiPage : wikiPageList) {
                SearchResourceContext wikiResourceContext = new SearchResourceContext(parentResourceContext);
                wikiResourceContext.setBusinessControlFor(BusinessGroupMainRunController.ORES_TOOLWIKI);
                wikiResourceContext.setDocumentType(TYPE);
                wikiResourceContext.setFilePath(wikiPage.getPageName());
                Document document = WikiPageDocument.createDocument(wikiResourceContext, wikiPage);
                indexWriter.addDocument(document);
            }
        } catch (NullPointerException nex) {
            logWarn("NullPointerException in GroupWikiIndexer.doIndex.", nex);
        }
    } else {
        if (isLogDebugEnabled())
            logDebug("Group=" + businessGroup + " has no Wiki.");
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) BusinessGroup(org.olat.group.BusinessGroup) SearchResourceContext(org.olat.search.service.SearchResourceContext) WikiPage(org.olat.modules.wiki.WikiPage) CollaborationTools(org.olat.collaboration.CollaborationTools) Wiki(org.olat.modules.wiki.Wiki) WikiPageDocument(org.olat.search.service.document.WikiPageDocument) Document(org.apache.lucene.document.Document)

Example 2 with WikiPage

use of org.olat.modules.wiki.WikiPage in project OpenOLAT by OpenOLAT.

the class WikiRepositoryIndexer method doIndex.

/**
 * @see org.olat.repository.handlers.RepositoryHandler#supportsDownload()
 */
@Override
public void doIndex(SearchResourceContext resourceContext, Object parentObject, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    RepositoryEntry repositoryEntry = (RepositoryEntry) parentObject;
    if (isLogDebugEnabled())
        logDebug("Analyse Wiki RepositoryEntry...");
    String repoEntryName = "*name not available*";
    try {
        repoEntryName = repositoryEntry.getDisplayname();
        Wiki wiki = WikiManager.getInstance().getOrLoadWiki(repositoryEntry.getOlatResource());
        // loop over all wiki pages
        List<WikiPage> wikiPageList = wiki.getAllPagesWithContent();
        for (WikiPage wikiPage : wikiPageList) {
            try {
                SearchResourceContext wikiContext = new SearchResourceContext(resourceContext);
                wikiContext.setDocumentType(TYPE);
                wikiContext.setFilePath(wikiPage.getPageName());
                Document document = WikiPageDocument.createDocument(wikiContext, wikiPage);
                indexWriter.addDocument(document);
            } catch (Exception e) {
                logError("Error indexing wiki page:" + repoEntryName + " " + (wikiPage == null ? "null" : wikiPage.getPageName()), e);
            }
        }
    } catch (Exception e) {
        logError("Error indexing wiki:" + repoEntryName, e);
    }
}
Also used : SearchResourceContext(org.olat.search.service.SearchResourceContext) WikiPage(org.olat.modules.wiki.WikiPage) Wiki(org.olat.modules.wiki.Wiki) RepositoryEntry(org.olat.repository.RepositoryEntry) Document(org.apache.lucene.document.Document) WikiPageDocument(org.olat.search.service.document.WikiPageDocument) IOException(java.io.IOException)

Example 3 with WikiPage

use of org.olat.modules.wiki.WikiPage in project openolat by klemens.

the class GroupWikiIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext parentResourceContext, Object businessObj, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    if (!(businessObj instanceof BusinessGroup))
        throw new AssertException("businessObj must be BusinessGroup");
    BusinessGroup businessGroup = (BusinessGroup) businessObj;
    // Index Group Wiki
    if (isLogDebugEnabled())
        logDebug("Analyse Wiki for Group=" + businessGroup);
    CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(businessGroup);
    if (collabTools.isToolEnabled(CollaborationTools.TOOL_WIKI)) {
        try {
            Wiki wiki = WikiManager.getInstance().getOrLoadWiki(businessGroup);
            // loop over all wiki pages
            List<WikiPage> wikiPageList = wiki.getAllPagesWithContent();
            for (WikiPage wikiPage : wikiPageList) {
                SearchResourceContext wikiResourceContext = new SearchResourceContext(parentResourceContext);
                wikiResourceContext.setBusinessControlFor(BusinessGroupMainRunController.ORES_TOOLWIKI);
                wikiResourceContext.setDocumentType(TYPE);
                wikiResourceContext.setFilePath(wikiPage.getPageName());
                Document document = WikiPageDocument.createDocument(wikiResourceContext, wikiPage);
                indexWriter.addDocument(document);
            }
        } catch (NullPointerException nex) {
            logWarn("NullPointerException in GroupWikiIndexer.doIndex.", nex);
        }
    } else {
        if (isLogDebugEnabled())
            logDebug("Group=" + businessGroup + " has no Wiki.");
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) BusinessGroup(org.olat.group.BusinessGroup) SearchResourceContext(org.olat.search.service.SearchResourceContext) WikiPage(org.olat.modules.wiki.WikiPage) CollaborationTools(org.olat.collaboration.CollaborationTools) Wiki(org.olat.modules.wiki.Wiki) WikiPageDocument(org.olat.search.service.document.WikiPageDocument) Document(org.apache.lucene.document.Document)

Example 4 with WikiPage

use of org.olat.modules.wiki.WikiPage in project openolat by klemens.

the class WikiRepositoryIndexer method doIndex.

/**
 * @see org.olat.repository.handlers.RepositoryHandler#supportsDownload()
 */
@Override
public void doIndex(SearchResourceContext resourceContext, Object parentObject, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    RepositoryEntry repositoryEntry = (RepositoryEntry) parentObject;
    if (isLogDebugEnabled())
        logDebug("Analyse Wiki RepositoryEntry...");
    String repoEntryName = "*name not available*";
    try {
        repoEntryName = repositoryEntry.getDisplayname();
        Wiki wiki = WikiManager.getInstance().getOrLoadWiki(repositoryEntry.getOlatResource());
        // loop over all wiki pages
        List<WikiPage> wikiPageList = wiki.getAllPagesWithContent();
        for (WikiPage wikiPage : wikiPageList) {
            try {
                SearchResourceContext wikiContext = new SearchResourceContext(resourceContext);
                wikiContext.setDocumentType(TYPE);
                wikiContext.setFilePath(wikiPage.getPageName());
                Document document = WikiPageDocument.createDocument(wikiContext, wikiPage);
                indexWriter.addDocument(document);
            } catch (Exception e) {
                logError("Error indexing wiki page:" + repoEntryName + " " + (wikiPage == null ? "null" : wikiPage.getPageName()), e);
            }
        }
    } catch (Exception e) {
        logError("Error indexing wiki:" + repoEntryName, e);
    }
}
Also used : SearchResourceContext(org.olat.search.service.SearchResourceContext) WikiPage(org.olat.modules.wiki.WikiPage) Wiki(org.olat.modules.wiki.Wiki) RepositoryEntry(org.olat.repository.RepositoryEntry) Document(org.apache.lucene.document.Document) WikiPageDocument(org.olat.search.service.document.WikiPageDocument) IOException(java.io.IOException)

Example 5 with WikiPage

use of org.olat.modules.wiki.WikiPage in project openolat by klemens.

the class WikiArtefactHandler method prefillArtefactAccordingToSource.

/**
 * @see org.olat.portfolio.EPAbstractHandler#prefillArtefactAccordingToSource(org.olat.portfolio.model.artefacts.AbstractArtefact, java.lang.Object)
 */
@Override
public void prefillArtefactAccordingToSource(AbstractArtefact artefact, Object source) {
    super.prefillArtefactAccordingToSource(artefact, source);
    WikiPage page = null;
    OLATResourceable ores = null;
    if (source instanceof OLATResourceable) {
        ores = (OLATResourceable) source;
        // fxdiff: FXOLAT-148 a wiki from a businessgroup needs to be wrapped accordingly!
        if (artefact.getBusinessPath().contains(BusinessGroup.class.getSimpleName())) {
            ores = OresHelper.createOLATResourceableInstance(BusinessGroup.class, ores.getResourceableId());
        }
        Wiki wiki = WikiManager.getInstance().getOrLoadWiki(ores);
        String pageName = getPageName(artefact.getBusinessPath());
        page = wiki.getPage(pageName, true);
    } else if (source instanceof WikiPage) {
        page = (WikiPage) source;
    }
    if (page != null) {
        artefact.setSource(getSourceInfo(artefact.getBusinessPath(), ores));
        artefact.setTitle(page.getPageName());
        artefact.setFulltextContent(page.getContent());
        artefact.setSignature(70);
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) BusinessGroup(org.olat.group.BusinessGroup) WikiPage(org.olat.modules.wiki.WikiPage) Wiki(org.olat.modules.wiki.Wiki)

Aggregations

WikiPage (org.olat.modules.wiki.WikiPage)12 Wiki (org.olat.modules.wiki.Wiki)8 Document (org.apache.lucene.document.Document)6 SearchResourceContext (org.olat.search.service.SearchResourceContext)6 WikiPageDocument (org.olat.search.service.document.WikiPageDocument)6 BusinessGroup (org.olat.group.BusinessGroup)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 IOException (java.io.IOException)2 CollaborationTools (org.olat.collaboration.CollaborationTools)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 AssertException (org.olat.core.logging.AssertException)2 Media (org.olat.modules.portfolio.Media)2 MediaInformations (org.olat.modules.portfolio.MediaInformations)2 CourseNodeDocument (org.olat.search.service.document.CourseNodeDocument)2