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