GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
DataManager dm = gc.getBean(DataManager.class);
String id = dm.getMetadataId(uuid.toLowerCase());
if (id == null) {
throw new OperationAbortedEx("Metadata record with uuid "+uuid+" doesn't exist");
}
// -- check download permissions (should be ok since admin but...)
try {
Lib.resource.checkPrivilege(context, id, ReservedOperation.download);
}
catch (Exception e) {
throw new OperationAbortedEx("Download access not available on metadata record with uuid "+uuid);
}
// -- get metadata
boolean forEditing = false, withValidationErrors = false, keepXlinkAttributes = false;
Element elMd = dm.getMetadata(context, id, forEditing, withValidationErrors, keepXlinkAttributes);
if (elMd == null) {
throw new OperationAbortedEx("Metadata record "+uuid+" doesn't exist");
}
// -- transform record into brief version
Element elBrief = dm.extractSummary(elMd);
// -- find link using XPath and create URL for further processing
XPath xp = XPath.newInstance ("link[contains(@protocol,'metadata-schema')]");
List<?> elems = xp.selectNodes(elBrief);
try {
url = getMetadataSchemaUrl(elems);
}
catch (MalformedURLException mu) {
throw new OperationAbortedEx("Metadata schema URL link for metadata record "+uuid+" is malformed : "+mu.getMessage());
}
if (url == null) {
throw new OperationAbortedEx("Unable to find metadata schema URL link for metadata record "+uuid);
}
}
// -- get the schema zip archive from the net
if (url != null) {