removed ASL Session, ported to gCube Client Context
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/my-vres@134136 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6a1fe04ec7
commit
660ddada36
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" output="target/my-vres-2.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
<classpathentry kind="src" output="target/my-vres-2.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry excluding="**" kind="src" output="target/my-vres-2.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
<classpathentry excluding="**" kind="src" output="target/my-vres-2.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
@ -38,5 +38,5 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/my-vres-2.1.0-SNAPSHOT/WEB-INF/classes"/>
|
<classpathentry kind="output" path="target/my-vres-2.2.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<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="/target/generated-sources/gwt"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||||
<dependent-module archiveName="gcube-widgets-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
|
<dependent-module archiveName="gcube-widgets-2.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
|
||||||
<dependency-type>uses</dependency-type>
|
<dependency-type>uses</dependency-type>
|
||||||
</dependent-module>
|
</dependent-module>
|
||||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||||
|
|
18
pom.xml
18
pom.xml
|
@ -13,7 +13,7 @@
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>my-vres</artifactId>
|
<artifactId>my-vres</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>2.1.0-SNAPSHOT</version>
|
<version>2.2.0-SNAPSHOT</version>
|
||||||
<name>My VREs Portlet</name>
|
<name>My VREs Portlet</name>
|
||||||
<description>
|
<description>
|
||||||
gCube My VREs Portlet shows only the VO and VREs a user is member of, divided by category.
|
gCube My VREs Portlet shows only the VO and VREs a user is member of, divided by category.
|
||||||
|
@ -57,18 +57,10 @@
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>gcube-widgets</artifactId>
|
<artifactId>gcube-widgets</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.portal</groupId>
|
|
||||||
<artifactId>custom-portal-handler</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common.portal</groupId>
|
<groupId>org.gcube.common.portal</groupId>
|
||||||
<artifactId>portal-manager</artifactId>
|
<artifactId>portal-manager</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
|
||||||
<artifactId>aslcore</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.dvos</groupId>
|
<groupId>org.gcube.dvos</groupId>
|
||||||
<artifactId>usermanagement-core</artifactId>
|
<artifactId>usermanagement-core</artifactId>
|
||||||
|
@ -78,6 +70,14 @@
|
||||||
<artifactId>portal-service</artifactId>
|
<artifactId>portal-service</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.portlet</groupId>
|
<groupId>javax.portlet</groupId>
|
||||||
<artifactId>portlet-api</artifactId>
|
<artifactId>portlet-api</artifactId>
|
||||||
|
|
|
@ -6,13 +6,9 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
|
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
|
||||||
import org.gcube.application.framework.core.session.SessionManager;
|
|
||||||
import org.gcube.common.portal.GCubePortalConstants;
|
import org.gcube.common.portal.GCubePortalConstants;
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
|
||||||
import org.gcube.portlet.user.my_vres.client.MyVREsService;
|
import org.gcube.portlet.user.my_vres.client.MyVREsService;
|
||||||
import org.gcube.portlet.user.my_vres.shared.UserBelonging;
|
import org.gcube.portlet.user.my_vres.shared.UserBelonging;
|
||||||
import org.gcube.portlet.user.my_vres.shared.VRE;
|
import org.gcube.portlet.user.my_vres.shared.VRE;
|
||||||
|
@ -44,24 +40,10 @@ public class MyVREsServiceImpl extends RemoteServiceServlet implements MyVREsSer
|
||||||
|
|
||||||
public static final String ADD_MORE_CATEGORY = "Add More";
|
public static final String ADD_MORE_CATEGORY = "Add More";
|
||||||
public static final String ADD_MORE_IMAGE_PATH= "images/More.png";
|
public static final String ADD_MORE_IMAGE_PATH= "images/More.png";
|
||||||
|
|
||||||
private ASLSession getASLSession() {
|
|
||||||
String sessionID = this.getThreadLocalRequest().getSession().getId();
|
|
||||||
String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
|
|
||||||
if (user == null) {
|
|
||||||
_log.warn("USER IS NULL setting test.user");
|
|
||||||
user = "test.user";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_log.info("LIFERAY PORTAL DETECTED user=" + user);
|
|
||||||
}
|
|
||||||
return SessionManager.getInstance().getASLSession(sessionID, user);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSiteLandingPagePath() {
|
public String getSiteLandingPagePath() {
|
||||||
String user = getASLSession().getUsername();
|
|
||||||
_log.debug("user=" + user + " has no VREs");
|
|
||||||
String toReturn = PortalContext.getConfiguration().getSiteLandingPagePath(getThreadLocalRequest())+GCubePortalConstants.VRES_EXPLORE_FRIENDLY_URL;
|
String toReturn = PortalContext.getConfiguration().getSiteLandingPagePath(getThreadLocalRequest())+GCubePortalConstants.VRES_EXPLORE_FRIENDLY_URL;
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
@ -83,14 +65,14 @@ public class MyVREsServiceImpl extends RemoteServiceServlet implements MyVREsSer
|
||||||
* first method called by the UI
|
* first method called by the UI
|
||||||
*/
|
*/
|
||||||
public LinkedHashMap<String, ArrayList<VRE>> getUserVREs() {
|
public LinkedHashMap<String, ArrayList<VRE>> getUserVREs() {
|
||||||
getASLSession();
|
|
||||||
//_log.trace("getInfrastructureVOs method called");
|
//_log.trace("getInfrastructureVOs method called");
|
||||||
if (!isWithinPortal())
|
if (!isWithinPortal())
|
||||||
return getFakeVREs();
|
return getFakeVREs();
|
||||||
//return new ArrayList<VO>();
|
//return new ArrayList<VO>();
|
||||||
else
|
else
|
||||||
try {
|
try {
|
||||||
String username = getASLSession().getUsername();
|
PortalContext context = PortalContext.getConfiguration();
|
||||||
|
String username = context.getCurrentUser(getThreadLocalRequest()).getUsername();
|
||||||
GroupManager gm = new LiferayGroupManager();
|
GroupManager gm = new LiferayGroupManager();
|
||||||
|
|
||||||
LinkedHashMap<String, ArrayList<VRE>> toReturn = new LinkedHashMap<String, ArrayList<VRE>>();
|
LinkedHashMap<String, ArrayList<VRE>> toReturn = new LinkedHashMap<String, ArrayList<VRE>>();
|
||||||
|
@ -147,7 +129,6 @@ public class MyVREsServiceImpl extends RemoteServiceServlet implements MyVREsSer
|
||||||
Collections.sort(toSort);
|
Collections.sort(toSort);
|
||||||
}
|
}
|
||||||
HttpServletRequest request = getThreadLocalRequest();
|
HttpServletRequest request = getThreadLocalRequest();
|
||||||
PortalContext context = PortalContext.getConfiguration();
|
|
||||||
String gatewayURL = context.getGatewayURL(request);
|
String gatewayURL = context.getGatewayURL(request);
|
||||||
String exploreURL = gatewayURL+context.getSiteLandingPagePath(request)+GCubePortalConstants.VRES_EXPLORE_FRIENDLY_URL;
|
String exploreURL = gatewayURL+context.getSiteLandingPagePath(request)+GCubePortalConstants.VRES_EXPLORE_FRIENDLY_URL;
|
||||||
VRE addMore = new VRE("", "", "", "", exploreURL, UserBelonging.BELONGING);
|
VRE addMore = new VRE("", "", "", "", exploreURL, UserBelonging.BELONGING);
|
||||||
|
|
|
@ -10,18 +10,11 @@ import javax.portlet.ActionResponse;
|
||||||
import javax.portlet.GenericPortlet;
|
import javax.portlet.GenericPortlet;
|
||||||
import javax.portlet.PortletException;
|
import javax.portlet.PortletException;
|
||||||
import javax.portlet.PortletRequestDispatcher;
|
import javax.portlet.PortletRequestDispatcher;
|
||||||
import javax.portlet.PortletSession;
|
|
||||||
import javax.portlet.RenderRequest;
|
import javax.portlet.RenderRequest;
|
||||||
import javax.portlet.RenderResponse;
|
import javax.portlet.RenderResponse;
|
||||||
|
|
||||||
import com.liferay.portal.kernel.exception.PortalException;
|
|
||||||
import com.liferay.portal.kernel.exception.SystemException;
|
|
||||||
import com.liferay.portal.kernel.log.Log;
|
import com.liferay.portal.kernel.log.Log;
|
||||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||||
import com.liferay.portal.kernel.util.WebKeys;
|
|
||||||
import com.liferay.portal.model.User;
|
|
||||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
|
||||||
import com.liferay.portal.theme.ThemeDisplay;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MyVREsPortlet Portlet Class
|
* MyVREsPortlet Portlet Class
|
||||||
|
@ -38,30 +31,6 @@ public class MyVREsPortlet extends GenericPortlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
|
public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
|
||||||
long userid = Long.parseLong(renderRequest.getRemoteUser());
|
|
||||||
|
|
||||||
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
|
|
||||||
renderRequest.getPortletSession().setAttribute(WebKeys.THEME_DISPLAY, themeDisplay, PortletSession.APPLICATION_SCOPE);
|
|
||||||
|
|
||||||
|
|
||||||
User user = null;
|
|
||||||
try {
|
|
||||||
user = UserLocalServiceUtil.getUser(userid);
|
|
||||||
|
|
||||||
} catch (SystemException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (PortalException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//get the username
|
|
||||||
String username = user.getScreenName();
|
|
||||||
|
|
||||||
//Set the username to the portlet session, so that it can be accessed through the servlet
|
|
||||||
renderRequest.getPortletSession().setAttribute("username", username, PortletSession.APPLICATION_SCOPE);
|
|
||||||
renderRequest.getPortletSession().setAttribute("user", username, PortletSession.APPLICATION_SCOPE);
|
|
||||||
|
|
||||||
include(viewJSP, renderRequest, renderResponse);
|
include(viewJSP, renderRequest, renderResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue