Correctly checking return type of POST method

This commit is contained in:
Antonis Lempesis 2020-10-14 09:20:46 +00:00
parent 2fbf8478d7
commit 6d6b70f87b
1 changed files with 7 additions and 12 deletions

View File

@ -565,22 +565,17 @@ public class RepositoryServiceImpl implements RepositoryService {
HttpEntity<String> httpEntity = new HttpEntity <> (json_interface,httpHeaders);
restTemplate.postForObject(uriComponents.toUri(),httpEntity, String.class);
ResponseEntity responseEntity = restTemplate.postForObject(uriComponents.toUri(),httpEntity,ResponseEntity.class);
emailUtils.sendAdminRegisterInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
emailUtils.sendUserRegisterInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
emailUtils.sendAdminRegisterInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
emailUtils.sendUserRegisterInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
submitInterfaceValidation(e, registeredBy, repositoryInterface, false);
submitInterfaceValidation(e, registeredBy, repositoryInterface, false);
return repositoryInterface;
} else {
LOGGER.debug(responseEntity.getBody().toString());
throw new Exception("Registering" + baseAddress + " returned " + responseEntity.getStatusCode());
}
return repositoryInterface;
} catch (JSONException | ValidatorServiceException e) {
LOGGER.debug("Exception on addRepositoryInterface" , e);
} catch (Exception e) {
LOGGER.error("Exception on addRepositoryInterface" , e);
emailUtils.reportException(e);
throw e;
}