Collections.sort(updates, BaseContentItem.REVERSE_COMPARATOR);
SyndFeed feed = new SyndFeedImpl();
feed.setTitle(livingStory.getTitle());
feed.setLink(createLspUrl(req));
SyndContent feedDescription = new SyndContentImpl();
feedDescription.setType("text/html");
feedDescription.setValue(StringUtil.stripForExternalSites(livingStory.getSummary()));
feed.setDescriptionEx(feedDescription);
List<SyndEntry> items = Lists.newArrayList();
for (BaseContentItem update : updates) {
SyndContent title = new SyndContentImpl();
SyndContent content = new SyndContentImpl();
if (update.getContentItemType() == ContentItemType.EVENT) {
EventContentItem event = (EventContentItem) update;
title.setType("text/html");
title.setValue(event.getEventUpdate());
content.setType("text/html");
content.setValue(StringUtil.stripForExternalSites(event.getEventSummary()));
} else if (update.getContentItemType() == ContentItemType.NARRATIVE) {
NarrativeContentItem narrative = (NarrativeContentItem) update;
title.setType("text/html");
title.setValue(narrative.getHeadline() + " - "
+ narrative.getNarrativeType().toString());
content.setType("text/html");
String narrativeSummary = StringUtil.stripForExternalSites(
narrative.getNarrativeSummary());
if (GlobalUtil.isContentEmpty(narrativeSummary)) {
content.setValue(SnippetUtil.createSnippet(
JavaNodeAdapter.fromHtml(narrative.getContent()), MAXIMUM_SNIPPET_LENGTH));
} else {
content.setValue(narrativeSummary);
}
}
SyndEntry entry = new SyndEntryImpl();
entry.setLink(createContentItemUrl(req, update.getId()));
entry.setPublishedDate(update.getDateSortKey());