use of com.rometools.rome.feed.synd.SyndContentImpl in project opennms by OpenNMS.
the class AlarmFeed method getFeed.
/**
* <p>getFeed</p>
*
* @return a {@link com.rometools.rome.feed.synd.SyndFeed} object.
*/
@Override
public SyndFeed getFeed() {
SyndFeed feed = new SyndFeedImpl();
feed.setTitle("Alarms");
feed.setDescription("OpenNMS Alarms");
feed.setLink(getUrlBase() + "alarm/list.htm");
List<SyndEntry> entries = new ArrayList<>();
List<Filter> filters = new ArrayList<>();
if (this.getRequest().getParameter("node") != null) {
Integer nodeId = WebSecurityUtils.safeParseInt(this.getRequest().getParameter("node"));
filters.add(new NodeFilter(nodeId, getServletContext()));
}
if (this.getRequest().getParameter("severity") != null) {
String sev = this.getRequest().getParameter("severity");
for (OnmsSeverity severity : OnmsSeverity.values()) {
if (severity.getLabel().equalsIgnoreCase(sev)) {
filters.add(new SeverityFilter(severity));
}
}
}
OnmsCriteria queryCriteria = AlarmUtil.getOnmsCriteria(new AlarmCriteria(filters.toArray(new Filter[] {}), SortStyle.FIRSTEVENTTIME, AcknowledgeType.BOTH, this.getMaxEntries(), AlarmCriteria.NO_OFFSET));
OnmsAlarm[] alarms = m_webAlarmRepository.getMatchingAlarms(queryCriteria);
SyndEntry entry;
for (OnmsAlarm alarm : alarms) {
entry = new SyndEntryImpl();
entry.setPublishedDate(alarm.getFirstEventTime());
if (alarm.getAckTime() != null) {
entry.setTitle(sanitizeTitle(alarm.getLogMsg()) + " (acknowledged by " + alarm.getAckUser() + ")");
entry.setUpdatedDate(alarm.getAckTime());
} else {
entry.setTitle(sanitizeTitle(alarm.getLogMsg()));
entry.setUpdatedDate(alarm.getFirstEventTime());
}
entry.setLink(getUrlBase() + "alarm/detail.htm?id=" + alarm.getId());
entry.setAuthor("OpenNMS");
SyndContent content = new SyndContentImpl();
content.setType("text/html");
content.setValue(alarm.getDescription());
entry.setDescription(content);
entries.add(entry);
}
feed.setEntries(entries);
return feed;
}
use of com.rometools.rome.feed.synd.SyndContentImpl in project opennms by OpenNMS.
the class EventFeed method getFeed.
/**
* <p>getFeed</p>
*
* @return a {@link com.rometools.rome.feed.synd.SyndFeed} object.
*/
@Override
public SyndFeed getFeed() {
SyndFeed feed = new SyndFeedImpl();
feed.setTitle("Events");
feed.setDescription("OpenNMS Events");
feed.setLink(getUrlBase() + "event/list.htm");
List<SyndEntry> entries = new ArrayList<>();
try {
Event[] events;
ArrayList<Filter> filters = new ArrayList<>();
if (this.getRequest().getParameter("node") != null) {
Integer nodeId = WebSecurityUtils.safeParseInt(this.getRequest().getParameter("node"));
filters.add(new NodeFilter(nodeId, getServletContext()));
}
if (this.getRequest().getParameter("severity") != null) {
String parameter = this.getRequest().getParameter("severity");
try {
Integer severityId = WebSecurityUtils.safeParseInt(parameter);
filters.add(new SeverityFilter(severityId));
} catch (NumberFormatException e) {
for (OnmsSeverity sev : OnmsSeverity.values()) {
if (sev.getLabel().equalsIgnoreCase(parameter)) {
filters.add(new SeverityFilter(sev));
break;
}
}
}
}
events = EventFactory.getEvents(SortStyle.TIME, AcknowledgeType.BOTH, filters.toArray(new Filter[] {}), this.getMaxEntries(), 0);
SyndEntry entry;
for (Event event : events) {
entry = new SyndEntryImpl();
entry.setPublishedDate(event.getTime());
if (event.getAcknowledgeTime() != null) {
entry.setTitle(sanitizeTitle(event.getLogMessage()) + " (Acknowledged by " + event.getAcknowledgeUser() + ")");
entry.setUpdatedDate(event.getAcknowledgeTime());
} else {
entry.setTitle(sanitizeTitle(event.getLogMessage()));
entry.setUpdatedDate(event.getTime());
}
entry.setLink(getUrlBase() + "event/detail.jsp?id=" + event.getId());
entry.setAuthor("OpenNMS");
SyndContent content = new SyndContentImpl();
content.setType("text/html");
content.setValue(event.getDescription());
entry.setDescription(content);
entries.add(entry);
}
} catch (SQLException e) {
LOG.warn("unable to get event(s)", e);
}
feed.setEntries(entries);
return feed;
}
use of com.rometools.rome.feed.synd.SyndContentImpl in project coffeenet-frontpage-plugin-rss by coffeenet.
the class BlogParserTest method parseBlog.
@Test
public void parseBlog() throws FeedException, IOException {
SyndContentImpl description = new SyndContentImpl();
description.setValue("description");
SyndEntryImpl syndEntry = new SyndEntryImpl();
syndEntry.setDescription(description);
syndEntry.setLink("link");
syndEntry.setAuthor("author");
syndEntry.setTitle("title");
syndEntry.setPublishedDate(Date.from(Instant.parse("2014-12-03T10:15:30.00Z")));
SyndFeed result = new SyndFeedImpl();
result.setEntries(singletonList(syndEntry));
when(feedFactory.build(any(URL.class))).thenReturn(result);
List<BlogEntry> blogEntries = sut.parse("http://blog/feed/", 10, 150);
assertThat(blogEntries, hasSize(1));
assertThat(blogEntries.get(0).getDescription(), is("description"));
assertThat(blogEntries.get(0).getLink(), is("link"));
assertThat(blogEntries.get(0).getPublishDate(), is("3. December 2014"));
assertThat(blogEntries.get(0).getAuthor(), is("author"));
assertThat(blogEntries.get(0).getTitle(), is("title"));
}
use of com.rometools.rome.feed.synd.SyndContentImpl in project rubia-forums by flashboss.
the class FeedsServlet method getEntry.
private SyndEntry getEntry(Post post, String url, String urlType) {
SyndEntry entry;
SyndContent description;
entry = new SyndEntryImpl();
entry.setTitle(post.getMessage().getSubject() + BY + post.getPoster().getUserId());
entry.setLink(postLink(post.getId().toString(), url, urlType));
entry.setPublishedDate(post.getCreateDate());
description = new SyndContentImpl();
description.setType("text/html");
String text = post.getMessage().getText();
description.setValue(post.getMessage().getHTMLEnabled() ? escapeHtml(text) : text);
entry.setDescription(description);
return entry;
}
use of com.rometools.rome.feed.synd.SyndContentImpl in project archiva by apache.
the class RssFeedGenerator method getEntries.
private List<SyndEntry> getEntries(List<RssFeedEntry> dataEntries) {
List<SyndEntry> entries = new ArrayList<>();
SyndEntry entry;
SyndContent description;
for (RssFeedEntry dataEntry : dataEntries) {
entry = new SyndEntryImpl();
entry.setTitle(dataEntry.getTitle());
entry.setPublishedDate(dataEntry.getPublishedDate());
description = new SyndContentImpl();
description.setType("text/plain");
description.setValue(dataEntry.getDescription());
entry.setDescription(description);
entries.add(entry);
}
return entries;
}
Aggregations