*/
@Produces
public SyndFeed getSyndFeed(@Context Providers providers,
@Context LinkBuilders linkBuilders,
@Context UriInfo uriInfo) {
SyndFeed feed = new SyndFeed();
feed.setId("urn:com:hp:qadefects:defects");
feed.setTitle(new SyndText("Defects"));
feed.addAuthor(new SyndPerson("admin"));
feed.setUpdated(new Date());
feed.setBase(uriInfo.getAbsolutePath().toString());
boolean editable = true;
SystemLinksBuilder systemLinksBuilder = linkBuilders.createSystemLinksBuilder();
// generate history links
if (history) {
// all defects in the collection are the history of the same defect
// and they all have the
// same defect id, so we can use the id of the first one
systemLinksBuilder.subResource(DefectsResource.DEFECT_HISTORY_URL)
.pathParam(DefectsResource.DEFECT_VAR, defects.get(0).getId()).build(feed
.getLinks());
if (!defects.isEmpty()) {
// if this is a history of a defect, then the last defect in the
// list is the latest state of the defect
editable = !(defects.get(defects.size() - 1).isDeleted());
}
} else {
// generate system links
systemLinksBuilder.build(feed.getLinks());
}
// set the entries
for (DefectBean defect : defects) {
DefectAsset defectAsset = new DefectAsset(defect, true, history);
// set whether to generate the edit link or not
defectAsset.setEditable(editable);
SyndEntry entry = defectAsset.getSyndEntry(providers, uriInfo, linkBuilders);
// we don't want content for entries
entry.setContent(null);
feed.addEntry(entry);
}
return feed;
}