remove mail service

This commit is contained in:
amentis 2023-12-12 16:42:11 +02:00
parent f46543f1a4
commit f47f9721fe
14 changed files with 203 additions and 41 deletions

View File

@ -0,0 +1,20 @@
package eu.eudat.configurations.notification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties(NotificationProperties.class)
public class NotificationConfiguration {
private final NotificationProperties properties;
@Autowired
public NotificationConfiguration(NotificationProperties properties) {
this.properties = properties;
}
public NotificationProperties getProperties() {
return properties;
}
}

View File

@ -0,0 +1,89 @@
package eu.eudat.configurations.notification;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "notification")
public class NotificationProperties {
private String confirmation;
private String dataManagementPlan;
private String finalised;
private String mergeConfirmation;
private String modified;
private String modifiedFinalised;
private String publish;
private String template;
private String unlinkConfirmation;
public String getConfirmation() {
return confirmation;
}
public void setConfirmation(String confirmation) {
this.confirmation = confirmation;
}
public String getDataManagementPlan() {
return dataManagementPlan;
}
public void setDataManagementPlan(String dataManagementPlan) {
this.dataManagementPlan = dataManagementPlan;
}
public String getFinalised() {
return finalised;
}
public void setFinalised(String finalised) {
this.finalised = finalised;
}
public String getMergeConfirmation() {
return mergeConfirmation;
}
public void setMergeConfirmation(String mergeConfirmation) {
this.mergeConfirmation = mergeConfirmation;
}
public String getModified() {
return modified;
}
public void setModified(String modified) {
this.modified = modified;
}
public String getModifiedFinalised() {
return modifiedFinalised;
}
public void setModifiedFinalised(String modifiedFinalised) {
this.modifiedFinalised = modifiedFinalised;
}
public String getPublish() {
return publish;
}
public void setPublish(String publish) {
this.publish = publish;
}
public String getTemplate() {
return template;
}
public void setTemplate(String template) {
this.template = template;
}
public String getUnlinkConfirmation() {
return unlinkConfirmation;
}
public void setUnlinkConfirmation(String unlinkConfirmation) {
this.unlinkConfirmation = unlinkConfirmation;
}
}

View File

@ -13,6 +13,7 @@ import eu.eudat.commons.types.descriptiontemplate.*;
import eu.eudat.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity; import eu.eudat.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity;
import eu.eudat.commons.types.descriptiontemplate.importexport.*; import eu.eudat.commons.types.descriptiontemplate.importexport.*;
import eu.eudat.commons.types.notification.*; import eu.eudat.commons.types.notification.*;
import eu.eudat.configurations.notification.NotificationProperties;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionTemplateEntity; import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.UserDescriptionTemplateEntity; import eu.eudat.data.UserDescriptionTemplateEntity;
@ -106,6 +107,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
private final StorageFileService storageFileService; private final StorageFileService storageFileService;
private final JsonHandlingService jsonHandlingService; private final JsonHandlingService jsonHandlingService;
private final NotificationIntegrationEventHandler eventHandler; private final NotificationIntegrationEventHandler eventHandler;
private final NotificationProperties notificationProperties;
@Autowired @Autowired
public DescriptionTemplateServiceImpl( public DescriptionTemplateServiceImpl(
@ -116,7 +118,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
ConventionService conventionService, ConventionService conventionService,
MessageSource messageSource, MessageSource messageSource,
XmlHandlingService xmlHandlingService, XmlHandlingService xmlHandlingService,
FieldDataHelperServiceProvider fieldDataHelperServiceProvider, QueryFactory queryFactory, ErrorThesaurusProperties errors, ValidationService validationService, TenantScope tenantScope, Environment environment, ResponseUtilsService responseUtilsService, StorageFileService storageFileService, JsonHandlingService jsonHandlingService, NotificationIntegrationEventHandler eventHandler) { FieldDataHelperServiceProvider fieldDataHelperServiceProvider, QueryFactory queryFactory, ErrorThesaurusProperties errors, ValidationService validationService, TenantScope tenantScope, Environment environment, ResponseUtilsService responseUtilsService, StorageFileService storageFileService, JsonHandlingService jsonHandlingService, NotificationIntegrationEventHandler eventHandler, NotificationProperties notificationProperties) {
this.entityManager = entityManager; this.entityManager = entityManager;
this.userScope = userScope; this.userScope = userScope;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
@ -135,6 +137,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
this.storageFileService = storageFileService; this.storageFileService = storageFileService;
this.jsonHandlingService = jsonHandlingService; this.jsonHandlingService = jsonHandlingService;
this.eventHandler = eventHandler; this.eventHandler = eventHandler;
this.notificationProperties = notificationProperties;
} }
//region Persist //region Persist
@ -222,7 +225,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null); NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
event.setContactHint(jsonHandlingService.toJsonSafe(contactData)); event.setContactHint(jsonHandlingService.toJsonSafe(contactData));
event.setContactTypeHint(NotificationContactType.EMAIL); event.setContactTypeHint(NotificationContactType.EMAIL);
event.setNotificationType(UUID.fromString("223BB607-EFA1-4CE7-99EC-4BEABFEF9A8B")); event.setNotificationType(UUID.fromString(notificationProperties.getTemplate()));
NotificationFieldData data = new NotificationFieldData(); NotificationFieldData data = new NotificationFieldData();
List<FieldInfo> fieldInfoList = new ArrayList<>(); List<FieldInfo> fieldInfoList = new ArrayList<>();
fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, user.getName())); fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, user.getName()));

View File

@ -52,7 +52,7 @@ notification:
body-path: classpath:notification_templates/Confirmation/Email/body.{language}.html body-path: classpath:notification_templates/Confirmation/Email/body.{language}.html
body-field-options: body-field-options:
mandatory: [ ] mandatory: [ "{host}", "{confirmationToken}" ]
optional: optional:
- key: "{expiration_time}" - key: "{expiration_time}"
value: -- value: --
@ -94,7 +94,7 @@ notification:
optional: [ ] optional: [ ]
body-path: classpath:notification_templates/Finalised/Email/body.{language}.html body-path: classpath:notification_templates/Finalised/Email/body.{language}.html
body-field-options: body-field-options:
mandatory: [ "{reasonName}", "{name}" ] mandatory: [ "{reasonName}", "{name}", "{host}", "{path}", "{id}" ]
optional: optional:
- key: "{recipient}" - key: "{recipient}"
value: value:
@ -138,7 +138,7 @@ notification:
optional: [ ] optional: [ ]
body-path: classpath:notification_templates/Modified/Email/body.{language}.html body-path: classpath:notification_templates/Modified/Email/body.{language}.html
body-field-options: body-field-options:
mandatory: [ "{reasonName}", "{name}" ] mandatory: [ "{reasonName}", "{name}", "{host}", "{path}", "{id}" ]
optional: optional:
- key: "{recipient}" - key: "{recipient}"
value: value:
@ -160,7 +160,7 @@ notification:
optional: [ ] optional: [ ]
body-path: classpath:notification_templates/ModifiedFinalised/Email/body.{language}.html body-path: classpath:notification_templates/ModifiedFinalised/Email/body.{language}.html
body-field-options: body-field-options:
mandatory: [ "{reasonName}", "{name}" ] mandatory: [ "{reasonName}", "{name}", "{host}", "{path}", "{id}" ]
optional: optional:
- key: "{recipient}" - key: "{recipient}"
value: value:
@ -182,7 +182,7 @@ notification:
optional: [ ] optional: [ ]
body-path: classpath:notification_templates/Publish/Email/body.{language}.html body-path: classpath:notification_templates/Publish/Email/body.{language}.html
body-field-options: body-field-options:
mandatory: [ "{reasonName}", "{name}" ] mandatory: [ "{reasonName}", "{name}", "{host}", "{path}", "{id}" ]
optional: optional:
- key: "{recipient}" - key: "{recipient}"
value: value:

View File

@ -75,7 +75,7 @@ public class EmailConfirmationManager {
// if (user.getEmail() != null) //TODO // if (user.getEmail() != null) //TODO
// throw new HasConfirmedEmailException("User already has confirmed his Email."); // throw new HasConfirmedEmailException("User already has confirmed his Email.");
apiContext.getUtilitiesService().getConfirmationEmailService().sentConfirmationEmail(email); apiContext.getUtilitiesService().getConfirmationEmailService().sentConfirmationEmail(databaseRepository.getLoginConfirmationEmailDao(), email, user);
} }
private void mergeNewUserToOld(UserEntity newUser, UserEntity oldUser) throws InvalidApplicationException { private void mergeNewUserToOld(UserEntity newUser, UserEntity oldUser) throws InvalidApplicationException {

View File

@ -9,6 +9,9 @@ import eu.eudat.exceptions.security.UnauthorisedException;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.model.User; import eu.eudat.model.User;
import eu.eudat.models.data.invitation.Invitation; import eu.eudat.models.data.invitation.Invitation;
import eu.eudat.query.DmpQuery;
import eu.eudat.query.UserQuery;
import gr.cite.tools.data.query.QueryFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -25,12 +28,14 @@ public class InvitationsManager {
private ApiContext apiContext; private ApiContext apiContext;
private DataManagementPlanManager dataManagementPlanManager; private DataManagementPlanManager dataManagementPlanManager;
private final UserScope userScope; private final UserScope userScope;
private final QueryFactory queryFactory;
@Autowired @Autowired
public InvitationsManager(ApiContext apiContext, DataManagementPlanManager dataManagementPlanManager, UserScope userScope) { public InvitationsManager(ApiContext apiContext, DataManagementPlanManager dataManagementPlanManager, UserScope userScope, QueryFactory queryFactory) {
this.apiContext = apiContext; this.apiContext = apiContext;
this.dataManagementPlanManager = dataManagementPlanManager; this.dataManagementPlanManager = dataManagementPlanManager;
this.userScope = userScope; this.userScope = userScope;
this.queryFactory = queryFactory;
} }
public void inviteUsers(Invitation invitation) throws Exception { public void inviteUsers(Invitation invitation) throws Exception {
@ -63,9 +68,19 @@ public class InvitationsManager {
apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().createOrUpdate(userAssociation); apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().createOrUpdate(userAssociation);
}*/ }*/
} }
DmpEntity dataManagementPlan = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(invitation.getDataManagementPlan()); DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).ids(invitation.getDataManagementPlan());
// apiContext.getUtilitiesService().getInvitationService().createInvitations(apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao(), apiContext.getUtilitiesService().getMailService(), invitation.getUsers().stream().map(UserInfoInvitationModel::toDataModel).collect(Collectors.toList()), dataManagementPlan, invitation.getRole(), principalUser); if(dmpQuery != null){
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userInfoToUserDmp, dataManagementPlan); // DmpEntity dataManagementPlan = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(invitation.getDataManagementPlan());
DmpEntity dmpEntity = dmpQuery.first();
UserQuery userQuery = this.queryFactory.query(UserQuery.class).ids(invitation.getUsers().stream().map(user -> user.getId()).collect(Collectors.toList()));
if (userQuery != null){
List<UserEntity> userEntities = userQuery.collect();
// apiContext.getUtilitiesService().getInvitationService().createInvitations(apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao(), invitation.getUsers().stream().map(UserInfoInvitationModel::toDataModel).collect(Collectors.toList()), dmpEntity, invitation.getRole(), principalUser);
apiContext.getUtilitiesService().getInvitationService().createInvitations(apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao(), userEntities, dmpEntity, invitation.getRole(), principalUser);
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userInfoToUserDmp, dmpEntity);
}
}
} }
public List<User> getUsers() throws InstantiationException, IllegalAccessException, InvalidApplicationException { public List<User> getUsers() throws InstantiationException, IllegalAccessException, InvalidApplicationException {

View File

@ -10,7 +10,10 @@ import eu.eudat.exceptions.emailconfirmation.TokenExpiredException;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.model.UserContactInfo;
import eu.eudat.query.UserContactInfoQuery;
import eu.eudat.query.UserQuery; import eu.eudat.query.UserQuery;
import gr.cite.tools.data.query.Ordering;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -70,18 +73,18 @@ public class MergeEmailConfirmationManager {
return userToBeMergedEmail; return userToBeMergedEmail;
} }
public void sendConfirmationEmail(String email, UUID userId, Integer provider) throws HasConfirmedEmailException, InvalidApplicationException { public void sendMergeConfirmationEmail(String email, Integer provider) throws HasConfirmedEmailException, InvalidApplicationException {
UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first(); UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
//TODO UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId());
// if (user.getEmail() != null && !user.getEmail().equals(email)) { query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal));
// apiContext.getUtilitiesService().getConfirmationEmailService().createMergeConfirmationEmail( if (query.first().getValue() != null && !query.first().getValue().equals(email)) {
// databaseRepository.getLoginConfirmationEmailDao(), apiContext.getUtilitiesService().getConfirmationEmailService().sentMergeConfirmationEmail(
// apiContext.getUtilitiesService().getMailService(), databaseRepository.getLoginConfirmationEmailDao(),
// email, email,
// user, user,
// provider provider
// ); );
// } }
} }
@Transactional @Transactional

View File

@ -25,7 +25,6 @@ public class NotificationManager {
private ApiContext apiContext; private ApiContext apiContext;
private Environment environment; private Environment environment;
// private MailService mailService;
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
@Autowired @Autowired
@ -34,7 +33,6 @@ public class NotificationManager {
QueryFactory queryFactory) { QueryFactory queryFactory) {
this.apiContext = apiContext; this.apiContext = apiContext;
this.environment = environment; this.environment = environment;
// this.mailService = mailService;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
} }

View File

@ -2,7 +2,7 @@ package eu.eudat.logic.managers;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.UserCredentialEntity; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.old.EmailConfirmation; import eu.eudat.data.old.EmailConfirmation;
import eu.eudat.data.UserEntity; import eu.eudat.data.UserEntity;
import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException; import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException;
@ -32,12 +32,14 @@ public class UnlinkEmailConfirmationManager {
private ApiContext apiContext; private ApiContext apiContext;
private DatabaseRepository databaseRepository; private DatabaseRepository databaseRepository;
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final UserScope userScope;
@Autowired @Autowired
public UnlinkEmailConfirmationManager(ApiContext apiContext, QueryFactory queryFactory) { public UnlinkEmailConfirmationManager(ApiContext apiContext, QueryFactory queryFactory, UserScope userScope) {
this.apiContext = apiContext; this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.userScope = userScope;
} }
@Transactional @Transactional
@ -79,8 +81,8 @@ public class UnlinkEmailConfirmationManager {
// } // }
} }
public void sendUnlinkConfirmationEmail(String email, UUID userId, Integer provider) throws InvalidApplicationException { public void sendUnlinkConfirmationEmail(String email, Integer provider) throws InvalidApplicationException {
UserEntity user = this.queryFactory.query(UserQuery.class).ids(userId).first(); UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId()); UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId());
query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal)); query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal));
if (query.first().getValue() != null && !query.first().getValue().equals(email)) { if (query.first().getValue() != null && !query.first().getValue().equals(email)) {

View File

@ -7,7 +7,7 @@ import javax.management.InvalidApplicationException;
public interface ConfirmationEmailService { public interface ConfirmationEmailService {
public void sentConfirmationEmail(String email) throws InvalidApplicationException; public void sentConfirmationEmail(EmailConfirmationDao loginConfirmationEmailDao, String email, UserEntity user) throws InvalidApplicationException;
public void sentUnlinkConfirmationEmail(EmailConfirmationDao loginConfirmationEmailDao, String email, UserEntity user, Integer provider) throws InvalidApplicationException; public void sentUnlinkConfirmationEmail(EmailConfirmationDao loginConfirmationEmailDao, String email, UserEntity user, Integer provider) throws InvalidApplicationException;

View File

@ -7,6 +7,7 @@ import eu.eudat.commons.enums.ContactInfoType;
import eu.eudat.commons.enums.notification.NotificationContactType; import eu.eudat.commons.enums.notification.NotificationContactType;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.commons.types.notification.*; import eu.eudat.commons.types.notification.*;
import eu.eudat.configurations.notification.NotificationProperties;
import eu.eudat.data.dao.entities.EmailConfirmationDao; import eu.eudat.data.dao.entities.EmailConfirmationDao;
import eu.eudat.data.old.EmailConfirmation; import eu.eudat.data.old.EmailConfirmation;
import eu.eudat.data.UserEntity; import eu.eudat.data.UserEntity;
@ -23,7 +24,6 @@ import org.springframework.stereotype.Service;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
@Service("ConfirmationEmailService") @Service("ConfirmationEmailService")
public class ConfirmationEmailServiceImpl implements ConfirmationEmailService { public class ConfirmationEmailServiceImpl implements ConfirmationEmailService {
@ -34,19 +34,34 @@ public class ConfirmationEmailServiceImpl implements ConfirmationEmailService {
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final JsonHandlingService jsonHandlingService; private final JsonHandlingService jsonHandlingService;
private final NotificationIntegrationEventHandler eventHandler; private final NotificationIntegrationEventHandler eventHandler;
private final NotificationProperties notificationProperties;
public ConfirmationEmailServiceImpl(/*Logger logger,*/ Environment environment, UserScope userScope, QueryFactory queryFactory, JsonHandlingService jsonHandlingService, NotificationIntegrationEventHandler eventHandler) { public ConfirmationEmailServiceImpl(/*Logger logger,*/ Environment environment, UserScope userScope, QueryFactory queryFactory, JsonHandlingService jsonHandlingService, NotificationIntegrationEventHandler eventHandler, NotificationProperties notificationProperties) {
// this.logger = logger; // this.logger = logger;
this.environment = environment; this.environment = environment;
this.userScope = userScope; this.userScope = userScope;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.jsonHandlingService = jsonHandlingService; this.jsonHandlingService = jsonHandlingService;
this.eventHandler = eventHandler; this.eventHandler = eventHandler;
this.notificationProperties = notificationProperties;
} }
@Override @Override
public void sentConfirmationEmail(String email) throws InvalidApplicationException { public void sentConfirmationEmail(EmailConfirmationDao loginConfirmationEmailDao, String email, UserEntity user) throws InvalidApplicationException {
EmailConfirmation confirmationEmail = new EmailConfirmation();
confirmationEmail.setEmail(email);
confirmationEmail.setExpiresAt(Date
.from(new Date()
.toInstant()
.plusSeconds(Long.parseLong(this.environment.getProperty("conf_email.expiration_time_seconds")))
)
);
confirmationEmail.setUserId(user.getId());
confirmationEmail.setIsConfirmed(false);
confirmationEmail.setToken(UUID.randomUUID());
confirmationEmail = loginConfirmationEmailDao.createOrUpdate(confirmationEmail);
NotificationIntegrationEvent event = new NotificationIntegrationEvent(); NotificationIntegrationEvent event = new NotificationIntegrationEvent();
event.setUserId(userScope.getUserIdSafe()); event.setUserId(userScope.getUserIdSafe());
@ -55,9 +70,11 @@ public class ConfirmationEmailServiceImpl implements ConfirmationEmailService {
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null); NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
event.setContactHint(jsonHandlingService.toJsonSafe(contactData)); event.setContactHint(jsonHandlingService.toJsonSafe(contactData));
event.setContactTypeHint(NotificationContactType.EMAIL); event.setContactTypeHint(NotificationContactType.EMAIL);
event.setNotificationType(UUID.fromString("4FDBFA80-7A71-4A69-B854-67CBB70648F1")); event.setNotificationType(UUID.fromString(notificationProperties.getConfirmation()));
NotificationFieldData data = new NotificationFieldData(); NotificationFieldData data = new NotificationFieldData();
List<FieldInfo> fieldInfoList = new ArrayList<>(); List<FieldInfo> fieldInfoList = new ArrayList<>();
fieldInfoList.add(new FieldInfo("{host}", DataType.String, this.environment.getProperty("dmp.domain")));
fieldInfoList.add(new FieldInfo("{confirmationToken}", DataType.String, confirmationEmail.getToken().toString()));
fieldInfoList.add(new FieldInfo("{expiration_time}", DataType.String, this.secondsToTime(Integer.parseInt(this.environment.getProperty("conf_email.expiration_time_seconds"))))); fieldInfoList.add(new FieldInfo("{expiration_time}", DataType.String, this.secondsToTime(Integer.parseInt(this.environment.getProperty("conf_email.expiration_time_seconds")))));
data.setFields(fieldInfoList); data.setFields(fieldInfoList);
event.setData(jsonHandlingService.toJsonSafe(data)); event.setData(jsonHandlingService.toJsonSafe(data));
@ -96,7 +113,7 @@ public class ConfirmationEmailServiceImpl implements ConfirmationEmailService {
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null); NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
event.setContactHint(jsonHandlingService.toJsonSafe(contactData)); event.setContactHint(jsonHandlingService.toJsonSafe(contactData));
event.setContactTypeHint(NotificationContactType.EMAIL); event.setContactTypeHint(NotificationContactType.EMAIL);
event.setNotificationType(UUID.fromString("C9BC3F16-057E-4BBA-8A5F-36BD835E5604")); event.setNotificationType(UUID.fromString(notificationProperties.getUnlinkConfirmation()));
NotificationFieldData data = new NotificationFieldData(); NotificationFieldData data = new NotificationFieldData();
List<FieldInfo> fieldInfoList = new ArrayList<>(); List<FieldInfo> fieldInfoList = new ArrayList<>();
fieldInfoList.add(new FieldInfo("{host}", DataType.String, this.environment.getProperty("dmp.domain"))); fieldInfoList.add(new FieldInfo("{host}", DataType.String, this.environment.getProperty("dmp.domain")));
@ -139,7 +156,7 @@ public class ConfirmationEmailServiceImpl implements ConfirmationEmailService {
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null); NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
event.setContactHint(jsonHandlingService.toJsonSafe(contactData)); event.setContactHint(jsonHandlingService.toJsonSafe(contactData));
event.setContactTypeHint(NotificationContactType.EMAIL); event.setContactTypeHint(NotificationContactType.EMAIL);
event.setNotificationType(UUID.fromString("BFE68845-CB05-4C5A-A03D-29161A7C9660")); event.setNotificationType(UUID.fromString(notificationProperties.getMergeConfirmation()));
NotificationFieldData data = new NotificationFieldData(); NotificationFieldData data = new NotificationFieldData();
List<FieldInfo> fieldInfoList = new ArrayList<>(); List<FieldInfo> fieldInfoList = new ArrayList<>();
fieldInfoList.add(new FieldInfo("{userName}", DataType.String, user.getName())); fieldInfoList.add(new FieldInfo("{userName}", DataType.String, user.getName()));

View File

@ -3,9 +3,11 @@ package eu.eudat.logic.services.utilities;
import eu.eudat.commons.JsonHandlingService; import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.enums.ContactInfoType; import eu.eudat.commons.enums.ContactInfoType;
import eu.eudat.commons.enums.DmpUserRole;
import eu.eudat.commons.enums.notification.NotificationContactType; import eu.eudat.commons.enums.notification.NotificationContactType;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.commons.types.notification.*; import eu.eudat.commons.types.notification.*;
import eu.eudat.configurations.notification.NotificationProperties;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
import eu.eudat.data.DmpUserEntity; import eu.eudat.data.DmpUserEntity;
import eu.eudat.data.dao.entities.DMPDao; import eu.eudat.data.dao.entities.DMPDao;
@ -34,7 +36,6 @@ import java.io.StringWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Service("invitationService") @Service("invitationService")
@ -44,13 +45,15 @@ public class InvitationServiceImpl implements InvitationService {
private final UserScope userScope; private final UserScope userScope;
private final NotificationIntegrationEventHandler eventHandler; private final NotificationIntegrationEventHandler eventHandler;
private final JsonHandlingService jsonHandlingService; private final JsonHandlingService jsonHandlingService;
private final NotificationProperties notificationProperties;
@Autowired @Autowired
public InvitationServiceImpl(Environment environment, UserScope userScope, NotificationIntegrationEventHandler eventHandler, JsonHandlingService jsonHandlingService, QueryFactory queryFactory) { public InvitationServiceImpl(Environment environment, UserScope userScope, NotificationIntegrationEventHandler eventHandler, JsonHandlingService jsonHandlingService, NotificationProperties notificationProperties, QueryFactory queryFactory) {
this.environment = environment; this.environment = environment;
this.userScope = userScope; this.userScope = userScope;
this.eventHandler = eventHandler; this.eventHandler = eventHandler;
this.jsonHandlingService = jsonHandlingService; this.jsonHandlingService = jsonHandlingService;
this.notificationProperties = notificationProperties;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
} }
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
@ -112,14 +115,14 @@ public class InvitationServiceImpl implements InvitationService {
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null); NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
event.setContactHint(jsonHandlingService.toJsonSafe(contactData)); event.setContactHint(jsonHandlingService.toJsonSafe(contactData));
event.setContactTypeHint(NotificationContactType.EMAIL); event.setContactTypeHint(NotificationContactType.EMAIL);
event.setNotificationType(UUID.fromString("065DEECD-21BB-44AF-9983-E660FDF24BC4")); event.setNotificationType(UUID.fromString(notificationProperties.getDataManagementPlan()));
NotificationFieldData data = new NotificationFieldData(); NotificationFieldData data = new NotificationFieldData();
List<FieldInfo> fieldInfoList = new ArrayList<>(); List<FieldInfo> fieldInfoList = new ArrayList<>();
fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, user.getName())); fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, user.getName()));
fieldInfoList.add(new FieldInfo("{invitationID}", DataType.String, invitation.getId().toString())); fieldInfoList.add(new FieldInfo("{invitationID}", DataType.String, invitation.getId().toString()));
fieldInfoList.add(new FieldInfo("{host}", DataType.String, this.environment.getProperty("dmp.domain"))); fieldInfoList.add(new FieldInfo("{host}", DataType.String, this.environment.getProperty("dmp.domain")));
fieldInfoList.add(new FieldInfo("{dmpname}", DataType.String, dmp.getLabel())); fieldInfoList.add(new FieldInfo("{dmpname}", DataType.String, dmp.getLabel()));
// fieldInfoList.add(new FieldInfo("{dmprole}", DataType.String, UserDMP.UserDMPRoles.fromInteger(role).name())); //TODO fieldInfoList.add(new FieldInfo("{dmprole}", DataType.String, DmpUserRole.of(role.shortValue()).toString()));
data.setFields(fieldInfoList); data.setFields(fieldInfoList);
event.setData(jsonHandlingService.toJsonSafe(data)); event.setData(jsonHandlingService.toJsonSafe(data));
eventHandler.handle(event); eventHandler.handle(event);

View File

@ -26,5 +26,7 @@ spring:
optional:classpath:config/storage.yml[.yml], optional:classpath:config/storage-${spring.profiles.active}.yml[.yml], optional:file:../config/storage-${spring.profiles.active}.yml[.yml], optional:classpath:config/storage.yml[.yml], optional:classpath:config/storage-${spring.profiles.active}.yml[.yml], optional:file:../config/storage-${spring.profiles.active}.yml[.yml],
optional:classpath:config/reference-type.yml[.yml], optional:classpath:config/reference-type-${spring.profiles.active}.yml[.yml], optional:file:../config/reference-type-${spring.profiles.active}.yml[.yml], optional:classpath:config/reference-type.yml[.yml], optional:classpath:config/reference-type-${spring.profiles.active}.yml[.yml], optional:file:../config/reference-type-${spring.profiles.active}.yml[.yml],
optional:classpath:config/tenant.yml[.yml], optional:classpath:config/tenant-${spring.profiles.active}.yml[.yml], optional:file:../config/tenant-${spring.profiles.active}.yml[.yml], optional:classpath:config/tenant.yml[.yml], optional:classpath:config/tenant-${spring.profiles.active}.yml[.yml], optional:file:../config/tenant-${spring.profiles.active}.yml[.yml],
optional:classpath:config/queue.yml[.yml], optional:classpath:config/queue-${spring.profiles.active}.yml[.yml], optional:file:../config/queue-${spring.profiles.active}.yml[.yml] optional:classpath:config/queue.yml[.yml], optional:classpath:config/queue-${spring.profiles.active}.yml[.yml], optional:file:../config/queue-${spring.profiles.active}.yml[.yml],
optional:classpath:config/notification.yml[.yml], optional:classpath:config/notification-${spring.profiles.active}.yml[.yml], optional:file:../config/notification-${spring.profiles.active}.yml[.yml]

View File

@ -0,0 +1,10 @@
notification:
confirmation: 4FDBFA80-7A71-4A69-B854-67CBB70648F1
dataManagementPlan: 065DEECD-21BB-44AF-9983-E660FDF24BC4
finalised: 90DB0B46-42DE-BD89-AEBF-6F27EFEB256E
mergeConfirmation: BFE68845-CB05-4C5A-A03D-29161A7C9660
modified: 4542262A-22F8-4BAA-9DB6-1C8E70AC1DBB
modifiedFinalised: D3CD55FE-8DA2-42E7-A501-3795EE4F16D3
publish: 55736F7A-83AB-4190-AF43-9D031A6F9612
template: 223BB607-EFA1-4CE7-99EC-4BEABFEF9A8B
unlinkConfirmation: C9BC3F16-057E-4BBA-8A5F-36BD835E5604