fixing from & quantity values for export-to-csv functionality

This commit is contained in:
Ioannis Diplas 2019-09-04 12:21:53 +00:00
parent 835f973caf
commit 61e7696832
7 changed files with 475 additions and 43 deletions

View File

@ -1,7 +1,11 @@
package eu.dnetlib.repo.manager.controllers;
import eu.dnetlib.api.functionality.ValidatorServiceException;
import eu.dnetlib.domain.data.RepositoryInterface;
import eu.dnetlib.domain.functionality.validator.StoredJob;
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
import eu.dnetlib.repo.manager.service.EmailUtils;
import eu.dnetlib.repo.manager.service.RepositoryService;
import eu.dnetlib.repo.manager.service.ValidatorServiceImpl;
import eu.dnetlib.repo.manager.shared.InterfaceInformation;
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
@ -28,6 +32,9 @@ public class ValidatorController {
@Autowired
private ValidatorServiceImpl validatorService;
@Autowired
private EmailUtils emailUtils;
@RequestMapping(value = "/submitJobForValidation",method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@ -94,9 +101,25 @@ public class ValidatorController {
@RequestMapping(value = "/getInterfaceInformation" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public InterfaceInformation getInterfaceInformation(@RequestParam(value = "baseUrl", required = true) String baseUrl) throws ValidationServiceException {
public InterfaceInformation getInterfaceInformation(@RequestParam(value = "baseUrl") String baseUrl) throws ValidationServiceException {
return validatorService.getInterfaceInformation(baseUrl);
}
@RequestMapping(value = "/complete" , method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public void validationCompleted(
@RequestParam(value = "interfaceId") String interfaceId,
@RequestParam(value = "repoId") String repoId,
@RequestParam(value = "jobId") String jobId,
@RequestParam(value = "issuerEmail") String issuerEmail,
@RequestParam(value = "isUpdate") boolean isUpdate,
@RequestParam(value = "isSuccess") boolean isSuccess,
@RequestParam(value = "scoreUsage") int scoreUsage,
@RequestParam(value = "scoreContent") int scoreContent) throws Exception {
emailUtils.sendUponJobCompletion(repoId,interfaceId,scoreUsage,scoreContent,isSuccess,isUpdate,issuerEmail, jobId);
}
}

View File

@ -2,7 +2,11 @@ package eu.dnetlib.repo.manager.service;
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 eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
import org.json.JSONException;
import org.springframework.security.core.Authentication;
public interface EmailUtils {
@ -18,13 +22,52 @@ public interface EmailUtils {
void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception;
/****USER REGISTRATION REQUEST EMAILS****/
void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
/****SUCCESSFUL REGISTRATION RESULTS EMAILS****/
void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
/****FAILURE REGISTRATION RESULTS EMAILS****/
void sendUserRegistrationResultsFailureEmail(String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
/****SUCCESSFUL UPDATE RESULTS EMAILS****/
void sendUserUpdateResultsSuccessEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
/****FAILURE UPDATE RESULTS EMAILS****/
void sendUserUpdateResultsFailureEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
/****VALIDATION OF CONTENT PROVIDER EMAILS****/
void sendUserValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
void sendAdminValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
/****GENERAL FAILURE OF VALIDATOR****/
void sendAdminGeneralFailure(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
void sendAdminUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception;
void sendUserUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception;
void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception;
void sendUponJobCompletion(String repoId,
String repoInterfaceId,
int scoreUsage,
int scoreContent,
boolean isSuccess,
boolean isUpdate,
String issuerEmail,
String jobId) throws Exception;
}

View File

@ -2,14 +2,19 @@ package eu.dnetlib.repo.manager.service;
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 eu.dnetlib.repo.manager.config.CascadingPropertyLoader;
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
import eu.dnetlib.utils.MailLibrary;
import org.apache.log4j.Logger;
import org.json.JSONException;
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;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@ -18,6 +23,7 @@ import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Component("emailUtils")
@ -47,6 +53,12 @@ public class EmailUtilsImpl implements EmailUtils {
@Value("${services.provide.adminEmail}")
private String provideAdminEmail;
@Value("${validator.results.url}")
private String valBaseUrl;
@Autowired
private RepositoryService repositoryService;
@PostConstruct
public void init(){
@ -225,7 +237,8 @@ public class EmailUtilsImpl implements EmailUtils {
String subject = "OpenAIRE content provider registration request started for " +
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
String message = "Dear user,\n" +
"\n" +
"We received a request to register the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]" +
" to the OpenAIRE compliant list of content providers. " +
@ -246,6 +259,331 @@ public class EmailUtilsImpl implements EmailUtils {
}
}
@Override
public void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
try {
String subject = "OpenAIRE content provider registration request - results (success) for " +
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
String message = "Dear user,\n" +
"\n" +
"the compatibility test on " + "[" + repository.getEnglishName() + "]" +
" was successful and the datasource type \""+ repository.getDatasourceType() + "\" will be prepared for aggregation in OpenAIRE."+
"\n\n" +
"Please note that it usually takes about 3-4 weeks until a data source is indexed and its metadata visible on openaire.eu.\n\n" +
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
"\nOfficial Name:" + repository.getOfficialName() +
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
"\n\n\nPlease do not reply to this email\n"+
"This message has been generated manually\n\n"+
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
"Regards,\n" +
"the OpenAIRE technical team\n";
this.sendMail(repository.getRegisteredBy(), subject, message, false, null);
} catch (Exception e) {
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
throw e;
}
}
@Override
public void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
try {
String subject = "OpenAIRE content provider registration request - results (success) for " +
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
String message = "Dear admin ,\n" +
"\n" +
"the compatibility test on " + "[" + repository.getEnglishName() + "]" +
" was successful and the datasource type \""+ repository.getDatasourceType() + "\" will be prepared for aggregation in OpenAIRE."+
"\n\n" +
"Please note that it usually takes about 3-4 weeks until a data source is indexed and its metadata visible on openaire.eu.\n\n" +
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
"\nOfficial Name:" + repository.getOfficialName() +
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
"\n\nUser Contact:"+ issuerEmail +""+
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
"\n\n\nPlease do not reply to this email\n"+
"This message has been generated manually\n\n"+
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
"Regards,\n" +
"the OpenAIRE technical team\n";
this.sendMail(this.provideAdminEmail, subject, message, false, null);
} catch (Exception e) {
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
throw e;
}
}
@Override
public void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
try {
String subject = "OpenAIRE content provider registration request - results (failure) for " +
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
String message = "Dear user,\n" +
"\n" +
"the compatibility test on " + "[" + repository.getEnglishName() + "]" +
" was not successful and the registration process was interrupted."+
"\n\n" +
"We will check what caused the problem and get back to you within a couple of days.\n\n" +
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
"\nOfficial Name:" + repository.getOfficialName() +
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
"\n\n\nPlease do not reply to this email\n"+
"This message has been generated manually\n\n"+
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
"Regards,\n" +
"the OpenAIRE technical team\n";
this.sendMail(repository.getRegisteredBy(), subject, message, false, null);
} catch (Exception e) {
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
throw e;
}
}
@Override
public void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
try {
String subject = "OpenAIRE content provider registration request - results (failure) for " +
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
String message = "Dear admin,\n" +
"\n" +
"the compatibility test on " + "[" + repository.getEnglishName() + "]" +
" was not successful and the registration process was interrupted."+
"\n\n" +
"We will check what caused the problem and get back to you within a couple of days.\n\n" +
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
"\nOfficial Name:" + repository.getOfficialName() +
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
"\n\nUser Contact:"+ issuerEmail +""+
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
"\n\n\nPlease do not reply to this email\n"+
"This message has been generated manually\n\n"+
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
"Regards,\n" +
"the OpenAIRE technical team\n";
this.sendMail(this.provideAdminEmail, subject, message, false, null);
} catch (Exception e) {
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
throw e;
}
}
@Override
public void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
try {
String subject = "OpenAIRE content provider registration request - results (success) for " +
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
String message = "Dear user,\n" +
"\n" +
"the compatibility test on [" + repository.getEnglishName()+"] has been successful\n\n" +
"We will check your transmitted information and adjust the aggregation settings accordingly. Please note that it usually takes about 3-4 weeks until the changes are visible on openaire.eu."+"\n\n" +
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
"\nOfficial Name:" + repository.getOfficialName() +
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
"\n\n\nPlease do not reply to this email\n"+
"This message has been generated manually\n\n"+
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
"Regards,\n" +
"the OpenAIRE technical team\n";
this.sendMail(issuer, subject, message, false, null);
} catch (Exception e) {
LOGGER.error("Error while sending registration notification email to the administrator", e);
throw e;
}
}
@Override
public void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
try {
String subject = "OpenAIRE content provider registration request - results (success) for " +
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
String message = "Dear admin,\n" +
"\n" +
"the compatibility test on [" + repository.getEnglishName()+"] has been successful\n\n" +
"We will check your transmitted information and adjust the aggregation settings accordingly. Please note that it usually takes about 3-4 weeks until the changes are visible on openaire.eu."+"\n\n" +
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
"\nOfficial Name:" + repository.getOfficialName() +
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
"\n\nUser Contact:"+ issuerEmail +""+
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
"\n\n\nPlease do not reply to this email\n"+
"This message has been generated manually\n\n"+
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
"Regards,\n" +
"the OpenAIRE technical team\n";
this.sendMail(this.provideAdminEmail, subject, message, false, null);
} catch (Exception e) {
LOGGER.error("Error while sending registration notification email to the administrator", e);
throw e;
}
}
@Override
public void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
try {
String subject = "OpenAIRE content provider update request - results (failure) for " +
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
String message = "Dear user,\n" +
"\n" +
"the compatibility test on " + "[" + repository.getEnglishName() + "]" +
" was not successful."+
"\n\n" +
"WWe will check your transmitted information to see what caused the problem and get back to you within a couple of days.\n\n" +
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
"\nOfficial Name:" + repository.getOfficialName() +
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
"\n\n\nPlease do not reply to this email\n"+
"This message has been generated manually\n\n"+
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
"Regards,\n" +
"the OpenAIRE technical team\n";
this.sendMail(issuer, subject, message, false, null);
} catch (Exception e) {
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
throw e;
}
}
@Override
public void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
try {
String subject = "OpenAIRE content provider update request - results (failure) for " +
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
String message = "Dear admin,\n" +
"\n" +
"the compatibility test on " + "[" + repository.getEnglishName() + "]" +
" was not successful."+
"\n\n" +
"WWe will check your transmitted information to see what caused the problem and get back to you within a couple of days.\n\n" +
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
"\nOfficial Name:" + repository.getOfficialName() +
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
"\n\nUser Contact:"+ issuerEmail +""+
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
"\n\n\nPlease do not reply to this email\n"+
"This message has been generated manually\n\n"+
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
"Regards,\n" +
"the OpenAIRE technical team\n";
this.sendMail(this.provideAdminEmail, subject, message, false, null);
} catch (Exception e) {
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
throw e;
}
}
@Override
public void sendUserValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
try {
String subject = "OpenAIRE validator - Test results ";
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
String message = "Dear user,\n" +
"\n" +
"the validation request you have submitted has finished. You can retrieve the results by following this url: "+ valBaseUrl+"" + jobId+" .\n\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(issuer, subject, message, false, null);
} catch (Exception e) {
LOGGER.error("Error while sending validation submission notification email to user: " + issuer, e);
throw e;
}
}
@Override
public void sendAdminValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
try {
String subject = "OpenAIRE validator - Test results ";
String message = "Dear admin,\n" +
"\n" +
"the validation request you have submitted has finished. You can retrieve the results by following this url: "+ valBaseUrl+"" + jobId+" .\n\n" +
"\n\nUser Contact:"+ issuer +""+
"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(this.provideAdminEmail, subject, message, false, null);
} catch (Exception e) {
LOGGER.error("Error while sending validation submission notification email to user: " + issuer, e);
throw e;
}
}
@Override
public void sendAdminGeneralFailure(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
try {
String subject = "OpenAIRE validator - job failure";
String message = "Dear admin,\n" +
"\n" +
"the validation job that was automatically submitted for the update/registration of the interface "+repositoryInterface.getId()+" ("+repositoryInterface.getBaseUrl()+", "+repositoryInterface.getAccessSet()+") of the repository "+repository.getId()+" ("+repository.getOfficialName()+") failed to complete." +
"This message has been generated automatically.\n\n" +
"Regards,\n" +
"the OpenAIRE technical team\n";
this.sendMail(this.provideAdminEmail, subject, message, false, null);
} catch (Exception e) {
LOGGER.error("Error while sending validation submission notification email to user: " + issuer, e);
throw e;
}
}
@Override
public void sendAdminUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception {
try {
@ -275,7 +613,8 @@ public class EmailUtilsImpl implements EmailUtils {
String subject = "OpenAIRE content provider update request started for " +
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
String message = "Dear user,\n" +
"\n" +
"We received a request to update the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]." +
"A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" +
@ -298,7 +637,8 @@ public class EmailUtilsImpl implements EmailUtils {
try {
String subject = "OpenAIRE validator - Test submission ";
String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
String message = "Dear user,\n" +
"\n" +
"The validation request you have submitted has started.\n" +
"Please do not reply to this message.\n" +
@ -315,13 +655,59 @@ public class EmailUtilsImpl implements EmailUtils {
}
}
@Override
public void sendUponJobCompletion(
String repoId,
String repoInterfaceId,
int scoreUsage,
int scoreContent,
boolean isSuccess,
boolean isUpdate,
String issuerEmail,
String jobId) throws Exception {
List<RepositoryInterface> repositoryInterfaces = repositoryService.getRepositoryInterface(repoId);
if(repositoryInterfaces.size()==0)
throw new ValidationServiceException("Repository interface with id \""+repoInterfaceId+"\" not found",ValidationServiceException.ErrorCode.GENERAL_ERROR);
RepositoryInterface repositoryInterface = repositoryInterfaces.stream().filter( repoInterface -> repoInterface.getId().equals(repoInterfaceId)).collect(Collectors.toList()).get(0);
Repository repository = repositoryService.getRepositoryById(repoId);
if(!isUpdate){
if(isSuccess){
if(scoreContent>=50 && scoreUsage >= 50){
this.sendUserRegistrationResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
this.sendAdminRegistrationResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication());
}else{
this.sendUserRegistrationResultsFailureEmail(jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
this.sendAdminRegistrationResultsFailureEmail(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication());
}
}else{
this.sendAdminGeneralFailure(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication());
}
}else{
if(isSuccess){
if(scoreContent>=50 && scoreUsage >= 50){
this.sendUserUpdateResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
this.sendAdminUpdateResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
}else{
this.sendUserUpdateResultsFailureEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
this.sendAdminUpdateResultsFailureEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
}
}else{
this.sendAdminGeneralFailure(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication());
}
}
}
private void sendMail(String email, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception {
ArrayList<String> to = new ArrayList<String>();
to.add(email);
this.sendMail(to,subject,message,sendToSpecial,repoAdminMails);
}
private void sendMail(List<String> recipients, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception {
public void sendMail(List<String> recipients, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception {
try {
if (sendToSpecial) {
@ -383,5 +769,4 @@ public class EmailUtilsImpl implements EmailUtils {
this.logonly = logonly;
}
}

View File

@ -535,7 +535,7 @@ public class RepositoryServiceImpl implements RepositoryService {
HttpEntity<String> httpEntity = new HttpEntity <> (json_interface,httpHeaders);
restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class);
submitInterfaceValidation(e, registeredBy, repositoryInterface);
submitInterfaceValidation(e, registeredBy, repositoryInterface, false);
return repositoryInterface;
@ -554,11 +554,11 @@ public class RepositoryServiceImpl implements RepositoryService {
this.updateBaseUrl(repoId,repositoryInterface.getId(),repositoryInterface.getBaseUrl());
this.updateCompliance(repoId,repositoryInterface.getId(),repositoryInterface.getCompliance());
this.updateValidationSet(repoId,repositoryInterface.getId(),repositoryInterface.getAccessSet());
submitInterfaceValidation(getRepositoryById(repoId),registeredBy,repositoryInterface);
submitInterfaceValidation(getRepositoryById(repoId),registeredBy,repositoryInterface,true);
return repositoryInterface;
}
private void submitInterfaceValidation(Repository repo, String userEmail, RepositoryInterface iFace) throws ValidatorServiceException {
private void submitInterfaceValidation(Repository repo, String userEmail, RepositoryInterface iFace, boolean updateExisting) throws ValidatorServiceException {
JobForValidation job = new JobForValidation();
job.setActivationId(UUID.randomUUID().toString());
@ -572,8 +572,8 @@ public class RepositoryServiceImpl implements RepositoryService {
job.setUserEmail(userEmail);
job.setValidationSet((iFace.getAccessSet().isEmpty() ? "none" : iFace.getAccessSet()));
job.setRecords(-1);
job.setRegistration(true);
job.setUpdateExisting(false);
job.setRegistration(!updateExisting);
job.setUpdateExisting(updateExisting);
this.validatorService.submitJobForValidation(job);
}

View File

@ -55,14 +55,14 @@
<value>classpath*:/application.properties</value>
<value>classpath*:/email-texts.properties</value>
<value>classpath*:dnet-site-wizard.properties</value>
<value>classpath*:dnet-site-override.properties</value>
<value>classpath*:dnet-wizard.properties</value>
<value>classpath*:dnet-override.properties</value>
<value>classpath*:dnet-validator-wizard.properties</value>
<value>classpath*:dnet-validator-override.properties</value>
<value>classpath*:dnet-site-force-override.properties</value>
<value>classpath*:dnet-force-override.properties</value>
<!-- <value>classpath*:dnet-site-wizard.properties</value>-->
<!-- <value>classpath*:dnet-site-override.properties</value>-->
<!-- <value>classpath*:dnet-wizard.properties</value>-->
<!-- <value>classpath*:dnet-override.properties</value>-->
<!-- <value>classpath*:dnet-validator-wizard.properties</value>-->
<!-- <value>classpath*:dnet-validator-override.properties</value>-->
<!-- <value>classpath*:dnet-site-force-override.properties</value>-->
<!-- <value>classpath*:dnet-force-override.properties</value>-->
</list>
</property>
</bean>

View File

@ -1,15 +1,12 @@
log4j.rootLogger = WARN, R
log4j.logger.eu.dnetlib = DEBUG
log4j.logger.eu.dnetlib = INFO
log4j.logger.eu.dnetlib.repo.manager = INFO
log4j.logger.eu.dnetlib.clients.data.datasourcemanager.ws.Converter = FATAL
log4j.logger.org.springframework = INFO, S
log4j.additivity.org.springframework = false
log4j.logger.com.opensymphony.xwork2.ognl.OgnlValueStack = FATAL
log4j.logger.com.opensymphony.xwork2.ObjectFactory = FATAL
log4j.logger.eu.dnetlib.repo.manager=DEBUG
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/tmp/repository-service.log
#log4j.appender.R.File=/var/log/tomcat_dnet/8780/repository-service.log
@ -24,22 +21,4 @@ log4j.appender.S.File=/tmp/repository-service-spring.log
log4j.appender.S.MaxFileSize=10MB
log4j.appender.S.MaxBackupIndex=10
log4j.appender.S.layout=org.apache.log4j.PatternLayout
log4j.appender.S.layout.ConversionPattern= %d %p %t [%c] - %m%n
#log4j.rootLogger = WARN, R
#
#log4j.logger.org.springframework = DEBUG, S
#log4j.additivity.org.springframework = false
#
#log4j.logger.com.opensymphony.xwork2.ognl.OgnlValueStack = FATAL
#log4j.logger.com.opensymphony.xwork2.ObjectFactory = FATAL
#
#log4j.logger.eu.dnetlib.repo.manager=DEBUG
#
#log4j.appender.R=org.apache.log4j.ConsoleAppender
#log4j.appender.R.layout=org.apache.log4j.PatternLayout
#log4j.appender.R.layout.ConversionPattern= %d %p %t [%c] - %m%n
#
#log4j.appender.S=org.apache.log4j.ConsoleAppender
#log4j.appender.S.layout=org.apache.log4j.PatternLayout
#log4j.appender.S.layout.ConversionPattern= %d %p %t [%c] - %m%n
log4j.appender.S.layout.ConversionPattern= %d %p %t [%c] - %m%n

View File

@ -6,6 +6,8 @@
</listener>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
<!-- TODO: import correct dependency -->
<!-- <listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class>-->
</listener>
<context-param>