@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())); }
public AvailablePluginCollectionRepresentation( Iterable<PluginVersion> pluginVersions, UpmUriBuilder uriBuilder, LinkBuilder linkBuilder, HostStatusRepresentation hostStatus) { super( linkBuilder.buildLinksFor(uriBuilder.buildAvailablePluginCollectionUri()).build(), pluginVersions, uriBuilder, hostStatus); }
private Person generatePerson(String username) { String product = applicationProperties.getDisplayName(); Person person = new Person(); // don't want to get a default UserProfile when the "user" is anon or the product, // and anyway there could be a user with the username "anonymous" or "Confluence" etc if (i18nResolver.getText("upm.auditLog.anonymous").equals(username) || product.equals(username)) { person.setName(username); } else { UserProfile userProfile = userManager.getUserProfile(username); final String userFullname = userProfile == null ? null : userProfile.getFullName(); person.setName((userFullname != null) ? userFullname : username); URI userUri = uriBuilder.buildAbsoluteProfileUri(userProfile); if (userUri != null) { person.setUrl(userUri.toString()); } } return person; }