Created the functionality to alter an interface's compliance after its successful validation

This commit is contained in:
Konstantinos Spyrou 2023-01-16 20:30:09 +02:00
parent 87f610b06b
commit 817446df41
16 changed files with 712 additions and 219 deletions

View File

@ -38,6 +38,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator-autoconfigure</artifactId>

View File

@ -0,0 +1,40 @@
package eu.dnetlib.repo.manager.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
@Configuration
@EnableTransactionManagement
public class JpaConfig {
@Autowired
DataSource dataSource;
@Autowired
EntityManagerFactory entityManagerFactory;
@Bean
public PlatformTransactionManager transactionManager() {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(entityManagerFactory);
return transactionManager;
}
@Bean
public PersistenceExceptionTranslationPostProcessor exceptionTranslation(){
return new PersistenceExceptionTranslationPostProcessor();
}
}

View File

@ -0,0 +1,47 @@
package eu.dnetlib.repo.manager.controllers;
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequest;
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequestId;
import eu.dnetlib.repo.manager.domain.dto.InterfaceComplianceRequestDTO;
import eu.dnetlib.repo.manager.service.InterfaceComplianceService;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
@RestController
@RequestMapping("compliance")
public class InterfaceComplianceRequestController {
private final InterfaceComplianceService service;
public InterfaceComplianceRequestController(InterfaceComplianceService service) {
this.service = service;
}
@GetMapping("{repositoryId}/{interfaceId}")
public InterfaceComplianceRequest get(@PathVariable("repositoryId") String repositoryId, @PathVariable("interfaceId") String interfaceId) {
InterfaceComplianceRequestId id = new InterfaceComplianceRequestId();
id.setRepositoryId(repositoryId);
id.setInterfaceId(interfaceId);
return service.getById(id).orElse(null);
}
@GetMapping()
public Iterable<InterfaceComplianceRequest> get() {
return service.get();
}
@PostMapping()
public InterfaceComplianceRequest add(@RequestBody InterfaceComplianceRequestDTO requestDTO) {
requestDTO.setSubmissionDate(new Date());
return service.create(InterfaceComplianceRequest.from(requestDTO));
}
@DeleteMapping("{repositoryId}/{interfaceId}")
public void delete(@PathVariable("repositoryId") String repositoryId, @PathVariable("interfaceId") String interfaceId) {
InterfaceComplianceRequestId id = new InterfaceComplianceRequestId();
id.setRepositoryId(repositoryId);
id.setInterfaceId(interfaceId);
this.service.delete(id);
}
}

View File

@ -210,9 +210,10 @@ public class RepositoryController {
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
@RequestParam("repoId") String id,
@RequestParam(required = false, name = "desiredCompatibilityLevel") String desiredCompatibilityLevel,
@RequestParam(value = "comment", required = false) String comment,
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
return repositoryService.addRepositoryInterface(datatype, id, comment, repositoryInterface);
return repositoryService.addRepositoryInterface(datatype, id, comment, repositoryInterface, desiredCompatibilityLevel);
}
@RequestMapping(value = "/updateRepositoryInterface", method = RequestMethod.POST,

View File

@ -0,0 +1,95 @@
package eu.dnetlib.repo.manager.domain;
import eu.dnetlib.repo.manager.domain.dto.InterfaceComplianceRequestDTO;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Transient;
import java.util.Date;
@Entity
@IdClass(InterfaceComplianceRequestId.class)
public class InterfaceComplianceRequest {
@Id
String repositoryId;
@Id
String interfaceId;
String desiredCompatibilityLevel;
Date submissionDate;
public InterfaceComplianceRequest() {
this.submissionDate = new Date();
}
public InterfaceComplianceRequest(String repositoryId, String interfaceId, String desiredCompatibilityLevel) {
this.submissionDate = new Date();
this.repositoryId = repositoryId;
this.interfaceId = interfaceId;
this.desiredCompatibilityLevel = desiredCompatibilityLevel;
}
public static InterfaceComplianceRequest from(InterfaceComplianceRequestDTO dto) {
InterfaceComplianceRequest request = new InterfaceComplianceRequest();
request.setRepositoryId(dto.getRepositoryId());
request.setInterfaceId(dto.getInterfaceId());
if (dto.getSubmissionDate() != null) {
request.setSubmissionDate(dto.getSubmissionDate());
} else {
request.setSubmissionDate(new Date());
}
request.setDesiredCompatibilityLevel(dto.getDesiredCompatibilityLevel());
return request;
}
@Transient
public InterfaceComplianceRequestId getId() {
InterfaceComplianceRequestId id = new InterfaceComplianceRequestId();
id.repositoryId = this.repositoryId;
id.interfaceId = this.interfaceId;
return id;
}
public String getRepositoryId() {
return repositoryId;
}
public void setRepositoryId(String repositoryId) {
this.repositoryId = repositoryId;
}
public String getInterfaceId() {
return interfaceId;
}
public void setInterfaceId(String interfaceId) {
this.interfaceId = interfaceId;
}
public String getDesiredCompatibilityLevel() {
return desiredCompatibilityLevel;
}
public void setDesiredCompatibilityLevel(String desiredCompatibilityLevel) {
this.desiredCompatibilityLevel = desiredCompatibilityLevel;
}
public Date getSubmissionDate() {
return submissionDate;
}
public void setSubmissionDate(Date submissionDate) {
this.submissionDate = submissionDate;
}
@Override
public String toString() {
return "InterfaceComplianceRequest{" +
"repositoryId='" + repositoryId + '\'' +
", interfaceId='" + interfaceId + '\'' +
", desiredCompatibilityLevel='" + desiredCompatibilityLevel + '\'' +
", submissionDate=" + submissionDate +
'}';
}
}

View File

@ -0,0 +1,50 @@
package eu.dnetlib.repo.manager.domain;
import java.io.Serializable;
public class InterfaceComplianceRequestId implements Serializable {
String repositoryId;
String interfaceId;
public String getRepositoryId() {
return repositoryId;
}
public void setRepositoryId(String repositoryId) {
this.repositoryId = repositoryId;
}
public String getInterfaceId() {
return interfaceId;
}
public void setInterfaceId(String interfaceId) {
this.interfaceId = interfaceId;
}
public static InterfaceComplianceRequestId of(String repositoryId, String interfaceId) {
InterfaceComplianceRequestId id = new InterfaceComplianceRequestId();
id.setRepositoryId(repositoryId);
id.setInterfaceId(interfaceId);
return id;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof InterfaceComplianceRequestId)) return false;
InterfaceComplianceRequestId that = (InterfaceComplianceRequestId) o;
if (getRepositoryId() != null ? !getRepositoryId().equals(that.getRepositoryId()) : that.getRepositoryId() != null)
return false;
return getInterfaceId() != null ? getInterfaceId().equals(that.getInterfaceId()) : that.getInterfaceId() == null;
}
@Override
public int hashCode() {
int result = getRepositoryId() != null ? getRepositoryId().hashCode() : 0;
result = 31 * result + (getInterfaceId() != null ? getInterfaceId().hashCode() : 0);
return result;
}
}

View File

@ -0,0 +1,47 @@
package eu.dnetlib.repo.manager.domain.dto;
import java.util.Date;
public class InterfaceComplianceRequestDTO {
String repositoryId;
String interfaceId;
String desiredCompatibilityLevel;
Date submissionDate;
public InterfaceComplianceRequestDTO() {
// no-arg constructor
}
public String getRepositoryId() {
return repositoryId;
}
public void setRepositoryId(String repositoryId) {
this.repositoryId = repositoryId;
}
public String getInterfaceId() {
return interfaceId;
}
public void setInterfaceId(String interfaceId) {
this.interfaceId = interfaceId;
}
public String getDesiredCompatibilityLevel() {
return desiredCompatibilityLevel;
}
public void setDesiredCompatibilityLevel(String desiredCompatibilityLevel) {
this.desiredCompatibilityLevel = desiredCompatibilityLevel;
}
public Date getSubmissionDate() {
return submissionDate;
}
public void setSubmissionDate(Date submissionDate) {
this.submissionDate = submissionDate;
}
}

View File

@ -0,0 +1,13 @@
package eu.dnetlib.repo.manager.exception;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(HttpStatus.CONFLICT)
public class ResourceConflictException extends RuntimeException {
public ResourceConflictException(String message) {
super(message);
}
}

View File

@ -0,0 +1,15 @@
package eu.dnetlib.repo.manager.repository;
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequest;
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequestId;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.Set;
@Repository
public interface InterfaceComplianceRequestsRepository extends CrudRepository<InterfaceComplianceRequest, InterfaceComplianceRequestId> {
Set<InterfaceComplianceRequest> findAllBySubmissionDateBefore(Date submittedBefore);
}

View File

@ -2,11 +2,14 @@ package eu.dnetlib.repo.manager.service;
import eu.dnetlib.domain.data.PiwikInfo;
import eu.dnetlib.domain.functionality.validator.JobForValidation;
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequest;
import eu.dnetlib.repo.manager.domain.Repository;
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
import org.springframework.scheduling.annotation.Async;
import org.springframework.security.core.Authentication;
import java.util.List;
public interface EmailUtils {
@Async
@ -36,42 +39,49 @@ public interface EmailUtils {
/****SUCCESSFUL REGISTRATION RESULTS EMAILS****/
@Async
void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
@Async
void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
/****FAILURE REGISTRATION RESULTS EMAILS****/
@Async
void sendUserRegistrationResultsFailureEmail(String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
@Async
void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
/****SUCCESSFUL UPDATE RESULTS EMAILS****/
@Async
void sendUserUpdateResultsSuccessEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
@Async
void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
/****FAILURE UPDATE RESULTS EMAILS****/
@Async
void sendUserUpdateResultsFailureEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
@Async
void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
/****FAILURE UPDATE INTERFACE COMPLIANCE****/
@Async
void sendUserUpdateInterfaceComplianceFailure(List<String> emails, Repository repository, RepositoryInterface repositoryInterface, InterfaceComplianceRequest request);
@Async
void sendAdminUpdateInterfaceComplianceFailure(Repository repository, RepositoryInterface repositoryInterface, InterfaceComplianceRequest request);
/****VALIDATION OF CONTENT PROVIDER EMAILS****/
@Async
void sendUserValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
void sendUserValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
@Async
void sendAdminValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
void sendAdminValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
/****GENERAL FAILURE OF VALIDATOR****/
@Async
void sendAdminGeneralFailure(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
void sendAdminGeneralFailure(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
@Async

View File

@ -2,6 +2,7 @@ package eu.dnetlib.repo.manager.service;
import eu.dnetlib.domain.data.PiwikInfo;
import eu.dnetlib.domain.functionality.validator.JobForValidation;
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequest;
import eu.dnetlib.repo.manager.domain.Repository;
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
@ -53,14 +54,14 @@ public class EmailUtilsImpl implements EmailUtils {
String message =
"we have received a request to enable the OpenAIRE usage statistics for the following repository \n" +
"\n" +
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
"Matomo ID - " + piwikInfo.getSiteId() + "\n" +
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
"\n" +
"For more information about this request, go here: \n" +
this.baseUrl + "/admin/metrics";
"\n" +
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
"Matomo ID - " + piwikInfo.getSiteId() + "\n" +
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
"\n" +
"For more information about this request, go here: \n" +
this.baseUrl + "/admin/metrics";
message = createAdminMail(message);
this.sendMail(this.usageStatsAdminEmail, subject, message);
@ -114,12 +115,12 @@ public class EmailUtilsImpl implements EmailUtils {
String message =
"The installation and configuration of OpenAIRE's tracking code for the following repository " +
"has been completed and validated and the usage statistics have been enabled in OpenAIRE.\n" +
"\n" +
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
"Piwik ID - " + piwikInfo.getSiteId() + "\n" +
"Authentication token - " + piwikInfo.getAuthenticationToken();
"has been completed and validated and the usage statistics have been enabled in OpenAIRE.\n" +
"\n" +
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
"Piwik ID - " + piwikInfo.getSiteId() + "\n" +
"Authentication token - " + piwikInfo.getAuthenticationToken();
message = createAdminMail(message);
this.sendMail(this.usageStatsAdminEmail, subject, message);
@ -164,12 +165,12 @@ public class EmailUtilsImpl implements EmailUtils {
String message =
"We received a request to register the " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]" +
" to the OpenAIRE compliant list of content providers. " +
"\n\n" +
"User Contact: " + authentication.getName() + " (" + ((OIDCAuthenticationToken) authentication).getUserInfo().getEmail() + ")" +
"\n\n" +
"Please do not reply to this message\n" +
"This message has been generated automatically.";
" to the OpenAIRE compliant list of content providers. " +
"\n\n" +
"User Contact: " + authentication.getName() + " (" + ((OIDCAuthenticationToken) authentication).getUserInfo().getEmail() + ")" +
"\n\n" +
"Please do not reply to this message\n" +
"This message has been generated automatically.";
message = createAdminMail(message);
this.sendMail(this.provideAdminEmail, subject, message);
@ -187,11 +188,11 @@ public class EmailUtilsImpl implements EmailUtils {
String message =
"We received a request to register the " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]" +
" to the OpenAIRE compliant list of content providers. " +
"\n\n" +
"Please do not reply to this message\n" +
"This message has been generated automatically.\n\n" +
"If you have any questions, write to 'helpdesk@openaire.eu'.";
" to the OpenAIRE compliant list of content providers. " +
"\n\n" +
"Please do not reply to this message\n" +
"This message has been generated automatically.\n\n" +
"If you have any questions, write to 'helpdesk@openaire.eu'.";
message = createUserMail(message, authentication);
this.sendMail(repository.getRegisteredby(), subject, message);
@ -209,10 +210,10 @@ public class EmailUtilsImpl implements EmailUtils {
String message =
"We received a request to add the following interface: \n\n" +
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
"Set: " + repositoryInterface.getAccessSet() + "\n" +
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
"to " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
"Set: " + repositoryInterface.getAccessSet() + "\n" +
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
"to " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
if (comment != null)
message += "\nThe users comment was '" + comment + "'\n";
@ -240,10 +241,10 @@ public class EmailUtilsImpl implements EmailUtils {
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
String message =
"We received a request to add the following interface: \n\n" +
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
"Set: " + repositoryInterface.getAccessSet() + "\n" +
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
"to " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
"Set: " + repositoryInterface.getAccessSet() + "\n" +
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
"to " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
if (comment != null) {
message += "\n Your comment was '" + comment + "'\n";
@ -271,18 +272,18 @@ public class EmailUtilsImpl implements EmailUtils {
String message =
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
" was successful and the datasource type \""+ repository.getEoscDatasourceType() + "\" 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.getCompatibilityOverride() +
"\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'.";
" was successful and the datasource type \"" + repository.getEoscDatasourceType() + "\" 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.getCompatibilityOverride() +
"\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'.";
message = createUserMail(message, authentication);
this.sendMail(repository.getRegisteredby(), subject, message);
@ -293,26 +294,26 @@ public class EmailUtilsImpl implements EmailUtils {
}
@Override
public void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) {
public void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) {
try {
String subject = "OpenAIRE new interface registration request - results (success) for " +
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
String message =
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
" was successful and the datasource type \""+ repository.getEoscDatasourceType() + "\" 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.getCompatibilityOverride() +
"\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'.";
" was successful and the datasource type \"" + repository.getEoscDatasourceType() + "\" 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.getCompatibilityOverride() +
"\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'.";
message = createAdminMail(message);
this.sendMail(this.provideAdminEmail, subject, message);
@ -329,18 +330,18 @@ public class EmailUtilsImpl implements EmailUtils {
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
String message =
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
" 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.getCompatibilityOverride() +
"\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'.";
" 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.getCompatibilityOverride() +
"\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'.";
message = createUserMail(message, authentication);
this.sendMail(repository.getRegisteredby(), subject, message);
@ -358,19 +359,19 @@ public class EmailUtilsImpl implements EmailUtils {
String message =
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
" 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.getCompatibilityOverride() +
"\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'.";
" 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.getCompatibilityOverride() +
"\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'.";
message = createAdminMail(message);
this.sendMail(this.provideAdminEmail, subject, message);
@ -387,17 +388,17 @@ public class EmailUtilsImpl implements EmailUtils {
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
String message =
"the compatibility test on [" + repository.getOfficialname()+"] 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.getCompatibilityOverride() +
"\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'.";
"the compatibility test on [" + repository.getOfficialname() + "] 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.getCompatibilityOverride() +
"\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'.";
message = createUserMail(message, authentication);
this.sendMail(issuer, subject, message);
@ -409,30 +410,30 @@ public class EmailUtilsImpl implements EmailUtils {
@Override
public void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) {
try {
String subject = "OpenAIRE interface update request - results (success) for " +
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
try {
String subject = "OpenAIRE interface update request - results (success) for " +
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
String message =
"the compatibility test on [" + repository.getOfficialname()+"] 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.getCompatibilityOverride() +
"\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'.";
message = createAdminMail(message);
String message =
"the compatibility test on [" + repository.getOfficialname() + "] 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.getCompatibilityOverride() +
"\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'.";
message = createAdminMail(message);
this.sendMail(this.provideAdminEmail, subject, message);
this.sendMail(this.provideAdminEmail, subject, message);
} catch (Exception e) {
logger.error("Error while sending registration notification email to the administrator", e);
}
} catch (Exception e) {
logger.error("Error while sending registration notification email to the administrator", e);
}
}
@Override
@ -443,18 +444,18 @@ public class EmailUtilsImpl implements EmailUtils {
String message =
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
" 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.getCompatibilityOverride() +
"\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'.";
" 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.getCompatibilityOverride() +
"\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'.";
message = createUserMail(message, authentication);
this.sendMail(issuer, subject, message);
@ -472,19 +473,75 @@ public class EmailUtilsImpl implements EmailUtils {
String message =
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
" 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.getCompatibilityOverride() +
"\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'.";
" 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.getCompatibilityOverride() +
"\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'.";
message = createAdminMail(message);
this.sendMail(this.provideAdminEmail, subject, message);
} catch (Exception e) {
logger.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
}
}
@Override
public void sendUserUpdateInterfaceComplianceFailure(List<String> emails, Repository repository, RepositoryInterface repositoryInterface, InterfaceComplianceRequest request) {
try {
String subject = "OpenAIRE interface update compliance request - results (failure) for " +
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
String message =
"The request for changing the compatibility of " + "[" + repository.getOfficialname() + "]" +
" was not successful." +
"\n\n" +
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
"\nOfficial Name:" + repository.getOfficialname() +
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: " + request.getDesiredCompatibilityLevel() +
"\n\n\nPlease do not reply to this email\n" +
"This message has been generated automatically\n\n" +
"If you have any questions, write to 'helpdesk@openaire.eu'.";
message = createRepoAdminsMail(message);
this.sendMail(emails, subject, message);
} catch (Exception e) {
logger.error("Notification email to repository admins failed.\nRepository: {}\nRequest: {}", repository, request, e);
}
}
@Override
public void sendAdminUpdateInterfaceComplianceFailure(Repository repository, RepositoryInterface repositoryInterface, InterfaceComplianceRequest request) {
try {
String subject = "OpenAIRE interface update compliance request - results (failure) for " +
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
String message =
"The request for changing the compatibility of " + "[" + repository.getOfficialname() + "]" +
" was not successful." +
"\n\n" +
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
"\nOfficial Name:" + repository.getOfficialname() +
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: " + request.getDesiredCompatibilityLevel() +
"\n\n\nPlease do not reply to this email\n" +
"This message has been generated automatically\n\n" +
"If you have any questions, write to 'helpdesk@openaire.eu'.";
message = createAdminMail(message);
this.sendMail(this.provideAdminEmail, subject, message);
@ -500,10 +557,10 @@ public class EmailUtilsImpl implements EmailUtils {
String subject = "OpenAIRE validator - Test results ";
String message =
"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'.";
"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'.";
message = createUserMail(message, authentication);
this.sendMail(issuer, subject, message);
@ -519,11 +576,11 @@ public class EmailUtilsImpl implements EmailUtils {
String subject = "OpenAIRE validator - Test results ";
String message =
"a validation request 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'.";
"a validation request 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'.";
message = createAdminMail(message);
this.sendMail(this.provideAdminEmail, subject, message);
@ -539,8 +596,8 @@ public class EmailUtilsImpl implements EmailUtils {
String subject = "OpenAIRE validator - job failure";
String message =
"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.";
"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.";
message = createAdminMail(message);
this.sendMail(this.provideAdminEmail, subject, message);
@ -558,8 +615,8 @@ public class EmailUtilsImpl implements EmailUtils {
String message =
"We received a request to update the basic information for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n\n" +
"Please do not reply to this message\n" +
"This message has been generated automatically.";
"Please do not reply to this message\n" +
"This message has been generated automatically.";
message = createAdminMail(message);
this.sendMail(this.provideAdminEmail, subject, message);
@ -577,9 +634,9 @@ public class EmailUtilsImpl implements EmailUtils {
String message =
"We received a request to update the basic information for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n\n" +
"Please do not reply to this message\n" +
"This message has been generated automatically.\n\n" +
"If you have any questions, write to 'helpdesk@openaire.eu'.";
"Please do not reply to this message\n" +
"This message has been generated automatically.\n\n" +
"If you have any questions, write to 'helpdesk@openaire.eu'.";
message = createUserMail(message, authentication);
this.sendMail(repository.getRegisteredby(), subject, message);
@ -597,10 +654,10 @@ public class EmailUtilsImpl implements EmailUtils {
String message =
"We received a request to update the following interface: \n\n" +
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
"Set: " + repositoryInterface.getAccessSet() + "\n" +
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
"for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
"Set: " + repositoryInterface.getAccessSet() + "\n" +
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
"for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
if (comment != null)
message += "\nThe users comment was '" + comment + "'\n";
@ -627,10 +684,10 @@ public class EmailUtilsImpl implements EmailUtils {
String message =
"We received a request to update the following interface: \n\n" +
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
"Set: " + repositoryInterface.getAccessSet() + "\n" +
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
"for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
"Set: " + repositoryInterface.getAccessSet() + "\n" +
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
"for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
if (comment != null) {
message += "\n Your comment was '" + comment + "'\n";
@ -656,9 +713,9 @@ public class EmailUtilsImpl implements EmailUtils {
String message =
"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'.";
"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'.";
message = createUserMail(message, authentication);
this.sendMail(jobForValidation.getUserEmail(), subject, message);
@ -679,35 +736,35 @@ public class EmailUtilsImpl implements EmailUtils {
String issuerEmail,
String jobId) throws Exception {
List<RepositoryInterface> repositoryInterfaces = repositoryService.getRepositoryInterface(repoId);
if(repositoryInterfaces.isEmpty())
throw new ValidationServiceException("Repository interface with id \""+repoInterfaceId+"\" not found",ValidationServiceException.ErrorCode.GENERAL_ERROR);
if (repositoryInterfaces.isEmpty())
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);
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());
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 {
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 {
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());
} else {
this.sendAdminGeneralFailure(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication());
}
}
@ -738,12 +795,19 @@ public class EmailUtilsImpl implements EmailUtils {
return body;
}
private String createRepoAdminsMail(String body) {
body = "Dear repository admins,\n\n" + body;
body += "\n\nBest Regards,\nthe OpenAIRE technical team\n";
return body;
}
private String getUserName(Authentication authentication) {
String user = "user";
if (authentication != null) {
try {
user = ((OIDCAuthenticationToken) authentication).getUserInfo().getName();
} catch (NullPointerException ex) {}
} catch (NullPointerException ex) {
}
}
return user; // It may be just "user". TODO - Wouldn't be better if it was null?
}

View File

@ -0,0 +1,87 @@
package eu.dnetlib.repo.manager.service;
import eu.dnetlib.repo.manager.domain.*;
import eu.dnetlib.repo.manager.domain.dto.User;
import eu.dnetlib.repo.manager.exception.ResourceConflictException;
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
import eu.dnetlib.repo.manager.repository.InterfaceComplianceRequestsRepository;
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
import org.json.JSONException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class InterfaceComplianceService {
private static final Logger logger = LoggerFactory.getLogger(InterfaceComplianceService.class);
private final InterfaceComplianceRequestsRepository repository;
private final EmailUtils emailUtils;
private final AuthorizationService authorizationService;
private final RepositoryService repositoryService;
public InterfaceComplianceService(InterfaceComplianceRequestsRepository repository,
EmailUtils emailUtils,
AuthorizationService authorizationService,
RepositoryService repositoryService) {
this.repository = repository;
this.emailUtils = emailUtils;
this.authorizationService = authorizationService;
this.repositoryService = repositoryService;
}
@Scheduled(cron = "0 0 0 * * *") // every day at 00:00
public void cleanUp() {
Set<InterfaceComplianceRequest> requests = getOutdated();
for (InterfaceComplianceRequest request : requests) {
try {
Map<String, RepositoryInterface> repositoryInterfaceMap = repositoryService.getRepositoryInterface(request.getRepositoryId())
.stream()
.collect(Collectors.toMap(ApiDetails::getId, i -> i));
Repository repo = repositoryService.getRepositoryById(request.getRepositoryId());
RepositoryInterface iFace = repositoryInterfaceMap.get(request.getInterfaceId());
List<User> repositoryAdmins = authorizationService.getAdminsOfRepo(request.getRepositoryId());
emailUtils.sendUserUpdateInterfaceComplianceFailure(repositoryAdmins.stream().map(User::getEmail).collect(Collectors.toList()), repo, iFace, request);
emailUtils.sendAdminUpdateInterfaceComplianceFailure(repo, iFace, request);
} catch (JSONException | ResourceNotFoundException e) {
logger.error("Error", e);
}
}
repository.deleteAll(requests);
}
private Set<InterfaceComplianceRequest> getOutdated() {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, -7);
return this.repository.findAllBySubmissionDateBefore(calendar.getTime());
}
public Optional<InterfaceComplianceRequest> getById(InterfaceComplianceRequestId id) {
return this.repository.findById(id);
}
public Iterable<InterfaceComplianceRequest> get() {
return this.repository.findAll();
}
public InterfaceComplianceRequest create(InterfaceComplianceRequest request) {
Optional<InterfaceComplianceRequest> existing = getById(request.getId());
if (existing.isPresent()) {
logger.warn("New Request: {}\nExisting request: {}", request, existing.get());
throw new ResourceConflictException("A request for altering compliance already exists. Desired Compatibility value: " + existing.get().getDesiredCompatibilityLevel());
}
return this.repository.save(request);
}
public void delete(InterfaceComplianceRequestId id) {
this.repository.deleteById(id);
}
}

View File

@ -193,9 +193,9 @@ public class PiWikServiceImpl implements PiWikService {
String repoWebsite,
PiwikInfo piwikInfo) throws RepositoryServiceException {
try {
String URL = analyticsURL + "siteName=" + URLEncoder.encode(officialName, "UTF-8") + "&url="
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);
Map map = new ObjectMapper().readValue(new URL(url), Map.class);
String siteId = null;
if (map.get("value") != null) {
siteId = map.get("value").toString();

View File

@ -60,7 +60,9 @@ public interface RepositoryService {
RepositoryInterface addRepositoryInterface(String datatype,
String repoId,
String comment, RepositoryInterface repositoryInterface) throws Exception;
String comment,
RepositoryInterface repositoryInterface,
String desiredCompatibilityLevel) throws Exception;
List<String> getDnetCountries();

View File

@ -62,6 +62,7 @@ public class RepositoryServiceImpl implements RepositoryService {
private final PiWikService piWikService;
private final EmailUtils emailUtils;
private final ValidatorService validatorService;
private final InterfaceComplianceService interfaceComplianceService;
@Value("${services.provide.clients.dsm}")
private String baseAddress;
@ -98,7 +99,8 @@ public class RepositoryServiceImpl implements RepositoryService {
Converter converter,
@Lazy EmailUtils emailUtils,
@Lazy ValidatorService validatorService,
@Lazy PiWikService piWikService) {
@Lazy PiWikService piWikService,
@Lazy InterfaceComplianceService interfaceComplianceService) {
this.authorizationService = authorizationService;
this.roleMappingService = roleMappingService;
this.registryCalls = registryCalls;
@ -110,6 +112,7 @@ public class RepositoryServiceImpl implements RepositoryService {
this.validatorService = validatorService;
this.restTemplate = restTemplate;
this.objectMapper = objectMapper;
this.interfaceComplianceService = interfaceComplianceService;
}
@PostConstruct
@ -634,7 +637,9 @@ public class RepositoryServiceImpl implements RepositoryService {
@Override
public RepositoryInterface addRepositoryInterface(String datatype,
String repoId,
String comment, RepositoryInterface repositoryInterface) throws Exception {
String comment,
RepositoryInterface repositoryInterface,
String desiredCompatibilityLevel) throws Exception {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
Repository e = this.getRepositoryById(repoId);
repositoryInterface = createRepositoryInterface(e, repositoryInterface, datatype);
@ -652,6 +657,11 @@ public class RepositoryServiceImpl implements RepositoryService {
emailUtils.sendAdminRegisterInterfaceEmail(e, comment, repositoryInterface, authentication);
emailUtils.sendUserRegisterInterfaceEmail(e, comment, repositoryInterface, authentication);
if (desiredCompatibilityLevel!= null && !repositoryInterface.getCompatibility().equals(desiredCompatibilityLevel)) {
InterfaceComplianceRequest request = new InterfaceComplianceRequest(repoId, repositoryInterface.getId(), desiredCompatibilityLevel);
interfaceComplianceService.create(request);
}
submitInterfaceValidation(e, getAuthenticatedUser().getEmail(), repositoryInterface, false, repositoryInterface.getCompatibility());
return repositoryInterface;
@ -670,7 +680,11 @@ public class RepositoryServiceImpl implements RepositoryService {
emailUtils.sendAdminUpdateInterfaceEmail(repository, comment, repositoryInterface, authentication);
emailUtils.sendUserUpdateInterfaceEmail(repository, comment, repositoryInterface, authentication);
logger.warn("Create entry in DB for requesting another compatibility level");
if (desiredCompatibilityLevel!= null && !repositoryInterface.getCompatibility().equals(desiredCompatibilityLevel)) {
InterfaceComplianceRequest request = new InterfaceComplianceRequest(repoId, repositoryInterface.getId(), desiredCompatibilityLevel);
interfaceComplianceService.create(request);
}
submitInterfaceValidation(getRepositoryById(repoId), getAuthenticatedUser().getEmail(), repositoryInterface, true, desiredCompatibilityLevel);
return repositoryInterface;

View File

@ -5,9 +5,7 @@ import eu.dnetlib.domain.functionality.validator.JobForValidation;
import eu.dnetlib.domain.functionality.validator.Rule;
import eu.dnetlib.domain.functionality.validator.RuleSet;
import eu.dnetlib.domain.functionality.validator.StoredJob;
import eu.dnetlib.repo.manager.domain.Constants;
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
import eu.dnetlib.repo.manager.domain.*;
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
import eu.dnetlib.repo.manager.utils.CrisValidatorUtils;
import eu.dnetlib.repo.manager.utils.OaiTools;
@ -70,6 +68,9 @@ public class ValidatorServiceImpl implements ValidatorService {
@Autowired
private MapJobDao crisJobs;
@Autowired
InterfaceComplianceService interfaceComplianceService;
public static final Pattern OPENAIRE_DATA_REGEX = Pattern.compile("^openaire[1-9].0_data$");
public static final Pattern OPENAIRE_OR_DRIVER_REGEX = Pattern.compile("^(?:openaire[1-9].0|driver)$");
@ -310,12 +311,15 @@ public class ValidatorServiceImpl implements ValidatorService {
@Override
public void onComplete(String repoId, String interfaceId, String jobId, String issuerEmail, boolean isUpdate, boolean isSuccess, int scoreUsage, int scoreContent) throws Exception {
emailUtils.sendUponJobCompletion(repoId,interfaceId,scoreUsage,scoreContent,isSuccess,isUpdate,issuerEmail, jobId);
String compliance = ""; // FIXME: search DB for change in compatibility request
// TODO: delete table entry if exists
logger.warn("Missing implementation for changing compatibility level");
if (scoreContent > 50) {
// TODO: update compliance
repositoryService.updateInterfaceCompliance(repoId, interfaceId, compliance);
InterfaceComplianceRequestId requestId = InterfaceComplianceRequestId.of(repoId, interfaceId);
Optional<InterfaceComplianceRequest> request = interfaceComplianceService.getById(requestId);
if (request.isPresent()) {
logger.info("Changing compatibility level. Request: {}", request);
if (scoreContent > 50) {
repositoryService.updateInterfaceCompliance(repoId, interfaceId, request.get().getDesiredCompatibilityLevel());
}
interfaceComplianceService.delete(requestId);
}
}