diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
index 8907d91..bbf0648 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -5,9 +5,6 @@
-
- uses
-
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 17b1341..125c87c 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
@@ -10,10 +10,12 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.UUID;
import javax.net.ssl.HttpsURLConnection;
@@ -54,6 +56,7 @@ import org.gcube.portlets.user.shareupdates.shared.UserSettings;
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
import org.gcube.social_networking.socialutillibrary.Utils;
import org.gcube.vomanagement.usermanagement.GroupManager;
+import org.gcube.vomanagement.usermanagement.RoleManager;
import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.TeamRetrievalFault;
@@ -86,12 +89,15 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
private DatabookStore store;
/**
- * connect to cassandra at startup
+ * Connect to cassandra at startup
*/
public void init() {
store = new DBCassandraAstyanaxImpl();
}
+ /**
+ * Close connection pool on close
+ */
public void destroy() {
store.closeConnection();
}
@@ -209,7 +215,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
// check if is needed to notify people in the vre
- notifyPeopleGroup(pLevel, vreOrgId, notifyGroup, username, email, fullName, thumbnailAvatarURL, toShare, hashtags, vreScope2Set, escapedFeedText);
+ notifyPeopleGroup(pLevel, vreOrgId, notifyGroup, username, email, fullName, thumbnailAvatarURL, toShare, hashtags, vreScope2Set, escapedFeedText, mentionedUsers);
//send the notification to the mentioned users
if (mentionedUsers != null && mentionedUsers.size() > 0)
@@ -384,7 +390,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
// check if is needed to notify people in the vre
- notifyPeopleGroup(pLevel, vreOrgId, notifyGroup, username, email, fullName, thumbnailAvatarURL, toShare, hashtags, vreScope2Set, textToPost);
+ notifyPeopleGroup(pLevel, vreOrgId, notifyGroup, username, email, fullName, thumbnailAvatarURL, toShare, hashtags, vreScope2Set, textToPost, mentionedUsers);
//send the notification to the mentioned users
if (mentionedUsers != null && mentionedUsers.size() > 0)
@@ -416,7 +422,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
private void notifyPeopleGroup(PrivacyLevel pLevel, Long vreOrgId,
boolean notifyGroup, String username, String email,
String fullName, String thumbnailAvatarURL, Feed toShare,
- List hashtags, String vreScope2Set, String postText) {
+ List hashtags, String vreScope2Set, String postText, ArrayList mentionedUsers) {
//send the notification about this posts to everyone in the group if notifyGroup is true
if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null && notifyGroup) {
@@ -425,7 +431,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
vreScope2Set,
new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL),
NEWS_FEED_PORTLET_CLASSNAME);
- Thread thread = new Thread(new PostNotificationsThread(toShare.getKey(), postText, ""+vreOrgId, nm, hashtags));
+ Thread thread = new Thread(new PostNotificationsThread(new LiferayUserManager(), toShare.getKey(), postText, ""+vreOrgId, nm, new HashSet(hashtags), getVreGroupsNames(mentionedUsers)));
thread.start();
}
@@ -449,6 +455,28 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
.start();
}
}
+
+ /**
+ * Extract mentioned VRE's group names
+ * @return Set of vre groups' names
+ */
+ private static Set getVreGroupsNames(ArrayList mentionedUsers){
+
+ Set toReturn = new HashSet();
+ RoleManager rManager = new LiferayRoleManager();
+ for (ItemBean itemBean : mentionedUsers) {
+
+ if(itemBean.isItemGroup())
+ try {
+ toReturn.add(rManager.getTeam(Long.parseLong(itemBean.getId())).getTeamName());
+ } catch (NumberFormatException | UserManagementSystemException
+ | TeamRetrievalFault e) {
+ _log.warn("Unable to add this team", e);
+ }
+ }
+
+ return toReturn;
+ }
/**
* Common method to notify users.