Search in sources :

Example 1 with NotificationRSSRenderer

use of org.xwiki.notifications.notifiers.rss.NotificationRSSRenderer in project xwiki-platform by xwiki.

the class DefaultNotificationRSSManager method renderFeed.

@Override
public SyndFeed renderFeed(List<CompositeEvent> events) {
    SyndFeed feed = new SyndFeedImpl();
    // Define the general properties of the rss
    feed.setFeedType("rss_2.0");
    feed.setTitle(this.contextualLocalizationManager.getTranslationPlain("notifications.rss.feedTitle"));
    // Set the RSS feed link to the service generating the feed
    feed.setLink(this.modelBridge.getDocumentURL(new DocumentReference(wikiDescriptorManager.getCurrentWikiId(), Arrays.asList("XWiki", "Notifications", "Code"), "NotificationRSSService"), "get", "outputSyntax=plain"));
    // Set the feed description
    feed.setDescription(this.contextualLocalizationManager.getTranslationPlain("notifications.rss.feedDescription"));
    // Add every given CompositeEvent entry to the rss
    List<SyndEntry> entries = new ArrayList<>();
    for (CompositeEvent event : events) {
        try {
            NotificationRSSRenderer renderer = this.getRenderer(event);
            if (renderer != null) {
                entries.add(renderer.renderNotification(event));
            } else {
                entries.add(defaultNotificationRSSRenderer.renderNotification(event));
            }
        } catch (NotificationException e) {
            this.logger.warn("Unable to render RSS entry for CompositeEvent [{}] : [{}]", event, ExceptionUtils.getRootCauseMessage(e));
        }
    }
    feed.setEntries(entries);
    return feed;
}
Also used : SyndFeed(com.rometools.rome.feed.synd.SyndFeed) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) NotificationRSSRenderer(org.xwiki.notifications.notifiers.rss.NotificationRSSRenderer) ArrayList(java.util.ArrayList) NotificationException(org.xwiki.notifications.NotificationException) SyndFeedImpl(com.rometools.rome.feed.synd.SyndFeedImpl) CompositeEvent(org.xwiki.notifications.CompositeEvent) DocumentReference(org.xwiki.model.reference.DocumentReference)

Aggregations

SyndEntry (com.rometools.rome.feed.synd.SyndEntry)1 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)1 SyndFeedImpl (com.rometools.rome.feed.synd.SyndFeedImpl)1 ArrayList (java.util.ArrayList)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 CompositeEvent (org.xwiki.notifications.CompositeEvent)1 NotificationException (org.xwiki.notifications.NotificationException)1 NotificationRSSRenderer (org.xwiki.notifications.notifiers.rss.NotificationRSSRenderer)1