Search in sources :

Example 1 with SRevisionIdComparator

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());
}
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) ServiceException(org.bimserver.shared.exceptions.ServiceException) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) SyndFeedImpl(com.rometools.rome.feed.synd.SyndFeedImpl) SRevisionIdComparator(org.bimserver.shared.comparators.SRevisionIdComparator)

Aggregations

SyndContent (com.rometools.rome.feed.synd.SyndContent)1 SyndContentImpl (com.rometools.rome.feed.synd.SyndContentImpl)1 SyndEntry (com.rometools.rome.feed.synd.SyndEntry)1 SyndEntryImpl (com.rometools.rome.feed.synd.SyndEntryImpl)1 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)1 SyndFeedImpl (com.rometools.rome.feed.synd.SyndFeedImpl)1 SyndFeedOutput (com.rometools.rome.io.SyndFeedOutput)1 ArrayList (java.util.ArrayList)1 SProject (org.bimserver.interfaces.objects.SProject)1 SRevision (org.bimserver.interfaces.objects.SRevision)1 SUser (org.bimserver.interfaces.objects.SUser)1 SRevisionIdComparator (org.bimserver.shared.comparators.SRevisionIdComparator)1 ServiceException (org.bimserver.shared.exceptions.ServiceException)1