From ff5badd29f60b424d709bb513fa136fbe906d686 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Wed, 2 Apr 2014 13:29:51 +0000 Subject: [PATCH] integrated session expiration popup git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@94085 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 4 ++-- .settings/com.google.gdt.eclipse.core.prefs | 2 +- distro/changelog.xml | 7 ++++++ pom.xml | 9 +++++-- .../newsfeed/client/panels/NewsFeedPanel.java | 17 +++++++++++-- .../server/CommentNotificationsThread.java | 24 +++++++++++++++---- .../server/LikeNotificationsThread.java | 18 ++++++++------ .../user/newsfeed/server/NewsServiceImpl.java | 14 ++++++----- .../portlets/user/newsfeed/NewsFeed.gwt.xml | 5 ++-- src/main/webapp/NewsFeed.css | 18 ++++++++------ 10 files changed, 84 insertions(+), 34 deletions(-) diff --git a/.classpath b/.classpath index 0c51cee..1d55106 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,6 @@ - + @@ -31,5 +31,5 @@ - + diff --git a/.settings/com.google.gdt.eclipse.core.prefs b/.settings/com.google.gdt.eclipse.core.prefs index d5dcf60..4e87f2d 100644 --- a/.settings/com.google.gdt.eclipse.core.prefs +++ b/.settings/com.google.gdt.eclipse.core.prefs @@ -1,5 +1,5 @@ eclipse.preferences.version=1 jarsExcludedFromWebInfLib= -lastWarOutDir=/Users/massi/Documents/workspace/news-feed/target/news-feed-1.6.3-SNAPSHOT +lastWarOutDir=/Users/massi/Documents/workspace/news-feed/target/news-feed-1.6.4-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/distro/changelog.xml b/distro/changelog.xml index aa76a76..c42f0b4 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,4 +1,11 @@ + + Implemented the autmoatic scroll back in time for feeds + Fixed double notifications for post owner who commented his post + Fixed double notifications for post owner who liked his post + Added session checking popup + Moved to Java7 diff --git a/pom.xml b/pom.xml index 2173a4a..771b197 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.gcube.portlets.user news-feed war - 1.6.3-SNAPSHOT + 1.6.4-SNAPSHOT gCube News Feed Portlet @@ -75,7 +75,12 @@ org.gcube.applicationsupportlayer accesslogger - + + + org.gcube.portlets.widgets + session-checker + [0.2.0-SNAPSHOT, 1.0.0-SNAPSHOT) + org.gcube.applicationsupportlayer aslsocial diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/panels/NewsFeedPanel.java b/src/main/java/org/gcube/portlets/user/newsfeed/client/panels/NewsFeedPanel.java index a51d298..d8ea4f8 100644 --- a/src/main/java/org/gcube/portlets/user/newsfeed/client/panels/NewsFeedPanel.java +++ b/src/main/java/org/gcube/portlets/user/newsfeed/client/panels/NewsFeedPanel.java @@ -43,6 +43,7 @@ import org.gcube.portlets.user.newsfeed.client.templates.TweetTemplate; import org.gcube.portlets.user.newsfeed.shared.EnhancedFeed; import org.gcube.portlets.user.newsfeed.shared.MoreFeedsBean; import org.gcube.portlets.user.newsfeed.shared.UserSettings; +import org.gcube.portlets.widgets.sessionchecker.client.CheckSession; import org.gcube.portlets.widgets.userselection.client.UserSelectionDialog; import org.gcube.portlets.widgets.userselection.client.events.SelectedUserEvent; import org.gcube.portlets.widgets.userselection.client.events.SelectedUserEventHandler; @@ -250,7 +251,7 @@ public class NewsFeedPanel extends Composite { currentScope = result.getCurrentScope(); if (result.getUserInfo().getUsername().equals("test.user")) { doStopFeedsTimer(); - Window.alert("Your Session Expired, please logout and login again"); + doShowSessionExpired(); } else { if (getFeedToShowId() != null) { @@ -366,7 +367,7 @@ public class NewsFeedPanel extends Composite { public void onSuccess(UserSettings result) { if (result.getUserInfo().getUsername().equals("test.user")) { doStopFeedsTimer(); - Window.alert("Your Session Expired, please logout and login again"); + doShowSessionExpired(); } /** * this check avoids the 2 tabs open in 2 different scope, if the previous tab was open at VRE Level and then antoher @@ -753,6 +754,18 @@ public class NewsFeedPanel extends Composite { }); } + private void doShowSessionExpired() { + GWT.runAsync(UserSelectionDialog.class, new RunAsyncCallback() { + @Override + public void onSuccess() { + CheckSession.showLogoutDialog(); + } + public void onFailure(Throwable reason) { + Window.alert("Could not load this component: " + reason.getMessage()); + } + }); + } + private void doShowLikes(final String feedId) { GWT.runAsync(UserSelectionDialog.class, new RunAsyncCallback() { @Override 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 index 9b7177d..50b489d 100644 --- a/src/main/java/org/gcube/portlets/user/newsfeed/server/CommentNotificationsThread.java +++ b/src/main/java/org/gcube/portlets/user/newsfeed/server/CommentNotificationsThread.java @@ -1,11 +1,13 @@ 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; @@ -26,15 +28,19 @@ public class CommentNotificationsThread implements Runnable { 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) { + 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); @@ -50,17 +56,25 @@ public class CommentNotificationsThread implements Runnable { @Override public void run() { - String feedOwnerFullName = ""; + 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) { - boolean result = nm.notifyCommentReply(userId, commentedFeedId, commentText, feedOwnerFullName); - _log.trace("Sending Notification for also commented to: " + feedOwnerFullName + " result?"+ result); + 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); + _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 index c4dc3e0..514bcba 100644 --- a/src/main/java/org/gcube/portlets/user/newsfeed/server/LikeNotificationsThread.java +++ b/src/main/java/org/gcube/portlets/user/newsfeed/server/LikeNotificationsThread.java @@ -18,10 +18,12 @@ public class LikeNotificationsThread implements Runnable { private NotificationsManager nm; private ArrayList likes; - - - public LikeNotificationsThread(String commentText, NotificationsManager nm, 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; @@ -30,11 +32,13 @@ public class LikeNotificationsThread implements Runnable { @Override public void run() { for (Like fav : likes) { - boolean result = nm.notifyCommentOnFavorite(fav.getUserid(), fav.getFeedid(), commentText); - _log.trace("Sending Notification for favorited post comment added to: " + fav.getFullName() + " result?"+ result); + 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/NewsServiceImpl.java b/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java index 9a4f689..1ea0cfc 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 @@ -491,13 +491,15 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService boolean result = nm.notifyOwnCommentReply(feedOwnerId, feedid, escapeHtml(commentText)); _log.trace("Comment Notification to post owner added? " + result); } - //notify the other users who commented this post - Thread commentsNotificationthread = new Thread(new CommentNotificationsThread(store, user.getUsername(), comment.getFeedid(), commentText, nm, feedOwnerId)); - commentsNotificationthread.start(); - - //if there are other users who liked this post they get notified too, asynchronously with this thread - Thread likesThread = new Thread(new LikeNotificationsThread(commentText, nm, getAllLikesByFeed(feedid))); + + //if there are users who liked this post they get notified, asynchronously with this thread + ArrayList favorites = getAllLikesByFeed(feedid); + Thread likesThread = new Thread(new LikeNotificationsThread(commentText, nm, favorites, feedOwnerId)); likesThread.start(); + + //notify the other users who commented this post (excluding the ones above) + Thread commentsNotificationthread = new Thread(new CommentNotificationsThread(store, user.getUsername(), comment.getFeedid(), commentText, nm, feedOwnerId, favorites)); + commentsNotificationthread.start(); } return comment; } 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 d002cd4..31b8a77 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,8 +4,8 @@ - - + + @@ -15,6 +15,7 @@ + diff --git a/src/main/webapp/NewsFeed.css b/src/main/webapp/NewsFeed.css index 4cd6bf2..1116be8 100644 --- a/src/main/webapp/NewsFeed.css +++ b/src/main/webapp/NewsFeed.css @@ -9,13 +9,10 @@ table { margin: 0 0 10px; padding: 10px; margin: 0px 5px; - background: #FFF url(images/vre_bg_gray.png) repeat-x left bottom; - border-radius: 6px !important; - -moz-border-radius: 6px !important; - -webkit-border-radius: 6px !important; - + -moz-border-radius: 6px !important; + -webkit-border-radius: 6px !important; border: 1px solid #DBDBDB; } @@ -253,7 +250,7 @@ table { } .openImage:hover { - background: url(images/open-sep.png) 0px -14px no-repeat; + background: url(images/open-sep.png) 0px -14px no-repeat; cursor: pointer; cursor: hand; } @@ -358,7 +355,14 @@ a.person-link:hover { font-size: 14px; line-height: 18px; color: #333; - word-break:break-all; + width: 500px; + word-wrap: break-word; + -ms-word-break: break-all; + /* Non standard for webkit */ + word-break: break-word; + -webkit-hyphens: auto; + -moz-hyphens: auto; + hyphens: auto; } .tweet-separator {