use of com.rometools.rome.feed.synd.SyndContent in project onebusaway-application-modules by camsys.
the class StatusUpdateAction method setAgencyServiceAlerts.
// these are top-level service alerts without a route/stop affects clause
protected void setAgencyServiceAlerts(List<SyndEntry> entries, String baseUrl) {
// Add Service Alerts
SyndEntry serviceAlertEntry = new SyndEntryImpl();
SyndContent saContent = new SyndContentImpl();
serviceAlertEntry.setTitle("Agency Advisories");
serviceAlertEntry.setLink(baseUrl + "/rss/service-alerts-update");
entries.add(serviceAlertEntry);
StatusGroup saGroup = _statusProvider.getAgencyServiceAlertStatus();
if (saGroup.getItems().size() == 0) {
serviceAlertEntry = new SyndEntryImpl();
serviceAlertEntry.setTitle("All systems operational");
entries.add(serviceAlertEntry);
} else {
for (StatusItem saItem : saGroup.getItems()) {
serviceAlertEntry = new SyndEntryImpl();
serviceAlertEntry.setTitle(saItem.getTitle());
saContent = new SyndContentImpl();
saContent.setValue(saItem.getDescription());
serviceAlertEntry.setDescription(saContent);
entries.add(serviceAlertEntry);
}
}
}
use of com.rometools.rome.feed.synd.SyndContent in project onebusaway-application-modules by camsys.
the class StatusUpdateAction method setIcingaAlerts.
private void setIcingaAlerts(List<SyndEntry> entries, String baseUrl) {
// Add Icinga Alerts
SyndEntry icingaEntry = new SyndEntryImpl();
SyndContent icingaContent = new SyndContentImpl();
icingaEntry.setTitle("System Monitoring");
icingaEntry.setLink(baseUrl + "/rss/monitoring-alerts-update");
entries.add(icingaEntry);
StatusGroup icingaGroup = _statusProvider.getIcingaStatus();
StatusGroup icingaProblems = new StatusGroup();
icingaProblems.setTitle(icingaGroup.getTitle());
// Only report items where status is not "OK"
for (StatusItem icingaItem : icingaGroup.getItems()) {
if (icingaItem.getStatus() != StatusItem.Status.OK) {
icingaProblems.addItem(icingaItem);
}
}
if (icingaProblems.getItems().size() == 0) {
icingaEntry = new SyndEntryImpl();
icingaEntry.setTitle("All systems operational");
entries.add(icingaEntry);
} else {
for (StatusItem icingaItem : icingaProblems.getItems()) {
icingaEntry = new SyndEntryImpl();
icingaEntry.setTitle(icingaItem.getTitle());
icingaContent = new SyndContentImpl();
icingaContent.setValue(icingaItem.getStatus() + ": " + icingaItem.getDescription());
icingaEntry.setDescription(icingaContent);
entries.add(icingaEntry);
}
}
}
use of com.rometools.rome.feed.synd.SyndContent in project openolat by klemens.
the class RomeFeedFetcherTest method convertEntry.
@Test
public void convertEntry() {
// prepare the mock
String author = "author";
when(syndEntryMock.getAuthor()).thenReturn(author);
String description = "description";
when(syndEntryMock.getDescription().getValue()).thenReturn(description);
String link = "link";
when(syndEntryMock.getLink()).thenReturn(link);
String title = "title";
when(syndEntryMock.getTitle()).thenReturn(title);
String uri = "uri";
when(syndEntryMock.getUri()).thenReturn(uri);
Date publishedDate = new Date();
when(syndEntryMock.getPublishedDate()).thenReturn(publishedDate);
Date updatedDate = new Date();
when(syndEntryMock.getUpdatedDate()).thenReturn(updatedDate);
List<SyndContent> contents = Arrays.asList(syndContentMock);
when(syndEntryMock.getContents()).thenReturn(contents);
when(syndEnclosureMock.getUrl()).thenReturn("URL");
List<SyndEnclosure> enclosures = Arrays.asList(syndEnclosureMock);
when(syndEntryMock.getEnclosures()).thenReturn(enclosures);
// call the method
Item item = sut.convertEntry(feedMock, syndEntryMock);
// test
assertThat(item.getFeed()).isEqualTo(feedMock);
assertThat(item.getAuthor()).isEqualTo(author);
assertThat(item.getContent()).isNotNull();
assertThat(item.getDescription()).isEqualTo(description);
assertThat(item.getEnclosure()).isNotNull();
assertThat(item.getExternalLink()).isEqualTo(link);
assertThat(item.getTitle()).isEqualTo(title);
assertThat(item.getGuid()).isEqualTo(uri);
assertThat(item.getLastModified()).isEqualTo(updatedDate);
assertThat(item.getPublishDate()).isEqualTo(publishedDate);
}
use of com.rometools.rome.feed.synd.SyndContent in project openolat by klemens.
the class RomeFeedFetcher method convertEntry.
/**
* Converts a <code>SyndEntry</code> into an <code>Item</code>
*
* @param entry
* @return
*/
protected Item convertEntry(Feed feed, SyndEntry entry) {
Item item = new ItemImpl(feed);
item.setAuthor(entry.getAuthor());
item.setExternalLink(entry.getLink());
item.setGuid(entry.getUri());
item.setLastModified(entry.getUpdatedDate());
item.setPublishDate(entry.getPublishedDate());
item.setTitle(entry.getTitle());
if (entry.getDescription() != null) {
item.setDescription(entry.getDescription().getValue());
}
List<SyndContent> contents = entry.getContents();
item.setContent(joinContents(contents));
List<SyndEnclosure> enclosures = entry.getEnclosures();
item.setEnclosure(convertEnclosures(enclosures));
return item;
}
use of com.rometools.rome.feed.synd.SyndContent in project asterixdb by apache.
the class RSSFeedServlet method getFeed.
protected SyndFeed getFeed(IServletRequest req) throws IOException, FeedException, ParseException {
SyndFeed feed = new SyndFeedImpl();
feed.setTitle("Sample Feed (created with ROME)");
feed.setLink("http://rome.dev.java.net");
feed.setDescription("This feed has been created using ROME (Java syndication utilities");
List<SyndEntry> entries = new ArrayList<>();
SyndEntry entry;
SyndContent description;
entry = new SyndEntryImpl();
entry.setTitle("AsterixDB 0.8.7");
entry.setLink("http://http://asterixdb.apache.org/docs/0.8.7-incubating/index.html");
entry.setPublishedDate(DATE_PARSER.parse("2012-06-08"));
description = new SyndContentImpl();
description.setType("text/plain");
description.setValue("AsterixDB 0.8.7 Release");
entry.setDescription(description);
entries.add(entry);
entry = new SyndEntryImpl();
entry.setTitle("Couchbase 4.1");
entry.setLink("http://blog.couchbase.com/2015/december/introducing-couchbase-server-4.1");
entry.setPublishedDate(DATE_PARSER.parse("2015-12-09"));
description = new SyndContentImpl();
description.setType("text/plain");
description.setValue("Couchbase Server 4.1 Release. Bug fixes, minor API changes and some new features");
entry.setDescription(description);
entries.add(entry);
entry = new SyndEntryImpl();
entry.setTitle("ROME v0.3");
entry.setLink("http://wiki.java.net/bin/view/Javawsxml/rome03");
entry.setPublishedDate(DATE_PARSER.parse("2004-07-27"));
description = new SyndContentImpl();
description.setType("text/html");
description.setValue("<p>Bug fixes, API changes, some new features and some Unit testing</p>" + "<p>For details check the <a href=\"https://rometools.jira.com/wiki/display/ROME/Change+Log#" + "ChangeLog-Changesmadefromv0.3tov0.4\">Changes Log for 0.3</a></p>");
entry.setDescription(description);
entries.add(entry);
entry = new SyndEntryImpl();
entry.setTitle("ROME v0.4");
entry.setLink("http://wiki.java.net/bin/view/Javawsxml/rome04");
entry.setPublishedDate(DATE_PARSER.parse("2004-09-24"));
description = new SyndContentImpl();
description.setType("text/html");
description.setValue("<p>Bug fixes, API changes, some new features, Unit testing completed</p>" + "<p>For details check the <a href=\"https://rometools.jira.com/wiki/display/ROME/Change+Log#" + "ChangeLog-Changesmadefromv0.4tov0.5\">Changes Log for 0.4</a></p>");
entry.setDescription(description);
entries.add(entry);
feed.setEntries(entries);
return feed;
}
Aggregations