@SuppressWarnings("unchecked") private void addAuditLogEntries(Feed feed, Integer maxResults, Integer startIndex) { FeedData feedData = getFeedData(maxResults, startIndex); addTotalEntriesMarkup(feed, feedData.totalEntries); addStartIndexMarkup(feed, feedData.startIndex); // add links to next and previous pages if any exist, and to first/last pages int nextPageStartIndex = feedData.startIndex + feedData.maxResults; int previousPageStartIndex = max(feedData.startIndex - feedData.maxResults, 0); int firstPageStartIndex = 0; int lastPageStartIndex = (int) Math.floor((feedData.totalEntries - 1) / feedData.maxResults) * feedData.maxResults; if (nextPageStartIndex < feedData.totalEntries) { addLink( feed, uriBuilder.buildAuditLogFeedUri(feedData.maxResults, nextPageStartIndex), "next"); addLink( feed, uriBuilder.buildAuditLogFeedUri(feedData.maxResults, lastPageStartIndex), "last"); } if (feedData.startIndex > 0) { addLink( feed, uriBuilder.buildAuditLogFeedUri(feedData.maxResults, firstPageStartIndex), "first"); addLink( feed, uriBuilder.buildAuditLogFeedUri(feedData.maxResults, previousPageStartIndex), "previous"); } // transform AuditLogEntry elements to rome Entry elements and add to the feed feed.getEntries() .addAll(Collections2.transform(feedData.entries, auditLogEntryToFeedEntryFn())); }
protected void addEntries(Feed feed, Element parent) throws FeedException { List items = feed.getEntries(); for (int i = 0; i < items.size(); i++) { addEntry((Entry) items.get(i), parent); } checkEntriesConstraints(parent); }
@SuppressWarnings("unchecked") protected List<String> getAllFeedSubscribers(String processInstanceId, Integer authorId) { Feed comments = getCommentsFeed(processInstanceId); if (comments == null) { return null; } return getEmails(comments.getEntries(), getUserMail(authorId)); }
/** Parse entry from reader. */ public static Entry parseEntry(final Reader rd, final String baseURI, final Locale locale) throws JDOMException, IOException, IllegalArgumentException, FeedException { // Parse entry into JDOM tree final SAXBuilder builder = new SAXBuilder(); final Document entryDoc = builder.build(rd); final Element fetchedEntryElement = entryDoc.getRootElement(); fetchedEntryElement.detach(); // Put entry into a JDOM document with 'feed' root so that Rome can // handle it final Feed feed = new Feed(); feed.setFeedType("atom_1.0"); final WireFeedOutput wireFeedOutput = new WireFeedOutput(); final Document feedDoc = wireFeedOutput.outputJDom(feed); feedDoc.getRootElement().addContent(fetchedEntryElement); if (baseURI != null) { feedDoc.getRootElement().setAttribute("base", baseURI, Namespace.XML_NAMESPACE); } final WireFeedInput input = new WireFeedInput(false, locale); final Feed parsedFeed = (Feed) input.build(feedDoc); return parsedFeed.getEntries().get(0); }