diff --git a/src/main/java/eu/dnetlib/uoaorcidservice/controllers/WorkController.java b/src/main/java/eu/dnetlib/uoaorcidservice/controllers/WorkController.java index 5fe8b09..25a7e7d 100644 --- a/src/main/java/eu/dnetlib/uoaorcidservice/controllers/WorkController.java +++ b/src/main/java/eu/dnetlib/uoaorcidservice/controllers/WorkController.java @@ -186,7 +186,7 @@ public class WorkController { @RequestMapping(value = "/orcid/work/update/{putCode}", method = RequestMethod.POST) public Work updateWork(@PathVariable String putCode, - @RequestBody String resultString) throws AccessDeniedException, BadPaddingException, InvalidKeyException, NoSuchAlgorithmException, IllegalBlockSizeException, IOException, NoSuchPaddingException, InvalidAlgorithmParameterException, InvalidKeySpecException { + @RequestBody String resultString) throws Exception { log.debug("updateWork: putCode = " + putCode); Gson gson = new GsonBuilder().create(); @@ -229,7 +229,15 @@ public class WorkController { if (response.getStatusCode() != HttpStatus.OK) { orcid_log.error("Updating work response code is: " + response.getStatusCode()); orcid_log.error("Unexpected Response: "+response.getBody()); - return null; + + if(response.getStatusCode() == HttpStatus.UNAUTHORIZED) { + throw new AuthorizationServiceException("You are not allowed to update work"); + } else if(response.getStatusCode() == HttpStatus.CONFLICT) { + throw new ConflictException("Work is already saved"); + } else { + throw new Exception("Internal server error"); + } +// return null; } else { orcid_log.info("Response: "+response); Date date = new Date();