Search in sources :

Example 1 with SyndFeedOutput

use of com.sun.syndication.io.SyndFeedOutput in project xwiki-platform by xwiki.

the class ActivityStreamImpl method getFeedOutput.

@Override
public String getFeedOutput(SyndFeed feed, String type) {
    feed.setFeedType(type);
    StringWriter writer = new StringWriter();
    SyndFeedOutput output = new SyndFeedOutput();
    try {
        output.output(feed, writer);
        writer.close();
        return writer.toString();
    } catch (Exception e) {
        return "";
    }
}
Also used : StringWriter(java.io.StringWriter) SyndFeedOutput(com.sun.syndication.io.SyndFeedOutput) XWikiException(com.xpn.xwiki.XWikiException) MalformedURLException(java.net.MalformedURLException) ActivityStreamException(com.xpn.xwiki.plugin.activitystream.api.ActivityStreamException)

Example 2 with SyndFeedOutput

use of com.sun.syndication.io.SyndFeedOutput in project xwiki-platform by xwiki.

the class FeedPlugin method getFeedOutput.

/**
 * @see FeedPluginApi#getFeedOutput(SyndFeed, String)
 */
public String getFeedOutput(SyndFeed feed, String type, XWikiContext context) {
    feed.setFeedType(type);
    StringWriter writer = new StringWriter();
    SyndFeedOutput output = new SyndFeedOutput();
    try {
        output.output(feed, writer);
        writer.close();
        return writer.toString();
    } catch (Exception e) {
        e.printStackTrace();
        return "";
    }
}
Also used : StringWriter(java.io.StringWriter) SyndFeedOutput(com.sun.syndication.io.SyndFeedOutput) XWikiException(com.xpn.xwiki.XWikiException) ConversionException(org.xwiki.rendering.converter.ConversionException) IOException(java.io.IOException) CacheException(org.xwiki.cache.CacheException)

Example 3 with SyndFeedOutput

use of com.sun.syndication.io.SyndFeedOutput in project wildfly-camel by wildfly-extras.

the class RSSFeedServlet method doGet.

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType("rss_2.0");
    feed.setTitle("WildFly-Camel Test RSS Feed");
    feed.setLink("http://localhost:8080/rss-tests");
    feed.setDescription("Test RSS feed for the camel-rss component");
    List<SyndEntry> entries = new ArrayList<>();
    for (int i = 1; i <= 5; i++) {
        entries.add(createFeedEntry("Test entry: ", "Test content: ", i));
    }
    feed.setEntries(entries);
    SyndFeedOutput output = new SyndFeedOutput();
    try {
        output.output(feed, response.getWriter());
    } catch (FeedException e) {
        throw new IllegalStateException("Error generating RSS feed", e);
    }
}
Also used : SyndFeed(com.sun.syndication.feed.synd.SyndFeed) SyndEntry(com.sun.syndication.feed.synd.SyndEntry) FeedException(com.sun.syndication.io.FeedException) ArrayList(java.util.ArrayList) SyndFeedImpl(com.sun.syndication.feed.synd.SyndFeedImpl) SyndFeedOutput(com.sun.syndication.io.SyndFeedOutput)

Example 4 with SyndFeedOutput

use of com.sun.syndication.io.SyndFeedOutput in project tutorials by eugenp.

the class RSSRomeExample method publishFeed.

private static void publishFeed(SyndFeed feed) throws IOException, FeedException {
    Writer writer = new FileWriter("xyz.txt");
    SyndFeedOutput syndFeedOutput = new SyndFeedOutput();
    syndFeedOutput.output(feed, writer);
    writer.close();
}
Also used : FileWriter(java.io.FileWriter) SyndFeedOutput(com.sun.syndication.io.SyndFeedOutput) FileWriter(java.io.FileWriter) Writer(java.io.Writer)

Example 5 with SyndFeedOutput

use of com.sun.syndication.io.SyndFeedOutput in project maven-plugins by apache.

the class FeedGenerator method export.

/**
 * Extract a feed and export it to a Writer.
 *
 * @param releases the List of Releases. Only the last release is used in the feed.
 * @param feedType The type of the feed to generate. See {@link #isSupportedFeedType(java.lang.String)} for
 *            supported values.
 * @param writer a Writer. Note that this is not flushed nor closed upon exit.
 * @throws IOException if an error occurs during export.
 */
public void export(final List<Release> releases, final String feedType, final Writer writer) throws IOException {
    feed.setFeedType(feedType);
    feed.setTitle(title);
    feed.setAuthor(author);
    feed.setPublishedDate(new Date());
    feed.setLink(link);
    feed.setDescription(rbundle.getString("report.changes.text.rssfeed.description"));
    feed.setLanguage(rbundle.getLocale().getLanguage());
    // feed.setCopyright( );
    // feed.setEncoding();
    feed.setEntries(getEntries(releases));
    try {
        new SyndFeedOutput().output(feed, writer);
    } catch (FeedException ex) {
        IOException ioex = new IOException(ex.getMessage());
        ioex.initCause(ex);
        throw ioex;
    }
}
Also used : FeedException(com.sun.syndication.io.FeedException) SyndFeedOutput(com.sun.syndication.io.SyndFeedOutput) IOException(java.io.IOException) Date(java.util.Date)

Aggregations

SyndFeedOutput (com.sun.syndication.io.SyndFeedOutput)11 SyndFeed (com.sun.syndication.feed.synd.SyndFeed)5 SyndFeedImpl (com.sun.syndication.feed.synd.SyndFeedImpl)5 FeedException (com.sun.syndication.io.FeedException)5 SyndEntry (com.sun.syndication.feed.synd.SyndEntry)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 FileWriter (java.io.FileWriter)3 Writer (java.io.Writer)3 SyndContent (com.sun.syndication.feed.synd.SyndContent)2 SyndContentImpl (com.sun.syndication.feed.synd.SyndContentImpl)2 SyndEntryImpl (com.sun.syndication.feed.synd.SyndEntryImpl)2 SyndImageImpl (com.sun.syndication.feed.synd.SyndImageImpl)2 XWikiException (com.xpn.xwiki.XWikiException)2 OutputStreamWriter (java.io.OutputStreamWriter)2 StringWriter (java.io.StringWriter)2 Date (java.util.Date)2 FeedEntryModel (com.gitblit.models.FeedEntryModel)1 SyndCategory (com.sun.syndication.feed.synd.SyndCategory)1 SyndCategoryImpl (com.sun.syndication.feed.synd.SyndCategoryImpl)1