catching email exceptions

This commit is contained in:
Antonis Lempesis 2021-10-20 22:49:56 +00:00
parent 07d077327e
commit 460156d734
1 changed files with 24 additions and 8 deletions

View File

@ -585,8 +585,12 @@ LOGGER.debug("json: " + jsonArray);
, ResponseEntity.class); , ResponseEntity.class);
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) { if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
try {
emailUtils.sendUserUpdateRepositoryInfoEmail(repository, authentication); emailUtils.sendUserUpdateRepositoryInfoEmail(repository, authentication);
emailUtils.sendAdminUpdateRepositoryInfoEmail(repository, authentication); emailUtils.sendAdminUpdateRepositoryInfoEmail(repository, authentication);
} catch (Exception e) {
LOGGER.error("Error sending emails: " + e);
}
} else } else
LOGGER.debug(responseEntity.getBody().toString()); LOGGER.debug(responseEntity.getBody().toString());
@ -610,8 +614,12 @@ LOGGER.debug("json: " + jsonArray);
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(), HttpMethod.POST, httpEntity, ResponseEntity.class); ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(), HttpMethod.POST, httpEntity, ResponseEntity.class);
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) { if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
try {
emailUtils.sendUserRegistrationEmail(repository, authentication); emailUtils.sendUserRegistrationEmail(repository, authentication);
emailUtils.sendAdminRegistrationEmail(repository, authentication); emailUtils.sendAdminRegistrationEmail(repository, authentication);
} catch (Exception e) {
LOGGER.error("Error sending emails: " + e);
}
} else { } else {
LOGGER.debug(responseEntity.getBody().toString()); LOGGER.debug(responseEntity.getBody().toString());
} }
@ -646,8 +654,12 @@ LOGGER.debug("json: " + jsonArray);
restTemplate.postForObject(uriComponents.toUri(), httpEntity, String.class); restTemplate.postForObject(uriComponents.toUri(), httpEntity, String.class);
try {
emailUtils.sendAdminRegisterInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication()); emailUtils.sendAdminRegisterInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
emailUtils.sendUserRegisterInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication()); emailUtils.sendUserRegisterInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
} catch (Exception e) {
LOGGER.error("Error sending emails: " + e);
}
submitInterfaceValidation(e, registeredBy, repositoryInterface, false); submitInterfaceValidation(e, registeredBy, repositoryInterface, false);
@ -664,9 +676,13 @@ LOGGER.debug("json: " + jsonArray);
this.updateValidationSet(repoId, repositoryInterface.getId(), repositoryInterface.getAccessSet()); this.updateValidationSet(repoId, repositoryInterface.getId(), repositoryInterface.getAccessSet());
Repository repository = this.getRepositoryById(repoId); Repository repository = this.getRepositoryById(repoId);
try {
try { try {
emailUtils.sendAdminUpdateInterfaceEmail(repository, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication()); emailUtils.sendAdminUpdateInterfaceEmail(repository, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
emailUtils.sendUserUpdateInterfaceEmail(repository, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication()); emailUtils.sendUserUpdateInterfaceEmail(repository, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
} catch (Exception e) {
LOGGER.error("Error sending emails: " + e);
}
} catch (Exception e) { } catch (Exception e) {
LOGGER.warn("Could not send emails", e); LOGGER.warn("Could not send emails", e);
} }