return atomContents;
}
protected Entry createAtomEntry(final SyndEntry sEntry) {
final Entry aEntry = new Entry();
aEntry.setModules(ModuleUtils.cloneModules(sEntry.getModules()));
aEntry.setId(sEntry.getUri());
final SyndContent sTitle = sEntry.getTitleEx();
if (sTitle != null) {
final Content title = new Content();
title.setType(sTitle.getType());
title.setValue(sTitle.getValue());
aEntry.setTitleEx(title);
}
final SyndContent sDescription = sEntry.getDescription();
if (sDescription != null) {
final 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
final List<Link> alternateLinks = new ArrayList<Link>();
final List<Link> otherLinks = new ArrayList<Link>();
boolean linkRelEnclosureExists = false;
final List<SyndLink> slinks = sEntry.getLinks();
final List<SyndEnclosure> enclosures = sEntry.getEnclosures();
if (slinks != null) {
for (final SyndLink syndLink : slinks) {
final 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()
final String sRel = syndLink.getRel();
if (sRel != null && "enclosure".equals(sRel)) {
linkRelEnclosureExists = true;
}
final String lRel = link.getRel();
if (Strings.isBlank(lRel) || "alternate".equals(sRel)) {
alternateLinks.add(link);
} else {
otherLinks.add(link);
}
}
}
// no alternate link? then use THE link if there is one
if (alternateLinks.isEmpty() && sEntry.getLink() != null) {
final 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 (final SyndEnclosure syndEnclosure : enclosures) {
final SyndEnclosure syndEncl = syndEnclosure;
final Link link = createAtomEnclosure(syndEncl);
otherLinks.add(link);
}
}
if (!alternateLinks.isEmpty()) {
aEntry.setAlternateLinks(alternateLinks);
}
if (!otherLinks.isEmpty()) {
aEntry.setOtherLinks(otherLinks);
}
final List<SyndCategory> sCats = sEntry.getCategories();
final List<Category> aCats = new ArrayList<Category>();
if (sCats != null) {
for (final SyndCategory sCat : sCats) {
final Category aCat = new Category();
aCat.setTerm(sCat.getName());
// TODO: aCat.setLabel(sCat.getLabel());
aCat.setScheme(sCat.getTaxonomyUri());
aCats.add(aCat);
}
}
if (!aCats.isEmpty()) {
aEntry.setCategories(aCats);
}
final List<SyndContent> syndContents = sEntry.getContents();
aEntry.setContents(createAtomContents(syndContents));
List<SyndPerson> authors = sEntry.getAuthors();
final String author = sEntry.getAuthor();
if (Lists.isNotEmpty(authors)) {
aEntry.setAuthors(ConverterForAtom03.createAtomPersons(authors));
} else if (author != null) {
final Person person = new Person();
person.setName(author);
authors = new ArrayList<SyndPerson>();
authors.add(person);
aEntry.setAuthors(authors);
}
final List<SyndPerson> contributors = sEntry.getContributors();
if (Lists.isNotEmpty(contributors)) {
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());
}
final List<Element> foreignMarkup = sEntry.getForeignMarkup();
if (!foreignMarkup.isEmpty()) {
aEntry.setForeignMarkup(foreignMarkup);
}
final SyndFeed sSource = sEntry.getSource();
if (sSource != null) {
final Feed aSource = (Feed) sSource.createWireFeed(getType());
aEntry.setSource(aSource);
}
return aEntry;
}