Search in sources :

Example 1 with SyndFeedImpl

use of com.rometools.rome.feed.synd.SyndFeedImpl in project BIMserver by opensourceBIM.

the class SyndicationServlet method writeCheckoutsFeed.

private void writeCheckoutsFeed(HttpServletRequest request, HttpServletResponse response, ServiceMap serviceMap) throws ServiceException, IOException, FeedException, PublicInterfaceNotFoundException {
    long poid = Long.parseLong(request.getParameter("poid"));
    SProject sProject = serviceMap.getServiceInterface().getProjectByPoid(poid);
    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType(FEED_TYPE);
    feed.setTitle("BIMserver.org checkouts feed for project '" + sProject.getName() + "'");
    feed.setLink(request.getContextPath());
    feed.setDescription("This feed represents all the checkouts of project '" + sProject.getName() + "'");
    List<SyndEntry> entries = new ArrayList<SyndEntry>();
    try {
        List<SCheckout> allCheckoutsOfProject = serviceMap.getServiceInterface().getAllCheckoutsOfProjectAndSubProjects(poid);
        for (SCheckout sCheckout : allCheckoutsOfProject) {
            SRevision revision = serviceMap.getServiceInterface().getRevision(sCheckout.getRevision().getOid());
            SProject project = serviceMap.getServiceInterface().getProjectByPoid(sCheckout.getProjectId());
            SUser user = serviceMap.getServiceInterface().getUserByUoid(sCheckout.getUserId());
            SyndEntry entry = new SyndEntryImpl();
            entry.setTitle("Checkout on " + project.getName() + ", revision " + revision.getId());
            entry.setLink(request.getContextPath() + "/project.jsp?poid=" + sProject.getOid());
            entry.setPublishedDate(sCheckout.getDate());
            SyndContent description = new SyndContentImpl();
            description.setType("text/plain");
            description.setValue("<table><tr><td>User</td><td>" + user.getUsername() + "</td></tr><tr><td>Revision</td><td>" + sCheckout.getRevision().getOid() + "</td></tr></table>");
            entry.setDescription(description);
            entries.add(entry);
        }
    } catch (UserException e) {
        LOGGER.error("", e);
    }
    feed.setEntries(entries);
    SyndFeedOutput output = new SyndFeedOutput();
    output.output(feed, response.getWriter());
}
Also used : SyndEntry(com.rometools.rome.feed.synd.SyndEntry) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) SUser(org.bimserver.interfaces.objects.SUser) ArrayList(java.util.ArrayList) SyndFeedOutput(com.rometools.rome.io.SyndFeedOutput) SProject(org.bimserver.interfaces.objects.SProject) SyndFeed(com.rometools.rome.feed.synd.SyndFeed) SRevision(org.bimserver.interfaces.objects.SRevision) SyndContent(com.rometools.rome.feed.synd.SyndContent) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) SyndFeedImpl(com.rometools.rome.feed.synd.SyndFeedImpl) UserException(org.bimserver.shared.exceptions.UserException) SCheckout(org.bimserver.interfaces.objects.SCheckout)

Example 2 with SyndFeedImpl

use of com.rometools.rome.feed.synd.SyndFeedImpl in project BIMserver by opensourceBIM.

the class SyndicationServlet method writeProjectsFeed.

private void writeProjectsFeed(HttpServletRequest request, HttpServletResponse response, ServiceMap serviceMap) throws UserException, IOException, FeedException, PublicInterfaceNotFoundException {
    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType(FEED_TYPE);
    feed.setTitle("BIMserver.org projects feed");
    feed.setLink(request.getContextPath());
    feed.setDescription("This feed represents all your available projects within this BIMserver");
    List<SyndEntry> entries = new ArrayList<SyndEntry>();
    try {
        List<SProject> allProjects = serviceMap.getServiceInterface().getAllProjects(false, true);
        for (SProject sProject : allProjects) {
            SyndEntry entry = new SyndEntryImpl();
            entry.setAuthor(serviceMap.getServiceInterface().getUserByUoid(sProject.getCreatedById()).getName());
            entry.setTitle(sProject.getName());
            entry.setLink(request.getContextPath() + "/project.jsp?poid=" + sProject.getOid());
            entry.setPublishedDate(sProject.getCreatedDate());
            SyndContent description = new SyndContentImpl();
            description.setType("text/plain");
            description.setValue(sProject.getDescription());
            entry.setDescription(description);
            entries.add(entry);
        }
        if (allProjects.size() == 0) {
            SyndEntry entry = new SyndEntryImpl();
            entry.setTitle("No projects found");
            entry.setLink(request.getContextPath() + "/main.jsp");
            entry.setPublishedDate(new Date());
            SyndContent description = new SyndContentImpl();
            description.setType("text/plain");
            description.setValue("No projects found");
            entry.setDescription(description);
            entries.add(entry);
        }
    } catch (ServiceException e) {
        LOGGER.error("", e);
    }
    feed.setEntries(entries);
    SyndFeedOutput output = new SyndFeedOutput();
    output.output(feed, response.getWriter());
}
Also used : SyndEntry(com.rometools.rome.feed.synd.SyndEntry) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) ArrayList(java.util.ArrayList) SyndFeedOutput(com.rometools.rome.io.SyndFeedOutput) SProject(org.bimserver.interfaces.objects.SProject) Date(java.util.Date) SyndFeed(com.rometools.rome.feed.synd.SyndFeed) SyndContent(com.rometools.rome.feed.synd.SyndContent) ServiceException(org.bimserver.shared.exceptions.ServiceException) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) SyndFeedImpl(com.rometools.rome.feed.synd.SyndFeedImpl)

Example 3 with SyndFeedImpl

use of com.rometools.rome.feed.synd.SyndFeedImpl in project opennms by OpenNMS.

the class OutageFeed method getFeed.

/**
 * <p>getFeed</p>
 *
 * @return a {@link com.rometools.rome.feed.synd.SyndFeed} object.
 */
@Override
public SyndFeed getFeed() {
    SyndFeed feed = new SyndFeedImpl();
    feed.setTitle("Nodes with Outages");
    feed.setDescription("OpenNMS Nodes with Outages");
    feed.setLink(getUrlBase() + "outage/list.htm");
    List<SyndEntry> entries = new ArrayList<>();
    try {
        Date date = new Date();
        date.setTime(date.getTime() - (1000 * 60 * 60 * 24));
        OutageSummary[] summaries = OutageModel.getAllOutageSummaries(date);
        SyndEntry entry;
        int count = 0;
        for (OutageSummary summary : summaries) {
            if (count++ == this.getMaxEntries()) {
                break;
            }
            String link = getUrlBase() + "element/node.jsp?node=" + summary.getNodeId();
            entry = new SyndEntryImpl();
            entry.setPublishedDate(summary.getTimeDown());
            if (summary.getTimeUp() == null) {
                entry.setTitle(sanitizeTitle(summary.getNodeLabel()));
                entry.setUpdatedDate(summary.getTimeDown());
            } else {
                entry.setTitle(sanitizeTitle(summary.getNodeLabel()) + " (Resolved)");
                entry.setUpdatedDate(summary.getTimeUp());
            }
            entry.setLink(link);
            entry.setAuthor("OpenNMS");
            entries.add(entry);
        }
    } catch (SQLException e) {
        LOG.warn("unable to get current outages", e);
    }
    feed.setEntries(entries);
    return feed;
}
Also used : SyndFeed(com.rometools.rome.feed.synd.SyndFeed) SQLException(java.sql.SQLException) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) OutageSummary(org.opennms.netmgt.model.outage.OutageSummary) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) ArrayList(java.util.ArrayList) SyndFeedImpl(com.rometools.rome.feed.synd.SyndFeedImpl) Date(java.util.Date)

Example 4 with SyndFeedImpl

use of com.rometools.rome.feed.synd.SyndFeedImpl in project xwiki-platform by xwiki.

the class DefaultNotificationRSSManager method renderFeed.

@Override
public SyndFeed renderFeed(List<CompositeEvent> events) {
    SyndFeed feed = new SyndFeedImpl();
    // Define the general properties of the rss
    feed.setFeedType("rss_2.0");
    feed.setTitle(this.contextualLocalizationManager.getTranslationPlain("notifications.rss.feedTitle"));
    // Set the RSS feed link to the service generating the feed
    feed.setLink(this.modelBridge.getDocumentURL(new DocumentReference(wikiDescriptorManager.getCurrentWikiId(), Arrays.asList("XWiki", "Notifications", "Code"), "NotificationRSSService"), "get", "outputSyntax=plain"));
    // Set the feed description
    feed.setDescription(this.contextualLocalizationManager.getTranslationPlain("notifications.rss.feedDescription"));
    // Add every given CompositeEvent entry to the rss
    List<SyndEntry> entries = new ArrayList<>();
    for (CompositeEvent event : events) {
        try {
            NotificationRSSRenderer renderer = this.getRenderer(event);
            if (renderer != null) {
                entries.add(renderer.renderNotification(event));
            } else {
                entries.add(defaultNotificationRSSRenderer.renderNotification(event));
            }
        } catch (NotificationException e) {
            this.logger.warn("Unable to render RSS entry for CompositeEvent [{}] : [{}]", event, ExceptionUtils.getRootCauseMessage(e));
        }
    }
    feed.setEntries(entries);
    return feed;
}
Also used : SyndFeed(com.rometools.rome.feed.synd.SyndFeed) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) NotificationRSSRenderer(org.xwiki.notifications.notifiers.rss.NotificationRSSRenderer) ArrayList(java.util.ArrayList) NotificationException(org.xwiki.notifications.NotificationException) SyndFeedImpl(com.rometools.rome.feed.synd.SyndFeedImpl) CompositeEvent(org.xwiki.notifications.CompositeEvent) DocumentReference(org.xwiki.model.reference.DocumentReference)

Example 5 with SyndFeedImpl

use of com.rometools.rome.feed.synd.SyndFeedImpl 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)

Aggregations

SyndFeedImpl (com.rometools.rome.feed.synd.SyndFeedImpl)17 ArrayList (java.util.ArrayList)15 SyndEntry (com.rometools.rome.feed.synd.SyndEntry)14 SyndEntryImpl (com.rometools.rome.feed.synd.SyndEntryImpl)13 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)12 SyndContentImpl (com.rometools.rome.feed.synd.SyndContentImpl)10 SyndContent (com.rometools.rome.feed.synd.SyndContent)9 SyndFeedOutput (com.rometools.rome.io.SyndFeedOutput)4 SQLException (java.sql.SQLException)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 SProject (org.bimserver.interfaces.objects.SProject)3 StatusGroup (org.onebusaway.enterprise.webapp.actions.status.model.StatusGroup)3 StatusItem (org.onebusaway.enterprise.webapp.actions.status.model.StatusItem)3 Date (java.util.Date)2 SRevision (org.bimserver.interfaces.objects.SRevision)2 SUser (org.bimserver.interfaces.objects.SUser)2 ServiceException (org.bimserver.shared.exceptions.ServiceException)2 OnmsSeverity (org.opennms.netmgt.model.OnmsSeverity)2 Filter (org.opennms.web.filter.Filter)2 Pager (com.willshex.blogwt.shared.api.Pager)1