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;
}
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());
}
}
}
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());
}
}
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));
}
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();
}
Aggregations