Search in sources :

Example 1 with StatusItem

use of org.onebusaway.enterprise.webapp.actions.status.model.StatusItem in project onebusaway-application-modules by camsys.

the class StatusAction method createGroups.

private List<StatusGroup> createGroups() {
    groups = new ArrayList<StatusGroup>();
    groups.add(_statusProvider.getIcingaStatus());
    groups.add(_statusProvider.getAgencyServiceAlertStatus());
    groups.add(_statusProvider.getAgencyMetadataStatus());
    // trim OKs
    for (StatusGroup group : groups) {
        List<StatusItem> items = new ArrayList<StatusItem>();
        for (StatusItem item : group.getItems()) {
            if (showItem(item.getStatus())) {
                items.add(item);
            }
        }
        group.setItems(items);
    }
    return groups;
}
Also used : StatusItem(org.onebusaway.enterprise.webapp.actions.status.model.StatusItem) StatusGroup(org.onebusaway.enterprise.webapp.actions.status.model.StatusGroup) ArrayList(java.util.ArrayList)

Example 2 with StatusItem

use of org.onebusaway.enterprise.webapp.actions.status.model.StatusItem in project onebusaway-application-modules by camsys.

the class AgencyMessagesUpdateAction method execute.

@Override
public String execute() {
    _feed = new SyndFeedImpl();
    StringBuilder title = new StringBuilder();
    title.append("OneBusAway General Notices");
    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("General Notices");
    List<SyndEntry> entries = new ArrayList<SyndEntry>();
    // Add Agency Messages
    SyndEntry agencyMsgEntry = new SyndEntryImpl();
    StatusGroup agencyMsgGroup = _statusProvider.getAgencyMetadataStatus();
    if (agencyMsgGroup.getItems().size() == 0) {
        agencyMsgEntry = new SyndEntryImpl();
        agencyMsgEntry.setTitle("No General Notices");
        entries.add(agencyMsgEntry);
    } else {
        for (StatusItem agencyMsgItem : agencyMsgGroup.getItems()) {
            agencyMsgEntry = new SyndEntryImpl();
            agencyMsgEntry.setTitle(agencyMsgItem.getTitle());
            entries.add(agencyMsgEntry);
        }
    }
    _feed.setEntries(entries);
    return SUCCESS;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) StatusItem(org.onebusaway.enterprise.webapp.actions.status.model.StatusItem) StatusGroup(org.onebusaway.enterprise.webapp.actions.status.model.StatusGroup) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) ArrayList(java.util.ArrayList) SyndFeedImpl(com.rometools.rome.feed.synd.SyndFeedImpl)

Example 3 with StatusItem

use of org.onebusaway.enterprise.webapp.actions.status.model.StatusItem 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;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) StatusItem(org.onebusaway.enterprise.webapp.actions.status.model.StatusItem) SyndContent(com.rometools.rome.feed.synd.SyndContent) StatusGroup(org.onebusaway.enterprise.webapp.actions.status.model.StatusGroup) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) ArrayList(java.util.ArrayList) SyndFeedImpl(com.rometools.rome.feed.synd.SyndFeedImpl)

Example 4 with StatusItem

use of org.onebusaway.enterprise.webapp.actions.status.model.StatusItem 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;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) StatusItem(org.onebusaway.enterprise.webapp.actions.status.model.StatusItem) SyndContent(com.rometools.rome.feed.synd.SyndContent) StatusGroup(org.onebusaway.enterprise.webapp.actions.status.model.StatusGroup) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) ArrayList(java.util.ArrayList) SyndFeedImpl(com.rometools.rome.feed.synd.SyndFeedImpl)

Example 5 with StatusItem

use of org.onebusaway.enterprise.webapp.actions.status.model.StatusItem 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);
        }
    }
}
Also used : StatusItem(org.onebusaway.enterprise.webapp.actions.status.model.StatusItem) SyndContent(com.rometools.rome.feed.synd.SyndContent) StatusGroup(org.onebusaway.enterprise.webapp.actions.status.model.StatusGroup) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl)

Aggregations

StatusItem (org.onebusaway.enterprise.webapp.actions.status.model.StatusItem)11 StatusGroup (org.onebusaway.enterprise.webapp.actions.status.model.StatusGroup)10 SyndEntry (com.rometools.rome.feed.synd.SyndEntry)6 SyndEntryImpl (com.rometools.rome.feed.synd.SyndEntryImpl)6 SyndContent (com.rometools.rome.feed.synd.SyndContent)4 SyndContentImpl (com.rometools.rome.feed.synd.SyndContentImpl)4 ArrayList (java.util.ArrayList)4 SyndFeedImpl (com.rometools.rome.feed.synd.SyndFeedImpl)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 HttpClient (org.apache.commons.httpclient.HttpClient)2 HttpMethod (org.apache.commons.httpclient.HttpMethod)2 GetMethod (org.apache.commons.httpclient.methods.GetMethod)2 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)2 JsonNode (org.codehaus.jackson.JsonNode)1 AgencyMetadata (org.onebusaway.agency_metadata.model.AgencyMetadata)1 IcingaItem (org.onebusaway.enterprise.webapp.actions.status.model.IcingaItem)1 IcingaResponse (org.onebusaway.enterprise.webapp.actions.status.model.IcingaResponse)1 AgencyWithCoverageBean (org.onebusaway.transit_data.model.AgencyWithCoverageBean)1