Search in sources :

Example 1 with SyndEntry

use of com.sun.syndication.feed.synd.SyndEntry in project jersey by jersey.

the class FeedDownloadTaskTest method syndEntry.

private SyndEntry syndEntry(String title, String link, String description, Date date) {
    SyndEntry entry = new SyndEntryImpl();
    entry.setLink(link);
    entry.setTitle(title);
    SyndContentImpl content = new SyndContentImpl();
    content.setValue(description);
    entry.setDescription(content);
    entry.setPublishedDate(date);
    return entry;
}
Also used : SyndEntry(com.sun.syndication.feed.synd.SyndEntry) SyndContentImpl(com.sun.syndication.feed.synd.SyndContentImpl) SyndEntryImpl(com.sun.syndication.feed.synd.SyndEntryImpl)

Example 2 with SyndEntry

use of com.sun.syndication.feed.synd.SyndEntry in project jersey by jersey.

the class FeedEntriesAtomBodyWriterTest method testWriteTo.

@Test
public void testWriteTo() throws Exception {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    testedClass.writeTo(feedEntries(), null, null, null, null, null, outputStream);
    SyndFeedInput input = new SyndFeedInput();
    InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    SyndFeed feed = input.build(new InputSource(inputStream));
    feed.setFeedType("atom_1.0");
    feed.setTitle("Combined Feed");
    feed.setDescription("Combined Feed created by a feed-combiner application");
    assertEquals("atom_1.0", feed.getFeedType());
    assertEquals("Combined Feed", feed.getTitle());
    assertEquals("Combined Feed created by a feed-combiner application", feed.getDescription());
    @SuppressWarnings("unchecked") List<SyndEntry> entries = feed.getEntries();
    assertEquals(2, entries.size());
    for (SyndEntry entry : entries) {
        if (TITLES[0].equals(entry.getTitle())) {
            assertEquals(entry.getLink(), LINKS[0]);
            assertEquals(entry.getTitle(), TITLES[0]);
            assertEquals(entry.getDescription().getValue(), DESCS[0]);
            assertEquals(entry.getPublishedDate().toString(), DATE.toString());
        } else {
            assertEquals(entry.getLink(), LINKS[1]);
            assertEquals(entry.getTitle(), TITLES[1]);
            assertEquals(entry.getDescription().getValue(), DESCS[1]);
            assertEquals(entry.getPublishedDate().toString(), DATE.toString());
        }
    }
}
Also used : SyndFeed(com.sun.syndication.feed.synd.SyndFeed) InputSource(org.xml.sax.InputSource) ByteArrayInputStream(java.io.ByteArrayInputStream) SyndFeedInput(com.sun.syndication.io.SyndFeedInput) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) SyndEntry(com.sun.syndication.feed.synd.SyndEntry) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 3 with SyndEntry

use of com.sun.syndication.feed.synd.SyndEntry in project quickstarts by jboss-switchyard.

the class RSSParseServiceImpl method parse.

@Override
public void parse(SyndFeed feed) throws Exception {
    @SuppressWarnings("unchecked") List<SyndEntry> entries = feed.getEntries();
    Iterator<SyndEntry> itEntries = entries.iterator();
    while (itEntries.hasNext()) {
        SyndEntry entry = (SyndEntry) itEntries.next();
        System.out.println("Title :  " + entry.getTitle());
    }
}
Also used : SyndEntry(com.sun.syndication.feed.synd.SyndEntry)

Example 4 with SyndEntry

use of com.sun.syndication.feed.synd.SyndEntry in project camel by apache.

the class UpdatedDateFilterTest method testFilter.

@Test
public void testFilter() {
    SyndEntry entry = new SyndEntryImpl();
    entry.setPublishedDate(now);
    entry.setAuthor("ANDY");
    assertTrue(fixture.isValidEntry(new RssEndpoint(), new SyndFeedImpl(), entry));
    entry = new SyndEntryImpl();
    entry.setPublishedDate(now);
    entry.setAuthor("ANDY");
    assertFalse(fixture.isValidEntry(new RssEndpoint(), new SyndFeedImpl(), entry));
    entry = new SyndEntryImpl();
    entry.setPublishedDate(now);
    entry.setAuthor("FRED");
    assertTrue(fixture.isValidEntry(new RssEndpoint(), new SyndFeedImpl(), entry));
}
Also used : SyndEntry(com.sun.syndication.feed.synd.SyndEntry) SyndEntryImpl(com.sun.syndication.feed.synd.SyndEntryImpl) SyndFeedImpl(com.sun.syndication.feed.synd.SyndFeedImpl) Test(org.junit.Test)

Example 5 with SyndEntry

use of com.sun.syndication.feed.synd.SyndEntry in project gitblit by gitblit.

the class SyndicationUtils method toRSS.

/**
	 * Outputs an RSS feed of the list of entries to the outputstream.
	 *
	 * @param hostUrl
	 * @param feedLink
	 * @param title
	 * @param description
	 * @param entryModels
	 * @param os
	 * @throws IOException
	 * @throws FeedException
	 */
public static void toRSS(String hostUrl, String feedLink, String title, String description, List<FeedEntryModel> entryModels, OutputStream os) throws IOException, FeedException {
    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType("rss_2.0");
    feed.setEncoding("UTF-8");
    feed.setTitle(title);
    feed.setLink(feedLink);
    if (StringUtils.isEmpty(description)) {
        feed.setDescription(title);
    } else {
        feed.setDescription(description);
    }
    SyndImageImpl image = new SyndImageImpl();
    image.setTitle(Constants.NAME);
    image.setUrl(hostUrl + "/gitblt_25.png");
    image.setLink(hostUrl);
    feed.setImage(image);
    List<SyndEntry> entries = new ArrayList<SyndEntry>();
    for (FeedEntryModel entryModel : entryModels) {
        SyndEntry entry = new SyndEntryImpl();
        entry.setTitle(entryModel.title);
        entry.setAuthor(entryModel.author);
        entry.setLink(entryModel.link);
        entry.setPublishedDate(entryModel.published);
        if (entryModel.tags != null && entryModel.tags.size() > 0) {
            List<SyndCategory> tags = new ArrayList<SyndCategory>();
            for (String tag : entryModel.tags) {
                SyndCategoryImpl cat = new SyndCategoryImpl();
                cat.setName(tag);
                tags.add(cat);
            }
            entry.setCategories(tags);
        }
        SyndContent content = new SyndContentImpl();
        if (StringUtils.isEmpty(entryModel.contentType) || entryModel.contentType.equalsIgnoreCase("text/plain")) {
            content.setType("text/html");
            content.setValue(StringUtils.breakLinesForHtml(entryModel.content));
        } else {
            content.setType(entryModel.contentType);
            content.setValue(entryModel.content);
        }
        entry.setDescription(content);
        entries.add(entry);
    }
    feed.setEntries(entries);
    OutputStreamWriter writer = new OutputStreamWriter(os, "UTF-8");
    SyndFeedOutput output = new SyndFeedOutput();
    output.output(feed, writer);
    writer.close();
}
Also used : SyndCategory(com.sun.syndication.feed.synd.SyndCategory) SyndImageImpl(com.sun.syndication.feed.synd.SyndImageImpl) FeedEntryModel(com.gitblit.models.FeedEntryModel) SyndEntry(com.sun.syndication.feed.synd.SyndEntry) SyndContentImpl(com.sun.syndication.feed.synd.SyndContentImpl) ArrayList(java.util.ArrayList) SyndFeedOutput(com.sun.syndication.io.SyndFeedOutput) SyndFeed(com.sun.syndication.feed.synd.SyndFeed) SyndCategoryImpl(com.sun.syndication.feed.synd.SyndCategoryImpl) SyndContent(com.sun.syndication.feed.synd.SyndContent) SyndEntryImpl(com.sun.syndication.feed.synd.SyndEntryImpl) SyndFeedImpl(com.sun.syndication.feed.synd.SyndFeedImpl) OutputStreamWriter(java.io.OutputStreamWriter)

Aggregations

SyndEntry (com.sun.syndication.feed.synd.SyndEntry)20 SyndEntryImpl (com.sun.syndication.feed.synd.SyndEntryImpl)12 SyndFeed (com.sun.syndication.feed.synd.SyndFeed)11 SyndFeedImpl (com.sun.syndication.feed.synd.SyndFeedImpl)10 ArrayList (java.util.ArrayList)10 SyndContent (com.sun.syndication.feed.synd.SyndContent)8 SyndContentImpl (com.sun.syndication.feed.synd.SyndContentImpl)8 Date (java.util.Date)5 SyndFeedOutput (com.sun.syndication.io.SyndFeedOutput)4 IOException (java.io.IOException)3 SQLException (java.sql.SQLException)3 SyndCategory (com.sun.syndication.feed.synd.SyndCategory)2 FeedException (com.sun.syndication.io.FeedException)2 SyndFeedInput (com.sun.syndication.io.SyndFeedInput)2 OutputStreamWriter (java.io.OutputStreamWriter)2 HashSet (java.util.HashSet)2 Test (org.junit.Test)2 OnmsSeverity (org.opennms.netmgt.model.OnmsSeverity)2 Filter (org.opennms.web.filter.Filter)2 Post (com.erudika.scoold.core.Post)1