Search in sources :

Example 1 with Wiki

use of org.olat.modules.wiki.Wiki 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 Wiki

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

the class OlatWikiDataHandler method exists.

/**
 * @see org.jamwiki.DataHandler#exists(java.lang.String, java.lang.String)
 */
public boolean exists(String virtualWiki, String topic) {
    if (!StringUtils.hasText(topic)) {
        return false;
    }
    if (PseudoTopicHandler.isPseudoTopic(topic)) {
        return true;
    }
    if (InterWikiHandler.isInterWiki(topic)) {
        return true;
    }
    // try {
    // Utilities.validateTopicName(topic);
    // } catch (WikiException e) {
    // throw new OLATRuntimeException(this.getClass(), "invalid topic name!", e);
    // }
    Wiki wiki = WikiManager.getInstance().getOrLoadWiki(ores);
    if (topic.startsWith(IMAGE_NAMESPACE) || topic.startsWith(MEDIA_NAMESPACE)) {
        return wiki.pageExists(topic);
    }
    String pageId = WikiManager.generatePageId(FilterUtil.normalizeWikiLink(topic));
    return wiki.pageExists(pageId);
}
Also used : Wiki(org.olat.modules.wiki.Wiki)

Example 3 with Wiki

use of org.olat.modules.wiki.Wiki 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 4 with Wiki

use of org.olat.modules.wiki.Wiki 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 5 with Wiki

use of org.olat.modules.wiki.Wiki 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)

Aggregations

Wiki (org.olat.modules.wiki.Wiki)14 WikiPage (org.olat.modules.wiki.WikiPage)8 Document (org.apache.lucene.document.Document)6 SearchResourceContext (org.olat.search.service.SearchResourceContext)6 WikiPageDocument (org.olat.search.service.document.WikiPageDocument)6 IOException (java.io.IOException)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 BusinessGroup (org.olat.group.BusinessGroup)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Date (java.util.Date)2 Topic (org.jamwiki.model.Topic)2 CollaborationTools (org.olat.collaboration.CollaborationTools)2 AssertException (org.olat.core.logging.AssertException)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 CourseNodeDocument (org.olat.search.service.document.CourseNodeDocument)2