Search in sources :

Example 11 with SyndContentImpl

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;
}
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 12 with SyndContentImpl

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;
}
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 13 with SyndContentImpl

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);
        }
    }
}
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)

Example 14 with SyndContentImpl

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);
        }
    }
}
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)

Example 15 with SyndContentImpl

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;
}
Also used : GenericValue(org.apache.ofbiz.entity.GenericValue) GeneralException(org.apache.ofbiz.base.util.GeneralException) HashMap(java.util.HashMap) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) IOException(java.io.IOException) LinkedList(java.util.LinkedList) SyndContent(com.rometools.rome.feed.synd.SyndContent) GenericEntityException(org.apache.ofbiz.entity.GenericEntityException) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl)

Aggregations

SyndContentImpl (com.rometools.rome.feed.synd.SyndContentImpl)33 SyndEntryImpl (com.rometools.rome.feed.synd.SyndEntryImpl)29 SyndEntry (com.rometools.rome.feed.synd.SyndEntry)27 SyndContent (com.rometools.rome.feed.synd.SyndContent)25 SyndFeedImpl (com.rometools.rome.feed.synd.SyndFeedImpl)15 ArrayList (java.util.ArrayList)14 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)13 SyndFeedOutput (com.rometools.rome.io.SyndFeedOutput)5 StatusGroup (org.onebusaway.enterprise.webapp.actions.status.model.StatusGroup)4 StatusItem (org.onebusaway.enterprise.webapp.actions.status.model.StatusItem)4 SyndCategory (com.rometools.rome.feed.synd.SyndCategory)3 SyndImageImpl (com.rometools.rome.feed.synd.SyndImageImpl)3 SProject (org.bimserver.interfaces.objects.SProject)3 Preconditions (com.google.common.base.Preconditions)2 Hashing (com.google.common.hash.Hashing)2 MediaType (com.google.common.net.MediaType)2 SyndCategoryImpl (com.rometools.rome.feed.synd.SyndCategoryImpl)2 SyndImage (com.rometools.rome.feed.synd.SyndImage)2 SyndPerson (com.rometools.rome.feed.synd.SyndPerson)2 SyndPersonImpl (com.rometools.rome.feed.synd.SyndPersonImpl)2