Add new emails for registering/updating repository
This commit is contained in:
parent
d83612439f
commit
7fafa3397f
|
@ -190,7 +190,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception{
|
public void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception{
|
||||||
/*try {
|
try {
|
||||||
String subject = "OpenAIRE content provider registration request started for " +
|
String subject = "OpenAIRE content provider registration request started for " +
|
||||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||||
|
|
||||||
|
@ -212,12 +212,31 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||||
throw e;
|
throw e;
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception {
|
public void sendUserUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception {
|
||||||
|
try {
|
||||||
|
String subject = "OpenAIRE content provider update request started for " +
|
||||||
|
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||||
|
|
||||||
|
String message = "Dear " + authentication.getName() + ",\n" +
|
||||||
|
"\n" +
|
||||||
|
"We received a request to update the \"" + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]" +
|
||||||
|
"\n A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started." +
|
||||||
|
"Please do not reply to this message\n" +
|
||||||
|
"This message has been generated automatically.\n" +
|
||||||
|
"If you have any questions, write to 'helpdesk@openaire.eu'. \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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMail(String email, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception {
|
private void sendMail(String email, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception {
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class RepositoryApiImpl implements RepositoryApi {
|
||||||
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
||||||
|
|
||||||
httpHeaders = new HttpHeaders();
|
httpHeaders = new HttpHeaders();
|
||||||
httpHeaders.set("Content-Type", "application/json");
|
httpHeaders.set("Content-Type", "application/json;charset=UTF-8");
|
||||||
|
|
||||||
for (String vocName : vocabularyNames) {
|
for (String vocName : vocabularyNames) {
|
||||||
vocabularyMap.put(vocName, vocabularyLoader.getVocabulary(vocName, Locale.ENGLISH, Locale.ROOT));
|
vocabularyMap.put(vocName, vocabularyLoader.getVocabulary(vocName, Locale.ENGLISH, Locale.ROOT));
|
||||||
|
@ -385,19 +385,19 @@ public class RepositoryApiImpl implements RepositoryApi {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//@PreAuthorize("hasRole('ROLE_USER') and #repository.registeredBy == authentication.userInfo.email")
|
//@PreAuthorize("hasRole('ROLE_USER') and #repository.registeredBy == authentication.userInfo.email")
|
||||||
public Repository updateRepository(Repository repository,Authentication authentication) throws Exception {
|
public Repository updateRepository(@RequestBody Repository repository,Authentication authentication) throws Exception {
|
||||||
UriComponents uriComponents = UriComponentsBuilder
|
UriComponents uriComponents = UriComponentsBuilder
|
||||||
.fromHttpUrl(baseAddress + "/ds/update/")
|
.fromHttpUrl(baseAddress + "/ds/update/")
|
||||||
.build()
|
.build()
|
||||||
.encode();
|
.encode();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String json_repository = Converter.repositoryObectToJson(repository);
|
String json_repository = Converter.repositoryObjectToJson(repository);
|
||||||
|
|
||||||
LOGGER.debug("JSON to update -> " + json_repository);
|
LOGGER.debug("JSON to update -> " + json_repository);
|
||||||
|
|
||||||
HttpEntity<String> httpEntity = new HttpEntity<String>(json_repository, httpHeaders);
|
HttpEntity<String> httpEntity = new HttpEntity<String>(json_repository, httpHeaders);
|
||||||
ResponseEntity responseEntity = restTemplate.postForObject(uriComponents.toUri(), httpEntity, ResponseEntity.class);
|
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(),HttpMethod.POST, httpEntity, ResponseEntity.class);
|
||||||
|
|
||||||
if (responseEntity.getStatusCode().equals(HttpStatus.OK))
|
if (responseEntity.getStatusCode().equals(HttpStatus.OK))
|
||||||
emailUtils.sendUserUpdateRepositoryEmail(repository, authentication);
|
emailUtils.sendUserUpdateRepositoryEmail(repository, authentication);
|
||||||
|
@ -478,7 +478,7 @@ public class RepositoryApiImpl implements RepositoryApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpEntity<String> httpEntity = new HttpEntity <String> (json_repository,httpHeaders);
|
HttpEntity<String> httpEntity = new HttpEntity <String> (json_repository,httpHeaders);
|
||||||
ResponseEntity responseEntity = restTemplate.postForObject(uriComponents.toUri(), httpEntity, ResponseEntity.class);
|
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(),HttpMethod.POST, httpEntity, ResponseEntity.class);
|
||||||
|
|
||||||
if(responseEntity.getStatusCode().equals(HttpStatus.OK))
|
if(responseEntity.getStatusCode().equals(HttpStatus.OK))
|
||||||
emailUtils.sendUserRegistrationEmail(repository,authentication);
|
emailUtils.sendUserRegistrationEmail(repository,authentication);
|
||||||
|
|
|
@ -12,7 +12,7 @@ log4j.logger.eu.dnetlib.repo.manager=DEBUG
|
||||||
|
|
||||||
log4j.appender.R=org.apache.log4j.RollingFileAppender
|
log4j.appender.R=org.apache.log4j.RollingFileAppender
|
||||||
#log4j.appender.R.File=/var/log/dnet/repo-manager/repo-manager-gui.log
|
#log4j.appender.R.File=/var/log/dnet/repo-manager/repo-manager-gui.log
|
||||||
log4j.appender.R.File=/var/log/tomcat_dnet/8780/repository-service.log
|
#log4j.appender.R.File=/var/log/tomcat_dnet/8780/repository-service.log
|
||||||
log4j.appender.R.MaxFileSize=10MB
|
log4j.appender.R.MaxFileSize=10MB
|
||||||
log4j.appender.R.MaxBackupIndex=10
|
log4j.appender.R.MaxBackupIndex=10
|
||||||
log4j.appender.R.layout=org.apache.log4j.PatternLayout
|
log4j.appender.R.layout=org.apache.log4j.PatternLayout
|
||||||
|
@ -20,7 +20,7 @@ log4j.appender.R.layout.ConversionPattern= %d %p %t [%c] - %m%n
|
||||||
|
|
||||||
log4j.appender.S=org.apache.log4j.RollingFileAppender
|
log4j.appender.S=org.apache.log4j.RollingFileAppender
|
||||||
#log4j.appender.S.File=/var/log/dnet/repo-manager/repo-manager-gui-spring.log
|
#log4j.appender.S.File=/var/log/dnet/repo-manager/repo-manager-gui-spring.log
|
||||||
log4j.appender.S.File=/var/log/tomcat_dnet/8780/repository-service-spring.log
|
#log4j.appender.S.File=/var/log/tomcat_dnet/8780/repository-service-spring.log
|
||||||
log4j.appender.S.MaxFileSize=10MB
|
log4j.appender.S.MaxFileSize=10MB
|
||||||
log4j.appender.S.MaxBackupIndex=10
|
log4j.appender.S.MaxBackupIndex=10
|
||||||
log4j.appender.S.layout=org.apache.log4j.PatternLayout
|
log4j.appender.S.layout=org.apache.log4j.PatternLayout
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
package unitest;
|
//package unitest;
|
||||||
|
//
|
||||||
import eu.dnetlib.repo.manager.service.controllers.SushiliteApi;
|
//import eu.dnetlib.repo.manager.service.controllers.SushiliteApi;
|
||||||
import org.junit.Test;
|
//import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
//import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
//import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
//import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
//import org.springframework.test.context.web.WebAppConfiguration;
|
||||||
|
//
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
//@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(locations = "classpath:applicationContext.xml")
|
//@ContextConfiguration(locations = "classpath:applicationContext.xml")
|
||||||
//@WebAppConfiguration
|
////@WebAppConfiguration
|
||||||
public class SushiTest {
|
//public class SushiTest {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
SushiliteApi sushiliteApi;
|
// SushiliteApi sushiliteApi;
|
||||||
|
//
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void getReportResults(){
|
// public void getReportResults(){
|
||||||
System.out.println("test");
|
// System.out.println("test");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
Loading…
Reference in New Issue