added ClientScopeHandler to help prevent the back button cache problem in Chrome and Firefox
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/gcube-loggedin@102001 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ecccd2a67c
commit
3d2f743533
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/gcube-loggedin-2.5.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/gcube-loggedin-2.5.1-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/gcube-loggedin-2.5.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/gcube-loggedin-2.5.1-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
eclipse.preferences.version=1
|
||||
jarsExcludedFromWebInfLib=
|
||||
lastWarOutDir=/Users/massi/Documents/workspace/gcube-loggedin/target/gcube-loggedin-2.5.0-SNAPSHOT
|
||||
lastWarOutDir=/Users/massi/Documents/workspace/gcube-loggedin/target/gcube-loggedin-2.5.1-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
<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"/>
|
||||
<dependent-module archiveName="gcube-widgets-1.9.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module archiveName="session-checker-0.3.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/session-checker/session-checker">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>gcube-loggedin</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>2.5.0-SNAPSHOT</version>
|
||||
<version>2.5.1-SNAPSHOT</version>
|
||||
|
||||
<name>gCube Loggedin Portlet</name>
|
||||
<description>
|
||||
|
@ -66,7 +66,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>gcube-widgets</artifactId>
|
||||
<scope>provided</scope>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.gcube.portlets.user.gcubeloggedin.shared.VObject;
|
|||
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.Window.Location;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.rpc.ServiceDefTarget;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
|
@ -35,7 +36,7 @@ public class GCubeLoggedin implements EntryPoint {
|
|||
// Associate the new panel with the HTML host page.
|
||||
RootPanel.get("LoggedinDiv").add(main_panel);
|
||||
|
||||
loggedinService.getSelectedRE(new AsyncCallback<VObject>() {
|
||||
loggedinService.getSelectedRE(Location.getHref(), new AsyncCallback<VObject>() {
|
||||
public void onFailure(Throwable caught) { }
|
||||
|
||||
public void onSuccess(VObject result) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
|||
@RemoteServiceRelativePath("LoggedinServiceImpl")
|
||||
public interface LoggedinService extends RemoteService {
|
||||
|
||||
VObject getSelectedRE();
|
||||
VObject getSelectedRE(String portalURL);
|
||||
|
||||
String getDefaultCommunityURL();
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
|||
public interface LoggedinServiceAsync {
|
||||
|
||||
|
||||
void getSelectedRE(AsyncCallback<VObject> callback);
|
||||
void getSelectedRE(String portalURL, AsyncCallback<VObject> callback);
|
||||
|
||||
|
||||
void getDefaultCommunityURL(AsyncCallback<String> callback);
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService;
|
|||
import org.gcube.portlets.user.gcubeloggedin.shared.VObject;
|
||||
import org.gcube.portlets.user.gcubeloggedin.shared.VObject.UserBelongingClient;
|
||||
import org.gcube.portlets.user.gcubeloggedin.shared.VREClient;
|
||||
import org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl;
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
|
@ -46,6 +47,7 @@ import com.liferay.portal.security.permission.PermissionChecker;
|
|||
import com.liferay.portal.security.permission.PermissionCheckerFactoryUtil;
|
||||
import com.liferay.portal.security.permission.PermissionThreadLocal;
|
||||
import com.liferay.portal.service.GroupLocalServiceUtil;
|
||||
import com.liferay.portal.service.OrganizationLocalServiceUtil;
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
import com.liferay.portal.theme.ThemeDisplay;
|
||||
|
||||
|
@ -70,7 +72,7 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
|||
_log.warn("LOGGEDIN PORTLET: USER IS NULL \n\n SESSION ID READ: " +sessionID );
|
||||
user = "test.user";
|
||||
_log.warn("session ID= *" + sessionID + "* user= *" + user + "*" );
|
||||
|
||||
|
||||
}
|
||||
|
||||
return SessionManager.getInstance().getASLSession(sessionID, user);
|
||||
|
@ -94,19 +96,33 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
|||
* return the current selected VRE
|
||||
*/
|
||||
|
||||
public VObject getSelectedRE() {
|
||||
public VObject getSelectedRE(String portalURL) {
|
||||
ASLSession aslSession = getASLSession();
|
||||
String username = aslSession.getUsername();
|
||||
if (! isWithinPortal()) {
|
||||
String friendlyURL = ScopeServiceImpl.extractOrgFriendlyURL(portalURL);
|
||||
|
||||
if (friendlyURL == null) {//the URL is not a portal URL, we are in devmode.
|
||||
return new VREClient("Test", "", "" +
|
||||
"Fishery and Aquaculture Resources Management (FARM) Virtual Organisation</b> The FARM Virtual Organisation is the <b><i>dynamic group of individuals</i></b> and/or <b><i>institutions</i></b> defined around a set of <b><i>sharing rules</i></b> in which <b><i>resource providers</i></b> and <b><i>consumers</i></b> specify clearly and carefully just what is shared, who is allowed to share, and the conditions under which sharing occurs to serve the needs of the <b><i>Fisheries and Aquaculture Resources Management</i></b>. This VO is conceived to support various application scenarios arising in the FARM Community including the production of Fisheries and Aquaculture Country Profiles, the management of catch statistics including harmonisation, the dynamic generation of biodiversity maps and species distribution maps. This Virtual Organisation currently consists of:<ul> <li> approximately <b><i>13 gCube nodes</i></b>, i.e. machines dedicated to run the gCube system;</li> <li> approximately <b><i>89 running instances</i></b>, i.e. running gCube services supporting the operation of the infrastructure;</li> <li> approximately <b><i>25 collections</i></b>, i.e. set of D4Science Information Objects including Earth images, AquaMaps, Graphs on catch statistics;</li> <li> approximately <b><i>66 metadata collections</i></b>, i.e. set of Metadata Objects describing the Information Objects through various features and schemas;</li> <li> approximately <b><i>58 other resources</i></b> including transformation programs, index types, etc.</li></ul></div>" +
|
||||
"", "", "", UserBelongingClient.BELONGING, false, true);
|
||||
}
|
||||
_log.trace("getting Selected Research Environment");
|
||||
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
|
||||
Organization currOrg = (Organization) session.getAttribute("CURR_RE_NAME");
|
||||
Organization currOrg = null;
|
||||
try {
|
||||
List<Group> groups = GroupLocalServiceUtil.getGroups(0, GroupLocalServiceUtil.getGroupsCount());
|
||||
for (Group g : groups) {
|
||||
if (g.isOrganization() || g.isCommunity())
|
||||
if (g.getFriendlyURL().compareTo(friendlyURL) == 0) {
|
||||
long organizationId = g.getClassPK();
|
||||
currOrg = OrganizationLocalServiceUtil.getOrganization(organizationId);
|
||||
String scopeToSet = ScopeServiceImpl.buildScope(g);
|
||||
getASLSession().setScope(scopeToSet);
|
||||
_log.info("GOT Selected Research Environment: " + scopeToSet);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
/**
|
||||
* set the current ORG bean in session
|
||||
|
@ -120,6 +136,7 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
|||
|
||||
String name = currOrg.getName();
|
||||
long logoId = currOrg.getLogoId();
|
||||
ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
|
||||
String logoURL = themeDisplay.getPathImage()+"/organization_logo?img_id="+ logoId +"&t" + ImageServletTokenUtil.getToken(logoId);
|
||||
String desc = "";
|
||||
//set the description for the vre
|
||||
|
@ -128,7 +145,7 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
|||
VREClient vre = new VREClient(name, "", desc, logoURL, "", UserBelongingClient.BELONGING, isEnabled(username, currOrg, MANDATORY_GROUP), isEnabled(username, currOrg, REQUEST_BASED_GROUP));
|
||||
return vre;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Boolean isEnabled(String username, Organization currOrg, String attrToCheck) {
|
||||
Boolean isEnabled = false;
|
||||
|
@ -137,7 +154,7 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
|||
return true;
|
||||
}
|
||||
try {
|
||||
|
||||
|
||||
long companyId = OrganizationsUtil.getCompany().getCompanyId();
|
||||
_log.trace("Setting Thread Permission");
|
||||
User user = UserLocalServiceUtil.getUserByScreenName(companyId, ScopeHelper.getAdministratorUsername());
|
||||
|
@ -190,18 +207,18 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
|||
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, false);
|
||||
PermissionThreadLocal.setPermissionChecker(permissionChecker);
|
||||
_log.trace("Setting Permission ok!");
|
||||
|
||||
|
||||
_log.debug("Creating and Setting custom attribute for colName " + attribute2Set + " to " +true);
|
||||
//add the custom attrs
|
||||
currUser = UserLocalServiceUtil.getUserByScreenName(companyId, username);
|
||||
|
||||
|
||||
if (! currOrg.getExpandoBridge().hasAttribute(attribute2Set))
|
||||
currOrg.getExpandoBridge().addAttribute(attribute2Set);
|
||||
|
||||
|
||||
currOrg.getExpandoBridge().setAttribute(attribute2Set, "true");
|
||||
_log.trace("setAttribute true");
|
||||
|
||||
|
||||
|
||||
|
||||
_log.trace("Setting Thread Permission back to regular");
|
||||
permissionChecker = PermissionCheckerFactoryUtil.create(currUser, false);
|
||||
PermissionThreadLocal.setPermissionChecker(permissionChecker);
|
||||
|
@ -275,7 +292,7 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
|||
_log.trace("\n getPortalBasicUrl: " +toReturn + "queryString: " + request.getQueryString());
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*@return the redirect url if everything goes ok, null otherwise
|
||||
*/
|
||||
|
@ -296,7 +313,7 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current group ID
|
||||
*
|
||||
|
@ -318,18 +335,18 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void removeUserFromHLGroup(String username, String group) {
|
||||
try {
|
||||
try {
|
||||
org.gcube.common.homelibrary.home.workspace.usermanager.UserManager um = HomeLibrary.getHomeManagerFactory().getUserManager();
|
||||
um.removeUserFromGroup(group, username, getASLSession().getUsername());
|
||||
} catch (InternalErrorException e) {
|
||||
_log.error("Failed to get the usermanager from HL. Could not add remove user from the HL group");
|
||||
} catch (ItemNotFoundException e1) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected static ArrayList<String> getAdministratorsEmails(String scope) {
|
||||
LiferayUserManager userManager = new LiferayUserManager();
|
||||
LiferayGroupManager groupManager = new LiferayGroupManager();
|
||||
|
@ -369,7 +386,7 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
|||
}
|
||||
return adminEmailsList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param scope .
|
||||
|
@ -414,7 +431,7 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
|||
|
||||
mailToAdmin.sendEmail();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String readGatewayName() {
|
||||
//get the portles to look for from the property file
|
||||
|
@ -432,8 +449,8 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
|||
//catch exception in case properties file does not exist
|
||||
catch(IOException e) {
|
||||
_log.warn("$CATALINA_HOME/conf/gcube-data.properties not found, Returning gateway name: " + gatewayLabel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return gatewayLabel;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<!-- Inherit the core Web Toolkit stuff. -->
|
||||
<inherits name='com.google.gwt.user.User' />
|
||||
|
||||
<set-property name="user.agent" value="gecko1_8,safari" />
|
||||
<!-- <set-property name="user.agent" value="gecko1_8,safari" /> -->
|
||||
|
||||
|
||||
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
|
||||
|
|
|
@ -4,21 +4,21 @@
|
|||
"http://java.sun.com/dtd/web-app_2_3.dtd">
|
||||
|
||||
<web-app>
|
||||
|
||||
<!-- Servlets -->
|
||||
<servlet>
|
||||
<servlet-name>LoggedinServiceImpl</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.user.gcubeloggedin.server.LoggedinServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>LoggedinServiceImpl</servlet-name>
|
||||
<url-pattern>/gcubeloggedin/LoggedinServiceImpl</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- Default page to serve -->
|
||||
<welcome-file-list>
|
||||
<welcome-file>GCubeLoggedin.html</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
<!-- Servlets -->
|
||||
<servlet>
|
||||
<servlet-name>LoggedinServiceImpl</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.user.gcubeloggedin.server.LoggedinServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>LoggedinServiceImpl</servlet-name>
|
||||
<url-pattern>/gcubeloggedin/LoggedinServiceImpl</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- Default page to serve -->
|
||||
<welcome-file-list>
|
||||
<welcome-file>GCubeLoggedin.html</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
</web-app>
|
||||
|
|
Loading…
Reference in New Issue