}
return atomContents;
}
protected Entry createAtomEntry(SyndEntry sEntry) {
Entry aEntry = new Entry();
aEntry.setModules(ModuleUtils.cloneModules(sEntry.getModules()));
aEntry.setId(sEntry.getUri());
SyndContent sTitle = sEntry.getTitleEx();
if (sTitle!=null) {
Content title = new Content();
title.setType(sTitle.getType());
title.setValue(sTitle.getValue());
aEntry.setTitleEx(title);
}
SyndContent sDescription = sEntry.getDescription();
if (sDescription!=null) {
Content summary = new Content();
summary.setType(sDescription.getType());
summary.setValue(sDescription.getValue());
aEntry.setSummary(summary);
}
// separate SyndEntry's links collection into alternate and other links
List alternateLinks = new ArrayList();
List otherLinks = new ArrayList();
List slinks = sEntry.getLinks();
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.size() == 0 && 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);
List sCats = sEntry.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) aEntry.setCategories(aCats);
List syndContents = sEntry.getContents();
aEntry.setContents(createAtomContents(syndContents));
List authors = sEntry.getAuthors();
if (authors!=null && authors.size() > 0) {
aEntry.setAuthors(ConverterForAtom03.createAtomPersons(authors));
} else if (sEntry.getAuthor() != null) {
Person person = new Person();
person.setName(sEntry.getAuthor());
authors = new ArrayList();
authors.add(person);
aEntry.setAuthors(authors);
}
List contributors = sEntry.getContributors();
if (contributors!=null && contributors.size() > 0) {
aEntry.setContributors(ConverterForAtom03.createAtomPersons(contributors));
}
aEntry.setPublished(sEntry.getPublishedDate());
// Fix for issue #41 "Use updated instead of published"
// And issue #42 "Atom 1.0 Date (Updated or Published) Not Set"
// Atom requires an updated date, if it's missing use the published date
if (sEntry.getUpdatedDate() != null) {
aEntry.setUpdated(sEntry.getUpdatedDate());
} else {
aEntry.setUpdated(sEntry.getPublishedDate());
}
if (((List)sEntry.getForeignMarkup()).size() > 0) {
aEntry.setForeignMarkup((List)sEntry.getForeignMarkup());
}
SyndFeed sSource = sEntry.getSource();
if (sSource != null) {
Feed aSource = (Feed) sSource.createWireFeed(getType());
aEntry.setSource(aSource);
}
return aEntry;
}