* @param users collection
* @param linkBuilders reference to LinkBuilders instance
* @return SyndFeed syndication feed
*/
private SyndFeed createUsersSyndFeed(Collection<User> users, LinkBuilders linkBuilders) {
SyndFeed usersSyndFeed = new SyndFeed();
usersSyndFeed.setId("urn:com:hp:users");
usersSyndFeed.setTitle(new SyndText("Users"));
usersSyndFeed.addAuthor(new SyndPerson("admin"));
usersSyndFeed.setUpdated(new Date());
// 1. Generate collection system links: "edit", "alternate"
linkBuilders.createSystemLinksBuilder(). // Create SystemLinksBuilder
build(usersSyndFeed.getLinks()); // Build all system links
// 2. Add "custom" collection link with type "search". Make it always be
// absolute
linkBuilders.createSingleLinkBuilder(). // Create instance of
// SingleLinkBuilder
queryParam("q", "username"). // Set link query parameter
rel("search"). // Set link relation type
relativize(false). // Create absolute URI
build(usersSyndFeed.getLinks()); // Build link
// 3. Populate and set the collection members
for (User user : users) {
SyndEntry userSyndEntry = createUserSyndEntry(user);
// generate collection member (single user) system links: "edit",
// "alternate"
// all link must be relative to users collection URI "users"
linkBuilders.createSystemLinksBuilder().subResource(userSyndEntry.getId())
.build(userSyndEntry.getLinks());
usersSyndFeed.addEntry(userSyndEntry);
}
return usersSyndFeed;
}