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);
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
emailUtils.sendUserUpdateRepositoryInfoEmail(repository, authentication);
emailUtils.sendAdminUpdateRepositoryInfoEmail(repository, authentication);
try {
emailUtils.sendUserUpdateRepositoryInfoEmail(repository, authentication);
emailUtils.sendAdminUpdateRepositoryInfoEmail(repository, authentication);
} catch (Exception e) {
LOGGER.error("Error sending emails: " + e);
}
} else
LOGGER.debug(responseEntity.getBody().toString());
@ -610,8 +614,12 @@ LOGGER.debug("json: " + jsonArray);
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(), HttpMethod.POST, httpEntity, ResponseEntity.class);
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
emailUtils.sendUserRegistrationEmail(repository, authentication);
emailUtils.sendAdminRegistrationEmail(repository, authentication);
try {
emailUtils.sendUserRegistrationEmail(repository, authentication);
emailUtils.sendAdminRegistrationEmail(repository, authentication);
} catch (Exception e) {
LOGGER.error("Error sending emails: " + e);
}
} else {
LOGGER.debug(responseEntity.getBody().toString());
}
@ -646,8 +654,12 @@ LOGGER.debug("json: " + jsonArray);
restTemplate.postForObject(uriComponents.toUri(), httpEntity, String.class);
emailUtils.sendAdminRegisterInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
emailUtils.sendUserRegisterInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
try {
emailUtils.sendAdminRegisterInterfaceEmail(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);
@ -665,8 +677,12 @@ LOGGER.debug("json: " + jsonArray);
Repository repository = this.getRepositoryById(repoId);
try {
emailUtils.sendAdminUpdateInterfaceEmail(repository, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
emailUtils.sendUserUpdateInterfaceEmail(repository, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
try {
emailUtils.sendAdminUpdateInterfaceEmail(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) {
LOGGER.warn("Could not send emails", e);
}