Search in sources :

Example 11 with WikiPage

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

the class WikiMediaHandler method createMedia.

@Override
public Media createMedia(String title, String description, Object mediaObject, String businessPath, Identity author) {
    String content = null;
    if (mediaObject instanceof WikiPage) {
        WikiPage page = (WikiPage) mediaObject;
        content = page.getContent();
    }
    Media media = mediaDao.createMedia(title, description, content, WIKI_HANDLER, businessPath, null, 70, author);
    ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(), LoggingResourceable.wrap(media));
    return media;
}
Also used : WikiPage(org.olat.modules.wiki.WikiPage) Media(org.olat.modules.portfolio.Media)

Example 12 with WikiPage

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

the class WikiCourseNodeIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) {
    String repoEntryName = "*name not available*";
    try {
        SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, TYPE);
        Document nodeDocument = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
        indexWriter.addDocument(nodeDocument);
        RepositoryEntry repositoryEntry = courseNode.getReferencedRepositoryEntry();
        if (repositoryEntry == null)
            return;
        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 {
                courseNodeResourceContext.setFilePath(wikiPage.getPageName());
                Document document = WikiPageDocument.createDocument(courseNodeResourceContext, wikiPage);
                indexWriter.addDocument(document);
            } catch (Exception e) {
                log.error("Error indexing wiki page:" + (wikiPage == null ? "null" : wikiPage.getPageName()), e);
            }
        }
    } catch (Exception e) {
        log.error("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) WikiPageDocument(org.olat.search.service.document.WikiPageDocument) Document(org.apache.lucene.document.Document) CourseNodeDocument(org.olat.search.service.document.CourseNodeDocument)

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