*/
@Produces( {MediaType.WILDCARD, MediaType.APPLICATION_JSON})
public SyndEntry getSyndEntry(@Context Providers providers,
@Context UriInfo uriInfo,
@Context LinkBuilders linkBuilders) throws IOException {
SyndEntry entry = new SyndEntry();
String id = defect.getId();
entry.setId("urn:com:hp:qadefects:defect:" + id);
entry.setTitle(new SyndText(defect.getName()));
entry.setSummary(new SyndText(defect.getDescription()));
entry.addAuthor(new SyndPerson(defect.getAuthor()));
entry.addCategory(new SyndCategory("urn:com:hp:qadefects:categories:severity", defect
.getSeverity(), null));
entry.addCategory(new SyndCategory("urn:com:hp:qadefects:categories:status", defect
.getStatus(), null));
if (defect.getCreated() != null) {
entry.setPublished(new Date(defect.getCreated().getTime()));
}
// serialize the defect xml
// String contentString =
// ProviderUtils.writeToString(providers, defect, MediaType.APPLICATION_XML_TYPE);
entry.setContent(new SyndContent(defect, MediaType.APPLICATION_XML));
// set base uri if this is a standalone entry
if (!child) {
entry.setBase(uriInfo.getAbsolutePath().toString());
}
// generate the edit link
SingleLinkBuilder singleLinkBuilder = linkBuilders.createSingleLinkBuilder();
if (editable) {
singleLinkBuilder.subResource(DefectsResource.DEFECT_URL)
.pathParam(DefectsResource.DEFECT_VAR, id).rel(AtomConstants.ATOM_REL_EDIT)
.build(entry.getLinks());
}
// if this entry is not part of a history response, then generate the
// history link
if (!history) {
singleLinkBuilder.subResource(DefectsResource.DEFECT_HISTORY_URL)
.pathParam(DefectsResource.DEFECT_VAR, id).rel(AtomConstants.ATOM_REL_HISTORY)
.type(MediaType.APPLICATION_ATOM_XML_TYPE).build(entry.getLinks());
}
// generate system links to self and alternate.
// for the system links we add the revision of the defect to the defect
// id
String idAndRev =
String.format("%s;%s=%s", id, DefectsResource.REVISION, defect.getRevision());
linkBuilders.createSystemLinksBuilder().subResource(DefectsResource.DEFECT_URL)
.pathParam(DefectsResource.DEFECT_VAR, idAndRev)
.types(SystemLinksBuilder.LinkType.SELF, SystemLinksBuilder.LinkType.ALTERNATE)
.build(entry.getLinks());
return entry;
}