in progress
This commit is contained in:
parent
60cb48c098
commit
6c26aa65cc
|
@ -55,6 +55,16 @@
|
|||
<artifactId>default-lc-managers</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.social-networking</groupId>
|
||||
<artifactId>social-service-client</artifactId>
|
||||
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-text</artifactId>
|
||||
<version>1.11.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>cms-test-commons</artifactId>
|
||||
|
|
|
@ -368,6 +368,7 @@ public class NotificationsPlugin extends AbstractPlugin implements EventListener
|
|||
String linkToFileWithMessages = subscribedConfig.getLinkToMessages();
|
||||
List<SubscribeNotificationEvent> list = subscribedConfig.getListNotificationEventSubscribed();
|
||||
|
||||
//Filtering list of SubscribeNotificationEvent for itemObserved Event
|
||||
List<SubscribeNotificationEvent> filterList = list.stream()
|
||||
.filter(sne -> sne.getEvent().equals(itemObserved.getEvent())).collect(Collectors.toList());
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<NotificationFor> 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<NotificationWhen> notificationsCompliantToPhase = notificationFor.getWhen().stream()
|
||||
.filter(when -> when.getTarget_phase().contains(itemPhase)).collect(Collectors.toList());
|
||||
|
||||
|
@ -60,25 +67,25 @@ public class ManageDoActionNotification {
|
|||
|
||||
if (notificationsCompliantToPhase != null && notificationsCompliantToPhase.size() > 0) {
|
||||
// GET LIST USER COMPLIANT TO ROLES
|
||||
List<UserMock> notifyUsers = getListUserCompliantToRoles(notificationFor);
|
||||
|
||||
List<User> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class UserMock.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Feb 1, 2024
|
||||
*/
|
||||
// MOCK
|
||||
public class UserMock {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -86,37 +93,61 @@ public class ManageDoActionNotification {
|
|||
* 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<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<UserMock> notifyUsers = new ArrayList<UserMock>();
|
||||
|
||||
String scope = UserUtils.getCurrent().getContext();
|
||||
|
||||
if (notifyUserWithRoles.contains("Any")) {
|
||||
// All user in the VRE
|
||||
// read and return them
|
||||
List<User> notifyUsers = new ArrayList<User>();
|
||||
String anyRole = NotificationGenericConstants.CUSTOM_USER_ROLES.Any.name();
|
||||
SocialClients socialClients = new SocialClients();
|
||||
if (notifyUserWithRoles.contains(anyRole)) {
|
||||
try {
|
||||
// String token = AccessTokenProvider.instance.set(s);
|
||||
List<String> 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<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;
|
||||
|
||||
log.error("returing {} users to be notified: ", notifyUsers.size());
|
||||
return notifyUsers;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
||||
private NotificationFor notificationFor;
|
||||
private User recipientUser;
|
||||
|
||||
public ManageNotifyUser() {
|
||||
// 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,15 +64,37 @@ 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<SubscribeNotificationEvent> events = notificationEventsSubs.getListNotificationEventSubscribed();
|
||||
for (SubscribeNotificationEvent subscribeNotificationEvent : events) {
|
||||
sysOut(subscribeNotificationEvent);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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() {
|
||||
org.junit.Assume.assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
|
@ -91,8 +114,12 @@ 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);
|
||||
|
@ -107,136 +134,82 @@ public class CatalogueBindingPluginTest extends BasicPluginTest {
|
|||
String serializeTOJSON = Serialization.write(sne);
|
||||
System.out.println("Serialized toJSON :" + serializeTOJSON);
|
||||
|
||||
SubscribeNotificationEvent deserializeToJSON = Serialization.read(serializeTOJSON, SubscribeNotificationEvent.class);
|
||||
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);
|
||||
* 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 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 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
|
||||
|
|
Loading…
Reference in New Issue