Skip to content

Commit

Permalink
Merge pull request DSpace#9834 from mwoodiupui/doi-organiser-better-d…
Browse files Browse the repository at this point in the history
…iagnostics

More information about failed DOI registrations.
  • Loading branch information
tdonohue authored Dec 17, 2024
2 parents b994a2c + b8f4ab0 commit 1449e2e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,8 @@ public void update(DOI doiRow) {
}
} catch (IdentifierException ex) {
if (!(ex instanceof DOIIdentifierException)) {
LOG.error("It wasn't possible to register the identifier online. ", ex);
LOG.error("Registering DOI {} for object {}: the registrar returned an error.",
doiRow.getDoi(), dso.getID(), ex);
}

DOIIdentifierException doiIdentifierException = (DOIIdentifierException) ex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,10 @@ public void reserveDOI(Context context, DSpaceObject dso, String doi)
log.warn("While reserving the DOI {}, we got a http status code "
+ "{} and the message \"{}\".",
doi, Integer.toString(resp.statusCode), resp.getContent());
Format format = Format.getCompactFormat();
format.setEncoding("UTF-8");
XMLOutputter xout = new XMLOutputter(format);
log.info("We send the following XML:\n{}", xout.outputString(root));
throw new DOIIdentifierException("Unable to parse an answer from "
+ "DataCite API. Please have a look into DSpace logs.",
DOIIdentifierException.BAD_ANSWER);
Expand Down Expand Up @@ -632,6 +636,14 @@ protected DataCiteResponse sendGetRequest(String doi, String path)
return sendHttpRequest(httpget, doi);
}

/**
* Send a DataCite metadata document to the registrar.
*
* @param doi identify the object.
* @param metadataRoot describe the object. The root element of the document.
* @return the registrar's response.
* @throws DOIIdentifierException passed through.
*/
protected DataCiteResponse sendMetadataPostRequest(String doi, Element metadataRoot)
throws DOIIdentifierException {
Format format = Format.getCompactFormat();
Expand All @@ -640,6 +652,14 @@ protected DataCiteResponse sendMetadataPostRequest(String doi, Element metadataR
return sendMetadataPostRequest(doi, xout.outputString(new Document(metadataRoot)));
}

/**
* Send a DataCite metadata document to the registrar.
*
* @param doi identify the object.
* @param metadata describe the object.
* @return the registrar's response.
* @throws DOIIdentifierException passed through.
*/
protected DataCiteResponse sendMetadataPostRequest(String doi, String metadata)
throws DOIIdentifierException {
// post mds/metadata/
Expand Down Expand Up @@ -687,7 +707,7 @@ protected DataCiteResponse sendMetadataPostRequest(String doi, String metadata)
* properties such as request URI and method type.
* @param doi DOI string to operate on
* @return response from DataCite
* @throws DOIIdentifierException if DOI error
* @throws DOIIdentifierException if registrar returns an error.
*/
protected DataCiteResponse sendHttpRequest(HttpUriRequest req, String doi)
throws DOIIdentifierException {
Expand Down

0 comments on commit 1449e2e

Please sign in to comment.