[Trunk | Orcid Service]:

1, WorkController.java: In method "updateWork()" (/orcid/work/update/{putCode}), if ORCID does not return HttpStatus.OK, 
	return AuthorizationServiceException (for HttpStatus.UNAUTHORIZED), ConflictException (for HttpStatus.CONFLICT) or Exception instead of null.
This commit is contained in:
Konstantina Galouni 2021-03-11 02:19:36 +00:00
parent ddefdc5056
commit 69f9eb6df6
1 changed files with 10 additions and 2 deletions

View File

@ -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();