log.error(ex.getMessage());
throw new IdentifierException("DOI request not sent: " + ex.getMessage());
}
// Send the request
EZIDResponse response;
try
{
response = request.mint(crosswalkMetadata(dso));
} catch (IOException | URISyntaxException ex) {
log.error("Failed to send EZID request: {}", ex.getMessage());
throw new IdentifierException("DOI request not sent: " + ex.getMessage());
}
// Good response?
if (HttpURLConnection.HTTP_CREATED != response.getHttpStatusCode())
{
log.error("EZID server responded: {} {}: {}",
new String[] {
String.valueOf(response.getHttpStatusCode()),
response.getHttpReasonPhrase(),
response.getEZIDStatusValue()
});
throw new IdentifierException("DOI not created: "
+ response.getHttpReasonPhrase()
+ ": "
+ response.getEZIDStatusValue());
}
// Extract the DOI from the content blob
if (response.isSuccess())
{
String value = response.getEZIDStatusValue();
int end = value.indexOf('|'); // Following pipe is "shadow ARK"
if (end < 0)
{
end = value.length();
}
String doi = value.substring(0, end).trim();
log.info("Created {}", doi);
return doi;
}
else
{
log.error("EZID responded: {}", response.getEZIDStatusValue());
throw new IdentifierException("No DOI returned");
}
}