Search in sources :

Example 16 with Enclosure

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

the class RomeFeedFetcherTest method convertEnclosures_Url_null.

@Test
public void convertEnclosures_Url_null() {
    when(syndEnclosureMock.getUrl()).thenReturn(null);
    List<SyndEnclosure> enclosures = Arrays.asList(syndEnclosureMock);
    Enclosure enclosure = sut.convertEnclosures(enclosures);
    assertThat(enclosure).isNull();
}
Also used : SyndEnclosure(com.rometools.rome.feed.synd.SyndEnclosure) SyndEnclosure(com.rometools.rome.feed.synd.SyndEnclosure) Enclosure(org.olat.modules.webFeed.Enclosure) Test(org.junit.Test)

Example 17 with Enclosure

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

the class RomeFeedFetcherTest method convertEnclosures_null.

@Test
public void convertEnclosures_null() {
    Enclosure enclosure = sut.convertEnclosures(null);
    assertThat(enclosure).isNull();
}
Also used : SyndEnclosure(com.rometools.rome.feed.synd.SyndEnclosure) Enclosure(org.olat.modules.webFeed.Enclosure) Test(org.junit.Test)

Example 18 with Enclosure

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

the class RomeFeedFetcherTest method convertEnclosures_emptyList.

@Test
public void convertEnclosures_emptyList() {
    List<SyndEnclosure> enclosures = new ArrayList<>();
    Enclosure enclosure = sut.convertEnclosures(enclosures);
    assertThat(enclosure).isNull();
}
Also used : SyndEnclosure(com.rometools.rome.feed.synd.SyndEnclosure) ArrayList(java.util.ArrayList) SyndEnclosure(com.rometools.rome.feed.synd.SyndEnclosure) Enclosure(org.olat.modules.webFeed.Enclosure) Test(org.junit.Test)

Example 19 with Enclosure

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

the class FeedManagerImpl method createItem.

@Override
public Feed createItem(Feed feed, Item item, FileElement file) {
    if (feed == null || item == null || !feed.isInternal())
        return null;
    // Set the current date as published date.
    if (item.getPublishDate() == null) {
        item.setPublishDate(new Date());
    }
    // Save the Enclosure
    Enclosure enclosure = replaceEnclosure(item, file);
    item.setEnclosure(enclosure);
    // Save the Item
    itemDAO.createItem(feed, item);
    // Set the modification date of the feed
    Feed reloadedFeed = feedDAO.loadFeed(feed.getKey());
    reloadedFeed.setLastModified(new Date());
    reloadedFeed = feedDAO.updateFeed(reloadedFeed);
    markPublisherNews(reloadedFeed);
    return reloadedFeed;
}
Also used : Enclosure(org.olat.modules.webFeed.Enclosure) Date(java.util.Date) SyndFeed(com.rometools.rome.feed.synd.SyndFeed) Feed(org.olat.modules.webFeed.Feed) RSSFeed(org.olat.modules.webFeed.RSSFeed)

Example 20 with Enclosure

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

the class RomeFeedFetcher method convertEnclosures.

/**
 * Converts a List of <code>SyndEnclosures</code> into an <code>Enclosure</code>.
 * Only one media file is supported. If the List has more than one entry, the
 * first entry is taken.
 * SyndEnclosures without an URL are not converted, because it is necessary to
 * fetch the enclosure.
 *
 * @param enclosures
 * @return the enclosure or null
 */
protected Enclosure convertEnclosures(List<SyndEnclosure> enclosures) {
    if (enclosures == null || enclosures.isEmpty())
        return null;
    SyndEnclosure syndEnclosure = enclosures.get(0);
    Enclosure enclosure = null;
    if (StringHelper.containsNonWhitespace(syndEnclosure.getUrl())) {
        enclosure = new EnclosureImpl();
        enclosure.setExternalUrl(syndEnclosure.getUrl());
        enclosure.setLength(syndEnclosure.getLength());
        enclosure.setType(syndEnclosure.getType());
    }
    return enclosure;
}
Also used : SyndEnclosure(com.rometools.rome.feed.synd.SyndEnclosure) Enclosure(org.olat.modules.webFeed.Enclosure) SyndEnclosure(com.rometools.rome.feed.synd.SyndEnclosure) EnclosureImpl(org.olat.modules.webFeed.model.EnclosureImpl)

Aggregations

Enclosure (org.olat.modules.webFeed.Enclosure)20 SyndEnclosure (com.rometools.rome.feed.synd.SyndEnclosure)10 Test (org.junit.Test)10 EnclosureImpl (org.olat.modules.webFeed.model.EnclosureImpl)6 Date (java.util.Date)4 Feed (org.olat.modules.webFeed.Feed)4 Item (org.olat.modules.webFeed.Item)4 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)2 File (java.io.File)2 LocalDate (java.time.LocalDate)2 ArrayList (java.util.ArrayList)2 Identity (org.olat.core.id.Identity)2 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 VFSItem (org.olat.core.util.vfs.VFSItem)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 RSSFeed (org.olat.modules.webFeed.RSSFeed)2 OLATResource (org.olat.resource.OLATResource)2