From 06d657d522ea3e898cab993229e81e31b95054eb Mon Sep 17 00:00:00 2001 From: Antonis Lempesis Date: Thu, 21 Oct 2021 12:30:53 +0000 Subject: [PATCH] making emails asynv --- .../manager/config/AsyncConfiguration.java | 27 +++++++++++++++++++ .../dnetlib/repo/manager/config/Config.java | 9 +------ .../repo/manager/service/EmailUtils.java | 26 ++++++++++++++++++ 3 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 src/main/java/eu/dnetlib/repo/manager/config/AsyncConfiguration.java diff --git a/src/main/java/eu/dnetlib/repo/manager/config/AsyncConfiguration.java b/src/main/java/eu/dnetlib/repo/manager/config/AsyncConfiguration.java new file mode 100644 index 0000000..9ffa643 --- /dev/null +++ b/src/main/java/eu/dnetlib/repo/manager/config/AsyncConfiguration.java @@ -0,0 +1,27 @@ +package eu.dnetlib.repo.manager.config; + +import eu.dnetlib.repo.manager.service.ValidatorServiceImpl; +import org.apache.log4j.Logger; +import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.AsyncConfigurer; +import org.springframework.scheduling.annotation.EnableAsync; + +import java.lang.reflect.Method; + +@Configuration +@EnableAsync +public class AsyncConfiguration implements AsyncConfigurer { + + @Override + public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { + return new AsyncUncaughtExceptionHandler() { + private final Logger logger = Logger.getLogger(getClass()); + + @Override + public void handleUncaughtException(Throwable throwable, Method method, Object... objects) { + //logger.error("Async error", throwable); + } + }; + } +} \ No newline at end of file diff --git a/src/main/java/eu/dnetlib/repo/manager/config/Config.java b/src/main/java/eu/dnetlib/repo/manager/config/Config.java index b450635..44271ce 100644 --- a/src/main/java/eu/dnetlib/repo/manager/config/Config.java +++ b/src/main/java/eu/dnetlib/repo/manager/config/Config.java @@ -11,17 +11,13 @@ import gr.uoa.di.driver.enabling.islookup.ISLookUpImpl; import gr.uoa.di.driver.util.ServiceLocator; import gr.uoa.di.driver.util.StaticServiceLocator; import gr.uoa.di.driver.xml.VocabularyXmlConverter; -import org.apache.cxf.frontend.ClientProxyFactoryBean; import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.*; @Configuration -//@ImportResource({"classpath*:/gr/**/springContext-*.xml","/eu/dnetlib/clients/ws/springContext-locatorFactory.xml","/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.xml","/eu/dnetlib/enabling/hcm/springContext-hcmService.xml"}) @ImportResource("application-compat.xml") - @PropertySource("application-compat.properties") - public class Config { @Value("${ISLookUpService.url}") @@ -33,10 +29,8 @@ public class Config { private ServiceLocator createIsLookupServiceLocator() throws Exception { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); - //factory.setServiceClass(eu.dnetlib.services.ISLookUpService.class); factory.setServiceClass(eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService.class); factory.setAddress(lookupURL); - //eu.dnetlib.services.ISLookUpService client = (eu.dnetlib.services.ISLookUpService) factory.create(); eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService client = (eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService) factory.create(); ISLookUpClient service = new ISLookUpClient(); @@ -75,5 +69,4 @@ public class Config { return locator; } - -} +} \ No newline at end of file diff --git a/src/main/java/eu/dnetlib/repo/manager/service/EmailUtils.java b/src/main/java/eu/dnetlib/repo/manager/service/EmailUtils.java index 3191033..5bc1912 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/EmailUtils.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/EmailUtils.java @@ -4,66 +4,92 @@ import eu.dnetlib.domain.data.PiwikInfo; import eu.dnetlib.domain.data.Repository; import eu.dnetlib.domain.data.RepositoryInterface; import eu.dnetlib.domain.functionality.validator.JobForValidation; +import org.springframework.scheduling.annotation.Async; import org.springframework.security.core.Authentication; public interface EmailUtils { + @Async void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception; + @Async void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception; + @Async void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) throws Exception; + @Async void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception; /****USER REGISTRATION REQUEST EMAILS****/ + @Async void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception; + @Async void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception; + @Async void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception; + @Async void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception; /****SUCCESSFUL REGISTRATION RESULTS EMAILS****/ + @Async void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; + @Async void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; /****FAILURE REGISTRATION RESULTS EMAILS****/ + @Async void sendUserRegistrationResultsFailureEmail(String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; + @Async void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; /****SUCCESSFUL UPDATE RESULTS EMAILS****/ + @Async void sendUserUpdateResultsSuccessEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; + @Async void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; /****FAILURE UPDATE RESULTS EMAILS****/ + @Async void sendUserUpdateResultsFailureEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; + @Async void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; /****VALIDATION OF CONTENT PROVIDER EMAILS****/ + @Async void sendUserValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; + @Async void sendAdminValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; /****GENERAL FAILURE OF VALIDATOR****/ + @Async void sendAdminGeneralFailure(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; + @Async void sendAdminUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) throws Exception; + @Async void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) throws Exception; + @Async void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception; + @Async void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception; + @Async void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception; + @Async void sendUponJobCompletion(String repoId, String repoInterfaceId, int scoreUsage,