diff --git a/src/main/java/eu/dnetlib/repo/manager/service/controllers/EmailUtils.java b/src/main/java/eu/dnetlib/repo/manager/service/controllers/EmailUtils.java index 67744b2..a432257 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/controllers/EmailUtils.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/controllers/EmailUtils.java @@ -2,6 +2,7 @@ package eu.dnetlib.repo.manager.service.controllers; import eu.dnetlib.domain.data.PiwikInfo; import eu.dnetlib.domain.data.Repository; +import eu.dnetlib.domain.functionality.validator.JobForValidation; import org.springframework.security.core.Authentication; public interface EmailUtils { @@ -20,4 +21,6 @@ public interface EmailUtils { void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception; void sendUserUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception; + + void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception; } diff --git a/src/main/java/eu/dnetlib/repo/manager/service/controllers/EmailUtilsImpl.java b/src/main/java/eu/dnetlib/repo/manager/service/controllers/EmailUtilsImpl.java index fd8634a..2fcd03a 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/controllers/EmailUtilsImpl.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/controllers/EmailUtilsImpl.java @@ -2,9 +2,11 @@ package eu.dnetlib.repo.manager.service.controllers; import eu.dnetlib.domain.data.PiwikInfo; import eu.dnetlib.domain.data.Repository; +import eu.dnetlib.domain.functionality.validator.JobForValidation; import eu.dnetlib.repo.manager.service.config.CascadingPropertyLoader; import eu.dnetlib.utils.MailLibrary; import org.apache.log4j.Logger; +import org.mitre.openid.connect.model.OIDCAuthenticationToken; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.security.core.Authentication; @@ -194,16 +196,16 @@ public class EmailUtilsImpl implements EmailUtils { String subject = "OpenAIRE content provider registration request started for " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; - String message = "Dear " + authentication.getName() + ",\n" + + String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" + "\n" + - "We received a request to register the \"" + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]" + - " to the OpenAIRE compliant list of content providers. " + - "\n A validation process against the OpenAIRE guidelines compatibility " + - " has been started. You will be informed in another message once the process is finished." + + "We received a request to register the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]" + + " to the OpenAIRE compliant list of content providers.\n " + + "A validation process against the OpenAIRE guidelines compatibility " + + "has been started. You will be informed in another message once the process is finished." + "\n" + - "Please do not reply to this message\n" + + "Please do not reply to this message.\n" + "This message has been generated automatically.\n" + - "If you have any questions, write to 'helpdesk@openaire.eu'. \n" + + "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" + "Regards,\n" + "the OpenAIRE technical team\n"; @@ -221,13 +223,13 @@ public class EmailUtilsImpl implements EmailUtils { String subject = "OpenAIRE content provider update request started for " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; - String message = "Dear " + authentication.getName() + ",\n" + + String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" + "\n" + - "We received a request to update the \"" + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]" + - "\n A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started." + - "Please do not reply to this message\n" + + "We received a request to update the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n" + + "A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n" + + "Please do not reply to this message.\n" + "This message has been generated automatically.\n" + - "If you have any questions, write to 'helpdesk@openaire.eu'. \n" + + "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" + "Regards,\n" + "the OpenAIRE technical team\n"; @@ -239,6 +241,28 @@ public class EmailUtilsImpl implements EmailUtils { } } + @Override + public void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception { + try { + String subject = "OpenAIRE validator - Test submission "; + + String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" + + "\n" + + "The validation request you have submitted has started.\n" + + "Please do not reply to this message.\n" + + "This message has been generated automatically.\n" + + "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" + + "Regards,\n" + + "the OpenAIRE technical team\n"; + + this.sendMail(jobForValidation.getUserEmail(), subject, message, false, null); + + } catch (Exception e) { + LOGGER.error("Error while sending validation submission notification email to user: " + jobForValidation.getUserEmail(), e); + throw e; + } + } + private void sendMail(String email, String subject, String message, boolean sendToSpecial, List repoAdminMails) throws Exception { ArrayList to = new ArrayList(); to.add(email); diff --git a/src/main/java/eu/dnetlib/repo/manager/service/controllers/PiWikApiImpl.java b/src/main/java/eu/dnetlib/repo/manager/service/controllers/PiWikApiImpl.java index 99657a6..1e4a80f 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/controllers/PiWikApiImpl.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/controllers/PiWikApiImpl.java @@ -133,9 +133,7 @@ public class PiWikApiImpl implements PiWikApi{ public PiwikInfo enableMetricsForRepository(@RequestParam("officialName") String officialName, @RequestParam("repoWebsite") String repoWebsite, @RequestBody PiwikInfo piwikInfo) throws RepositoryServiceException { - try { - String URL = analyticsURL + "siteName=" + URLEncoder.encode(officialName, "UTF-8") + "&url=" + URLEncoder.encode(repoWebsite, "UTF-8"); Map map = new ObjectMapper().readValue(new URL(URL), Map.class); diff --git a/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApiImpl.java b/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApiImpl.java index 0d28c12..492e546 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApiImpl.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApiImpl.java @@ -467,6 +467,8 @@ public class RepositoryApiImpl implements RepositoryApi { .fromHttpUrl(baseAddress + "/ds/add/") .build() .encode(); + + String json_repository = Converter.repositoryObjectToJson(repository); ObjectMapper mapper = new ObjectMapper(); diff --git a/src/main/java/eu/dnetlib/repo/manager/service/controllers/ValidatorApiImpl.java b/src/main/java/eu/dnetlib/repo/manager/service/controllers/ValidatorApiImpl.java index 7ab25f4..08611b9 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/controllers/ValidatorApiImpl.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/controllers/ValidatorApiImpl.java @@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; @@ -92,11 +93,14 @@ public class ValidatorApiImpl implements ValidatorApi{ public JobForValidation submitJobForValidation(@RequestBody JobForValidation jobForValidation) throws ValidatorServiceException { LOGGER.debug("Submit job for validation with id : " + jobForValidation.getDatasourceId()); try { + emailUtils.sendSubmitJobForValidationEmail(SecurityContextHolder.getContext().getAuthentication(),jobForValidation); this.getValidationService().submitValidationJob(jobForValidation); } catch (ValidatorServiceException e) { LOGGER.debug("Exception on submitJobForValidation" , e); emailUtils.reportException(e); throw e; + } catch (Exception e) { + e.printStackTrace(); } return jobForValidation; } diff --git a/src/main/java/eu/dnetlib/repo/manager/service/utils/Converter.java b/src/main/java/eu/dnetlib/repo/manager/service/utils/Converter.java index c78757c..223889b 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/utils/Converter.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/utils/Converter.java @@ -356,10 +356,6 @@ public class Converter { public static List getAggregationHistoryFromJson(JSONObject datasourceInfo) throws JSONException { - - // if(datasourceInfo.get("aggregationHistory").toString().equals("[]")) - // return null; - JSONArray rs = new JSONArray(datasourceInfo.get("aggregationHistory").toString()); List aggregationDetailsList = new ArrayList<>(); for(int i=0;i + + + + + + file://$MODULE_DIR$/src/main/webapp/WEB-INF/applicationContext.xml + file://$MODULE_DIR$/src/main/webapp/WEB-INF/aai-security.xml + file://$MODULE_DIR$/src/main/resources/application-context.xml + file://$MODULE_DIR$/src/main/webapp/WEB-INF/spring-servlet.xml + file://$MODULE_DIR$/src/main/java/eu/dnetlib/repo/manager/service/config/Config.java + file://$MODULE_DIR$/src/main/java/eu/dnetlib/repo/manager/service/config/JdbcConfig.java + file://$MODULE_DIR$/src/main/java/eu/dnetlib/repo/manager/service/config/PropertyPlaceHolder.java + file://$MODULE_DIR$/src/main/java/eu/dnetlib/repo/manager/service/config/SwaggerConfig.java + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file