Search in sources :

Example 96 with Feed

use of org.olat.modules.webFeed.Feed in project openolat by klemens.

the class ItemsController method displayItemController.

/**
 * Displays the item in the mainPanel of this controller.
 *
 * @param ureq
 * @param item
 */
private ItemController displayItemController(UserRequest ureq, Item item) {
    removeAsListenerAndDispose(itemCtr);
    Link editButton = getButtonByUserObject(item, editButtons);
    Link deleteButton = getButtonByUserObject(item, deleteButtons);
    Controller artefactLink = getArtefactLinkByUserObject(item);
    Feed feed = feedManager.loadFeed(feedResource);
    item = feedManager.loadItem(item.getKey());
    if (item != null) {
        itemCtr = new ItemController(ureq, getWindowControl(), item, feed, helper, uiFactory, callback, editButton, deleteButton, artefactLink, displayConfig);
        listenTo(itemCtr);
        mainPanel.setContent(itemCtr.getInitialComponent());
    }
    return itemCtr;
}
Also used : UserCommentsAndRatingsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsAndRatingsController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController) BasicController(org.olat.core.gui.control.controller.BasicController) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) YearNavigationController(org.olat.core.commons.controllers.navigation.YearNavigationController) Controller(org.olat.core.gui.control.Controller) Link(org.olat.core.gui.components.link.Link) Feed(org.olat.modules.webFeed.Feed)

Example 97 with Feed

use of org.olat.modules.webFeed.Feed in project openolat by klemens.

the class FeedCourseNodeIndexer method doIndex.

/**
 * @see org.olat.search.service.indexer.Indexer#doIndex(org.olat.search.service.SearchResourceContext,
 *      java.lang.Object, org.olat.search.service.indexer.OlatFullIndexer)
 */
@Override
public void doIndex(SearchResourceContext courseResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexer) throws IOException, InterruptedException {
    SearchResourceContext courseNodeResourceContext = createSearchResourceContext(courseResourceContext, courseNode, getDocumentType());
    Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
    indexer.addDocument(document);
    RepositoryEntry repositoryEntry = courseNode.getReferencedRepositoryEntry();
    if (repositoryEntry != null) {
        // used for log messages
        String repoEntryName = "*name not available*";
        try {
            repoEntryName = repositoryEntry.getDisplayname();
            if (log.isDebug()) {
                log.info("Indexing: " + repoEntryName);
            }
            Feed feed = FeedManager.getInstance().loadFeed(repositoryEntry.getOlatResource());
            List<Item> publishedItems = FeedManager.getInstance().loadPublishedItems(feed);
            // Create the olatDocument for the feed course node itself
            OlatDocument feedNodeDoc = new FeedNodeDocument(feed, courseNodeResourceContext);
            indexer.addDocument(feedNodeDoc.getLuceneDocument());
            // Only index items. FeedImpl itself is indexed by RepositoryEntryIndexer.
            for (Item item : publishedItems) {
                OlatDocument itemDoc = new FeedItemDocument(item, courseNodeResourceContext);
                indexer.addDocument(itemDoc.getLuceneDocument());
            }
        } catch (NullPointerException e) {
            log.error("Error indexing feed:" + repoEntryName, e);
        }
    }
}
Also used : Item(org.olat.modules.webFeed.Item) OlatDocument(org.olat.search.model.OlatDocument) FeedItemDocument(org.olat.modules.webFeed.search.document.FeedItemDocument) SearchResourceContext(org.olat.search.service.SearchResourceContext) FeedNodeDocument(org.olat.modules.webFeed.search.document.FeedNodeDocument) RepositoryEntry(org.olat.repository.RepositoryEntry) FeedNodeDocument(org.olat.modules.webFeed.search.document.FeedNodeDocument) Document(org.apache.lucene.document.Document) OlatDocument(org.olat.search.model.OlatDocument) FeedItemDocument(org.olat.modules.webFeed.search.document.FeedItemDocument) CourseNodeDocument(org.olat.search.service.document.CourseNodeDocument) Feed(org.olat.modules.webFeed.Feed)

Example 98 with Feed

use of org.olat.modules.webFeed.Feed in project openolat by klemens.

the class FeedRepositoryIndexer method doIndex.

/**
 * @see org.olat.search.service.indexer.Indexer#doIndex(org.olat.search.service.SearchResourceContext,
 *      java.lang.Object, org.olat.search.service.indexer.OlatFullIndexer)
 */
@Override
public void doIndex(SearchResourceContext searchResourceContext, Object parentObject, OlatFullIndexer indexer) throws IOException, InterruptedException {
    RepositoryEntry repositoryEntry = (RepositoryEntry) parentObject;
    // used for log messages
    String repoEntryName = "*name not available*";
    try {
        repoEntryName = repositoryEntry.getDisplayname();
        if (isLogDebugEnabled()) {
            logDebug("Indexing: " + repoEntryName);
        }
        Feed feed = FeedManager.getInstance().loadFeed(repositoryEntry.getOlatResource());
        if (feed != null) {
            // Only index items. Feed itself is indexed by RepositoryEntryIndexer.
            List<Item> publishedItems = FeedManager.getInstance().loadPublishedItems(feed);
            if (isLogDebugEnabled()) {
                logDebug("PublishedItems size=" + publishedItems.size());
            }
            for (Item item : publishedItems) {
                SearchResourceContext feedContext = new SearchResourceContext(searchResourceContext);
                feedContext.setDocumentType(getDocumentType());
                OlatDocument itemDoc = new FeedItemDocument(item, feedContext);
                indexer.addDocument(itemDoc.getLuceneDocument());
            }
        }
    } catch (NullPointerException e) {
        logError("Error indexing feed:" + repoEntryName, e);
    }
}
Also used : Item(org.olat.modules.webFeed.Item) OlatDocument(org.olat.search.model.OlatDocument) FeedItemDocument(org.olat.modules.webFeed.search.document.FeedItemDocument) SearchResourceContext(org.olat.search.service.SearchResourceContext) RepositoryEntry(org.olat.repository.RepositoryEntry) Feed(org.olat.modules.webFeed.Feed)

Example 99 with Feed

use of org.olat.modules.webFeed.Feed in project openolat by klemens.

the class FeedFileResource method evaluate.

public static ResourceEvaluation evaluate(File file, String filename, String type) {
    ResourceEvaluation eval = new ResourceEvaluation();
    try {
        IndexFileFilter visitor = new IndexFileFilter();
        Path fPath = PathUtils.visit(file, filename, visitor);
        if (visitor.isValid()) {
            Feed feed = FeedManager.getInstance().loadFeedFromXML(fPath);
            if (feed != null && type.equals(feed.getResourceableTypeName())) {
                eval.setValid(true);
                eval.setDisplayname(feed.getTitle());
                eval.setDescription(feed.getDescription());
            }
        }
        PathUtils.closeSubsequentFS(fPath);
    } catch (IOException | IllegalArgumentException e) {
        log.error("", e);
    }
    return eval;
}
Also used : Path(java.nio.file.Path) IOException(java.io.IOException) Feed(org.olat.modules.webFeed.Feed)

Example 100 with Feed

use of org.olat.modules.webFeed.Feed in project OpenOLAT by OpenOLAT.

the class FeedDAOTest method removeFeed.

@Test
public void removeFeed() {
    // store 3 feeds
    OLATResource resource1 = JunitTestHelper.createRandomResource();
    OLATResource resource2 = JunitTestHelper.createRandomResource();
    OLATResource resource3 = JunitTestHelper.createRandomResource();
    Feed feed1 = feedDao.createFeedForResourcable(resource1);
    Feed feed2 = feedDao.createFeedForResourcable(resource2);
    Feed feed3 = feedDao.createFeedForResourcable(resource3);
    dbInstance.commitAndCloseSession();
    // delete 1 feed
    feedDao.removeFeedForResourceable(feed2);
    dbInstance.commitAndCloseSession();
    // check if one feed is deleted and two feeds are still in the database
    Feed reloaded1 = feedDao.loadFeed(feed1.getKey());
    Assert.assertNotNull(reloaded1);
    Feed reloaded2 = feedDao.loadFeed(feed2.getKey());
    Assert.assertNull(reloaded2);
    Feed reloaded3 = feedDao.loadFeed(feed3.getKey());
    Assert.assertNotNull(reloaded3);
}
Also used : OLATResource(org.olat.resource.OLATResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Aggregations

Feed (org.olat.modules.webFeed.Feed)216 Test (org.junit.Test)162 Item (org.olat.modules.webFeed.Item)98 FeedImpl (org.olat.modules.webFeed.model.FeedImpl)76 OLATResource (org.olat.resource.OLATResource)72 BlogFileResource (org.olat.fileresource.types.BlogFileResource)60 ItemImpl (org.olat.modules.webFeed.model.ItemImpl)52 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)36 VFSContainer (org.olat.core.util.vfs.VFSContainer)28 RSSFeed (org.olat.modules.webFeed.RSSFeed)24 Date (java.util.Date)22 RepositoryEntry (org.olat.repository.RepositoryEntry)12 OLATResourceable (org.olat.core.id.OLATResourceable)8 Path (java.nio.file.Path)6 LocalDate (java.time.LocalDate)6 VFSItem (org.olat.core.util.vfs.VFSItem)6 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)6 FeedItemDocument (org.olat.modules.webFeed.search.document.FeedItemDocument)6 OlatDocument (org.olat.search.model.OlatDocument)6 IOException (java.io.IOException)4