diff --git a/dmp-backend/core/src/main/java/eu/eudat/configurations/notification/NotificationProperties.java b/dmp-backend/core/src/main/java/eu/eudat/configurations/notification/NotificationProperties.java index 49524f479..384d53ea1 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/configurations/notification/NotificationProperties.java +++ b/dmp-backend/core/src/main/java/eu/eudat/configurations/notification/NotificationProperties.java @@ -2,89 +2,100 @@ package eu.eudat.configurations.notification; import org.springframework.boot.context.properties.ConfigurationProperties; +import java.util.UUID; + @ConfigurationProperties(prefix = "notification") public class NotificationProperties { - private String dmpInvitation; - private String dmpModified; - private String dmpFinalised; - private String descriptionModified; - private String descriptionFinalised; - private String mergeAccountConfirmation; - private String removeCredentialConfirmation; - private String dmpDeposit; - private String descriptionTemplateInvitation; + private UUID dmpInvitationExternalUser; + private UUID dmpInvitationExistingUser; + private UUID dmpModified; + private UUID dmpFinalised; + private UUID descriptionModified; + private UUID descriptionFinalised; + private UUID mergeAccountConfirmation; + private UUID removeCredentialConfirmation; + private UUID dmpDeposit; + private UUID descriptionTemplateInvitation; private String emailExpirationTimeSeconds; - public String getDmpInvitation() { - return dmpInvitation; + public UUID getDmpInvitationExternalUser() { + return dmpInvitationExternalUser; } - public void setDmpInvitation(String dmpInvitation) { - this.dmpInvitation = dmpInvitation; + public void setDmpInvitationExternalUser(UUID dmpInvitationExternalUser) { + this.dmpInvitationExternalUser = dmpInvitationExternalUser; } - public String getDmpModified() { + public UUID getDmpInvitationExistingUser() { + return dmpInvitationExistingUser; + } + + public void setDmpInvitationExistingUser(UUID dmpInvitationExistingUser) { + this.dmpInvitationExistingUser = dmpInvitationExistingUser; + } + + public UUID getDmpModified() { return dmpModified; } - public void setDmpModified(String dmpModified) { + public void setDmpModified(UUID dmpModified) { this.dmpModified = dmpModified; } - public String getDmpFinalised() { + public UUID getDmpFinalised() { return dmpFinalised; } - public void setDmpFinalised(String dmpFinalised) { + public void setDmpFinalised(UUID dmpFinalised) { this.dmpFinalised = dmpFinalised; } - public String getDescriptionModified() { + public UUID getDescriptionModified() { return descriptionModified; } - public void setDescriptionModified(String descriptionModified) { + public void setDescriptionModified(UUID descriptionModified) { this.descriptionModified = descriptionModified; } - public String getDescriptionFinalised() { + public UUID getDescriptionFinalised() { return descriptionFinalised; } - public void setDescriptionFinalised(String descriptionFinalised) { + public void setDescriptionFinalised(UUID descriptionFinalised) { this.descriptionFinalised = descriptionFinalised; } - public String getMergeAccountConfirmation() { + public UUID getMergeAccountConfirmation() { return mergeAccountConfirmation; } - public void setMergeAccountConfirmation(String mergeAccountConfirmation) { + public void setMergeAccountConfirmation(UUID mergeAccountConfirmation) { this.mergeAccountConfirmation = mergeAccountConfirmation; } - public String getRemoveCredentialConfirmation() { + public UUID getRemoveCredentialConfirmation() { return removeCredentialConfirmation; } - public void setRemoveCredentialConfirmation(String removeCredentialConfirmation) { + public void setRemoveCredentialConfirmation(UUID removeCredentialConfirmation) { this.removeCredentialConfirmation = removeCredentialConfirmation; } - public String getDmpDeposit() { + public UUID getDmpDeposit() { return dmpDeposit; } - public void setDmpDeposit(String dmpDeposit) { + public void setDmpDeposit(UUID dmpDeposit) { this.dmpDeposit = dmpDeposit; } - public String getDescriptionTemplateInvitation() { + public UUID getDescriptionTemplateInvitation() { return descriptionTemplateInvitation; } - public void setDescriptionTemplateInvitation(String descriptionTemplateInvitation) { + public void setDescriptionTemplateInvitation(UUID descriptionTemplateInvitation) { this.descriptionTemplateInvitation = descriptionTemplateInvitation; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/actionconfirmation/ActionConfirmationServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/actionconfirmation/ActionConfirmationServiceImpl.java index 998a63c03..5d917e1b9 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/actionconfirmation/ActionConfirmationServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/actionconfirmation/ActionConfirmationServiceImpl.java @@ -71,7 +71,7 @@ public class ActionConfirmationServiceImpl implements ActionConfirmationService public void persist(ActionConfirmationPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException{ logger.debug(new MapLogEntry("persisting data").And("model", model).And("fields", fields)); -// this.authorizationService.authorizeForce(Permission.EditActionConfirmation); TODO +// this.authorizationService.authorizeForce(Permission.EditActionConfirmation); //TODO Boolean isUpdate = this.conventionService.isValidGuid(model.getId()); diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java index 5c3082a45..c343dbae1 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java @@ -233,9 +233,9 @@ public class DescriptionServiceImpl implements DescriptionService { private NotificationIntegrationEvent applyNotificationType(DescriptionStatus status, NotificationIntegrationEvent event) { switch (status) { case Draft: - event.setNotificationType(UUID.fromString(notificationProperties.getDescriptionModified())); + event.setNotificationType(notificationProperties.getDescriptionModified()); case Finalized: - event.setNotificationType(UUID.fromString(notificationProperties.getDescriptionFinalised())); + event.setNotificationType(notificationProperties.getDescriptionFinalised()); default: throw new MyApplicationException("Unsupported Description Status."); } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateServiceImpl.java index 2152b5a8b..16eb9a331 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateServiceImpl.java @@ -222,7 +222,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic NotificationContactData contactData = new NotificationContactData(contactPairs, null, null); event.setContactHint(jsonHandlingService.toJsonSafe(contactData)); event.setContactTypeHint(NotificationContactType.EMAIL); - event.setNotificationType(UUID.fromString(notificationProperties.getDescriptionTemplateInvitation())); + event.setNotificationType(notificationProperties.getDescriptionTemplateInvitation()); NotificationFieldData data = new NotificationFieldData(); List fieldInfoList = new ArrayList<>(); fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, user.getName())); diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java index 5a927b055..c2ce1b982 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java @@ -201,10 +201,10 @@ public class DmpServiceImpl implements DmpService { private NotificationIntegrationEvent applyNotificationType(DmpStatus status, NotificationIntegrationEvent event) { switch (status) { case Draft: - event.setNotificationType(UUID.fromString(notificationProperties.getDmpModified())); + event.setNotificationType(notificationProperties.getDmpModified()); return event; case Finalized: - event.setNotificationType(UUID.fromString(notificationProperties.getDmpFinalised())); + event.setNotificationType(notificationProperties.getDmpFinalised()); return event; default: throw new MyApplicationException("Unsupported Dmp Status."); @@ -702,22 +702,17 @@ public class DmpServiceImpl implements DmpService { dmpUserPersist.setUser(type.getUserId()); dmpUserPersist.setRole(model.getRole()); this.assignUsers(id, List.of(dmpUserPersist), null); + this.sendDmpInvitationExistingUser(type.getUserId(), dmp, model.getRole()); } else if (type.getEmail() != null) { - this.sendDmpInvitation(type.getEmail(),dmp, model.getRole()); + this.sendDmpInvitationExternalUser(type.getEmail(),dmp, model.getRole()); } } } - private void sendDmpInvitation(String email, DmpEntity dmp, DmpUserRole role) throws JAXBException, InvalidApplicationException { - ActionConfirmationPersist persist = new ActionConfirmationPersist(); - persist.setType(ActionConfirmationType.DmpInvitation); - persist.setStatus(ActionConfirmationStatus.Requested); - persist.setToken(UUID.randomUUID().toString()); - persist.setDmpInvitation(new DmpInvitationPersist(email, dmp.getId(), role)); - persist.setCreatedById(this.userScope.getUserIdSafe()); - persist.setExpiresAt(Instant.now().plusSeconds(Long.parseLong(this.notificationProperties.getEmailExpirationTimeSeconds()))); - this.actionConfirmationService.persist(persist, null); + private void sendDmpInvitationExistingUser(UUID userId, DmpEntity dmp, DmpUserRole role) throws InvalidApplicationException { + UserEntity recipient = this.queryFactory.query(UserQuery.class).ids(userId).isActive(IsActive.Active).first(); + String email = this.queryFactory.query(UserContactInfoQuery.class).userIds(recipient.getId()).first().getValue(); NotificationIntegrationEvent event = new NotificationIntegrationEvent(); event.setUserId(this.userScope.getUserIdSafe()); @@ -727,11 +722,11 @@ public class DmpServiceImpl implements DmpService { NotificationContactData contactData = new NotificationContactData(contactPairs, null, null); event.setContactHint(jsonHandlingService.toJsonSafe(contactData)); event.setContactTypeHint(NotificationContactType.EMAIL); - event.setNotificationType(UUID.fromString(notificationProperties.getDmpInvitation())); + event.setNotificationType(notificationProperties.getDmpInvitationExistingUser()); NotificationFieldData data = new NotificationFieldData(); List fieldInfoList = new ArrayList<>(); - fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, email)); - fieldInfoList.add(new FieldInfo("{confirmationToken}", DataType.String, persist.getToken())); + fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, recipient.getName())); + fieldInfoList.add(new FieldInfo("{reasonName}", DataType.String, this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserIdSafe()).first().getName())); fieldInfoList.add(new FieldInfo("{dmpname}", DataType.String, dmp.getLabel())); fieldInfoList.add(new FieldInfo("{dmprole}", DataType.String, role.toString())); data.setFields(fieldInfoList); @@ -739,6 +734,42 @@ public class DmpServiceImpl implements DmpService { eventHandler.handle(event); } + private void sendDmpInvitationExternalUser(String email, DmpEntity dmp, DmpUserRole role) throws JAXBException, InvalidApplicationException { + String token = this.createActionConfirmation(email, dmp, role); + + NotificationIntegrationEvent event = new NotificationIntegrationEvent(); + event.setUserId(this.userScope.getUserIdSafe()); + + List contactPairs = new ArrayList<>(); + contactPairs.add(new ContactPair(ContactInfoType.Email, email)); + NotificationContactData contactData = new NotificationContactData(contactPairs, null, null); + event.setContactHint(jsonHandlingService.toJsonSafe(contactData)); + event.setContactTypeHint(NotificationContactType.EMAIL); + event.setNotificationType(notificationProperties.getDmpInvitationExternalUser()); + NotificationFieldData data = new NotificationFieldData(); + List fieldInfoList = new ArrayList<>(); + fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, email)); + fieldInfoList.add(new FieldInfo("{confirmationToken}", DataType.String, token)); + fieldInfoList.add(new FieldInfo("{dmpname}", DataType.String, dmp.getLabel())); + fieldInfoList.add(new FieldInfo("{dmprole}", DataType.String, role.toString())); + data.setFields(fieldInfoList); + event.setData(jsonHandlingService.toJsonSafe(data)); + eventHandler.handle(event); + } + + private String createActionConfirmation(String email, DmpEntity dmp, DmpUserRole role) throws JAXBException, InvalidApplicationException { + ActionConfirmationPersist persist = new ActionConfirmationPersist(); + persist.setType(ActionConfirmationType.DmpInvitation); + persist.setStatus(ActionConfirmationStatus.Requested); + persist.setToken(UUID.randomUUID().toString()); + persist.setDmpInvitation(new DmpInvitationPersist(email, dmp.getId(), role)); + persist.setCreatedById(this.userScope.getUserIdSafe()); + persist.setExpiresAt(Instant.now().plusSeconds(Long.parseLong(this.notificationProperties.getEmailExpirationTimeSeconds()))); + this.actionConfirmationService.persist(persist, null); + + return persist.getToken(); + } + public void dmpInvitationAccept(String token) throws InvalidApplicationException { ActionConfirmationEntity action = this.queryFactory.query(ActionConfirmationQuery.class).tokens(token).types(ActionConfirmationType.DmpInvitation).isActive(IsActive.Active).first(); diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/user/UserServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/user/UserServiceImpl.java index 1fa74f1dd..15951d035 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/user/UserServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/user/UserServiceImpl.java @@ -342,28 +342,20 @@ public class UserServiceImpl implements UserService { //notifications public void sendMergeAccountConfirmation(String email) throws InvalidApplicationException, JAXBException { - ActionConfirmationPersist persist = new ActionConfirmationPersist(); - persist.setType(ActionConfirmationType.MergeAccount); - persist.setStatus(ActionConfirmationStatus.Requested); - persist.setToken(UUID.randomUUID().toString()); - persist.setEmailConfirmation(new EmailConfirmationPersist(email)); -// persist.setCreatedById(this.userScope.getUserIdSafe()); TODO - persist.setCreatedById(UUID.fromString("2c447092-ae88-40ab-ae7d-43b80b373a5f")); - persist.setExpiresAt(Instant.now().plusSeconds(Long.parseLong(this.notificationProperties.getEmailExpirationTimeSeconds()))); - this.actionConfirmationService.persist(persist, null); + String token = this.createActionConfirmation(email, ActionConfirmationType.MergeAccount); NotificationIntegrationEvent event = new NotificationIntegrationEvent(); - event.setUserId(UUID.fromString("2c447092-ae88-40ab-ae7d-43b80b373a5f")); + event.setUserId(this.userScope.getUserIdSafe()); List contactPairs = new ArrayList<>(); contactPairs.add(new ContactPair(ContactInfoType.Email, email)); NotificationContactData contactData = new NotificationContactData(contactPairs, null, null); event.setContactHint(jsonHandlingService.toJsonSafe(contactData)); event.setContactTypeHint(NotificationContactType.EMAIL); - event.setNotificationType(UUID.fromString(notificationProperties.getMergeAccountConfirmation())); + event.setNotificationType(notificationProperties.getMergeAccountConfirmation()); NotificationFieldData data = new NotificationFieldData(); List fieldInfoList = new ArrayList<>(); - fieldInfoList.add(new FieldInfo("{userName}", DataType.String, this.queryFactory.query(UserQuery.class).ids(UUID.fromString("2c447092-ae88-40ab-ae7d-43b80b373a5f")).first().getName())); - fieldInfoList.add(new FieldInfo("{confirmationToken}", DataType.String, persist.getToken())); + fieldInfoList.add(new FieldInfo("{userName}", DataType.String, this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserIdSafe()).first().getName())); + fieldInfoList.add(new FieldInfo("{confirmationToken}", DataType.String, token)); fieldInfoList.add(new FieldInfo("{expiration_time}", DataType.String, this.secondsToTime(Integer.parseInt(this.notificationProperties.getEmailExpirationTimeSeconds())))); data.setFields(fieldInfoList); event.setData(jsonHandlingService.toJsonSafe(data)); @@ -371,37 +363,29 @@ public class UserServiceImpl implements UserService { } public void sendRemoveCredentialConfirmation(String email) throws InvalidApplicationException, JAXBException { - ActionConfirmationPersist persist = new ActionConfirmationPersist(); - persist.setType(ActionConfirmationType.RemoveCredential); - persist.setStatus(ActionConfirmationStatus.Requested); - persist.setToken(UUID.randomUUID().toString()); - UserContactInfoEntity userContactInfo = this.queryFactory.query(UserContactInfoQuery.class).types(ContactInfoType.Email).userIds(UUID.fromString("d107dbad-c67f-418d-a930-f928a690dbfc")).values(email).first(); + UserContactInfoEntity userContactInfo = this.queryFactory.query(UserContactInfoQuery.class).types(ContactInfoType.Email).userIds(this.userScope.getUserIdSafe()).values(email).first(); if(userContactInfo == null){ - throw new InvalidApplicationException("Email does not exist in this user!"); + throw new MyApplicationException("Email does not exist in this user!"); } - UserCredentialQuery query = this.queryFactory.query(UserCredentialQuery.class).userIds(UUID.fromString("d107dbad-c67f-418d-a930-f928a690dbfc")); + UserCredentialQuery query = this.queryFactory.query(UserCredentialQuery.class).userIds(this.userScope.getUserIdSafe()); if (query == null || query.count() == 0){ - throw new InvalidApplicationException("This user don't have credential!"); + throw new MyApplicationException("This user don't have credential!"); } - persist.setEmailConfirmation(new EmailConfirmationPersist(email)); -// persist.setCreatedById(this.userScope.getUserIdSafe()); TODO - persist.setCreatedById(UUID.fromString("d107dbad-c67f-418d-a930-f928a690dbfc")); - persist.setExpiresAt(Instant.now().plusSeconds(Long.parseLong(this.notificationProperties.getEmailExpirationTimeSeconds()))); - this.actionConfirmationService.persist(persist, null); + String token = this.createActionConfirmation(email, ActionConfirmationType.RemoveCredential); NotificationIntegrationEvent event = new NotificationIntegrationEvent(); - event.setUserId(UUID.fromString("d107dbad-c67f-418d-a930-f928a690dbfc")); + event.setUserId(this.userScope.getUserIdSafe()); List contactPairs = new ArrayList<>(); contactPairs.add(new ContactPair(ContactInfoType.Email, email)); NotificationContactData contactData = new NotificationContactData(contactPairs, null, null); event.setContactHint(jsonHandlingService.toJsonSafe(contactData)); event.setContactTypeHint(NotificationContactType.EMAIL); - event.setNotificationType(UUID.fromString(notificationProperties.getRemoveCredentialConfirmation())); + event.setNotificationType(notificationProperties.getRemoveCredentialConfirmation()); NotificationFieldData data = new NotificationFieldData(); List fieldInfoList = new ArrayList<>(); - fieldInfoList.add(new FieldInfo("{confirmationToken}", DataType.String, persist.getToken())); + fieldInfoList.add(new FieldInfo("{confirmationToken}", DataType.String, token)); fieldInfoList.add(new FieldInfo("{email}", DataType.String, email)); fieldInfoList.add(new FieldInfo("{expiration_time}", DataType.String, this.secondsToTime(Integer.parseInt(this.notificationProperties.getEmailExpirationTimeSeconds())))); data.setFields(fieldInfoList); @@ -409,6 +393,18 @@ public class UserServiceImpl implements UserService { eventHandler.handle(event); } + private String createActionConfirmation(String email, ActionConfirmationType type) throws JAXBException, InvalidApplicationException { + ActionConfirmationPersist persist = new ActionConfirmationPersist(); + persist.setType(type); + persist.setStatus(ActionConfirmationStatus.Requested); + persist.setToken(UUID.randomUUID().toString()); + persist.setEmailConfirmation(new EmailConfirmationPersist(email)); + persist.setCreatedById(this.userScope.getUserIdSafe()); + persist.setExpiresAt(Instant.now().plusSeconds(Long.parseLong(this.notificationProperties.getEmailExpirationTimeSeconds()))); + this.actionConfirmationService.persist(persist, null); + + return persist.getToken(); + } private String secondsToTime(int seconds) { int sec = seconds % 60; @@ -427,7 +423,7 @@ public class UserServiceImpl implements UserService { action.setStatus(ActionConfirmationStatus.Accepted); //TODO merge - this.entityManager.merge(action); +// this.entityManager.merge(action); } public void confirmRemoveCredential(String token) throws InvalidApplicationException { @@ -435,10 +431,9 @@ public class UserServiceImpl implements UserService { this.checkActionState(action); - // EmailConfirmationEntity emailConfirmation = this.xmlHandlingService.fromXmlSafe(EmailConfirmationEntity.class, action.getData()); - UserCredentialEntity userCredential = this.queryFactory.query(UserCredentialQuery.class).userIds(UUID.fromString("d107dbad-c67f-418d-a930-f928a690dbfc")).first(); //ToDO + UserCredentialEntity userCredential = this.queryFactory.query(UserCredentialQuery.class).userIds(this.userScope.getUserIdSafe()).first(); if (userCredential == null){ - throw new InvalidApplicationException("This user does not have credential"); + throw new MyApplicationException("This user does not have credential"); } this.deleterFactory.deleter(UserCredentialDeleter.class).deleteAndSaveByIds(List.of(userCredential.getId())); @@ -446,15 +441,15 @@ public class UserServiceImpl implements UserService { this.entityManager.merge(action); } - private void checkActionState(ActionConfirmationEntity action) throws InvalidApplicationException { + private void checkActionState(ActionConfirmationEntity action) throws MyApplicationException { if (action == null){ - throw new InvalidApplicationException("Token does not exist!"); + throw new MyApplicationException("Token does not exist!"); } if (action.getStatus().equals(ActionConfirmationStatus.Accepted)){ - throw new InvalidApplicationException("Account is already confirmed!"); + throw new MyApplicationException("Account is already confirmed!"); } if (action.getExpiresAt().compareTo(Instant.now()) < 0){ - throw new InvalidApplicationException("Token has expired!"); + throw new MyApplicationException("Token has expired!"); } } diff --git a/dmp-backend/notification-service/notification-web/src/main/resources/config/notification.yml b/dmp-backend/notification-service/notification-web/src/main/resources/config/notification.yml index b16586741..5fbc2b22a 100644 --- a/dmp-backend/notification-service/notification-web/src/main/resources/config/notification.yml +++ b/dmp-backend/notification-service/notification-web/src/main/resources/config/notification.yml @@ -11,9 +11,12 @@ notification: overrides: [] resolver: global-policies: - - #dmpInvitation + - #dmpInvitationExternalUser type: 065DEECD-21BB-44AF-9983-E660FDF24BC4 contacts: [ email ] + - #dmpInvitationExistingUser + type: 4904dea2-5079-46d3-83be-3a19c9ab45dc + contacts: [ email ] - #dpmModified type: 4542262A-22F8-4BAA-9DB6-1C8E70AC1DBB contacts: [ email ] @@ -43,13 +46,13 @@ notification: message: email: flows: - - #dmpInvitation + - #dmpInvitationExternalUser key: 065DEECD-21BB-44AF-9983-E660FDF24BC4 - subject-path: classpath:notification_templates/dmpinvitation/email/subject.{language}.txt + subject-path: classpath:notification_templates/dmpinvitationexternaluser/email/subject.{language}.txt subject-field-options: mandatory: [ ] optional: [ ] - body-path: classpath:notification_templates/dmpinvitation/email/body.{language}.html + body-path: classpath:notification_templates/dmpinvitationexternaluser/email/body.{language}.html body-field-options: mandatory: [ "{dmpname}", "{dmprole}", "{installation-url}", "{confirmationToken}" ] optional: @@ -65,6 +68,29 @@ notification: bcc-mode: 0 allow-attachments: false cipher-fields: [ ] + - #dmpInvitationExistingUser + key: 4904dea2-5079-46d3-83be-3a19c9ab45dc + subject-path: classpath:notification_templates/dmpinvitationexistinguser/email/subject.{language}.txt + subject-field-options: + mandatory: [ ] + optional: [ ] + body-path: classpath:notification_templates/dmpinvitationexistinguser/email/body.{language}.html + body-field-options: + mandatory: [ "{dmpname}", "{dmprole}", "{reasonName}" ] + optional: + - key: "{recipient}" + value: + formatting: + '[{dmpname}]': null + '[{dmprole}]': null + '[{reasonName}]': null + '[{recipient}]': null + cc: [ ] + cc-mode: 0 + bcc: [ ] + bcc-mode: 0 + allow-attachments: false + cipher-fields: [ ] - #dmpModified key: 4542262A-22F8-4BAA-9DB6-1C8E70AC1DBB subject-path: classpath:notification_templates/dmpmodified/email/subject.{language}.txt diff --git a/dmp-backend/notification-service/notification-web/src/main/resources/notification_templates/dmpinvitation/email/subject.en.txt b/dmp-backend/notification-service/notification-web/src/main/resources/notification_templates/dmpinvitation/email/subject.en.txt deleted file mode 100644 index bbb2ce3db..000000000 --- a/dmp-backend/notification-service/notification-web/src/main/resources/notification_templates/dmpinvitation/email/subject.en.txt +++ /dev/null @@ -1 +0,0 @@ -ARGOS - Dmp Invite \ No newline at end of file diff --git a/dmp-backend/notification-service/notification-web/src/main/resources/notification_templates/dmpinvitationexistinguser/email/body.en.html b/dmp-backend/notification-service/notification-web/src/main/resources/notification_templates/dmpinvitationexistinguser/email/body.en.html new file mode 100644 index 000000000..4259f6e59 --- /dev/null +++ b/dmp-backend/notification-service/notification-web/src/main/resources/notification_templates/dmpinvitationexistinguser/email/body.en.html @@ -0,0 +1,287 @@ + + + + + + Simple Transactional Email + + + + + + + + + +
  +
+ + + This is preheader text. Some clients will show this text as a preview. + + + + + + + + +
+ + + + +
+

Dear {recipient},

+

{reasonName} just add you to collaborate to Data Management plan {dmpname} with role {dmprole}.

+
+
+ + + + + + +
+
 
+ + \ No newline at end of file diff --git a/dmp-backend/notification-service/notification-web/src/main/resources/notification_templates/dmpinvitationexistinguser/email/subject.en.txt b/dmp-backend/notification-service/notification-web/src/main/resources/notification_templates/dmpinvitationexistinguser/email/subject.en.txt new file mode 100644 index 000000000..2c36d1524 --- /dev/null +++ b/dmp-backend/notification-service/notification-web/src/main/resources/notification_templates/dmpinvitationexistinguser/email/subject.en.txt @@ -0,0 +1 @@ +ARGOS - Data Management Plan Invite \ No newline at end of file diff --git a/dmp-backend/notification-service/notification-web/src/main/resources/notification_templates/dmpinvitation/email/body.en.html b/dmp-backend/notification-service/notification-web/src/main/resources/notification_templates/dmpinvitationexternaluser/email/body.en.html similarity index 100% rename from dmp-backend/notification-service/notification-web/src/main/resources/notification_templates/dmpinvitation/email/body.en.html rename to dmp-backend/notification-service/notification-web/src/main/resources/notification_templates/dmpinvitationexternaluser/email/body.en.html diff --git a/dmp-backend/notification-service/notification-web/src/main/resources/notification_templates/dmpinvitationexternaluser/email/subject.en.txt b/dmp-backend/notification-service/notification-web/src/main/resources/notification_templates/dmpinvitationexternaluser/email/subject.en.txt new file mode 100644 index 000000000..2c36d1524 --- /dev/null +++ b/dmp-backend/notification-service/notification-web/src/main/resources/notification_templates/dmpinvitationexternaluser/email/subject.en.txt @@ -0,0 +1 @@ +ARGOS - Data Management Plan Invite \ No newline at end of file diff --git a/dmp-backend/notification-service/notification-web/target/classes/config/notification.yml b/dmp-backend/notification-service/notification-web/target/classes/config/notification.yml index b16586741..5fbc2b22a 100644 --- a/dmp-backend/notification-service/notification-web/target/classes/config/notification.yml +++ b/dmp-backend/notification-service/notification-web/target/classes/config/notification.yml @@ -11,9 +11,12 @@ notification: overrides: [] resolver: global-policies: - - #dmpInvitation + - #dmpInvitationExternalUser type: 065DEECD-21BB-44AF-9983-E660FDF24BC4 contacts: [ email ] + - #dmpInvitationExistingUser + type: 4904dea2-5079-46d3-83be-3a19c9ab45dc + contacts: [ email ] - #dpmModified type: 4542262A-22F8-4BAA-9DB6-1C8E70AC1DBB contacts: [ email ] @@ -43,13 +46,13 @@ notification: message: email: flows: - - #dmpInvitation + - #dmpInvitationExternalUser key: 065DEECD-21BB-44AF-9983-E660FDF24BC4 - subject-path: classpath:notification_templates/dmpinvitation/email/subject.{language}.txt + subject-path: classpath:notification_templates/dmpinvitationexternaluser/email/subject.{language}.txt subject-field-options: mandatory: [ ] optional: [ ] - body-path: classpath:notification_templates/dmpinvitation/email/body.{language}.html + body-path: classpath:notification_templates/dmpinvitationexternaluser/email/body.{language}.html body-field-options: mandatory: [ "{dmpname}", "{dmprole}", "{installation-url}", "{confirmationToken}" ] optional: @@ -65,6 +68,29 @@ notification: bcc-mode: 0 allow-attachments: false cipher-fields: [ ] + - #dmpInvitationExistingUser + key: 4904dea2-5079-46d3-83be-3a19c9ab45dc + subject-path: classpath:notification_templates/dmpinvitationexistinguser/email/subject.{language}.txt + subject-field-options: + mandatory: [ ] + optional: [ ] + body-path: classpath:notification_templates/dmpinvitationexistinguser/email/body.{language}.html + body-field-options: + mandatory: [ "{dmpname}", "{dmprole}", "{reasonName}" ] + optional: + - key: "{recipient}" + value: + formatting: + '[{dmpname}]': null + '[{dmprole}]': null + '[{reasonName}]': null + '[{recipient}]': null + cc: [ ] + cc-mode: 0 + bcc: [ ] + bcc-mode: 0 + allow-attachments: false + cipher-fields: [ ] - #dmpModified key: 4542262A-22F8-4BAA-9DB6-1C8E70AC1DBB subject-path: classpath:notification_templates/dmpmodified/email/subject.{language}.txt diff --git a/dmp-backend/notification-service/notification-web/target/classes/notification_templates/dmpinvitation/email/subject.en.txt b/dmp-backend/notification-service/notification-web/target/classes/notification_templates/dmpinvitation/email/subject.en.txt deleted file mode 100644 index bbb2ce3db..000000000 --- a/dmp-backend/notification-service/notification-web/target/classes/notification_templates/dmpinvitation/email/subject.en.txt +++ /dev/null @@ -1 +0,0 @@ -ARGOS - Dmp Invite \ No newline at end of file diff --git a/dmp-backend/notification-service/notification-web/target/classes/notification_templates/dmpinvitationexistinguser/email/body.en.html b/dmp-backend/notification-service/notification-web/target/classes/notification_templates/dmpinvitationexistinguser/email/body.en.html new file mode 100644 index 000000000..4259f6e59 --- /dev/null +++ b/dmp-backend/notification-service/notification-web/target/classes/notification_templates/dmpinvitationexistinguser/email/body.en.html @@ -0,0 +1,287 @@ + + + + + + Simple Transactional Email + + + + + + + + + +
  +
+ + + This is preheader text. Some clients will show this text as a preview. + + + + + + + + +
+ + + + +
+

Dear {recipient},

+

{reasonName} just add you to collaborate to Data Management plan {dmpname} with role {dmprole}.

+
+
+ + + + + + +
+
 
+ + \ No newline at end of file diff --git a/dmp-backend/notification-service/notification-web/target/classes/notification_templates/dmpinvitationexistinguser/email/subject.en.txt b/dmp-backend/notification-service/notification-web/target/classes/notification_templates/dmpinvitationexistinguser/email/subject.en.txt new file mode 100644 index 000000000..2c36d1524 --- /dev/null +++ b/dmp-backend/notification-service/notification-web/target/classes/notification_templates/dmpinvitationexistinguser/email/subject.en.txt @@ -0,0 +1 @@ +ARGOS - Data Management Plan Invite \ No newline at end of file diff --git a/dmp-backend/notification-service/notification-web/target/classes/notification_templates/dmpinvitation/email/body.en.html b/dmp-backend/notification-service/notification-web/target/classes/notification_templates/dmpinvitationexternaluser/email/body.en.html similarity index 100% rename from dmp-backend/notification-service/notification-web/target/classes/notification_templates/dmpinvitation/email/body.en.html rename to dmp-backend/notification-service/notification-web/target/classes/notification_templates/dmpinvitationexternaluser/email/body.en.html diff --git a/dmp-backend/notification-service/notification-web/target/classes/notification_templates/dmpinvitationexternaluser/email/subject.en.txt b/dmp-backend/notification-service/notification-web/target/classes/notification_templates/dmpinvitationexternaluser/email/subject.en.txt new file mode 100644 index 000000000..2c36d1524 --- /dev/null +++ b/dmp-backend/notification-service/notification-web/target/classes/notification_templates/dmpinvitationexternaluser/email/subject.en.txt @@ -0,0 +1 @@ +ARGOS - Data Management Plan Invite \ No newline at end of file diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/ConfirmationEmailServiceImpl.java b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/ConfirmationEmailServiceImpl.java index 6ac269716..ea70c9123 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/ConfirmationEmailServiceImpl.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/ConfirmationEmailServiceImpl.java @@ -94,7 +94,7 @@ public class ConfirmationEmailServiceImpl implements ConfirmationEmailService { NotificationContactData contactData = new NotificationContactData(contactPairs, null, null); event.setContactHint(jsonHandlingService.toJsonSafe(contactData)); event.setContactTypeHint(NotificationContactType.EMAIL); - event.setNotificationType(UUID.fromString(notificationProperties.getRemoveCredentialConfirmation())); + event.setNotificationType(notificationProperties.getRemoveCredentialConfirmation()); NotificationFieldData data = new NotificationFieldData(); List fieldInfoList = new ArrayList<>(); fieldInfoList.add(new FieldInfo("{confirmationToken}", DataType.String, confirmationEmail.getToken().toString())); @@ -136,7 +136,7 @@ public class ConfirmationEmailServiceImpl implements ConfirmationEmailService { NotificationContactData contactData = new NotificationContactData(contactPairs, null, null); event.setContactHint(jsonHandlingService.toJsonSafe(contactData)); event.setContactTypeHint(NotificationContactType.EMAIL); - event.setNotificationType(UUID.fromString(notificationProperties.getMergeAccountConfirmation())); + event.setNotificationType(notificationProperties.getMergeAccountConfirmation()); NotificationFieldData data = new NotificationFieldData(); List fieldInfoList = new ArrayList<>(); fieldInfoList.add(new FieldInfo("{userName}", DataType.String, user.getName())); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/InvitationServiceImpl.java b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/InvitationServiceImpl.java index acff0b722..abd0b9eb3 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/InvitationServiceImpl.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/InvitationServiceImpl.java @@ -115,7 +115,7 @@ public class InvitationServiceImpl implements InvitationService { NotificationContactData contactData = new NotificationContactData(contactPairs, null, null); event.setContactHint(jsonHandlingService.toJsonSafe(contactData)); event.setContactTypeHint(NotificationContactType.EMAIL); - event.setNotificationType(UUID.fromString(notificationProperties.getDmpInvitation())); + event.setNotificationType(notificationProperties.getDmpInvitationExternalUser()); NotificationFieldData data = new NotificationFieldData(); List fieldInfoList = new ArrayList<>(); fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, user.getName())); diff --git a/dmp-backend/web/src/main/resources/config/notification.yml b/dmp-backend/web/src/main/resources/config/notification.yml index 02c4d393d..85c861a89 100644 --- a/dmp-backend/web/src/main/resources/config/notification.yml +++ b/dmp-backend/web/src/main/resources/config/notification.yml @@ -1,5 +1,6 @@ notification: - dmpInvitation: 065DEECD-21BB-44AF-9983-E660FDF24BC4 + dmpInvitationExternalUser: 065DEECD-21BB-44AF-9983-E660FDF24BC4 + dmpInvitationExistingUser: 4904dea2-5079-46d3-83be-3a19c9ab45dc dmpModified: 4542262A-22F8-4BAA-9DB6-1C8E70AC1DBB dmpFinalised: 90DB0B46-42DE-BD89-AEBF-6F27EFEB256E descriptionModified: 4FDBFA80-7A71-4A69-B854-67CBB70648F1