remove session checker

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@94022 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-04-01 17:09:26 +00:00
parent eb48d7dcf7
commit 2683e7284f
13 changed files with 105 additions and 153 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/news-feed-1.6.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/news-feed-1.6.3-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
@ -31,5 +31,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/news-feed-1.6.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/news-feed-1.6.3-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -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

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.google.gwt.eclipse.core.launch.gwtJUnit">
<stringAttribute key="com.google.gwt.eclipse.core.LOG_LEVEL" value="INFO"/>
<booleanAttribute key="com.google.gwt.eclipse.core.NOT_HEADLESS" value="false"/>
<stringAttribute key="com.google.gwt.eclipse.core.OUT_DIR" value="www-test"/>
<booleanAttribute key="com.google.gwt.eclipse.core.STANDARDS_MODE" value="false"/>
<stringAttribute key="com.google.gwt.eclipse.core.STYLE" value="OBFUSCATED"/>
<stringAttribute key="com.google.gwt.eclipse.core.WEB_MODE" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/news-feed/src/test/java/org/gcube/portlets/user/newsfeed/client/GwtTestNewsFeed.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.gcube.portlets.user.newsfeed.client.GwtTestNewsFeed"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="news-feed"/>
</launchConfiguration>

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.google.gwt.eclipse.core.launch.gwtJUnit">
<stringAttribute key="com.google.gwt.eclipse.core.LOG_LEVEL" value="INFO"/>
<booleanAttribute key="com.google.gwt.eclipse.core.NOT_HEADLESS" value="false"/>
<stringAttribute key="com.google.gwt.eclipse.core.OUT_DIR" value="www-test"/>
<booleanAttribute key="com.google.gwt.eclipse.core.STANDARDS_MODE" value="false"/>
<stringAttribute key="com.google.gwt.eclipse.core.STYLE" value="OBFUSCATED"/>
<stringAttribute key="com.google.gwt.eclipse.core.WEB_MODE" value="true"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/news-feed/src/test/java/org/gcube/portlets/user/newsfeed/client/GwtTestNewsFeed.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.gcube.portlets.user.newsfeed.client.GwtTestNewsFeed"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="news-feed"/>
</launchConfiguration>

View File

@ -13,7 +13,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>news-feed</artifactId>
<packaging>war</packaging>
<version>1.6.0-SNAPSHOT</version>
<version>1.6.3-SNAPSHOT</version>
<name>gCube News Feed Portlet</name>
<description>
@ -75,7 +75,7 @@
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>accesslogger</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslsocial</artifactId>
@ -139,7 +139,6 @@
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<version>6.0.6</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -1,28 +0,0 @@
package org.gcube.portlets.user.newsfeed.client.event;
import com.google.gwt.event.shared.GwtEvent;
public class StopTimerEvent extends GwtEvent<StopTimerEventHandler> {
public static Type<StopTimerEventHandler> TYPE = new Type<StopTimerEventHandler>();
private boolean restart;
public StopTimerEvent(boolean restart) {
this.restart = restart;
}
public boolean isRestart() {
return restart;
}
@Override
public Type<StopTimerEventHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(StopTimerEventHandler handler) {
handler.onStopTimer(this);
}
}

View File

@ -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);
}

View File

@ -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<UserSettings>() {
@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<EnhancedFeed>() {
@ -328,48 +340,67 @@ public class NewsFeedPanel extends Composite {
/**
* check for updates
*/
private void checkAllUpdatesFeeds() {
newsService.getAllUpdateUserFeeds(feedsNoPerCategory, new AsyncCallback<ArrayList<EnhancedFeed>>() {
private void checkAllUpdatesFeeds() {
newsService.getUserSettings(new AsyncCallback<UserSettings>() {
@Override
public void onSuccess(ArrayList<EnhancedFeed> 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<EnhancedFeed>(); //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<ArrayList<EnhancedFeed>>() {
@Override
public void onSuccess(ArrayList<EnhancedFeed> 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<EnhancedFeed>(); //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));

View File

@ -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<String> listToLogin = new ArrayList<String>();
listToLogin.add(myFeed.getFeed().getEntityId());
GWT.runAsync(new RunAsyncCallback() {

View File

@ -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<String, Feed> feedsMap = new HashMap<String, Feed>();
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<EnhancedFeed> getEclipseResult(String userName, boolean onlyConnections) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
private ArrayList<EnhancedFeed> getEclipseResult(String userName, int feedsNoPerCategory, boolean onlyConnections) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
ArrayList<Feed> toMerge = new ArrayList<Feed>();
HashMap<String, Feed> feedsMap = new HashMap<String, Feed>();
ArrayList<Feed> OrganizationFeeds = (ArrayList<Feed>) store.getRecentFeedsByVRE(getASLSession().getScope(), 5);
ArrayList<Feed> OrganizationFeeds = (ArrayList<Feed>) 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<Organization> 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;
}

View File

@ -17,7 +17,6 @@
<inherits name='org.gcube.portlets.widgets.userselection.UserSelection' />
<inherits
name='org.gcube.portlets.widgets.lighttree.WorkspacePortletLightTree' />
<inherits name='org.gcube.portal.databook.GCubeSocialNetworking' />
<!-- Specify the app entry point class. -->

View File

@ -32,7 +32,7 @@
<servlet-mapping>
<servlet-name>workspaceServiceImpl</servlet-name>
<url-pattern>/newsfeed/WorkspaceLightService</url-pattern>
</servlet-mapping>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>

View File

@ -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!");
}
}