use of com.sun.syndication.feed.synd.SyndEntry 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 = Config.getConfigParam("base_url", "https://scoold.com");
baseurl = baseurl.endsWith("/") ? baseurl : baseurl + "/";
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType("atom_1.0");
feed.setTitle("Scoold - Recent questions");
feed.setLink(baseurl);
feed.setDescription("A summary of the most recent questions asked on Scoold.");
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.SyndEntry in project opennms by OpenNMS.
the class OutageFeed method getFeed.
/**
* <p>getFeed</p>
*
* @return a {@link com.sun.syndication.feed.synd.SyndFeed} object.
*/
@Override
public SyndFeed getFeed() {
SyndFeed feed = new SyndFeedImpl();
feed.setTitle("Nodes with Outages");
feed.setDescription("OpenNMS Nodes with Outages");
feed.setLink(getUrlBase() + "outage/list.htm");
List<SyndEntry> entries = new ArrayList<SyndEntry>();
try {
Date date = new Date();
date.setTime(date.getTime() - (1000 * 60 * 60 * 24));
OutageSummary[] summaries = OutageModel.getAllOutageSummaries(date);
SyndEntry entry;
int count = 0;
for (OutageSummary summary : summaries) {
if (count++ == this.getMaxEntries()) {
break;
}
String link = getUrlBase() + "element/node.jsp?node=" + summary.getNodeId();
entry = new SyndEntryImpl();
entry.setPublishedDate(summary.getTimeDown());
if (summary.getTimeUp() == null) {
entry.setTitle(sanitizeTitle(summary.getNodeLabel()));
entry.setUpdatedDate(summary.getTimeDown());
} else {
entry.setTitle(sanitizeTitle(summary.getNodeLabel()) + " (Resolved)");
entry.setUpdatedDate(summary.getTimeUp());
}
entry.setLink(link);
entry.setAuthor("OpenNMS");
entries.add(entry);
}
} catch (SQLException e) {
LOG.warn("unable to get current outages", e);
}
feed.setEntries(entries);
return feed;
}
use of com.sun.syndication.feed.synd.SyndEntry in project cubrid-manager by CUBRID.
the class NoticeDashboardEntity method organizeContentByCategory.
private void organizeContentByCategory() {
if (rssData != null) {
// Get RSS item entities
@SuppressWarnings("unchecked") List<SyndEntry> entries = rssData.getEntries();
for (SyndEntry entry : entries) {
// category: language, type, client
@SuppressWarnings("unchecked") List<SyndCategory> categoryList = entry.getCategories();
Set<String> categories = new HashSet<String>();
if (categoryList != null) {
for (SyndCategory category : categoryList) {
categories.add(category.getName());
}
}
Set<SyndEntry> syndEntries;
if (!contents.containsKey(categories)) {
syndEntries = new HashSet<SyndEntry>();
contents.put(categories, syndEntries);
} else {
syndEntries = contents.get(categories);
}
syndEntries.add(entry);
}
saveRssToCache();
}
}
use of com.sun.syndication.feed.synd.SyndEntry in project quickstarts by jboss-switchyard.
the class CamelRSSPollTest method shouldRetrieveGreetings.
@Test
public void shouldRetrieveGreetings() throws Exception {
_testKit.removeService("PrintService");
final MockHandler printService = _testKit.registerInOnlyService("PrintService");
Thread.sleep(10001);
final LinkedBlockingQueue<Exchange> receivedMessages = printService.getMessages();
for (Exchange e : receivedMessages) {
SyndFeed feed = (SyndFeed) e.getMessage().getContent();
@SuppressWarnings("unchecked") List<SyndEntry> entries = feed.getEntries();
Assert.assertEquals(feed.getEntries().size(), 1);
Iterator<SyndEntry> itEntries = entries.iterator();
while (itEntries.hasNext()) {
SyndEntry entry = (SyndEntry) itEntries.next();
Assert.assertTrue(entry.getTitle().equals(SONG_TITLE));
Assert.assertTrue(entry.getLink().equals(SONG_URL));
Assert.assertTrue(entry.getDescription().getValue().equals(SONG_DESCRIPTION));
}
}
}
use of com.sun.syndication.feed.synd.SyndEntry in project jersey by jersey.
the class FeedEntriesAtomBodyWriter method writeTo.
@Override
public void writeTo(List<FeedEntry> entries, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
List<SyndEntry> syndEntries = entries.parallelStream().map(entry -> {
SyndContent description = new SyndContentImpl();
description.setType(MediaType.TEXT_PLAIN);
description.setValue(entry.getDescription());
SyndEntry syndEntry = new SyndEntryImpl();
syndEntry.setTitle(entry.getTitle());
syndEntry.setLink(entry.getLink());
syndEntry.setPublishedDate(entry.getPublishDate());
syndEntry.setDescription(description);
return syndEntry;
}).collect(Collectors.toList());
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType("atom_1.0");
feed.setTitle("Combined Feed");
feed.setDescription("Combined Feed created by a feed-combiner application");
feed.setPublishedDate(new Date());
feed.setEntries(syndEntries);
writeSyndFeed(entityStream, feed);
}
Aggregations