diff --git a/.classpath b/.classpath
index f220dd7..0c51cee 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 f972697..d5dcf60 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.0-SNAPSHOT
+lastWarOutDir=/Users/massi/Documents/workspace/news-feed/target/news-feed-1.6.3-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false
diff --git a/NewsFeedTest-dev.launch b/NewsFeedTest-dev.launch
deleted file mode 100644
index bc43953..0000000
--- a/NewsFeedTest-dev.launch
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/NewsFeedTest-prod.launch b/NewsFeedTest-prod.launch
deleted file mode 100644
index 94c3839..0000000
--- a/NewsFeedTest-prod.launch
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pom.xml b/pom.xml
index 8d6fb43..2173a4a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
org.gcube.portlets.user
news-feed
war
- 1.6.0-SNAPSHOT
+ 1.6.3-SNAPSHOT
gCube News Feed Portlet
@@ -75,7 +75,7 @@
org.gcube.applicationsupportlayer
accesslogger
-
+
org.gcube.applicationsupportlayer
aslsocial
@@ -139,7 +139,6 @@
com.liferay.portal
portal-service
- 6.0.6
provided
diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/event/StopTimerEvent.java b/src/main/java/org/gcube/portlets/user/newsfeed/client/event/StopTimerEvent.java
deleted file mode 100644
index 7caa594..0000000
--- a/src/main/java/org/gcube/portlets/user/newsfeed/client/event/StopTimerEvent.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.gcube.portlets.user.newsfeed.client.event;
-
-import com.google.gwt.event.shared.GwtEvent;
-
-
-
-public class StopTimerEvent extends GwtEvent {
- public static Type TYPE = new Type();
-
- private boolean restart;
- public StopTimerEvent(boolean restart) {
- this.restart = restart;
- }
-
- public boolean isRestart() {
- return restart;
- }
-
- @Override
- public Type getAssociatedType() {
- return TYPE;
- }
-
- @Override
- protected void dispatch(StopTimerEventHandler handler) {
- handler.onStopTimer(this);
- }
-}
diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/event/StopTimerEventHandler.java b/src/main/java/org/gcube/portlets/user/newsfeed/client/event/StopTimerEventHandler.java
deleted file mode 100644
index c76c02b..0000000
--- a/src/main/java/org/gcube/portlets/user/newsfeed/client/event/StopTimerEventHandler.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.gcube.portlets.user.newsfeed.client.event;
-
-import com.google.gwt.event.shared.EventHandler;
-
-public interface StopTimerEventHandler extends EventHandler {
- void onStopTimer(StopTimerEvent event);
-}
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 af8e77e..e4a7837 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
@@ -99,6 +99,7 @@ public class NewsFeedPanel extends Composite {
public static final String MESSAGE_LABEL = "Message";
private String vreLabel;
+ private String currentScope;
private boolean showFeedTimelineSource = false;
private boolean isInfrastructure = false;
@@ -110,7 +111,6 @@ public class NewsFeedPanel extends Composite {
private static final int feedsNoPerCategory = 10;
-
private Image loadingImage;
private UserInfo myUserInfo;
private FilterType currentFilter;
@@ -210,7 +210,6 @@ public class NewsFeedPanel extends Composite {
}
-
/**
*
*/
@@ -232,7 +231,7 @@ public class NewsFeedPanel extends Composite {
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
loadingImage = new Image(loading);
newsPanel.add(loadingImage);
-
+
newsService.getUserSettings(new AsyncCallback() {
@Override
public void onFailure(Throwable caught) {
@@ -243,8 +242,10 @@ public class NewsFeedPanel extends Composite {
myUserInfo = result.getUserInfo();
delayMillis = result.getRefreshingTimeInMillis();
vreLabel = result.getVreLabel();
+ currentScope = result.getCurrentScope();
if (result.getUserInfo().getUsername().equals("test.user")) {
- Window.alert("Your session has expired, please log out and login again");
+ doStopFeedsTimer();
+ Window.alert("Your Session Expired, please logout and login again");
}
else {
if (getFeedToShowId() != null) {
@@ -275,9 +276,16 @@ public class NewsFeedPanel extends Composite {
}
};
feedsTimer.scheduleRepeating(delayMillis);
+
+
+ }
+
+ /**
+ * stop the feeds timer (when session expires)
+ */
+ private void doStopFeedsTimer() {
+ feedsTimer.cancel();
}
-
-
/**
*
*/
@@ -301,6 +309,10 @@ public class NewsFeedPanel extends Composite {
private String getFeedToShowId() {
return Window.Location.getParameter(GET_OID_PARAMETER);
}
+ /**
+ * used from notification referrals (see this Post)
+ * @param feedKey
+ */
private void showSingleFeed(String feedKey) {
newsPanel.clear();
newsService.getSingleFeed(feedKey, new AsyncCallback() {
@@ -328,48 +340,67 @@ public class NewsFeedPanel extends Composite {
/**
* check for updates
*/
- private void checkAllUpdatesFeeds() {
- newsService.getAllUpdateUserFeeds(feedsNoPerCategory, new AsyncCallback>() {
+ private void checkAllUpdatesFeeds() {
+ newsService.getUserSettings(new AsyncCallback() {
@Override
- public void onSuccess(ArrayList feeds) {
- if (feeds != null && allUpdates.size() > 0) {
-
- Date myLastUpdateTime = allUpdates.get(0).getFeed().getTime(); //this is the last update in the View
- GWT.log("Last Mine: "+allUpdates.get(0).getFeed().getDescription());
-
- GWT.log("Last Retr.: "+feeds.get(0).getFeed().getDescription());
-
-
- tempCacheNewUpdates = new ArrayList(); //need to clear it everytime i check (in case someone deleted the updated in the meanwhile)
-
- //check if there are new updates (enter the while) and put them in a temporary cache for displaying on user click
-
- int i = 0;
- while (i < feeds.size() && feeds.get(i).getFeed().getTime().after(myLastUpdateTime)) {
- tempCacheNewUpdates.add(feeds.get(i));
- i++;
- }
-
- /* currNewUpdatesNo keeps the number of updates to be added on user clicks,
- * i keeps the total number as it arrives,
- * if they differ you got to refresh the updates to show the new number
- */
- if (currNewUpdatesNo < i) {
- //add the current "show new updates" alert panel if not present
- if (newsFeedAlert == null) {
- newsFeedAlert = new NewFeedsAvailable(i, eventBus);
- newUpdatesPanel.add(newsFeedAlert);
- }
- else //update it otherwise
- newsFeedAlert.updateNewUpdatesNo(i);
-
- currNewUpdatesNo = i;
- }
- }
+ public void onFailure(Throwable caught) {
+ doStopFeedsTimer();
}
@Override
- public void onFailure(Throwable caught) {}
- });
+ public void onSuccess(UserSettings result) {
+ if (result.getUserInfo().getUsername().equals("test.user")) {
+ doStopFeedsTimer();
+ Window.alert("Your Session Expired, please logout and login again");
+ }
+ /**
+ * this check avoids the 2 tabs open in 2 different scope, if the previous tab was open at VRE Level and then antoher
+ * is open at infra level the first tab stops checking for updates
+ */
+ if (result.getCurrentScope().compareTo(currentScope) == 0) {
+ newsService.getAllUpdateUserFeeds(feedsNoPerCategory, new AsyncCallback>() {
+ @Override
+ public void onSuccess(ArrayList feeds) {
+ if (feeds != null && allUpdates.size() > 0) {
+
+ Date myLastUpdateTime = allUpdates.get(0).getFeed().getTime(); //this is the last update in the View
+ GWT.log("Last Mine: "+allUpdates.get(0).getFeed().getDescription());
+
+ GWT.log("Last Retr.: "+feeds.get(0).getFeed().getDescription());
+
+
+ tempCacheNewUpdates = new ArrayList(); //need to clear it everytime i check (in case someone deleted the updated in the meanwhile)
+
+ //check if there are new updates (enter the while) and put them in a temporary cache for displaying on user click
+
+ int i = 0;
+ while (i < feeds.size() && feeds.get(i).getFeed().getTime().after(myLastUpdateTime)) {
+ tempCacheNewUpdates.add(feeds.get(i));
+ i++;
+ }
+
+ /* currNewUpdatesNo keeps the number of updates to be added on user clicks,
+ * i keeps the total number as it arrives,
+ * if they differ you got to refresh the updates to show the new number
+ */
+ if (currNewUpdatesNo < i) {
+ //add the current "show new updates" alert panel if not present
+ if (newsFeedAlert == null) {
+ newsFeedAlert = new NewFeedsAvailable(i, eventBus);
+ newUpdatesPanel.add(newsFeedAlert);
+ }
+ else //update it otherwise
+ newsFeedAlert.updateNewUpdatesNo(i);
+
+ currNewUpdatesNo = i;
+ }
+ }
+ }
+ @Override
+ public void onFailure(Throwable caught) {}
+ });
+ }
+ }
+ });
}
@@ -433,7 +464,7 @@ public class NewsFeedPanel extends Composite {
t.schedule(500);
//insert it also in the model so that the user who created it do not get notified about this new update
- allUpdates.add(0, toAdd); //insert in the model
+ allUpdates.add(0, toAdd); //insert in the model
}
/**
@@ -471,7 +502,7 @@ public class NewsFeedPanel extends Composite {
newsPanel.add(new Image(spacer));
}
//if you are showing more than feedsNoPerCategory*3-1 feeds there is probably more
- if (feeds.size() >= feedsNoPerCategory*3-1) {
+ if (feeds.size() >= feedsNoPerCategory*3-1 && (!isInfrastructure)) {
GWT.log("Show MORE " + feedsNoPerCategory);
showMoreUpdatesPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
showMoreUpdatesPanel.add(new ShowMoreFeeds(eventBus));
diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/templates/TweetTemplate.java b/src/main/java/org/gcube/portlets/user/newsfeed/client/templates/TweetTemplate.java
index ea1bbd3..6c118fc 100644
--- a/src/main/java/org/gcube/portlets/user/newsfeed/client/templates/TweetTemplate.java
+++ b/src/main/java/org/gcube/portlets/user/newsfeed/client/templates/TweetTemplate.java
@@ -16,7 +16,6 @@ import org.gcube.portlets.user.newsfeed.client.event.DeleteFeedEvent;
import org.gcube.portlets.user.newsfeed.client.event.OpenFeedEvent;
import org.gcube.portlets.user.newsfeed.client.event.SeeCommentsEvent;
import org.gcube.portlets.user.newsfeed.client.event.SeeLikesEvent;
-import org.gcube.portlets.user.newsfeed.client.event.StopTimerEvent;
import org.gcube.portlets.user.newsfeed.client.panels.NewsFeedPanel;
import org.gcube.portlets.user.newsfeed.shared.EnhancedFeed;
import org.gcube.portlets.widgets.wsmail.client.forms.MailForm;
@@ -284,8 +283,6 @@ public class TweetTemplate extends Composite {
void onLikeClick(ClickEvent e) {
if (!likeArea.getText().equals(NewsFeedPanel.LIKED_LABEL)) {
try {
- eventBus.fireEvent(new StopTimerEvent(true)); //reset the refresh page timer
-
int cur = Integer.parseInt(myFeed.getFeed().getLikesNo());
cur++;
if (cur == 1) {
@@ -312,8 +309,7 @@ public class TweetTemplate extends Composite {
if (! commentsFetched && totalComments > 2) { //if so, need to load all comments before adding a comment
fireSeeComments(true);
}
- showAddCommentForm();
- eventBus.fireEvent(new StopTimerEvent(false)); //stop the refresh page timer
+ showAddCommentForm();
}
else
GWT.log("Commenting disabled");
@@ -322,7 +318,6 @@ public class TweetTemplate extends Composite {
@UiHandler("messageArea")
void onMessageClick(ClickEvent e) {
if (! isAppFeed) {
- eventBus.fireEvent(new StopTimerEvent(false)); //stop the refresh page timer
final List listToLogin = new ArrayList();
listToLogin.add(myFeed.getFeed().getEntityId());
GWT.runAsync(new RunAsyncCallback() {
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 ea0e99e..9a4f689 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
@@ -100,7 +100,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
if (user == null) {
_log.warn("USER IS NULL setting testing user and Running OUTSIDE PORTAL");
user = getDevelopmentUser();
- //SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/TestVREFolder2");
+ SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE");
}
else {
withinPortal = true;
@@ -131,9 +131,13 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
thumbnailURL = "/image/user_male_portrait?img_id="+user.getPortraitId();
fullName = user.getFirstName() + " " + user.getLastName();
email = user.getEmailAddress();
- ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
- String accountURL = themeDisplay.getURLMyAccount().toString();
-
+ String accountURL = "";
+ try {
+ ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
+ accountURL = themeDisplay.getURLMyAccount().toString();
+ }catch (NullPointerException e) {
+ e.printStackTrace();
+ }
UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, isAdmin(), null);
CustomConfiguration config = getUserConfiguration();
UserSettings toReturn = new UserSettings(userInfo, config.getRefreshTime(), session.getScopeName(), config.getVreLabel(), isInfrastructureScope(), config.isShowTimelineSource());
@@ -169,7 +173,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
return false;
}
}
-
+
@@ -180,7 +184,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
HashMap feedsMap = new HashMap();
try {
if (!withinPortal) {
- return getEclipseResult(userName, false);
+ return getEclipseResult(userName, feedsNoPerCategory, false);
}
else {
//in case the portal is restarted and you have the social home open it will get test.user (no callback to set session info)
@@ -266,7 +270,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
String userName = getASLSession().getUsername();
try {
if (! withinPortal) {
- return getEclipseResult(userName, true);
+ return getEclipseResult(userName, 10, true);
}
else {
//UserFriends Feeds
@@ -369,11 +373,11 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
* @throws ColumnNameNotFoundException
* @throws FeedIDNotFoundException
*/
- private ArrayList getEclipseResult(String userName, boolean onlyConnections) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
+ private ArrayList getEclipseResult(String userName, int feedsNoPerCategory, boolean onlyConnections) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
ArrayList toMerge = new ArrayList();
HashMap feedsMap = new HashMap();
- ArrayList OrganizationFeeds = (ArrayList) store.getRecentFeedsByVRE(getASLSession().getScope(), 5);
+ ArrayList OrganizationFeeds = (ArrayList) store.getRecentFeedsByVRE(getASLSession().getScope(), feedsNoPerCategory*3);
for (Feed feed : OrganizationFeeds) {
feedsMap.put(feed.getKey(), feed);
_log.trace("Reading desc: " + feed.getDescription());
@@ -719,6 +723,9 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
* @throws PortalException
*/
private boolean isAdmin() throws PortalException, SystemException {
+ if (! withinPortal)
+ return false;
+
try {
User currUser = OrganizationsUtil.validateUser(getASLSession().getUsername());
List organizations = OrganizationLocalServiceUtil.getOrganizations(0, OrganizationLocalServiceUtil.getOrganizationsCount());
@@ -829,9 +836,9 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
minutes = 300000; //5 minutes
_log.error("settings.properties file not found under " + propertyfile +", returning 5 minutes");
}
-
+ toReturn = new CustomConfiguration(minutes, label, showTimelineSource);
_log.debug("Read Configuration from property file: " + toReturn);
- return new CustomConfiguration(minutes, label, showTimelineSource);
+ return toReturn;
}
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 cdf7246..d002cd4 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
@@ -17,7 +17,6 @@
-
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index 9e193e4..21cc887 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -32,7 +32,7 @@
workspaceServiceImpl
/newsfeed/WorkspaceLightService
-
+
diff --git a/src/test/java/org/gcube/portlets/user/newsfeed/test/TestForDeploy.java b/src/test/java/org/gcube/portlets/user/newsfeed/test/TestForDeploy.java
index f68ecd2..6ff0ff2 100644
--- a/src/test/java/org/gcube/portlets/user/newsfeed/test/TestForDeploy.java
+++ b/src/test/java/org/gcube/portlets/user/newsfeed/test/TestForDeploy.java
@@ -1,6 +1,6 @@
package org.gcube.portlets.user.newsfeed.test;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
import org.gcube.portlets.user.newsfeed.server.NewsServiceImpl;
import org.junit.Test;
@@ -15,5 +15,5 @@ public class TestForDeploy {
assertTrue(username.compareTo("test.user") == 0);
System.out.println("Test OK!");
}
-
+
}