use of org.bimserver.shared.comparators.SRevisionIdComparator in project BIMserver by opensourceBIM.
the class SyndicationServlet method writeRevisionsFeed.
private void writeRevisionsFeed(HttpServletRequest request, HttpServletResponse response, ServiceMap serviceMap) throws IOException, FeedException, ServiceException, 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 revisions feed for project '" + sProject.getName() + "'");
feed.setLink(request.getContextPath());
feed.setDescription("This feed represents all the revisions of project '" + sProject.getName() + "'");
List<SyndEntry> entries = new ArrayList<SyndEntry>();
try {
List<SRevision> allRevisionsOfProject = serviceMap.getServiceInterface().getAllRevisionsOfProject(poid);
Collections.sort(allRevisionsOfProject, new SRevisionIdComparator(false));
for (SRevision sVirtualRevision : allRevisionsOfProject) {
SUser user = serviceMap.getServiceInterface().getUserByUoid(sVirtualRevision.getUserId());
SyndEntry entry = new SyndEntryImpl();
entry.setTitle("Revision " + sVirtualRevision.getOid());
entry.setLink(request.getContextPath() + "/revision.jsp?poid=" + sVirtualRevision.getOid() + "&roid=" + sVirtualRevision.getOid());
entry.setPublishedDate(sVirtualRevision.getDate());
SyndContent description = new SyndContentImpl();
description.setType("text/html");
description.setValue("<table><tr><td>User</td><td>" + user.getUsername() + "</td></tr><tr><td>Comment</td><td>" + sVirtualRevision.getComment() + "</td></tr></table>");
entry.setDescription(description);
entries.add(entry);
}
} catch (ServiceException e) {
LOGGER.error("", e);
}
feed.setEntries(entries);
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, response.getWriter());
}
Aggregations