in progress

This commit is contained in:
Francesco Mangiacrapa 2024-03-20 17:03:04 +01:00
parent 60cb48c098
commit 6c26aa65cc
6 changed files with 331 additions and 247 deletions

View File

@ -1,85 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>notifications-plugins</artifactId>
<version>1.0.4-SNAPSHOT</version>
<name>gCube CMS - Notifications Plugins</name>
<artifactId>notifications-plugins</artifactId>
<version>1.0.4-SNAPSHOT</version>
<name>gCube CMS - Notifications Plugins</name>
<parent> <parent>
<groupId>org.gcube.application.cms</groupId> <groupId>org.gcube.application.cms</groupId>
<artifactId>gcube-cms-suite</artifactId> <artifactId>gcube-cms-suite</artifactId>
<version>[1.0.0, 2.0.0-SNAPSHOT)</version> <version>[1.0.0, 2.0.0-SNAPSHOT)</version>
</parent> </parent>
<properties>
<gitBaseUrl>https://code-repo.d4science.org/gCubeSystem</gitBaseUrl>
</properties>
<dependencyManagement> <properties>
<dependencies> <gitBaseUrl>https://code-repo.d4science.org/gCubeSystem</gitBaseUrl>
<dependency> </properties>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-smartgears-bom</artifactId>
<version>${gcube-smartgears-bom-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.gcube.application.cms</groupId>
<artifactId>cms-plugin-framework</artifactId>
<version>${plugin-framework-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<scm> <dependencyManagement>
<connection>scm:git:${gitBaseUrl}/gcube-cms-suite</connection> <dependencies>
<developerConnection>scm:git:${gitBaseUrl}/gcube-cms-suite</developerConnection> <dependency>
<url>${gitBaseUrl}/gcube-cms-suite</url> <groupId>org.gcube.distribution</groupId>
</scm> <artifactId>gcube-smartgears-bom</artifactId>
<version>${gcube-smartgears-bom-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.gcube.application.cms</groupId>
<artifactId>cms-plugin-framework</artifactId>
<version>${plugin-framework-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<scm>
<connection>scm:git:${gitBaseUrl}/gcube-cms-suite</connection>
<developerConnection>scm:git:${gitBaseUrl}/gcube-cms-suite</developerConnection>
<url>${gitBaseUrl}/gcube-cms-suite</url>
</scm>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.gcube.application.cms</groupId> <groupId>org.gcube.application.cms</groupId>
<artifactId>cms-plugin-framework</artifactId> <artifactId>cms-plugin-framework</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.application.cms</groupId> <groupId>org.gcube.application.cms</groupId>
<artifactId>default-lc-managers</artifactId> <artifactId>default-lc-managers</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.application.cms</groupId> <groupId>org.gcube.social-networking</groupId>
<artifactId>cms-test-commons</artifactId> <artifactId>social-service-client</artifactId>
<scope>test</scope> <version>[1.0.0, 2.0.0-SNAPSHOT)</version>
</dependency> </dependency>
</dependencies> <dependency>
<build> <groupId>org.apache.commons</groupId>
<plugins> <artifactId>commons-text</artifactId>
<version>1.11.0</version>
</dependency>
<dependency>
<groupId>org.gcube.application.cms</groupId>
<artifactId>cms-test-commons</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<id>make-uberjar</id> <id>make-uberjar</id>
<phase>package</phase> <phase>package</phase>
</execution> </execution>
<execution> <execution>
<id>make-servicearchive</id> <id>make-servicearchive</id>
<phase>package</phase> <phase>package</phase>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -368,6 +368,7 @@ public class NotificationsPlugin extends AbstractPlugin implements EventListener
String linkToFileWithMessages = subscribedConfig.getLinkToMessages(); String linkToFileWithMessages = subscribedConfig.getLinkToMessages();
List<SubscribeNotificationEvent> list = subscribedConfig.getListNotificationEventSubscribed(); List<SubscribeNotificationEvent> list = subscribedConfig.getListNotificationEventSubscribed();
//Filtering list of SubscribeNotificationEvent for itemObserved Event
List<SubscribeNotificationEvent> filterList = list.stream() List<SubscribeNotificationEvent> filterList = list.stream()
.filter(sne -> sne.getEvent().equals(itemObserved.getEvent())).collect(Collectors.toList()); .filter(sne -> sne.getEvent().equals(itemObserved.getEvent())).collect(Collectors.toList());

View File

@ -1,6 +1,8 @@
package org.gcube.application.cms.notifications.config; 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.JsonIgnoreProperties;
import org.gcube.com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data; import lombok.Data;
@ -11,8 +13,8 @@ import lombok.Data;
{ {
"type": "NOTIFICATION_TYPE", "type": "NOTIFICATION_TYPE",
"send": "true/false", "send": "true/false",
"attach_pdf_document": "true/false", "placeholder_msg": "PLACEHOLDER_MESSAGE_1",
"message": "PLACEHOLDER_MESSAGE_1" "export_as_pdf": "ExportAsPDF"
} }
* *
*/ */
@ -20,9 +22,10 @@ import lombok.Data;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class Notify { public class Notify {
public static enum NOTIFICATION_TYPE {PERSONAL_POST, EMAIL, VRE_POST, ANY}
NOTIFICATION_TYPE type; NOTIFICATION_TYPE type;
Boolean send; Boolean send;
Boolean attach_pdf_document; String placeholder_msg;
String message; @JsonProperty("export_as_pdf")
ExportAsPDF export_as_pdf;
} }

View File

@ -1,15 +1,20 @@
package org.gcube.application.cms.notifications.manage; package org.gcube.application.cms.notifications.manage;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.gcube.application.cms.implementations.utils.UserUtils; 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.NotificationFor;
import org.gcube.application.cms.notifications.config.NotificationWhen; import org.gcube.application.cms.notifications.config.NotificationWhen;
import org.gcube.application.cms.notifications.config.SubscribeNotificationEvent; 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.cms.plugins.events.ItemObserved;
import org.gcube.application.geoportal.common.model.document.Project; import org.gcube.application.geoportal.common.model.document.Project;
import org.gcube.application.geoportal.common.model.document.accounting.User;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -49,10 +54,12 @@ public class ManageDoActionNotification {
for (SubscribeNotificationEvent subscribeNotificationEvent : listSubscribedNotification) { for (SubscribeNotificationEvent subscribeNotificationEvent : listSubscribedNotification) {
List<NotificationFor> listNotificationFor = subscribeNotificationEvent.getNotificationFor(); List<NotificationFor> listNotificationFor = subscribeNotificationEvent.getNotificationFor();
// Reading 'phase' property from itemObserved
String itemPhase = itemObserved.getProject().getLifecycleInformation().getPhase(); String itemPhase = itemObserved.getProject().getLifecycleInformation().getPhase();
log.debug("ItemObserved 'phase' is: {}", itemPhase);
for (NotificationFor notificationFor : listNotificationFor) { for (final NotificationFor notificationFor : listNotificationFor) {
// Filtering notifications on phase according to item itemObserved phase // Filtering notifications on 'phase' according to item itemObserved 'phase'
List<NotificationWhen> notificationsCompliantToPhase = notificationFor.getWhen().stream() List<NotificationWhen> notificationsCompliantToPhase = notificationFor.getWhen().stream()
.filter(when -> when.getTarget_phase().contains(itemPhase)).collect(Collectors.toList()); .filter(when -> when.getTarget_phase().contains(itemPhase)).collect(Collectors.toList());
@ -60,9 +67,21 @@ public class ManageDoActionNotification {
if (notificationsCompliantToPhase != null && notificationsCompliantToPhase.size() > 0) { if (notificationsCompliantToPhase != null && notificationsCompliantToPhase.size() > 0) {
// GET LIST USER COMPLIANT TO ROLES // GET LIST USER COMPLIANT TO ROLES
List<UserMock> notifyUsers = getListUserCompliantToRoles(notificationFor); List<User> notifyUsers = getListUserCompliantToRoles(notificationFor, itemObserved);
if (notifyUsers.size() > 0) { 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. * Gets the list user compliant to roles.
* *
* @param notificationFor the notification for * @param notificationFor the notification for
* @param itemObserved
* @return the list user compliant to roles * @return the list user compliant to roles
*/ */
// GET LIST USER COMPLIANT TO ROLES // GET LIST USER COMPLIANT TO ROLES
public List<UserMock> getListUserCompliantToRoles(NotificationFor notificationFor) { public List<User> getListUserCompliantToRoles(NotificationFor notificationFor, ItemObserved<Project> itemObserved) {
log.debug("getListUserCompliantToRoles called for scope: {}", UserUtils.getCurrent().getContext());
List<String> notifyUserWithRoles = notificationFor.getRoles(); List<String> notifyUserWithRoles = notificationFor.getRoles();
List<User> notifyUsers = new ArrayList<User>();
List<UserMock> notifyUsers = new ArrayList<UserMock>(); String anyRole = NotificationGenericConstants.CUSTOM_USER_ROLES.Any.name();
SocialClients socialClients = new SocialClients();
String scope = UserUtils.getCurrent().getContext(); if (notifyUserWithRoles.contains(anyRole)) {
try {
if (notifyUserWithRoles.contains("Any")) { // String token = AccessTokenProvider.instance.set(s);
// All user in the VRE List<String> listUsername = socialClients.getUsernamesByScope();
// read and return them 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 // We need to create the list of users that must be notified
for (String role : notifyUserWithRoles) { for (String role : notifyUserWithRoles) {
// Reading the list of users in the VRE with specific role // Reading the list of users in the VRE with specific role
// Creator of the item // Creator of the item
if (role.compareTo("Item_Creator") == 0) { String itemCreatorRole = NotificationGenericConstants.CUSTOM_USER_ROLES.Item_Creator.name();
// add to list of users to notify; 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 { } else {
// Reading the list of users in the VRE with specific role try {
List<String> 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; // return the list of users that must be notified;
log.error("returing {} users to be notified: ", notifyUsers.size());
return notifyUsers; return notifyUsers;
} }

View File

@ -1,10 +1,76 @@
package org.gcube.application.cms.notifications.manage; 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 class ManageNotifyUser {
private NotificationFor notificationFor;
public ManageNotifyUser() { private User recipientUser;
// TODO Auto-generated constructor stub
public ManageNotifyUser(NotificationFor notificationFor, User recipientUser) {
this.notificationFor = notificationFor;
this.recipientUser = recipientUser;
}
public void send() throws Exception {
SocialClients socialClients = new SocialClients();
List<Notify> 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<Recipient> rec = Arrays.asList(new Recipient(recipientUser.getUsername()));
MessageInputBean message = new MessageInputBean("Test message",
"Sending message via client " + System.currentTimeMillis(), new ArrayList<Recipient>(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<Notify> toNotify() {
List<Notify> listNotifies = new ArrayList<Notify>();
List<NotificationWhen> listWhen = notificationFor.getWhen();
for (NotificationWhen notificationWhen : listWhen) {
listNotifies.addAll(notificationWhen.getNotify().stream().filter(n -> n.getSend() == true)
.collect(Collectors.toList()));
}
return listNotifies;
} }
} }

View File

@ -5,11 +5,12 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import org.gcube.application.cms.notifications.NotificationEventsSubscribedConfig; 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.NotificationsPlugin;
import org.gcube.application.cms.notifications.config.ExportAsPDF;
import org.gcube.application.cms.notifications.config.NotificationFor; import org.gcube.application.cms.notifications.config.NotificationFor;
import org.gcube.application.cms.notifications.config.NotificationWhen; import org.gcube.application.cms.notifications.config.NotificationWhen;
import org.gcube.application.cms.notifications.config.Notify; 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.notifications.config.SubscribeNotificationEvent;
import org.gcube.application.cms.plugins.events.EventManager.Event; import org.gcube.application.cms.plugins.events.EventManager.Event;
import org.gcube.application.cms.plugins.faults.InitializationException; import org.gcube.application.cms.plugins.faults.InitializationException;
@ -63,16 +64,38 @@ public class CatalogueBindingPluginTest extends BasicPluginTest {
NotificationEventsSubscribedConfig notificationEventsSubs; NotificationEventsSubscribedConfig notificationEventsSubs;
try { try {
System.out.println(NotificationEventsSubscribedConfig.class.getSimpleName() + ": ");
notificationEventsSubs = plugin.readNotificationsSubscribedFromConfigurationInTheUCD(descriptor); notificationEventsSubs = plugin.readNotificationsSubscribedFromConfigurationInTheUCD(descriptor);
System.out List<SubscribeNotificationEvent> events = notificationEventsSubs.getListNotificationEventSubscribed();
.println(NotificationEventsSubscribedConfig.class.getSimpleName() + ": " + notificationEventsSubs); for (SubscribeNotificationEvent subscribeNotificationEvent : events) {
sysOut(subscribeNotificationEvent);
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
//@Test private void sysOut(SubscribeNotificationEvent subscribeNotificationEvent) {
System.out.println("\n#SubscribeNotificationEvent - Event: " + subscribeNotificationEvent.getEvent());
List<NotificationFor> 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() { public void checkSerializeDeserialize() {
org.junit.Assume.assumeTrue(GCubeTest.isTestInfrastructureEnabled()); org.junit.Assume.assumeTrue(GCubeTest.isTestInfrastructureEnabled());
@ -91,153 +114,103 @@ public class CatalogueBindingPluginTest extends BasicPluginTest {
Notify notify = new Notify(); Notify notify = new Notify();
notify.setType(NOTIFICATION_TYPE.EMAIL); notify.setType(NOTIFICATION_TYPE.EMAIL);
notify.setSend(true); notify.setSend(true);
notify.setAttach_pdf_document(true); ExportAsPDF exportAsPDF = new ExportAsPDF();
notify.setMessage("message"); 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)); notificationWhen.setNotify(Arrays.asList(notify));
listWhen.add(notificationWhen); listWhen.add(notificationWhen);
notificatioFor.setWhen(listWhen); notificatioFor.setWhen(listWhen);
listNotificationFor.add(notificatioFor); listNotificationFor.add(notificatioFor);
sne.setNotificationFor(listNotificationFor); sne.setNotificationFor(listNotificationFor);
try { try {
String serializeTOJSON = Serialization.write(sne); String serializeTOJSON = Serialization.write(sne);
System.out.println("Serialized toJSON :"+serializeTOJSON); System.out.println("Serialized toJSON :" + serializeTOJSON);
SubscribeNotificationEvent deserializeToJSON = Serialization.read(serializeTOJSON, SubscribeNotificationEvent.class); SubscribeNotificationEvent deserializeToJSON = Serialization.read(serializeTOJSON,
System.out.println("Deserialized from JSON :"+deserializeToJSON); SubscribeNotificationEvent.class);
System.out.println("Deserialized from JSON :" + deserializeToJSON);
//Test Notify
// Test Notify
/* /*
String testNotify = "{\n" * String testNotify = "{\n" + " \"type\": \"EMAIL\",\n" +
+ " \"type\": \"EMAIL\",\n" * " \"send\": true,\n" + " \"attach_pdf_document\": false,\n" +
+ " \"send\": true,\n" * " \"message\": \"The project ${project_name} has just been rejected by ${user}\"\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("String :"+testNotify); * System.out.println("Ser from JSON :"+serialize);
Notify serialize = Serialization.read(testNotify, Notify.class); */
System.out.println("Ser from JSON :"+serialize);
*/ // Test NotificationFor
//Test NotificationFor
/* /*
String testNotificationFor = "{ \"when\": [\n" * String testNotificationFor = "{ \"when\": [\n" + " {\n" +
+ " {\n" * " \"target_phase\": [\n" +
+ " \"target_phase\": [\n" * " \"Rejected\"\n" + " ],\n" +
+ " \"Rejected\"\n" * " \"notify\": {\n" +
+ " ],\n" * " \"send_personal_nofitication\": false,\n" +
+ " \"notify\": {\n" * " \"send_email\": true,\n" +
+ " \"send_personal_nofitication\": false,\n" * " \"send_pdf_document\": false,\n" +
+ " \"send_email\": true,\n" * " \"post_on_vre\": false,\n" +
+ " \"send_pdf_document\": false,\n" * " \"message\": \"The project ${project_name} has just been rejected. You are kindly requested to review it\"\n"
+ " \"post_on_vre\": false,\n" * + " }\n" + " },\n" +
+ " \"message\": \"The project ${project_name} has just been rejected. You are kindly requested to review it\"\n" * " {\n" + " \"target_phase\": [\n" +
+ " }\n" * " \"Published\"\n" + " ],\n" +
+ " },\n" * " \"notify\": {\n" +
+ " {\n" * " \"send_personal_nofitication\": false,\n" +
+ " \"target_phase\": [\n" * " \"send_email\": true,\n" +
+ " \"Published\"\n" * " \"send_pdf_document\": true,\n" +
+ " ],\n" * " \"post_on_vre\": true,\n" +
+ " \"notify\": {\n" * " \"message\": \"The project ${project_name} has just been published. See it at @link\"\n"
+ " \"send_personal_nofitication\": false,\n" * + " }\n" + " }\n" + " ]}";
+ " \"send_email\": true,\n" *
+ " \"send_pdf_document\": true,\n" * System.out.println("String :"+testNotificationFor); NotificationFor
+ " \"post_on_vre\": true,\n" * serializeNotificationWhen = Serialization.read(testNotificationFor,
+ " \"message\": \"The project ${project_name} has just been published. See it at @link\"\n" * NotificationFor.class);
+ " }\n" * System.out.println("Ser from JSON :"+serializeNotificationWhen);
+ " }\n" */
+ " ]}";
// String testSubribeNotifications = "{\n" + " \"event\": \"LIFECYCLE_STEP_PERFORMED\",\n"
System.out.println("String :"+testNotificationFor); // + " \"notificationFor\": [\n" + " {\n" + " \"roles\": [\n" + " \"Data-Manager\"\n"
NotificationFor serializeNotificationWhen = Serialization.read(testNotificationFor, NotificationFor.class); // + " ],\n" + " \"when\": [\n" + " {\n" + " \"target_phase\": [\n"
System.out.println("Ser from JSON :"+serializeNotificationWhen); // + " \"Pending Approval\"\n" + " ],\n" + " \"notify\": [\n"
*/ // + " {\n" + " \"type\": \"SOCIAL_POST\",\n"
// + " \"send\": true,\n" + " \"attach_pdf_document\": false,\n"
String testSubribeNotifications = "{\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"
+ " \"event\": \"LIFECYCLE_STEP_PERFORMED\",\n" // + " }\n" + " ]\n" + " },\n" + " {\n"
+ " \"notificationFor\": [\n" // + " \"target_phase\": [\n" + " \"Rejected\"\n" + " ],\n"
+ " {\n" // + " \"notify\": [\n" + " {\n" + " \"type\": \"SOCIAL_POST\",\n"
+ " \"roles\": [\n" // + " \"send\": true,\n" + " \"attach_pdf_document\": false,\n"
+ " \"Data-Manager\"\n" // + " \"message\": \"The project ${project_name} has just been rejected by ${user}\"\n"
+ " ],\n" // + " }\n" + " ]\n" + " }\n" + " ]\n" + " },\n" + " {\n"
+ " \"when\": [\n" // + " \"roles\": [\n" + " \"Item_Creator\"\n" + " ],\n" + " \"when\": [\n"
+ " {\n" // + " {\n" + " \"target_phase\": [\n" + " \"Rejected\"\n"
+ " \"target_phase\": [\n" // + " ],\n" + " \"notify\": [\n" + " {\n"
+ " \"Pending Approval\"\n" // + " \"type\": \"EMAIL\",\n" + " \"send\": true,\n"
+ " ],\n" // + " \"attach_pdf_document\": false,\n"
+ " \"notify\": [\n" // + " \"message\": \"The project ${project_name} has just been rejected. You are kindly requested to review it\"\n"
+ " {\n" // + " }\n" + " ]\n" + " },\n" + " {\n"
+ " \"type\": \"EMAIL\",\n" // + " \"target_phase\": [\n" + " \"Published\"\n" + " ],\n"
+ " \"send\": true,\n" // + " \"notify\": [\n" + " {\n" + " \"type\": \"EMAIL\",\n"
+ " \"attach_pdf_document\": false,\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" // + " \"message\": \"The project ${project_name} has just been published. See it at @link\"\n"
+ " }\n" // + " }\n" + " ]\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}]}]}]}";
+ " {\n" //
+ " \"target_phase\": [\n" // System.out.println("String :" + testSubribeNotifications);
+ " \"Rejected\"\n" // SubscribeNotificationEvent serializeSubscribeNotificationEvent = Serialization
+ " ],\n" // .convert(testSubribeNotifications, SubscribeNotificationEvent.class);
+ " \"notify\": [\n" // System.out.println("Ser from JSON :" + serializeSubscribeNotificationEvent);
+ " {\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);
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();