From 88c2e4bb72c9df4c92f387403398c9f0d3ec1d77 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Thu, 9 Jul 2015 09:13:43 +0000 Subject: [PATCH] removed notification threads as they were moved into a shared library git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@117110 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 4 +- .settings/org.eclipse.wst.common.component | 4 +- pom.xml | 9 +- .../server/CommentNotificationsThread.java | 82 ------------------- .../server/LikeNotificationsThread.java | 44 ---------- .../server/MentionNotificationsThread.java | 39 --------- .../user/newsfeed/server/NewsServiceImpl.java | 10 ++- .../portlets/user/newsfeed/NewsFeed.gwt.xml | 2 +- 8 files changed, 21 insertions(+), 173 deletions(-) delete mode 100644 src/main/java/org/gcube/portlets/user/newsfeed/server/CommentNotificationsThread.java delete mode 100644 src/main/java/org/gcube/portlets/user/newsfeed/server/LikeNotificationsThread.java delete mode 100644 src/main/java/org/gcube/portlets/user/newsfeed/server/MentionNotificationsThread.java diff --git a/.classpath b/.classpath index 7f855e4..6ea5ab6 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,6 @@ - + @@ -31,5 +31,5 @@ - + diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 8acd000..19f7383 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -7,10 +7,10 @@ uses - + uses - + uses diff --git a/pom.xml b/pom.xml index ebd087f..3ac19f7 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.gcube.portlets.user news-feed war - 1.9.1-SNAPSHOT + 1.10.0-SNAPSHOT gCube News Feed Portlet @@ -95,6 +95,11 @@ social-networking-library provided + + org.gcube.portal + notifications-common-library + [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) + org.gcube.portlets.widgets user-selection-dialog @@ -104,7 +109,7 @@ org.gcube.portlets.widgets workspace-light-tree - [2.13.1-SNAPSHOT, 3.0.0-SNAPSHOT) + [2.14.0-SNAPSHOT, 3.0.0-SNAPSHOT) org.gcube.portlets.widgets diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/server/CommentNotificationsThread.java b/src/main/java/org/gcube/portlets/user/newsfeed/server/CommentNotificationsThread.java deleted file mode 100644 index 6e16361..0000000 --- a/src/main/java/org/gcube/portlets/user/newsfeed/server/CommentNotificationsThread.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.gcube.portlets.user.newsfeed.server; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - -import org.gcube.applicationsupportlayer.social.NotificationsManager; -import org.gcube.portal.databook.server.DatabookStore; -import org.gcube.portal.databook.shared.Comment; -import org.gcube.portal.databook.shared.Like; -import org.gcube.vomanagement.usermanagement.UserManager; -import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author Massimiliano Assante ISTI-CNR - * - */ -public class CommentNotificationsThread implements Runnable { - - private static final Logger _log = LoggerFactory.getLogger(CommentNotificationsThread.class); - - String commenterUserId; - String commentedFeedId; - private String commentText; - private String feedOwnerId; - private NotificationsManager nm; - private HashSet userIdsToNotify; - //needed to avoid sending notification twice (the user who favorited gets the notification anyways) - private ArrayList favorites; - - - public CommentNotificationsThread(DatabookStore storeInstance, String commenterUserId, - String commentedFeedId, String commentText, NotificationsManager nm, String feedOwnerId, ArrayList favorites) { - super(); - this.nm = nm; - this.commenterUserId = commenterUserId; - this.commentedFeedId = commentedFeedId; - this.commentText = commentText; - this.feedOwnerId = feedOwnerId; - this.favorites = favorites; - - userIdsToNotify = new HashSet(); - List feedComments = storeInstance.getAllCommentByFeed(commentedFeedId); - for (Comment comment : feedComments) { - if (comment.getUserid().compareTo(commenterUserId) != 0) { - userIdsToNotify.add(comment.getUserid()); - } - } - - //clean - //this.comments = comments; - } - - @Override - public void run() { - String feedOwnerFullName = ""; - UserManager um = new LiferayUserManager(); - try { - feedOwnerFullName = um.getUserByScreenName(feedOwnerId).getFullname(); - } catch (Exception e) { - feedOwnerFullName = feedOwnerId; - } - //get the list of userid who liked the post - ArrayList favoriteUserIds = new ArrayList<>(); - for (Like favorite : favorites) { - favoriteUserIds.add(favorite.getUserid()); - } - - if (userIdsToNotify != null) { - for (String userId : userIdsToNotify) { - if (userId.compareTo(feedOwnerId) != 0 && !(favoriteUserIds.contains(userId)) ) { //avoid notifying the owner and the user who liked twice - boolean result = nm.notifyCommentReply(userId, commentedFeedId, commentText, feedOwnerFullName, feedOwnerId); - _log.trace("Sending Notification for also commented to: " + feedOwnerFullName + " result?"+ result); - } - } - } - - } -} diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/server/LikeNotificationsThread.java b/src/main/java/org/gcube/portlets/user/newsfeed/server/LikeNotificationsThread.java deleted file mode 100644 index 514bcba..0000000 --- a/src/main/java/org/gcube/portlets/user/newsfeed/server/LikeNotificationsThread.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.gcube.portlets.user.newsfeed.server; - -import java.util.ArrayList; - -import org.gcube.applicationsupportlayer.social.NotificationsManager; -import org.gcube.portal.databook.shared.Like; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author Massimiliano Assante ISTI-CNR - * - */ -public class LikeNotificationsThread implements Runnable { - private static final Logger _log = LoggerFactory.getLogger(LikeNotificationsThread.class); - private String commentText; - - private NotificationsManager nm; - private ArrayList likes; - private String feedOwnerId; - - - public LikeNotificationsThread(String commentText, NotificationsManager nm, ArrayList likes, String feedOwnerId) { - super(); - this.feedOwnerId = feedOwnerId; - this.commentText = commentText; - this.nm = nm; - this.likes = likes; - } - - @Override - public void run() { - for (Like fav : likes) { - if (fav.getUserid().compareTo(feedOwnerId) != 0) { //avoid notifying the owner twice (if the post owner commented he gets the notification regardless) - boolean result = nm.notifyCommentOnFavorite(fav.getUserid(), fav.getFeedid(), commentText); - _log.trace("Sending Notification for favorited post comment added to: " + fav.getFullName() + " result?"+ result); - } - } - - } - - -} diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/server/MentionNotificationsThread.java b/src/main/java/org/gcube/portlets/user/newsfeed/server/MentionNotificationsThread.java deleted file mode 100644 index 62dd42c..0000000 --- a/src/main/java/org/gcube/portlets/user/newsfeed/server/MentionNotificationsThread.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.gcube.portlets.user.newsfeed.server; - -import java.util.ArrayList; - -import org.gcube.applicationsupportlayer.social.NotificationsManager; -import org.gcube.portlets.widgets.pickitem.shared.ItemBean; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author Massimiliano Assante ISTI-CNR - * - */ -public class MentionNotificationsThread implements Runnable { - private static Logger _log = LoggerFactory.getLogger(MentionNotificationsThread.class); - - private String postText; - private String postId; - private NotificationsManager nm; - private ArrayList users; - - - public MentionNotificationsThread(String postId, String postText, NotificationsManager nm, ArrayList users) { - super(); - this.postId = postId; - this.postText = postText; - this.nm = nm; - this.users = users; - } - - @Override - public void run() { - for (ItemBean userToNotify : users) { - boolean result = nm.notifyUserTag(userToNotify.getName(), postId, postText); - _log.trace("Sending Notification for post mention to: " + userToNotify.getName() + " result?"+ result); - } - } -} diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java b/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java index 3ba04c1..0cea4ab 100644 --- a/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java @@ -35,6 +35,10 @@ import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException; import org.gcube.portal.databook.shared.ex.FeedTypeNotFoundException; import org.gcube.portal.databook.shared.ex.LikeIDNotFoundException; import org.gcube.portal.databook.shared.ex.PrivacyLevelTypeNotFoundException; +import org.gcube.portal.notifications.bean.GenericItemBean; +import org.gcube.portal.notifications.thread.CommentNotificationsThread; +import org.gcube.portal.notifications.thread.LikeNotificationsThread; +import org.gcube.portal.notifications.thread.MentionNotificationsThread; import org.gcube.portlets.user.newsfeed.client.NewsService; import org.gcube.portlets.user.newsfeed.shared.EnhancedFeed; import org.gcube.portlets.user.newsfeed.shared.MoreFeedsBean; @@ -645,7 +649,11 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService //send the notification to the mentioned users, if any if (mentionedUsers != null && mentionedUsers.size() > 0) { - Thread thread = new Thread(new MentionNotificationsThread(comment.getFeedid(), commentText, nm, mentionedUsers)); + ArrayList toPass = new ArrayList(); + for (ItemBean u : mentionedUsers) { + toPass.add(new GenericItemBean(u.getId(), u.getName(), u.getAlternativeName(), u.getThumbnailURL())); + } + Thread thread = new Thread(new MentionNotificationsThread(comment.getFeedid(), commentText, nm, toPass)); thread.start(); } } diff --git a/src/main/resources/org/gcube/portlets/user/newsfeed/NewsFeed.gwt.xml b/src/main/resources/org/gcube/portlets/user/newsfeed/NewsFeed.gwt.xml index 505eed6..589f789 100644 --- a/src/main/resources/org/gcube/portlets/user/newsfeed/NewsFeed.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/newsfeed/NewsFeed.gwt.xml @@ -4,7 +4,7 @@ - +