@GET
@Path("{packageName}/versions")
@Produces(MediaType.APPLICATION_ATOM_XML)
public Feed getPackageVersionsAsFeed(@PathParam("packageName") String packageName) throws SerializationException {
PackageItem p = repository.loadPackage(packageName);
Factory factory = Abdera.getNewFactory();
Feed f = factory.getAbdera().newFeed();
f.setTitle("Version history of " + p.getName());
f.setBaseUri(uriInfo.getBaseUriBuilder().path("packages").build().toString());
PackageHistoryIterator it = p.getHistory();
while (it.hasNext()) {
try {
PackageItem historicalPackage = it.next();
if (historicalPackage.getVersionNumber() != 0) {
Entry e = factory.getAbdera().newEntry();
e.setTitle(Long.toString(historicalPackage
.getVersionNumber()));
e.setUpdated(historicalPackage.getLastModified().getTime());
Link l = factory.newLink();
l.setHref(uriInfo
.getBaseUriBuilder()
.path("packages")
.path(p.getName())
.path("versions")
.path(Long.toString(historicalPackage.getVersionNumber())).build().toString());
e.addLink(l);
f.addEntry(e);
}
} catch (Exception e) {
throw new WebApplicationException(e);