Search in sources :

Example 1 with Link

use of org.opencastproject.feed.api.Link in project opencast by opencast.

the class FeedImplTest method setterGetterTest.

@Test
public void setterGetterTest() {
    instance.setTitle("text");
    logger.info(instance.getTitle().getValue());
    Assert.assertEquals(instance.getTitle().getValue(), "text");
    instance.setLink("http://localhost:8080/feeds/rss/2.0/test");
    Assert.assertEquals(instance.getLink(), "http://localhost:8080/feeds/rss/2.0/test");
    instance.setCopyright("text");
    Assert.assertEquals(instance.getCopyright(), "text");
    List<Person> person = new ArrayList<Person>();
    instance.setAuthors(person);
    Assert.assertEquals(instance.getAuthors(), person);
    instance.setContributors(person);
    Assert.assertEquals(instance.getContributors(), person);
    instance.setUri("http://testuri/");
    Assert.assertEquals(instance.getUri(), "http://testuri/");
    List<Category> category = new ArrayList<Category>();
    instance.setCategories(category);
    Assert.assertEquals(instance.getCategories(), category);
    instance.setDescription("description");
    Assert.assertEquals(instance.getDescription().getValue(), "description");
    Content content = new ContentImpl("desciption");
    instance.setDescription(content);
    Assert.assertEquals(instance.getDescription(), content);
    instance.setEncoding("encode");
    Assert.assertEquals(instance.getEncoding(), "encode");
    List<FeedEntry> feed = new ArrayList<FeedEntry>();
    instance.setEntries(feed);
    Assert.assertEquals(instance.getEntries(), feed);
    Image image = new ImageImpl("http://picture/");
    instance.setImage(image);
    Assert.assertEquals(instance.getImage(), image);
    instance.setLanguage("English");
    Assert.assertEquals(instance.getLanguage(), "English");
    List<Link> link = new ArrayList<Link>();
    instance.setLinks(link);
    Assert.assertEquals(instance.getLinks(), link);
    List<FeedExtension> feedExtension = new ArrayList<FeedExtension>();
    instance.setModules(feedExtension);
    Assert.assertEquals(instance.getModules(), feedExtension);
    Date date = new Date(21091981);
    instance.setPublishedDate(date);
    Assert.assertEquals(instance.getPublishedDate(), date);
    instance.setUpdatedDate(date);
    Assert.assertEquals(instance.getUpdatedDate(), date);
    instance.setTitle(content);
    Assert.assertEquals(instance.getTitle(), content);
}
Also used : FeedExtension(org.opencastproject.feed.api.FeedExtension) Category(org.opencastproject.feed.api.Category) ArrayList(java.util.ArrayList) Image(org.opencastproject.feed.api.Image) Date(java.util.Date) FeedEntry(org.opencastproject.feed.api.FeedEntry) Content(org.opencastproject.feed.api.Content) Person(org.opencastproject.feed.api.Person) Link(org.opencastproject.feed.api.Link) Test(org.junit.Test)

Example 2 with Link

use of org.opencastproject.feed.api.Link in project opencast by opencast.

the class RomeAtomFeed method toRomeAtomLinks.

/**
 * Converts a list of links to a <code>ROME</code> link list.
 *
 * @param links
 *          original links
 * @return <code>ROME</code> link list
 */
private List<com.rometools.rome.feed.atom.Link> toRomeAtomLinks(List<Link> links) {
    if (links == null)
        return Collections.emptyList();
    List<com.rometools.rome.feed.atom.Link> romeLinks = new ArrayList<com.rometools.rome.feed.atom.Link>(links.size());
    for (Link link : links) {
        com.rometools.rome.feed.atom.Link romeLink = new com.rometools.rome.feed.atom.Link();
        romeLink.setHref(link.getHref());
        romeLink.setHreflang(link.getHreflang());
        romeLink.setLength(link.getLength());
        romeLink.setRel(link.getRel());
        romeLink.setTitle(link.getTitle());
        romeLink.setType(link.getType());
        romeLink.setTitle(link.getFlavour());
        romeLink.setLength(1);
        romeLinks.add(romeLink);
    }
    return romeLinks;
}
Also used : ArrayList(java.util.ArrayList) Link(org.opencastproject.feed.api.Link)

Example 3 with Link

use of org.opencastproject.feed.api.Link in project opencast by opencast.

the class RomeAtomFeed method init.

/**
 * Converts the replay feed to a rome feed, that can then be written to the reponse.
 *
 * @param originalFeed
 *          the original feed
 * @param feedInfo
 *          the feed info
 */
private void init(Feed originalFeed, FeedInfo feedInfo) {
    if (originalFeed == null)
        throw new IllegalArgumentException("Feed is null");
    // Create SyndFeed
    setEncoding(originalFeed.getEncoding());
    setFeedType(feedInfo.toROMEVersion());
    // Convert fields
    setModules(toRomeModules(originalFeed.getModules()));
    setAuthors(toRomeAtomPersons(originalFeed.getAuthors()));
    setCategories(toRomeAtomCategories(originalFeed.getCategories()));
    setContributors(toRomeAtomPersons(originalFeed.getContributors()));
    setInfo(toRomeAtomContent(originalFeed.getDescription()));
    setLanguage(originalFeed.getLanguage());
    setAlternateLinks(toRomeAtomLinks(originalFeed.getLinks()));
    setUpdated(originalFeed.getUpdatedDate());
    setTitleEx(toRomeAtomContent(originalFeed.getTitle()));
    setId(originalFeed.getUri());
    setCopyright(originalFeed.getCopyright());
    List<Link> otherLinks = new ArrayList<Link>();
    otherLinks.add(new LinkImpl(originalFeed.getLink()));
    setOtherLinks(toRomeAtomLinks(otherLinks));
    // Add SyndFeedEntries
    if (originalFeed.getEntries() != null) {
        List<Entry> romeEntries = new ArrayList<Entry>();
        for (FeedEntry entry : originalFeed.getEntries()) {
            Entry e = new Entry();
            e.setModules(toRomeModules(entry.getModules()));
            e.setAuthors(toRomeAtomPersons(entry.getAuthors()));
            e.setCategories(toRomeAtomCategories(entry.getCategories()));
            e.setContents(toRomeAtomContents(entry.getContents()));
            e.setContributors(toRomeAtomPersons(entry.getContributors()));
            e.setSummary(toRomeAtomContent(entry.getDescription()));
            e.setPublished(entry.getPublishedDate());
            e.setTitleEx(toRomeAtomContent(entry.getTitle()));
            e.setUpdated(entry.getUpdatedDate());
            e.setId(entry.getUri());
            List<com.rometools.rome.feed.atom.Link> links = toRomeAtomLinks(entry.getLinks());
            links.addAll(toRomeAtomEnclosures(entry.getEnclosures()));
            e.setOtherLinks(links);
            // todo this strategy seems to work but is unproven
            // if (links.size() > 0)
            // e.setLink(links.get(0).getHref());
            romeEntries.add(e);
        }
        setEntries(romeEntries);
    }
}
Also used : Entry(com.rometools.rome.feed.atom.Entry) FeedEntry(org.opencastproject.feed.api.FeedEntry) FeedEntry(org.opencastproject.feed.api.FeedEntry) ArrayList(java.util.ArrayList) Link(org.opencastproject.feed.api.Link)

Example 4 with Link

use of org.opencastproject.feed.api.Link in project opencast by opencast.

the class RomeRssFeed method toRomeLinks.

/**
 * Converts a list of links to a <code>ROME</code> link list.
 *
 * @param links
 *          original links
 * @return <code>ROME</code> link list
 */
private List<SyndLink> toRomeLinks(List<Link> links) {
    if (links == null)
        return Collections.emptyList();
    List<SyndLink> romeLinks = new ArrayList<SyndLink>(links.size());
    for (Link link : links) {
        SyndLinkImpl romeLink = new SyndLinkImpl();
        romeLink.setHref(link.getHref());
        romeLink.setHreflang(link.getHreflang());
        romeLink.setLength(link.getLength());
        romeLink.setRel(link.getRel());
        romeLink.setTitle(link.getTitle());
        romeLink.setType(link.getType());
        romeLinks.add(romeLink);
    }
    return romeLinks;
}
Also used : ArrayList(java.util.ArrayList) SyndLinkImpl(com.rometools.rome.feed.synd.SyndLinkImpl) SyndLink(com.rometools.rome.feed.synd.SyndLink) SyndLink(com.rometools.rome.feed.synd.SyndLink) Link(org.opencastproject.feed.api.Link)

Aggregations

ArrayList (java.util.ArrayList)4 Link (org.opencastproject.feed.api.Link)4 FeedEntry (org.opencastproject.feed.api.FeedEntry)2 Entry (com.rometools.rome.feed.atom.Entry)1 SyndLink (com.rometools.rome.feed.synd.SyndLink)1 SyndLinkImpl (com.rometools.rome.feed.synd.SyndLinkImpl)1 Date (java.util.Date)1 Test (org.junit.Test)1 Category (org.opencastproject.feed.api.Category)1 Content (org.opencastproject.feed.api.Content)1 FeedExtension (org.opencastproject.feed.api.FeedExtension)1 Image (org.opencastproject.feed.api.Image)1 Person (org.opencastproject.feed.api.Person)1