List enclosures = sEntry.getEnclosures();
boolean linkRelEnclosureExists = false;
if (slinks != null) {
for (Iterator iter=slinks.iterator(); iter.hasNext();) {
SyndLink syndLink = (SyndLink)iter.next();
Link link = createAtomLink(syndLink);
// Set this flag if there's a link of rel = enclosure so that
// enclosures won't be duplicated when pulled from
// SyndEntry.getEnclosures()
if (syndLink.getRel() != null &&
"enclosure".equals(syndLink.getRel())) {
linkRelEnclosureExists = true;
}
if (link.getRel() == null ||
"".equals(link.getRel().trim()) ||
"alternate".equals(syndLink.getRel())) {
alternateLinks.add(link);
} else {
otherLinks.add(link);
}
}
}
// no alternate link? then use THE link if there is one
if (alternateLinks.isEmpty() && sEntry.getLink() != null) {
Link link = new Link();
link.setRel("alternate");
link.setHref(sEntry.getLink());
alternateLinks.add(link);
}
// add SyndEnclosures as links with rel="enclosure" ONLY if
// there are no SyndEntry.getLinks() with rel="enclosure"
if (enclosures != null && linkRelEnclosureExists == false) {
for (Iterator iter=enclosures.iterator(); iter.hasNext();) {
SyndEnclosure syndEncl = (SyndEnclosure)iter.next();
Link link = createAtomEnclosure(syndEncl);
otherLinks.add(link);
}
}
if (alternateLinks.size() > 0) aEntry.setAlternateLinks(alternateLinks);
if (otherLinks.size() > 0) aEntry.setOtherLinks(otherLinks);