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);
}
}
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;
}
Aggregations