use of com.rometools.rome.feed.synd.SyndEntry in project onebusaway-application-modules by camsys.
the class ServiceAlertsUpdateAction method execute.
@Override
public String execute() {
_feed = new SyndFeedImpl();
StringBuilder title = new StringBuilder();
title.append("OneBusAway Agency Advisories");
HttpServletRequest request = ServletActionContext.getRequest();
StringBuilder b = new StringBuilder();
b.append("http://");
b.append(request.getServerName());
if (request.getServerPort() != 80)
b.append(":").append(request.getServerPort());
if (request.getContextPath() != null)
b.append(request.getContextPath());
String baseUrl = b.toString();
_feed.setTitle(title.toString());
_feed.setLink(baseUrl);
_feed.setDescription("Service Alerts");
List<SyndEntry> entries = new ArrayList<SyndEntry>();
// Add Service Alerts
SyndEntry serviceAlertEntry = new SyndEntryImpl();
SyndContent saContent = new SyndContentImpl();
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);
}
}
_feed.setEntries(entries);
return SUCCESS;
}
use of com.rometools.rome.feed.synd.SyndEntry 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.SyndEntry 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.SyndEntry in project onebusaway-application-modules by camsys.
the class StatusUpdateAction method execute.
@Override
public String execute() {
_feed = new SyndFeedImpl();
StringBuilder title = new StringBuilder();
title.append("OneBusAway System Status");
String baseUrl = createBaseUrl(ServletActionContext.getRequest());
_feed.setTitle(title.toString());
// _feed.setLink(baseUrl);
_feed.setLink("");
_feed.setDescription("System Status");
List<SyndEntry> entries = new ArrayList<SyndEntry>();
setIcingaAlerts(entries, baseUrl);
setAgencyServiceAlerts(entries, baseUrl);
setAgencyMessages(entries, baseUrl);
_feed.setEntries(entries);
return SUCCESS;
}
use of com.rometools.rome.feed.synd.SyndEntry in project ddf by codice.
the class OpenSearchSource method processResponse.
private SourceResponseImpl processResponse(InputStream is, QueryRequest queryRequest) throws UnsupportedQueryException {
List<Result> resultQueue = new ArrayList<>();
SyndFeedInput syndFeedInput = new SyndFeedInput();
SyndFeed syndFeed = null;
try {
syndFeed = syndFeedInput.build(new InputStreamReader(is, StandardCharsets.UTF_8));
} catch (FeedException e) {
LOGGER.debug("Unable to read RSS/Atom feed.", e);
}
List<SyndEntry> entries;
long totalResults = 0;
List<Element> foreignMarkup = null;
if (syndFeed != null) {
entries = syndFeed.getEntries();
for (SyndEntry entry : entries) {
resultQueue.addAll(createResponseFromEntry(entry));
}
totalResults = entries.size();
foreignMarkup = syndFeed.getForeignMarkup();
for (Element element : foreignMarkup) {
if (element.getName().equals("totalResults")) {
try {
totalResults = Long.parseLong(element.getContent(0).getValue());
} catch (NumberFormatException | IndexOutOfBoundsException e) {
// totalResults is already initialized to the correct value, so don't change it here.
LOGGER.debug("Received invalid number of results.", e);
}
}
}
}
SourceResponseImpl response = new SourceResponseImpl(queryRequest, resultQueue);
response.setHits(totalResults);
if (foreignMarkup != null) {
this.foreignMarkupBiConsumer.accept(Collections.unmodifiableList(foreignMarkup), response);
}
return response;
}
Aggregations