diff --git a/notifications-plugins/pom.xml b/notifications-plugins/pom.xml
index 5a2aa0a..240bccf 100644
--- a/notifications-plugins/pom.xml
+++ b/notifications-plugins/pom.xml
@@ -1,85 +1,95 @@
- 4.0.0
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+
+ notifications-plugins
+ 1.0.4-SNAPSHOT
+ gCube CMS - Notifications Plugins
- notifications-plugins
- 1.0.4-SNAPSHOT
- gCube CMS - Notifications Plugins
-
org.gcube.application.cms
gcube-cms-suite
[1.0.0, 2.0.0-SNAPSHOT)
-
-
- https://code-repo.d4science.org/gCubeSystem
-
-
-
-
- org.gcube.distribution
- gcube-smartgears-bom
- ${gcube-smartgears-bom-version}
- pom
- import
-
-
- org.gcube.application.cms
- cms-plugin-framework
- ${plugin-framework-version}
- pom
- import
-
-
-
+
+ https://code-repo.d4science.org/gCubeSystem
+
-
- scm:git:${gitBaseUrl}/gcube-cms-suite
- scm:git:${gitBaseUrl}/gcube-cms-suite
- ${gitBaseUrl}/gcube-cms-suite
-
+
+
+
+ org.gcube.distribution
+ gcube-smartgears-bom
+ ${gcube-smartgears-bom-version}
+ pom
+ import
+
+
+ org.gcube.application.cms
+ cms-plugin-framework
+ ${plugin-framework-version}
+ pom
+ import
+
+
+
+
+
+ scm:git:${gitBaseUrl}/gcube-cms-suite
+ scm:git:${gitBaseUrl}/gcube-cms-suite
+ ${gitBaseUrl}/gcube-cms-suite
+
-
-
- org.gcube.application.cms
- cms-plugin-framework
-
-
- org.gcube.application.cms
- default-lc-managers
- provided
-
-
- org.gcube.application.cms
- cms-test-commons
- test
-
-
-
-
+
+
+ org.gcube.application.cms
+ cms-plugin-framework
+
+
+ org.gcube.application.cms
+ default-lc-managers
+ provided
+
+
+ org.gcube.social-networking
+ social-service-client
+ [1.0.0, 2.0.0-SNAPSHOT)
+
+
+ org.apache.commons
+ commons-text
+ 1.11.0
+
+
+ org.gcube.application.cms
+ cms-test-commons
+ test
+
+
+
+
-
- org.apache.maven.plugins
- maven-assembly-plugin
-
-
- make-uberjar
- package
-
-
- make-servicearchive
- package
-
-
-
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+
+
+ make-uberjar
+ package
+
+
+ make-servicearchive
+ package
+
+
+
-
-
+
+
diff --git a/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/NotificationsPlugin.java b/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/NotificationsPlugin.java
index d97e302..e05b6e9 100644
--- a/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/NotificationsPlugin.java
+++ b/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/NotificationsPlugin.java
@@ -368,6 +368,7 @@ public class NotificationsPlugin extends AbstractPlugin implements EventListener
String linkToFileWithMessages = subscribedConfig.getLinkToMessages();
List list = subscribedConfig.getListNotificationEventSubscribed();
+ //Filtering list of SubscribeNotificationEvent for itemObserved Event
List filterList = list.stream()
.filter(sne -> sne.getEvent().equals(itemObserved.getEvent())).collect(Collectors.toList());
diff --git a/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/config/Notify.java b/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/config/Notify.java
index cdb2da9..c892f35 100644
--- a/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/config/Notify.java
+++ b/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/config/Notify.java
@@ -1,6 +1,8 @@
package org.gcube.application.cms.notifications.config;
+import org.gcube.application.cms.notifications.NotificationGenericConstants.NOTIFICATION_TYPE;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import org.gcube.com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@@ -11,8 +13,8 @@ import lombok.Data;
{
"type": "NOTIFICATION_TYPE",
"send": "true/false",
- "attach_pdf_document": "true/false",
- "message": "PLACEHOLDER_MESSAGE_1"
+ "placeholder_msg": "PLACEHOLDER_MESSAGE_1",
+ "export_as_pdf": "ExportAsPDF"
}
*
*/
@@ -20,9 +22,10 @@ import lombok.Data;
@JsonIgnoreProperties(ignoreUnknown = true)
public class Notify {
- public static enum NOTIFICATION_TYPE {PERSONAL_POST, EMAIL, VRE_POST, ANY}
+
NOTIFICATION_TYPE type;
Boolean send;
- Boolean attach_pdf_document;
- String message;
+ String placeholder_msg;
+ @JsonProperty("export_as_pdf")
+ ExportAsPDF export_as_pdf;
}
diff --git a/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/manage/ManageDoActionNotification.java b/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/manage/ManageDoActionNotification.java
index ec8fb6d..e47e158 100644
--- a/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/manage/ManageDoActionNotification.java
+++ b/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/manage/ManageDoActionNotification.java
@@ -1,15 +1,20 @@
package org.gcube.application.cms.notifications.manage;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.gcube.application.cms.implementations.utils.UserUtils;
+import org.gcube.application.cms.notifications.NotificationGenericConstants;
import org.gcube.application.cms.notifications.config.NotificationFor;
import org.gcube.application.cms.notifications.config.NotificationWhen;
import org.gcube.application.cms.notifications.config.SubscribeNotificationEvent;
+import org.gcube.application.cms.notifications.social.SocialClients;
import org.gcube.application.cms.plugins.events.ItemObserved;
import org.gcube.application.geoportal.common.model.document.Project;
+import org.gcube.application.geoportal.common.model.document.accounting.User;
import lombok.extern.slf4j.Slf4j;
@@ -49,10 +54,12 @@ public class ManageDoActionNotification {
for (SubscribeNotificationEvent subscribeNotificationEvent : listSubscribedNotification) {
List listNotificationFor = subscribeNotificationEvent.getNotificationFor();
+ // Reading 'phase' property from itemObserved
String itemPhase = itemObserved.getProject().getLifecycleInformation().getPhase();
+ log.debug("ItemObserved 'phase' is: {}", itemPhase);
- for (NotificationFor notificationFor : listNotificationFor) {
- // Filtering notifications on phase according to item itemObserved phase
+ for (final NotificationFor notificationFor : listNotificationFor) {
+ // Filtering notifications on 'phase' according to item itemObserved 'phase'
List notificationsCompliantToPhase = notificationFor.getWhen().stream()
.filter(when -> when.getTarget_phase().contains(itemPhase)).collect(Collectors.toList());
@@ -60,9 +67,21 @@ public class ManageDoActionNotification {
if (notificationsCompliantToPhase != null && notificationsCompliantToPhase.size() > 0) {
// GET LIST USER COMPLIANT TO ROLES
- List notifyUsers = getListUserCompliantToRoles(notificationFor);
-
+ List notifyUsers = getListUserCompliantToRoles(notificationFor, itemObserved);
if (notifyUsers.size() > 0) {
+ for (final User user : notifyUsers) {
+
+ Thread notificationT = new Thread() {
+
+ public void run() {
+ new ManageNotifyUser(notificationFor, user);
+ };
+
+ };
+
+ notificationT.run();
+ }
+
}
}
}
@@ -70,53 +89,65 @@ public class ManageDoActionNotification {
}
- /**
- * The Class UserMock.
- *
- * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
- *
- * Feb 1, 2024
- */
- // MOCK
- public class UserMock {
-
- }
-
/**
* Gets the list user compliant to roles.
*
* @param notificationFor the notification for
+ * @param itemObserved
* @return the list user compliant to roles
*/
// GET LIST USER COMPLIANT TO ROLES
- public List getListUserCompliantToRoles(NotificationFor notificationFor) {
+ public List getListUserCompliantToRoles(NotificationFor notificationFor, ItemObserved itemObserved) {
+ log.debug("getListUserCompliantToRoles called for scope: {}", UserUtils.getCurrent().getContext());
List notifyUserWithRoles = notificationFor.getRoles();
-
- List notifyUsers = new ArrayList();
-
- String scope = UserUtils.getCurrent().getContext();
-
- if (notifyUserWithRoles.contains("Any")) {
- // All user in the VRE
- // read and return them
+ List notifyUsers = new ArrayList();
+ String anyRole = NotificationGenericConstants.CUSTOM_USER_ROLES.Any.name();
+ SocialClients socialClients = new SocialClients();
+ if (notifyUserWithRoles.contains(anyRole)) {
+ try {
+ // String token = AccessTokenProvider.instance.set(s);
+ List listUsername = socialClients.getUsernamesByScope();
+ notifyUsers.addAll(
+ listUsername.stream().map(username -> new User(username, null)).collect(Collectors.toList()));
+ } catch (Exception e) {
+ log.error("Error on reading users from scope {}: ", UserUtils.getCurrent().getContext(), e);
+ }
+ log.info("returning {} users for role {}", notifyUsers.size(), anyRole);
+ return notifyUsers;
}
// We need to create the list of users that must be notified
for (String role : notifyUserWithRoles) {
// Reading the list of users in the VRE with specific role
-
// Creator of the item
- if (role.compareTo("Item_Creator") == 0) {
- // add to list of users to notify;
+ String itemCreatorRole = NotificationGenericConstants.CUSTOM_USER_ROLES.Item_Creator.name();
+ if (role.compareTo(itemCreatorRole) == 0) {
+ try {
+ String creatorUsername = itemObserved.getProject().getInfo().getCreationInfo().getUser()
+ .getUsername();
+ notifyUsers.add(
+ new User(creatorUsername, Stream.of(role).collect(Collectors.toCollection(HashSet::new))));
+ } catch (Exception e) {
+ log.error("Error on reading user {} from scope {}: ", itemCreatorRole,
+ UserUtils.getCurrent().getContext(), e);
+ }
} else {
- // Reading the list of users in the VRE with specific role
+ try {
+ List listUsernameForRole = socialClients.getUsernamesByRole(role);
+ notifyUsers.addAll(listUsernameForRole.stream()
+ .map(username -> new User(username,
+ Stream.of(role).collect(Collectors.toCollection(HashSet::new))))
+ .collect(Collectors.toList()));
+ } catch (Exception e) {
+ log.error("Error on reading users from scope {}: ", UserUtils.getCurrent().getContext(), e);
+ }
}
}
// return the list of users that must be notified;
-
+ log.error("returing {} users to be notified: ", notifyUsers.size());
return notifyUsers;
}
diff --git a/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/manage/ManageNotifyUser.java b/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/manage/ManageNotifyUser.java
index f16991d..6dd757f 100644
--- a/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/manage/ManageNotifyUser.java
+++ b/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/manage/ManageNotifyUser.java
@@ -1,10 +1,76 @@
package org.gcube.application.cms.notifications.manage;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.gcube.application.cms.notifications.config.NotificationFor;
+import org.gcube.application.cms.notifications.config.NotificationWhen;
+import org.gcube.application.cms.notifications.config.Notify;
+import org.gcube.application.cms.notifications.social.SocialClients;
+import org.gcube.application.geoportal.common.model.document.accounting.User;
+import org.gcube.portal.databook.shared.Post;
+import org.gcube.social_networking.socialnetworking.model.beans.MessageInputBean;
+import org.gcube.social_networking.socialnetworking.model.beans.PostInputBean;
+import org.gcube.social_networking.socialnetworking.model.beans.Recipient;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
public class ManageNotifyUser {
-
-
- public ManageNotifyUser() {
- // TODO Auto-generated constructor stub
+
+ private NotificationFor notificationFor;
+ private User recipientUser;
+
+
+ public ManageNotifyUser(NotificationFor notificationFor, User recipientUser) {
+ this.notificationFor = notificationFor;
+ this.recipientUser = recipientUser;
+ }
+
+ public void send() throws Exception {
+ SocialClients socialClients = new SocialClients();
+ List listNotifies = toNotify();
+
+ //TODO
+ //NotificationClient client = new NotificationClient();
+ //client.send ??????
+
+ for (Notify notify : listNotifies) {
+ switch (notify.getType()) {
+ case USER_POST:
+ String placeholderMessage = notify.getPlaceholder_msg();
+ List rec = Arrays.asList(new Recipient(recipientUser.getUsername()));
+ MessageInputBean message = new MessageInputBean("Test message",
+ "Sending message via client " + System.currentTimeMillis(), new ArrayList(rec));
+ String idMessage = socialClients.writeMessage(message);
+ break;
+ case VRE_POST:
+
+ PostInputBean toWrite = null;
+ Post thePost = socialClients.writeUserPost(toWrite);
+ log.info("{} post created: {} ", notify.getType(), thePost);
+ break;
+
+ case EMAIL:
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ }
+
+ private List toNotify() {
+ List listNotifies = new ArrayList();
+ List listWhen = notificationFor.getWhen();
+ for (NotificationWhen notificationWhen : listWhen) {
+ listNotifies.addAll(notificationWhen.getNotify().stream().filter(n -> n.getSend() == true)
+ .collect(Collectors.toList()));
+ }
+ return listNotifies;
}
}
diff --git a/notifications-plugins/src/test/java/CatalogueBindingPluginTest.java b/notifications-plugins/src/test/java/CatalogueBindingPluginTest.java
index 39d7cc0..9ad211e 100644
--- a/notifications-plugins/src/test/java/CatalogueBindingPluginTest.java
+++ b/notifications-plugins/src/test/java/CatalogueBindingPluginTest.java
@@ -5,11 +5,12 @@ import java.util.Arrays;
import java.util.List;
import org.gcube.application.cms.notifications.NotificationEventsSubscribedConfig;
+import org.gcube.application.cms.notifications.NotificationGenericConstants.NOTIFICATION_TYPE;
import org.gcube.application.cms.notifications.NotificationsPlugin;
+import org.gcube.application.cms.notifications.config.ExportAsPDF;
import org.gcube.application.cms.notifications.config.NotificationFor;
import org.gcube.application.cms.notifications.config.NotificationWhen;
import org.gcube.application.cms.notifications.config.Notify;
-import org.gcube.application.cms.notifications.config.Notify.NOTIFICATION_TYPE;
import org.gcube.application.cms.notifications.config.SubscribeNotificationEvent;
import org.gcube.application.cms.plugins.events.EventManager.Event;
import org.gcube.application.cms.plugins.faults.InitializationException;
@@ -63,16 +64,38 @@ public class CatalogueBindingPluginTest extends BasicPluginTest {
NotificationEventsSubscribedConfig notificationEventsSubs;
try {
+ System.out.println(NotificationEventsSubscribedConfig.class.getSimpleName() + ": ");
notificationEventsSubs = plugin.readNotificationsSubscribedFromConfigurationInTheUCD(descriptor);
- System.out
- .println(NotificationEventsSubscribedConfig.class.getSimpleName() + ": " + notificationEventsSubs);
+ List events = notificationEventsSubs.getListNotificationEventSubscribed();
+ for (SubscribeNotificationEvent subscribeNotificationEvent : events) {
+ sysOut(subscribeNotificationEvent);
+ }
} catch (Exception e) {
e.printStackTrace();
}
}
- //@Test
+ private void sysOut(SubscribeNotificationEvent subscribeNotificationEvent) {
+ System.out.println("\n#SubscribeNotificationEvent - Event: " + subscribeNotificationEvent.getEvent());
+ List listNotificationFor = subscribeNotificationEvent.getNotificationFor();
+ for (NotificationFor notificationFor : listNotificationFor) {
+ System.out.println("\tNotificationFor - roles: " + notificationFor.getRoles());
+ for (NotificationWhen notificationWhen : notificationFor.getWhen()) {
+ System.out.println("\t\tNotificationWhen - Target_phase: " + notificationWhen.getTarget_phase());
+ for (Notify notify : notificationWhen.getNotify()) {
+ System.out.println("\t\t\tNotify type : " + notify.getType());
+ System.out.println("\t\t\tNotify send : " + notify.getSend());
+ System.out.println("\t\t\tNotify placeholder_message : " + notify.getPlaceholder_msg());
+ if (notify.getExport_as_pdf() != null) {
+ System.out.println("\t\t\t\tExport as PDF : " + notify.getExport_as_pdf());
+ }
+ }
+ }
+ }
+ }
+
+ // @Test
public void checkSerializeDeserialize() {
org.junit.Assume.assumeTrue(GCubeTest.isTestInfrastructureEnabled());
@@ -91,153 +114,103 @@ public class CatalogueBindingPluginTest extends BasicPluginTest {
Notify notify = new Notify();
notify.setType(NOTIFICATION_TYPE.EMAIL);
notify.setSend(true);
- notify.setAttach_pdf_document(true);
- notify.setMessage("message");
+ ExportAsPDF exportAsPDF = new ExportAsPDF();
+ exportAsPDF.setExport(true);
+ exportAsPDF.setPlaceholder_msg("Export as PDF placeholder");
+ notify.setExport_as_pdf(exportAsPDF);
+ // notify.setAttach_pdf_document(true);
+ notify.setPlaceholder_msg("Notification Placeholder message");
notificationWhen.setNotify(Arrays.asList(notify));
-
+
listWhen.add(notificationWhen);
notificatioFor.setWhen(listWhen);
listNotificationFor.add(notificatioFor);
sne.setNotificationFor(listNotificationFor);
-
+
try {
-
+
String serializeTOJSON = Serialization.write(sne);
- System.out.println("Serialized toJSON :"+serializeTOJSON);
-
- SubscribeNotificationEvent deserializeToJSON = Serialization.read(serializeTOJSON, SubscribeNotificationEvent.class);
- System.out.println("Deserialized from JSON :"+deserializeToJSON);
-
- //Test Notify
+ System.out.println("Serialized toJSON :" + serializeTOJSON);
+
+ SubscribeNotificationEvent deserializeToJSON = Serialization.read(serializeTOJSON,
+ SubscribeNotificationEvent.class);
+ System.out.println("Deserialized from JSON :" + deserializeToJSON);
+
+ // Test Notify
/*
- String testNotify = "{\n"
- + " \"type\": \"EMAIL\",\n"
- + " \"send\": true,\n"
- + " \"attach_pdf_document\": false,\n"
- + " \"message\": \"The project ${project_name} has just been rejected by ${user}\"\n"
- + "}";
-
- System.out.println("String :"+testNotify);
- Notify serialize = Serialization.read(testNotify, Notify.class);
- System.out.println("Ser from JSON :"+serialize);
- */
-
- //Test NotificationFor
+ * String testNotify = "{\n" + " \"type\": \"EMAIL\",\n" +
+ * " \"send\": true,\n" + " \"attach_pdf_document\": false,\n" +
+ * " \"message\": \"The project ${project_name} has just been rejected by ${user}\"\n"
+ * + "}";
+ *
+ * System.out.println("String :"+testNotify); Notify serialize =
+ * Serialization.read(testNotify, Notify.class);
+ * System.out.println("Ser from JSON :"+serialize);
+ */
+
+ // Test NotificationFor
/*
- String testNotificationFor = "{ \"when\": [\n"
- + " {\n"
- + " \"target_phase\": [\n"
- + " \"Rejected\"\n"
- + " ],\n"
- + " \"notify\": {\n"
- + " \"send_personal_nofitication\": false,\n"
- + " \"send_email\": true,\n"
- + " \"send_pdf_document\": false,\n"
- + " \"post_on_vre\": false,\n"
- + " \"message\": \"The project ${project_name} has just been rejected. You are kindly requested to review it\"\n"
- + " }\n"
- + " },\n"
- + " {\n"
- + " \"target_phase\": [\n"
- + " \"Published\"\n"
- + " ],\n"
- + " \"notify\": {\n"
- + " \"send_personal_nofitication\": false,\n"
- + " \"send_email\": true,\n"
- + " \"send_pdf_document\": true,\n"
- + " \"post_on_vre\": true,\n"
- + " \"message\": \"The project ${project_name} has just been published. See it at @link\"\n"
- + " }\n"
- + " }\n"
- + " ]}";
-
- System.out.println("String :"+testNotificationFor);
- NotificationFor serializeNotificationWhen = Serialization.read(testNotificationFor, NotificationFor.class);
- System.out.println("Ser from JSON :"+serializeNotificationWhen);
- */
-
- String testSubribeNotifications = "{\n"
- + " \"event\": \"LIFECYCLE_STEP_PERFORMED\",\n"
- + " \"notificationFor\": [\n"
- + " {\n"
- + " \"roles\": [\n"
- + " \"Data-Manager\"\n"
- + " ],\n"
- + " \"when\": [\n"
- + " {\n"
- + " \"target_phase\": [\n"
- + " \"Pending Approval\"\n"
- + " ],\n"
- + " \"notify\": [\n"
- + " {\n"
- + " \"type\": \"EMAIL\",\n"
- + " \"send\": true,\n"
- + " \"attach_pdf_document\": false,\n"
- + " \"message\": \"${user} created the project ${project_name}. You are kindly requested to review it and decide either to APPROVE or REJECT it. See it at @link\"\n"
- + " }\n"
- + " ]\n"
- + " },\n"
- + " {\n"
- + " \"target_phase\": [\n"
- + " \"Rejected\"\n"
- + " ],\n"
- + " \"notify\": [\n"
- + " {\n"
- + " \"type\": \"EMAIL\",\n"
- + " \"send\": true,\n"
- + " \"attach_pdf_document\": false,\n"
- + " \"message\": \"The project ${project_name} has just been rejected by ${user}\"\n"
- + " }\n"
- + " ]\n"
- + " }\n"
- + " ]\n"
- + " },\n"
- + " {\n"
- + " \"roles\": [\n"
- + " \"Item_Creator\"\n"
- + " ],\n"
- + " \"when\": [\n"
- + " {\n"
- + " \"target_phase\": [\n"
- + " \"Rejected\"\n"
- + " ],\n"
- + " \"notify\": [\n"
- + " {\n"
- + " \"type\": \"EMAIL\",\n"
- + " \"send\": true,\n"
- + " \"attach_pdf_document\": false,\n"
- + " \"message\": \"The project ${project_name} has just been rejected. You are kindly requested to review it\"\n"
- + " }\n"
- + " ]\n"
- + " },\n"
- + " {\n"
- + " \"target_phase\": [\n"
- + " \"Published\"\n"
- + " ],\n"
- + " \"notify\": [\n"
- + " {\n"
- + " \"type\": \"EMAIL\",\n"
- + " \"send\": true,\n"
- + " \"attach_pdf_document\": false,\n"
- + " \"message\": \"The project ${project_name} has just been published. See it at @link\"\n"
- + " }\n"
- + " ]\n"
- + " }\n"
- + " ]\n"
- + " }\n"
- + " ]\n"
- + "}";
-
-
- testSubribeNotifications = "{event=LIFECYCLE_STEP_PERFORMED, notificationFor=[{roles=[Data-Manager], when=[{target_phase=[Pending Approval], notify=[{type=EMAIL, send=true, attach_pdf_document=false, message=${user} created the project ${project_name}. You are kindly requested to review it and decide either to APPROVE or REJECT it. See it at @link}]}, {target_phase=[Rejected], notify=[{type=EMAIL, send=true, attach_pdf_document=false, message=The project ${project_name} has just been rejected by ${user}}]}]}, {roles=[Item_Creator], when=[{target_phase=[Rejected], notify=[{type=EMAIL, send=true, attach_pdf_document=false, message=The project ${project_name} has just been rejected. You are kindly requested to review it}]}, {target_phase=[Published], notify=[{type=EMAIL, send=true, attach_pdf_document=false, message=The project ${project_name} has just been published. See it at @link}]}]}]}";
-
- System.out.println("String :"+testSubribeNotifications);
- SubscribeNotificationEvent serializeSubscribeNotificationEvent = Serialization.convert(testSubribeNotifications, SubscribeNotificationEvent.class);
- System.out.println("Ser from JSON :"+serializeSubscribeNotificationEvent);
-
-
+ * String testNotificationFor = "{ \"when\": [\n" + " {\n" +
+ * " \"target_phase\": [\n" +
+ * " \"Rejected\"\n" + " ],\n" +
+ * " \"notify\": {\n" +
+ * " \"send_personal_nofitication\": false,\n" +
+ * " \"send_email\": true,\n" +
+ * " \"send_pdf_document\": false,\n" +
+ * " \"post_on_vre\": false,\n" +
+ * " \"message\": \"The project ${project_name} has just been rejected. You are kindly requested to review it\"\n"
+ * + " }\n" + " },\n" +
+ * " {\n" + " \"target_phase\": [\n" +
+ * " \"Published\"\n" + " ],\n" +
+ * " \"notify\": {\n" +
+ * " \"send_personal_nofitication\": false,\n" +
+ * " \"send_email\": true,\n" +
+ * " \"send_pdf_document\": true,\n" +
+ * " \"post_on_vre\": true,\n" +
+ * " \"message\": \"The project ${project_name} has just been published. See it at @link\"\n"
+ * + " }\n" + " }\n" + " ]}";
+ *
+ * System.out.println("String :"+testNotificationFor); NotificationFor
+ * serializeNotificationWhen = Serialization.read(testNotificationFor,
+ * NotificationFor.class);
+ * System.out.println("Ser from JSON :"+serializeNotificationWhen);
+ */
+
+// String testSubribeNotifications = "{\n" + " \"event\": \"LIFECYCLE_STEP_PERFORMED\",\n"
+// + " \"notificationFor\": [\n" + " {\n" + " \"roles\": [\n" + " \"Data-Manager\"\n"
+// + " ],\n" + " \"when\": [\n" + " {\n" + " \"target_phase\": [\n"
+// + " \"Pending Approval\"\n" + " ],\n" + " \"notify\": [\n"
+// + " {\n" + " \"type\": \"SOCIAL_POST\",\n"
+// + " \"send\": true,\n" + " \"attach_pdf_document\": false,\n"
+// + " \"message\": \"${user} created the project ${project_name}. You are kindly requested to review it and decide either to APPROVE or REJECT it. See it at @link\"\n"
+// + " }\n" + " ]\n" + " },\n" + " {\n"
+// + " \"target_phase\": [\n" + " \"Rejected\"\n" + " ],\n"
+// + " \"notify\": [\n" + " {\n" + " \"type\": \"SOCIAL_POST\",\n"
+// + " \"send\": true,\n" + " \"attach_pdf_document\": false,\n"
+// + " \"message\": \"The project ${project_name} has just been rejected by ${user}\"\n"
+// + " }\n" + " ]\n" + " }\n" + " ]\n" + " },\n" + " {\n"
+// + " \"roles\": [\n" + " \"Item_Creator\"\n" + " ],\n" + " \"when\": [\n"
+// + " {\n" + " \"target_phase\": [\n" + " \"Rejected\"\n"
+// + " ],\n" + " \"notify\": [\n" + " {\n"
+// + " \"type\": \"EMAIL\",\n" + " \"send\": true,\n"
+// + " \"attach_pdf_document\": false,\n"
+// + " \"message\": \"The project ${project_name} has just been rejected. You are kindly requested to review it\"\n"
+// + " }\n" + " ]\n" + " },\n" + " {\n"
+// + " \"target_phase\": [\n" + " \"Published\"\n" + " ],\n"
+// + " \"notify\": [\n" + " {\n" + " \"type\": \"EMAIL\",\n"
+// + " \"send\": true,\n" + " \"attach_pdf_document\": false,\n"
+// + " \"message\": \"The project ${project_name} has just been published. See it at @link\"\n"
+// + " }\n" + " ]\n" + " }\n" + " ]\n" + " }\n" + " ]\n" + "}";
+//
+// testSubribeNotifications = "{event=LIFECYCLE_STEP_PERFORMED, notificationFor=[{roles=[Data-Manager], when=[{target_phase=[Pending Approval], notify=[{type=EMAIL, send=true, attach_pdf_document=false, message=${user} created the project ${project_name}. You are kindly requested to review it and decide either to APPROVE or REJECT it. See it at @link}]}, {target_phase=[Rejected], notify=[{type=EMAIL, send=true, attach_pdf_document=false, message=The project ${project_name} has just been rejected by ${user}}]}]}, {roles=[Item_Creator], when=[{target_phase=[Rejected], notify=[{type=EMAIL, send=true, attach_pdf_document=false, message=The project ${project_name} has just been rejected. You are kindly requested to review it}]}, {target_phase=[Published], notify=[{type=EMAIL, send=true, attach_pdf_document=false, message=The project ${project_name} has just been published. See it at @link}]}]}]}";
+//
+// System.out.println("String :" + testSubribeNotifications);
+// SubscribeNotificationEvent serializeSubscribeNotificationEvent = Serialization
+// .convert(testSubribeNotifications, SubscribeNotificationEvent.class);
+// System.out.println("Ser from JSON :" + serializeSubscribeNotificationEvent);
+
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();