use of com.rometools.rome.feed.synd.SyndContentImpl in project onebusaway-application-modules by camsys.
the class MonitoringAlertsUpdateAction method execute.
@Override
public String execute() {
_feed = new SyndFeedImpl();
StringBuilder title = new StringBuilder();
title.append("OneBusAway System Monitoring");
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("System Monitoring");
List<SyndEntry> entries = new ArrayList<SyndEntry>();
// Add Icinga Alerts
SyndEntry icingaEntry = new SyndEntryImpl();
SyndContent icingaContent = new SyndContentImpl();
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);
}
}
_feed.setEntries(entries);
return SUCCESS;
}
use of com.rometools.rome.feed.synd.SyndContentImpl 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.SyndContentImpl 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.SyndContentImpl 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.SyndContentImpl in project ofbiz-framework by apache.
the class BlogRssServices method generateEntryList.
public static List<SyndEntry> generateEntryList(LocalDispatcher dispatcher, Delegator delegator, String contentId, String entryLink, Locale locale, GenericValue userLogin) {
List<SyndEntry> entries = new LinkedList<>();
List<GenericValue> contentRecs = null;
try {
contentRecs = EntityQuery.use(delegator).from("ContentAssocViewTo").where("contentIdStart", contentId, "caContentAssocTypeId", "PUBLISH_LINK", "statusId", "CTNT_PUBLISHED").orderBy("-caFromDate").queryList();
} catch (GenericEntityException e) {
Debug.logError(e, MODULE);
}
if (contentRecs != null) {
for (GenericValue v : contentRecs) {
String sub = null;
try {
Map<String, Object> dummy = new HashMap<>();
sub = ContentWorker.renderSubContentAsText(dispatcher, v.getString("contentId"), MAP_KEY, dummy, locale, MIME_TYPE_ID, true);
} catch (GeneralException | IOException e) {
Debug.logError(e, MODULE);
}
if (sub != null) {
String thisLink = entryLink + "?articleContentId=" + v.getString("contentId") + "&blogContentId=" + contentId;
SyndContent desc = new SyndContentImpl();
desc.setType("text/plain");
desc.setValue(sub);
SyndEntry entry = new SyndEntryImpl();
entry.setTitle(v.getString("contentName"));
entry.setPublishedDate(v.getTimestamp("createdDate"));
entry.setDescription(desc);
entry.setLink(thisLink);
entry.setAuthor((v.getString("createdByUserLogin")));
entries.add(entry);
}
}
}
return entries;
}
Aggregations