From 531ac821b114146cec210166ee4b4fe037491910 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Mon, 3 Nov 2014 18:35:26 +0000 Subject: [PATCH] passing hashtags in subject email of post notifications git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@101410 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../user/shareupdates/client/ShareUpdates.java | 1 + .../server/PostNotificationsThread.java | 15 ++++++++++----- .../server/ShareUpdateServiceImpl.java | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/ShareUpdates.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/ShareUpdates.java index 08a9860..a45551a 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/ShareUpdates.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/ShareUpdates.java @@ -12,5 +12,6 @@ public class ShareUpdates implements EntryPoint { public void onModuleLoad() { RootPanel.get("shareUpdateDiv").add(new ShareUpdateForm()); + } } diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/server/PostNotificationsThread.java b/src/main/java/org/gcube/portlets/user/shareupdates/server/PostNotificationsThread.java index 47dce1d..7d9ee5c 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/server/PostNotificationsThread.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/server/PostNotificationsThread.java @@ -1,5 +1,7 @@ package org.gcube.portlets.user.shareupdates.server; +import java.util.List; + import org.gcube.applicationsupportlayer.social.NotificationsManager; import org.gcube.vomanagement.usermanagement.UserManager; import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager; @@ -14,26 +16,29 @@ import org.slf4j.LoggerFactory; */ public class PostNotificationsThread implements Runnable { private static Logger _log = LoggerFactory.getLogger(PostNotificationsThread.class); - + private String postText; private String postId; private String groupId; + private List hashtags; private NotificationsManager nm; - - public PostNotificationsThread(String postId, String postText, String groupId, NotificationsManager nm) { + + public PostNotificationsThread(String postId, String postText, String groupId, NotificationsManager nm, List hashtags) { super(); this.postId = postId; this.postText = postText; this.groupId = groupId; + this.hashtags = hashtags; this.nm = nm; } @Override public void run() { UserManager um = new LiferayUserManager(); - try { + String[] hashtagsToPass = hashtags.toArray(new String[hashtags.size()]); + try { for (UserModel user : um.listUsersByGroup(groupId)) { - boolean result = nm.notifyPost(user.getScreenName(), postId, postText); + boolean result = nm.notifyPost(user.getScreenName(), postId, postText, hashtagsToPass); _log.trace("Sending Notification for post alert to: " + user.getScreenName() + " result?"+ result); } } catch (Exception e) { diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java index c7ea647..ad2bd85 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java @@ -110,7 +110,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar if (user == null) { _log.warn("USER IS NULL setting test.user and Running OUTSIDE PORTAL"); user = getDevelopmentUser(); - SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE"); + SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/USTORE_VRE"); } return SessionManager.getInstance().getASLSession(sessionID, user); } @@ -240,7 +240,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar //send the notification about this posts to everyone in the group if notifyGroup is true if (pLevel == PrivacyLevel.SINGLE_VRE && vreId != null && vreId.compareTo("") != 0 && notifyGroup) { NotificationsManager nm = new ApplicationNotificationsManager(session, NEWS_FEED_PORTLET_CLASSNAME); - Thread thread = new Thread(new PostNotificationsThread(toShare.getKey(), textToPost, ""+session.getGroupId(), nm)); + Thread thread = new Thread(new PostNotificationsThread(toShare.getKey(), textToPost, ""+session.getGroupId(), nm, hashtags)); thread.start(); }