Search in sources :

Example 1 with ItemImpl

use of org.olat.modules.webFeed.model.ItemImpl in project OpenOLAT by OpenOLAT.

the class BlogArtefactHandler method getContent.

@Override
protected void getContent(AbstractArtefact artefact, StringBuilder sb, SearchResourceContext context, EPFrontendManager ePFManager) {
    String content = ePFManager.getArtefactFullTextContent(artefact);
    if (content != null) {
        try {
            XStream xstream = XStreamHelper.createXStreamInstance();
            xstream.alias("item", ItemImpl.class);
            ItemImpl item = (ItemImpl) xstream.fromXML(content);
            String mapperBaseURL = "";
            Filter mediaUrlFilter = FilterFactory.getBaseURLToMediaRelativeURLFilter(mapperBaseURL);
            sb.append(mediaUrlFilter.filter(item.getDescription())).append(" ").append(mediaUrlFilter.filter(item.getContent()));
        } catch (Exception e) {
            log.warn("Cannot read an artefact of type blog while indexing", e);
        }
    }
}
Also used : Filter(org.olat.core.util.filter.Filter) XStream(com.thoughtworks.xstream.XStream) ItemImpl(org.olat.modules.webFeed.model.ItemImpl)

Example 2 with ItemImpl

use of org.olat.modules.webFeed.model.ItemImpl in project OpenOLAT by OpenOLAT.

the class ItemDAO method createItem.

/**
 * Create a new Item and connect it with the feed.
 *
 * @param feed
 * @return the created item
 */
public Item createItem(Feed feed) {
    if (feed == null)
        return null;
    Item item = new ItemImpl(feed);
    item.setCreationDate(new Date());
    item.setLastModified(item.getCreationDate());
    dbInstance.getCurrentEntityManager().persist(item);
    return item;
}
Also used : Item(org.olat.modules.webFeed.Item) ItemImpl(org.olat.modules.webFeed.model.ItemImpl) Date(java.util.Date)

Example 3 with ItemImpl

use of org.olat.modules.webFeed.model.ItemImpl in project OpenOLAT by OpenOLAT.

the class RomeFeedFetcher method convertEntry.

/**
 * Converts a <code>SyndEntry</code> into an <code>Item</code>
 *
 * @param entry
 * @return
 */
protected Item convertEntry(Feed feed, SyndEntry entry) {
    Item item = new ItemImpl(feed);
    item.setAuthor(entry.getAuthor());
    item.setExternalLink(entry.getLink());
    item.setGuid(entry.getUri());
    item.setLastModified(entry.getUpdatedDate());
    item.setPublishDate(entry.getPublishedDate());
    item.setTitle(entry.getTitle());
    if (entry.getDescription() != null) {
        item.setDescription(entry.getDescription().getValue());
    }
    List<SyndContent> contents = entry.getContents();
    item.setContent(joinContents(contents));
    List<SyndEnclosure> enclosures = entry.getEnclosures();
    item.setEnclosure(convertEnclosures(enclosures));
    return item;
}
Also used : Item(org.olat.modules.webFeed.Item) SyndContent(com.rometools.rome.feed.synd.SyndContent) ItemImpl(org.olat.modules.webFeed.model.ItemImpl) SyndEnclosure(com.rometools.rome.feed.synd.SyndEnclosure)

Example 4 with ItemImpl

use of org.olat.modules.webFeed.model.ItemImpl in project OpenOLAT by OpenOLAT.

the class FeedFileStorgeTest method saveItemAsXML_overwrite.

@Test
public void saveItemAsXML_overwrite() {
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    Item item = new ItemImpl(feed);
    item.setGuid("123");
    item.setAuthor("autor");
    sut.saveItemAsXML(item);
    item.setAuthor("secondAuthor");
    sut.saveItemAsXML(item);
    // check if there is one file in the item container
    assertThat(sut.getOrCreateItemContainer(item).getItems().size()).isEqualTo(1);
    fileResourceManager.deleteFileResource(resource);
}
Also used : Item(org.olat.modules.webFeed.Item) ItemImpl(org.olat.modules.webFeed.model.ItemImpl) FeedImpl(org.olat.modules.webFeed.model.FeedImpl) BlogFileResource(org.olat.fileresource.types.BlogFileResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 5 with ItemImpl

use of org.olat.modules.webFeed.model.ItemImpl in project OpenOLAT by OpenOLAT.

the class FeedFileStorgeTest method getOrCreateItemMediaContainer_create.

@Test
public void getOrCreateItemMediaContainer_create() {
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    Item item = new ItemImpl(feed);
    item.setGuid("guid");
    VFSContainer itemMediaContainer = sut.getOrCreateItemMediaContainer(item);
    assertThat(itemMediaContainer).isNotNull();
    fileResourceManager.deleteFileResource(resource);
}
Also used : Item(org.olat.modules.webFeed.Item) ItemImpl(org.olat.modules.webFeed.model.ItemImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) FeedImpl(org.olat.modules.webFeed.model.FeedImpl) BlogFileResource(org.olat.fileresource.types.BlogFileResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Aggregations

ItemImpl (org.olat.modules.webFeed.model.ItemImpl)70 Item (org.olat.modules.webFeed.Item)64 Test (org.junit.Test)58 Feed (org.olat.modules.webFeed.Feed)52 BlogFileResource (org.olat.fileresource.types.BlogFileResource)36 FeedImpl (org.olat.modules.webFeed.model.FeedImpl)36 VFSContainer (org.olat.core.util.vfs.VFSContainer)20 OLATResource (org.olat.resource.OLATResource)16 Date (java.util.Date)10 LocalDate (java.time.LocalDate)4 SyndContent (com.rometools.rome.feed.synd.SyndContent)2 SyndEnclosure (com.rometools.rome.feed.synd.SyndEnclosure)2 XStream (com.thoughtworks.xstream.XStream)2 GregorianCalendar (java.util.GregorianCalendar)2 Link (org.olat.core.gui.components.link.Link)2 Identity (org.olat.core.id.Identity)2 Filter (org.olat.core.util.filter.Filter)2