Skip to content

Commit

Permalink
Added various debug log statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Willem Elbers committed May 13, 2020
1 parent ef753fa commit 9c6cbe7
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,24 @@ public String registerNewPID(final Configuration configuration, Map<HandleField,
.accept("application/json")
.post(Entity.entity(jsonArray.toString(), MediaType.APPLICATION_JSON));

return processCreateResponse(response, configuration);
return processCreateResponse(response, configuration);
}

private String processCreateResponse(final Response response, final Configuration configuration)
throws HttpException, RuntimeException {
if(response.getStatus() != 201) {
throw new HttpException("" + response.getStatus());
LOG.debug("Invalid API respose: code="+response.getStatus()+", message="+response.getStatusInfo().getReasonPhrase());
throw new HttpException("Invalid API response" + response.getStatus());
}

String base = configuration.getServiceBaseURL();
if(!base.endsWith("/")) {
base += "/";
}
return response.getLocation().toString().replace(base, "");

String location = response.getLocation().toString().replace(base, "");
LOG.debug("Registered new PID at location: "+location);
return location;
}

@Override
Expand All @@ -92,7 +96,10 @@ public void modifyPid(final Configuration configuration, final String pid, Map<H
.put(Entity.entity(jsonArray.toString(), MediaType.APPLICATION_JSON));

if(response.getStatus() != 201) {
throw new HttpException("Invalid response: "+response.getStatus());
LOG.debug("Invalid API respose: code="+response.getStatus()+", message="+response.getStatusInfo().getReasonPhrase());
throw new HttpException("Invalid API response: "+response.getStatus());
} else {
LOG.debug("Successfully modified PID: "+pid);
}
}

Expand Down

0 comments on commit 9c6cbe7

Please sign in to comment.