baseUri = uriInfo.getBaseUriBuilder()
.path("packages/{packageName}/assets/{assetName}")
.build(a.getModuleName(), a.getName());
}
Entry e = new Entry();
e.setTitle(a.getTitle());
e.setSummary(a.getDescription());
e.setPublished(new Date(a.getLastModified().getTimeInMillis()));
e.setBase(baseUri);
e.getAuthors().add(new Person(a.getLastContributor()));
e.setId(baseUri);
try {
AtomAssetMetadata atomAssetMetadata = e.getAnyOtherJAXBObject(AtomAssetMetadata.class);
if (atomAssetMetadata == null) {
atomAssetMetadata = new AtomAssetMetadata();
}
atomAssetMetadata.setArchived(a.isArchived());
atomAssetMetadata.setUuid(a.getUUID());
atomAssetMetadata.setState(a.getState() == null ? "" : a.getState().getName());
atomAssetMetadata.setFormat(a.getFormat());
atomAssetMetadata.setVersionNumber(a.getVersionNumber());
atomAssetMetadata.setCheckinComment(a.getCheckinComment());
String[] categories = new String[a.getCategories().size()];
int i = 0;
for (CategoryItem cItem : a.getCategories()) {
categories[i] = cItem.getName();
i++;
}
atomAssetMetadata.setCategories(categories);
e.setAnyOtherJAXBObject(atomAssetMetadata);
} catch (Exception ex) {
throw new WebServiceException(ex);
}
Content content = new Content();
content.setSrc(UriBuilder.fromUri(baseUri).path("binary").build());
content.setType(MediaType.APPLICATION_OCTET_STREAM_TYPE);
// content.setContentType(Type.MEDIA); // TODO remove me if not it's base64 encoded fine
e.setContent(content);
return e;
}