use of com.sun.syndication.feed.synd.SyndFeed in project play-cookbook by spinscale.
the class FeedTest method testThatAtomWorks.
@Test
public void testThatAtomWorks() throws Exception {
Response response = GET("/feed/posts.atom");
assertIsOk(response);
assertContentType("application/atom+xml", response);
assertCharset("utf-8", response);
SyndFeed feed = getFeed(response);
assertEquals("atom_0.3", feed.getFeedType());
}
use of com.sun.syndication.feed.synd.SyndFeed in project play-cookbook by spinscale.
the class FeedTest method testThatRss20Works.
@Test
public void testThatRss20Works() throws Exception {
Response response = GET("/feed/posts.rss2");
assertIsOk(response);
assertContentType("application/rss+xml", response);
assertCharset("utf-8", response);
SyndFeed feed = getFeed(response);
assertEquals("rss_2.0", feed.getFeedType());
}
use of com.sun.syndication.feed.synd.SyndFeed in project scoold by Erudika.
the class SearchController method getFeed.
private SyndFeed getFeed() throws IOException, FeedException {
List<Post> questions = pc.findQuery(Utils.type(Question.class), "*");
List<SyndEntry> entries = new ArrayList<SyndEntry>();
String baseurl = ScooldServer.getServerURL();
baseurl = baseurl.endsWith("/") ? baseurl : baseurl + "/";
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType("atom_1.0");
feed.setTitle(Config.APP_NAME + " - Recent questions");
feed.setLink(baseurl);
feed.setDescription("A summary of the most recent questions on " + Config.APP_NAME);
for (Post post : questions) {
SyndEntry entry;
SyndContent description;
String baselink = baseurl.concat("question/").concat(post.getId());
entry = new SyndEntryImpl();
entry.setTitle(post.getTitle());
entry.setLink(baselink);
entry.setPublishedDate(new Date(post.getTimestamp()));
entry.setAuthor(baseurl.concat("profile/").concat(post.getCreatorid()));
entry.setUri(baselink.concat("/").concat(Utils.stripAndTrim(post.getTitle()).replaceAll("\\p{Z}+", "-").toLowerCase()));
description = new SyndContentImpl();
description.setType("text/html");
description.setValue(Utils.markdownToHtml(post.getBody()));
entry.setDescription(description);
entries.add(entry);
}
feed.setEntries(entries);
return feed;
}
use of com.sun.syndication.feed.synd.SyndFeed in project apex-malhar by apache.
the class RomeSyndicationOperator method run.
/**
* Thread processing of the syndication feeds
*/
@Override
public void run() {
try {
while (true) {
InputStreamReader isr = null;
try {
isr = new InputStreamReader(getFeedInputStream());
SyndFeedInput feedInput = new SyndFeedInput();
SyndFeed feed = feedInput.build(isr);
List entries = feed.getEntries();
List<RomeFeedEntry> nfeedItems = new ArrayList<RomeFeedEntry>();
boolean oldEntries = false;
for (int i = 0; i < entries.size(); ++i) {
SyndEntry syndEntry = (SyndEntry) entries.get(i);
RomeFeedEntry romeFeedEntry = getSerializableEntry(syndEntry);
if (!oldEntries) {
if (!feedItems.contains(romeFeedEntry)) {
outputPort.emit(romeFeedEntry);
} else if (orderedUpdate) {
oldEntries = true;
}
}
nfeedItems.add(romeFeedEntry);
}
feedItems = nfeedItems;
} catch (Exception e) {
logger.error(e.getMessage());
} finally {
if (isr != null) {
try {
isr.close();
} catch (Exception ce) {
logger.error(ce.getMessage());
}
}
}
Thread.sleep(interval);
}
} catch (InterruptedException ie) {
logger.error("Interrupted: " + ie.getMessage());
}
}
use of com.sun.syndication.feed.synd.SyndFeed in project jersey by jersey.
the class FeedDownloader method apply.
@Override
@SuppressWarnings("unchecked")
public List<SyndEntry> apply(URL url) {
try (XmlReader xmlReader = new XmlReader(url)) {
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(xmlReader);
return feed.getEntries();
} catch (Exception e) {
LOG.warn("An error during downloading and parsing a given feed: " + url, e);
}
return Collections.emptyList();
}
Aggregations