Search in sources :

Example 1 with SyndLink

use of com.rometools.rome.feed.synd.SyndLink in project opencast by opencast.

the class RomeRssFeed 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(toRomePersons(originalFeed.getAuthors()));
    setCategories(toRomeCategories(originalFeed.getCategories()));
    setContributors(toRomePersons(originalFeed.getContributors()));
    setDescriptionEx(toRomeContent(originalFeed.getDescription()));
    setImage(toRomeImage(originalFeed.getImage()));
    setLanguage(originalFeed.getLanguage());
    setLinks(toRomeLinks(originalFeed.getLinks()));
    setPublishedDate(originalFeed.getPublishedDate());
    setTitleEx(toRomeContent(originalFeed.getTitle()));
    setCopyright(originalFeed.getCopyright());
    setUri(originalFeed.getUri());
    setLink(originalFeed.getLink());
    // Add SyndFeedEntries
    if (originalFeed.getEntries() != null) {
        List<SyndEntry> romeEntries = new ArrayList<SyndEntry>();
        for (FeedEntry entry : originalFeed.getEntries()) {
            SyndEntryImpl e = new SyndEntryImpl();
            e.setModules(toRomeModules(entry.getModules()));
            e.setAuthors(toRomePersons(entry.getAuthors()));
            e.setCategories(toRomeCategories(entry.getCategories()));
            e.setContents(toRomeContents(entry.getContents()));
            e.setContributors(toRomePersons(entry.getContributors()));
            e.setDescription(toRomeContent(entry.getDescription()));
            e.setEnclosures(toRomeEnclosures(entry.getEnclosures()));
            e.setPublishedDate(entry.getPublishedDate());
            e.setTitleEx(toRomeContent(entry.getTitle()));
            e.setUpdatedDate(entry.getUpdatedDate());
            e.setUri(entry.getUri());
            List<SyndLink> links = toRomeLinks(entry.getLinks());
            e.setLinks(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 : FeedEntry(org.opencastproject.feed.api.FeedEntry) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) ArrayList(java.util.ArrayList) SyndLink(com.rometools.rome.feed.synd.SyndLink)

Example 2 with SyndLink

use of com.rometools.rome.feed.synd.SyndLink 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

SyndLink (com.rometools.rome.feed.synd.SyndLink)2 ArrayList (java.util.ArrayList)2 SyndEntry (com.rometools.rome.feed.synd.SyndEntry)1 SyndEntryImpl (com.rometools.rome.feed.synd.SyndEntryImpl)1 SyndLinkImpl (com.rometools.rome.feed.synd.SyndLinkImpl)1 FeedEntry (org.opencastproject.feed.api.FeedEntry)1 Link (org.opencastproject.feed.api.Link)1