metadata.setLastModified(p.getLastModified().getTime());
metadata.setLastContributor(p.getLastContributor());
metadata.setState((p.getState() != null) ? p.getState().getName() : "");
metadata.setArchived(p.isArchived());
Package ret = new Package();
ret.setMetadata(metadata);
ret.setVersion(p.getVersionNumber());
ret.setTitle(p.getTitle());
ret.setCheckInComment(p.getCheckinComment());
ret.setDescription(p.getDescription());
ret.setBinaryLink(uriInfo.getBaseUriBuilder()
.path("/packages/{packageName}/binary")
.build(p.getName()));
ret.setSourceLink(uriInfo.getBaseUriBuilder()
.path("/packages/{packageName}/source")
.build(p.getName()));
//ret.setSnapshot(p.getSnapshotName());
ret.setVersion(p.getVersionNumber());
Iterator<AssetItem> iter = p.getAssets();
Set<URI> assets = new HashSet<URI>();
while (iter.hasNext()) {
AssetItem a = iter.next();
Asset asset = toAsset(a, uriInfo);
assets.add(asset.getRefLink());
}
ret.setAssets(assets);
return ret;
}