[Trunk | Orcid Service]: UserTokensController.java: In "getPersonalDetailsFromOrcid()" method (/orcid/personal-details), when getting error response from ORCID API, throw Exception.

This commit is contained in:
Konstantina Galouni 2021-02-24 10:38:44 +00:00
parent 92a487e3f8
commit f72dcedbd5
1 changed files with 8 additions and 2 deletions

View File

@ -107,7 +107,7 @@ public class UserTokensController {
}
@RequestMapping(value = "/orcid/personal-details", method = RequestMethod.GET)
public String getPersonalDetailsFromOrcid() throws BadPaddingException, InvalidKeyException, NoSuchAlgorithmException, IllegalBlockSizeException, IOException, NoSuchPaddingException, InvalidAlgorithmParameterException, InvalidKeySpecException {
public String getPersonalDetailsFromOrcid() throws Exception {
log.debug("getPersonalDetailsFromOrcid");
UserTokens userTokens = userTokensService.getUserTokens();
@ -144,7 +144,13 @@ public class UserTokensController {
if (response.getStatusCode() != HttpStatus.OK) {
orcid_log.error("Getting user details 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 get personal details");
} else {
throw new Exception("Internal server error");
}
// return null;
} else {
orcid_log.info("response: "+response);
return response.getBody().toString();