syndLink.setLength(link.getLength());
return syndLink;
}
public WireFeed createRealFeed(SyndFeed syndFeed) {
Feed aFeed = new Feed(getType());
aFeed.setModules(ModuleUtils.cloneModules(syndFeed.getModules()));
aFeed.setEncoding(syndFeed.getEncoding());
aFeed.setId(syndFeed.getUri());
aFeed.setTitle(syndFeed.getTitle());
// separate SyndEntry's links collection into alternate and other links
List alternateLinks = new ArrayList();
List otherLinks = new ArrayList();
String sLink = syndFeed.getLink();
List slinks = syndFeed.getLinks();
if (slinks != null) {
for (Iterator iter=slinks.iterator(); iter.hasNext();) {
SyndLink syndLink = (SyndLink)iter.next();
Link link = new Link();
link.setRel(syndLink.getRel());
link.setHref(syndLink.getHref());
link.setHreflang(syndLink.getHreflang());
link.setLength(syndLink.getLength());
if ("alternate".equals(syndLink.getRel())) {
alternateLinks.add(link);
} else {
otherLinks.add(link);
}
}
}
// no alternate link? then use THE link if there is one
if (alternateLinks.size() == 0 && syndFeed.getLink() != null) {
Link link = new Link();
link.setRel("alternate");
link.setHref(syndFeed.getLink());
alternateLinks.add(link);
}
if (alternateLinks.size() > 0) aFeed.setAlternateLinks(alternateLinks);
if (otherLinks.size() > 0) aFeed.setOtherLinks(otherLinks);
List sCats = syndFeed.getCategories();
List aCats = new ArrayList();
if (sCats != null) {
for (Iterator iter=sCats.iterator(); iter.hasNext();) {
SyndCategory sCat = (SyndCategory)iter.next();
Category aCat = new Category();
aCat.setTerm(sCat.getName());
// TODO: aCat.setLabel(sCat.getLabel());
aCat.setScheme(sCat.getTaxonomyUri());
aCats.add(aCat);
}
}
if (aCats.size() > 0) aFeed.setCategories(aCats);
String sDesc = syndFeed.getDescription();
if (sDesc != null) {
Content subtitle = new Content();
subtitle.setType(Content.TEXT); // TODO: need content type in SyndFeed
subtitle.setValue(sDesc);
aFeed.setSubtitle(subtitle);
}
List authors = syndFeed.getAuthors();
if (authors!=null && authors.size() > 0) {
aFeed.setAuthors(ConverterForAtom03.createAtomPersons(authors));
}
aFeed.setRights(syndFeed.getCopyright());
aFeed.setUpdated(syndFeed.getPublishedDate());
List sEntries = syndFeed.getEntries();
if (sEntries!=null) {
aFeed.setEntries(createAtomEntries(sEntries));
}
return aFeed;
}