added the option to send emails to users
This commit is contained in:
parent
b91330455d
commit
2e9657cb61
|
@ -170,8 +170,9 @@ public class RepositoryController {
|
||||||
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
|
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
|
||||||
@RequestParam("repoId") String repoId,
|
@RequestParam("repoId") String repoId,
|
||||||
@RequestParam("registeredBy") String registeredBy,
|
@RequestParam("registeredBy") String registeredBy,
|
||||||
|
@RequestParam("comment") String comment,
|
||||||
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
||||||
return repositoryService.addRepositoryInterface(datatype, repoId, registeredBy, repositoryInterface);
|
return repositoryService.addRepositoryInterface(datatype, repoId, registeredBy, comment, repositoryInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getUrlsOfUserRepos/{page}/{size}/",method = RequestMethod.GET,
|
@RequestMapping(value = "/getUrlsOfUserRepos/{page}/{size}/",method = RequestMethod.GET,
|
||||||
|
@ -226,7 +227,8 @@ public class RepositoryController {
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#repoId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#repoId).registeredBy=='null') and hasRole('ROLE_USER'))")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#repoId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#repoId).registeredBy=='null') and hasRole('ROLE_USER'))")
|
||||||
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String repoId,
|
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String repoId,
|
||||||
@RequestParam("registeredBy") String registeredBy,
|
@RequestParam("registeredBy") String registeredBy,
|
||||||
|
@RequestParam("comment") String comment,
|
||||||
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
||||||
return repositoryService.updateRepositoryInterface(repoId, registeredBy, repositoryInterface);
|
return repositoryService.updateRepositoryInterface(repoId, registeredBy, comment, repositoryInterface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,9 @@ public interface EmailUtils {
|
||||||
|
|
||||||
void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
|
void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
|
||||||
|
|
||||||
void sendAdminRegisterInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
||||||
|
|
||||||
void sendUserRegisterInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
||||||
|
|
||||||
/****SUCCESSFUL REGISTRATION RESULTS EMAILS****/
|
/****SUCCESSFUL REGISTRATION RESULTS EMAILS****/
|
||||||
void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||||
|
@ -61,9 +61,9 @@ public interface EmailUtils {
|
||||||
|
|
||||||
void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) throws Exception;
|
void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) throws Exception;
|
||||||
|
|
||||||
void sendAdminUpdateInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
||||||
|
|
||||||
void sendUserUpdateInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
||||||
|
|
||||||
void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception;
|
void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception;
|
||||||
|
|
||||||
|
|
|
@ -256,7 +256,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdminRegisterInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
public void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE new interface registration request started for " +
|
String subject = "OpenAIRE new interface registration request started for " +
|
||||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||||
|
@ -267,8 +267,12 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
"Base URL: " + repositoryInterface.getBaseUrl() + "\n" +
|
"Base URL: " + repositoryInterface.getBaseUrl() + "\n" +
|
||||||
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
||||||
"Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" +
|
"Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" +
|
||||||
"to " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n" +
|
"to " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n";
|
||||||
"A validation process for this interface against the OpenAIRE guidelines compatibility " +
|
|
||||||
|
if (comment != null)
|
||||||
|
comment += "\nThe users comment was '" + comment + "'\n";
|
||||||
|
|
||||||
|
message += "A validation process for this interface against the OpenAIRE guidelines compatibility " +
|
||||||
"has been started. You will be informed in another message once the process is finished." +
|
"has been started. You will be informed in another message once the process is finished." +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
"User Contact: " + authentication.getName() + " (" + ((OIDCAuthenticationToken) authentication).getUserInfo().getEmail() + ")" +
|
"User Contact: " + authentication.getName() + " (" + ((OIDCAuthenticationToken) authentication).getUserInfo().getEmail() + ")" +
|
||||||
|
@ -287,20 +291,24 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserRegisterInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
public void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE new interface registration request started for " +
|
String subject = "OpenAIRE new interface registration request started for " +
|
||||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||||
|
|
||||||
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
|
||||||
String message = "Dear "+SecurityContextHolder.getContext().getAuthentication().getName()+",\n" +
|
String message = "Dear "+SecurityContextHolder.getContext().getAuthentication().getName()+",\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"We received a request to add the following interface: \n\n" +
|
"We received a request to add the following interface: \n\n" +
|
||||||
"Base URL: " + repositoryInterface.getBaseUrl() + "\n" +
|
"Base URL: " + repositoryInterface.getBaseUrl() + "\n" +
|
||||||
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
||||||
"Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" +
|
"Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" +
|
||||||
"to " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n" +
|
"to " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n";
|
||||||
"A validation process for this interface against the OpenAIRE guidelines compatibility " +
|
|
||||||
|
if (comment != null) {
|
||||||
|
comment += "\n Your comment was '" + comment + "'\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
message += "A validation process for this interface against the OpenAIRE guidelines compatibility " +
|
||||||
"has been started. You will be informed in another message once the process is finished." +
|
"has been started. You will be informed in another message once the process is finished." +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
"Please do not reply to this message\n" +
|
"Please do not reply to this message\n" +
|
||||||
|
@ -688,7 +696,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdminUpdateInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
public void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE interface update request started for " +
|
String subject = "OpenAIRE interface update request started for " +
|
||||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||||
|
@ -699,8 +707,12 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
"Base URL: " + repositoryInterface.getBaseUrl() + "\n" +
|
"Base URL: " + repositoryInterface.getBaseUrl() + "\n" +
|
||||||
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
||||||
"Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" +
|
"Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" +
|
||||||
"for " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n" +
|
"for " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n";
|
||||||
"A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" +
|
|
||||||
|
if (comment != null)
|
||||||
|
comment += "\nThe users comment was '" + comment + "'\n";
|
||||||
|
|
||||||
|
message += "A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" +
|
||||||
"User Contact: " + authentication.getName() + " (" + ((OIDCAuthenticationToken) authentication).getUserInfo().getEmail() + ")" +
|
"User Contact: " + authentication.getName() + " (" + ((OIDCAuthenticationToken) authentication).getUserInfo().getEmail() + ")" +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
"Please do not reply to this message\n" +
|
"Please do not reply to this message\n" +
|
||||||
|
@ -717,7 +729,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserUpdateInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
public void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE interface update request started for " +
|
String subject = "OpenAIRE interface update request started for " +
|
||||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||||
|
@ -729,8 +741,13 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
"Base URL: " + repositoryInterface.getBaseUrl() + "\n" +
|
"Base URL: " + repositoryInterface.getBaseUrl() + "\n" +
|
||||||
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
||||||
"Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" +
|
"Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" +
|
||||||
"for " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n" +
|
"for " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n";
|
||||||
"A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" +
|
|
||||||
|
if (comment != null) {
|
||||||
|
comment += "\n Your comment was '" + comment + "'\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
message += "A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" +
|
||||||
"Please do not reply to this message\n" +
|
"Please do not reply to this message\n" +
|
||||||
"This message has been generated automatically.\n\n" +
|
"This message has been generated automatically.\n\n" +
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
|
||||||
import eu.dnetlib.domain.data.Repository;
|
import eu.dnetlib.domain.data.Repository;
|
||||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||||
import eu.dnetlib.repo.manager.domain.*;
|
import eu.dnetlib.repo.manager.domain.*;
|
||||||
|
@ -48,7 +47,7 @@ public interface RepositoryService {
|
||||||
RepositoryInterface addRepositoryInterface(String datatype,
|
RepositoryInterface addRepositoryInterface(String datatype,
|
||||||
String repoId,
|
String repoId,
|
||||||
String registeredBy,
|
String registeredBy,
|
||||||
RepositoryInterface iFace) throws Exception;
|
String comment, RepositoryInterface repositoryInterface) throws Exception;
|
||||||
|
|
||||||
List<String> getDnetCountries();
|
List<String> getDnetCountries();
|
||||||
|
|
||||||
|
@ -74,6 +73,6 @@ public interface RepositoryService {
|
||||||
|
|
||||||
Map<String, String> getListLatestUpdate(String mode) throws RepositoryServiceException, JSONException;
|
Map<String, String> getListLatestUpdate(String mode) throws RepositoryServiceException, JSONException;
|
||||||
|
|
||||||
RepositoryInterface updateRepositoryInterface(String repositoryId, String registeredBy, RepositoryInterface repositoryInterface) throws Exception;
|
RepositoryInterface updateRepositoryInterface(String repoId, String registeredBy, String comment, RepositoryInterface repositoryInterface) throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -552,7 +552,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
public RepositoryInterface addRepositoryInterface(String datatype,
|
public RepositoryInterface addRepositoryInterface(String datatype,
|
||||||
String repoId,
|
String repoId,
|
||||||
String registeredBy,
|
String registeredBy,
|
||||||
RepositoryInterface repositoryInterface) throws Exception {
|
String comment, RepositoryInterface repositoryInterface) throws Exception {
|
||||||
try {
|
try {
|
||||||
Repository e = this.getRepositoryById(repoId);
|
Repository e = this.getRepositoryById(repoId);
|
||||||
repositoryInterface = createRepositoryInterface(e,repositoryInterface,datatype);
|
repositoryInterface = createRepositoryInterface(e,repositoryInterface,datatype);
|
||||||
|
@ -568,9 +568,9 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
ResponseEntity responseEntity = restTemplate.postForObject(uriComponents.toUri(),httpEntity,ResponseEntity.class);
|
ResponseEntity responseEntity = restTemplate.postForObject(uriComponents.toUri(),httpEntity,ResponseEntity.class);
|
||||||
|
|
||||||
if(responseEntity.getStatusCode().equals(HttpStatus.OK)) {
|
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
|
||||||
emailUtils.sendAdminRegisterInterfaceEmail(e, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
|
emailUtils.sendAdminRegisterInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
|
||||||
emailUtils.sendUserRegisterInterfaceEmail(e, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
|
emailUtils.sendUserRegisterInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
|
||||||
|
|
||||||
submitInterfaceValidation(e, registeredBy, repositoryInterface, false);
|
submitInterfaceValidation(e, registeredBy, repositoryInterface, false);
|
||||||
return repositoryInterface;
|
return repositoryInterface;
|
||||||
|
@ -589,15 +589,15 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
@Override
|
@Override
|
||||||
public RepositoryInterface updateRepositoryInterface(String repoId,
|
public RepositoryInterface updateRepositoryInterface(String repoId,
|
||||||
String registeredBy,
|
String registeredBy,
|
||||||
RepositoryInterface repositoryInterface) throws Exception {
|
String comment, RepositoryInterface repositoryInterface) throws Exception {
|
||||||
|
|
||||||
this.updateBaseUrl(repoId,repositoryInterface.getId(),repositoryInterface.getBaseUrl());
|
this.updateBaseUrl(repoId,repositoryInterface.getId(),repositoryInterface.getBaseUrl());
|
||||||
this.updateCompliance(repoId,repositoryInterface.getId(),repositoryInterface.getCompliance());
|
this.updateCompliance(repoId,repositoryInterface.getId(),repositoryInterface.getCompliance());
|
||||||
this.updateValidationSet(repoId,repositoryInterface.getId(),repositoryInterface.getAccessSet());
|
this.updateValidationSet(repoId,repositoryInterface.getId(),repositoryInterface.getAccessSet());
|
||||||
|
|
||||||
Repository e = this.getRepositoryById(repoId);
|
Repository e = this.getRepositoryById(repoId);
|
||||||
emailUtils.sendAdminUpdateInterfaceEmail(e, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
|
emailUtils.sendAdminUpdateInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
|
||||||
emailUtils.sendUserUpdateInterfaceEmail(e, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
|
emailUtils.sendUserUpdateInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
|
||||||
submitInterfaceValidation(getRepositoryById(repoId),registeredBy,repositoryInterface,true);
|
submitInterfaceValidation(getRepositoryById(repoId),registeredBy,repositoryInterface,true);
|
||||||
|
|
||||||
return repositoryInterface;
|
return repositoryInterface;
|
||||||
|
|
Loading…
Reference in New Issue