added possibility to set mapParameters in URL for reload pages
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/session-checker@100451 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
517fe83f7a
commit
7684c7b863
|
@ -6,7 +6,6 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="target/generated-sources/gwt"/>
|
||||
<classpathentry including="**/*.java" kind="src" output="src/main/webapp/WEB-INF/classes" path="src/main/resources"/>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||
<property name="context-root" value="session-checker"/>
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -12,7 +12,7 @@
|
|||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>session-checker</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>0.2.4-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
<name>gCube Session Checker Widget</name>
|
||||
<description>
|
||||
gCube Session Checker Widget is a GWT Widget that can be used to automatically check if the session expired.
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.gcube.portlets.widgets.sessionchecker.client;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.gcube.portlets.user.gcubewidgets.client.popup.GCubeDialog;
|
||||
import org.gcube.portlets.widgets.sessionchecker.client.bundle.CheckSessionBundle;
|
||||
import org.gcube.portlets.widgets.sessionchecker.client.elements.Div;
|
||||
|
@ -10,6 +12,7 @@ import com.google.gwt.core.client.GWT;
|
|||
import com.google.gwt.dom.client.Style.Display;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HasAlignment;
|
||||
|
@ -137,8 +140,34 @@ public class CheckSession {
|
|||
else
|
||||
maskDiv.getElement().getStyle().setDisplay(Display.NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* shows the logout dialog
|
||||
*/
|
||||
public static void showLogoutDialog() {
|
||||
showLogoutDialog(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* shows the logout dialog with redirection appended with parametersMap
|
||||
* @param paramsMap a map containing the attrs and related values of what you want after the ?
|
||||
* e.g. aUrl?name=foo&lastname=fie
|
||||
*/
|
||||
public static void showLogoutDialog(HashMap<String, String> paramsMap) {
|
||||
String href = "javascript:location.reload();";
|
||||
|
||||
String params = "?";
|
||||
if (! (paramsMap == null || paramsMap.isEmpty()) ) {
|
||||
for (String attr : paramsMap.keySet()) {
|
||||
params += attr+"="+paramsMap.get(attr)+"&";
|
||||
}
|
||||
|
||||
href = Window.Location.getHref();
|
||||
if (Window.Location.getHref().contains("?"))
|
||||
href = href.substring(0, href.indexOf("?"));
|
||||
|
||||
href += params;
|
||||
}
|
||||
|
||||
GCubeDialog dlg = new GCubeDialog();
|
||||
dlg.setText("Your Session Expired!");
|
||||
|
||||
|
@ -150,7 +179,7 @@ public class CheckSession {
|
|||
HTML toShow = new HTML("<div style=\"margin-top: 40px;\">"
|
||||
+ "<img style=\"margin: 0; vertical-align: middle; \" src='" + images.expired().getSafeUri().asString() + "'>"
|
||||
+ "</div><div style=\"font-size: 18px; height: 20px; padding-top: 20px;\">"
|
||||
+ "Please <a href=\"javascript: location.reload();\">reload<a/> this page.</div>");
|
||||
+ "Please <a href=\""+href+"\">reload<a/> this page.</div>");
|
||||
|
||||
|
||||
topPanel.add(toShow);
|
||||
|
|
|
@ -36,6 +36,20 @@ public class SessionCheckerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
@Override
|
||||
public SessionInfoBean checkSession() {
|
||||
SessionManager manager = null;
|
||||
try {
|
||||
manager = SessionManager.getInstance();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
_log.error("SessionManager#getInstance null returning session expired");
|
||||
return new SessionInfoBean("",""); //tells session expired
|
||||
}
|
||||
if (manager == null) {
|
||||
_log.warn("Liferay Portal Detected but session Expired");
|
||||
return new SessionInfoBean("",""); //tells session expired
|
||||
}
|
||||
|
||||
|
||||
ASLSession session = null;
|
||||
try {
|
||||
session = getASLSession();
|
||||
|
@ -47,6 +61,7 @@ public class SessionCheckerServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
catch (Exception e) {
|
||||
_log.warn("Stopping session polling as you are in dev mode (am I wrong?)");
|
||||
e.printStackTrace();
|
||||
return new SessionInfoBean("","", true); //tells that you are in development mode
|
||||
}
|
||||
String user = session.getUsername();
|
||||
|
|
Loading…
Reference in New Issue