@Path("/entriesAsFeed") @GET @ApiOperation(value = "Get category entries as feed", notes = "Get a feed of category entries") @Produces(MediaType.APPLICATION_XML) @SecurityCheck(value = Role.USER, apiKeyAllowed = true) public Response getCategoryEntriesAsFeed( @ApiParam(value = "id of the category, 'all' or 'starred'", required = true) @QueryParam("id") String id) { Preconditions.checkNotNull(id); ReadingMode readType = ReadingMode.all; ReadingOrder order = ReadingOrder.desc; int offset = 0; int limit = 20; Entries entries = (Entries) getCategoryEntries(id, readType, null, offset, limit, order, null, false).getEntity(); SyndFeed feed = new SyndFeedImpl(); feed.setFeedType("rss_2.0"); feed.setTitle("CommaFeed - " + entries.getName()); feed.setDescription("CommaFeed - " + entries.getName()); String publicUrl = applicationSettingsService.get().getPublicUrl(); feed.setLink(publicUrl); List<SyndEntry> children = Lists.newArrayList(); for (Entry entry : entries.getEntries()) { children.add(entry.asRss()); } feed.setEntries(children); SyndFeedOutput output = new SyndFeedOutput(); StringWriter writer = new StringWriter(); try { output.output(feed, writer); } catch (Exception e) { writer.write("Could not get feed information"); log.error(e.getMessage(), e); } return Response.ok(writer.toString()).build(); }