use of com.rometools.rome.feed.synd.SyndFeed in project asterixdb by apache.
the class RSSFeedServlet method get.
@Override
protected void get(IServletRequest req, IServletResponse res) throws IOException {
try {
SyndFeed feed = getFeed(req);
String feedType = req.getParameter(FEED_TYPE);
feedType = (feedType != null) ? feedType : defaultFeedType;
feed.setFeedType(feedType);
HttpUtil.setContentType(res, MIME_TYPE);
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, res.writer());
} catch (FeedException | ParseException ex) {
GlobalConfig.ASTERIX_LOGGER.log(Level.WARNING, ex.getMessage(), ex);
String msg = COULD_NOT_GENERATE_FEED_ERROR;
res.writer().print(msg);
res.setStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);
}
}
use of com.rometools.rome.feed.synd.SyndFeed 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.SyndFeed 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.SyndFeed 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.SyndFeed in project KaellyBot by Kaysoro.
the class RSS method getRSSFeeds.
public static List<RSS> getRSSFeeds(Language lg) {
List<RSS> rss = new ArrayList<>();
try {
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(new URL(Translator.getLabel(lg, "game.url") + Translator.getLabel(lg, "feed.url"))));
for (SyndEntry entry : feed.getEntries()) {
Matcher m = Pattern.compile("<img.+src=\"(.*\\.jpg)\".+>").matcher(entry.getDescription().getValue());
rss.add(new RSS(entry.getTitle(), entry.getLink(), (m.find() ? m.group(1) : null), entry.getPublishedDate().getTime()));
}
} catch (FeedException e) {
Reporter.report(e);
LOG.error("getRSSFeeds", e);
} catch (IOException e) {
ExceptionManager.manageSilentlyIOException(e);
} catch (Exception e) {
ExceptionManager.manageSilentlyException(e);
}
Collections.sort(rss);
return rss;
}
Aggregations