removed ASL Session
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/questions@134750 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
01b42ff1ee
commit
a3635de5bb
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/questions-2.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/questions-2.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/questions-2.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<classpathentry excluding="**" kind="src" output="target/questions-2.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -39,5 +39,5 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/questions-2.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/questions-2.2.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<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="/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>
|
||||
</dependent-module>
|
||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.portlets-user.questions.2-2-0" date="2016-11-23">
|
||||
<Change>Removed ASL Session, increased performance</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.portlets-user.questions.2-1-0" date="2016-10-03">
|
||||
<Change>Removed leave group possibility</Change>
|
||||
<Change>Displays VRE-Managers and Groups in the related VRE</Change>
|
||||
|
|
31
pom.xml
31
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>questions</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>2.2.0-SNAPSHOT</version>
|
||||
<name>gCube Questions Ask Managers Portlet</name>
|
||||
<description>
|
||||
gCube Questions Ask Managers Portlet
|
||||
|
@ -74,11 +74,7 @@
|
|||
<artifactId>gcube-widgets</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>custom-portal-handler</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common.portal</groupId>
|
||||
<artifactId>portal-manager</artifactId>
|
||||
|
@ -93,11 +89,7 @@
|
|||
<artifactId>usermanagement-core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>aslcore</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google</groupId>
|
||||
<artifactId>gwt-jsonmaker</artifactId>
|
||||
|
@ -108,6 +100,23 @@
|
|||
<artifactId>portal-service</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>util-bridges</artifactId>
|
||||
<version>${liferay.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>util-taglib</artifactId>
|
||||
<version>${liferay.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>util-java</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
|
|
@ -6,14 +6,11 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
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.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.portal.databook.client.GCubeSocialNetworking;
|
||||
import org.gcube.portlets.user.questions.client.QuestionsService;
|
||||
import org.gcube.portlets.user.questions.shared.GroupDTO;
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||
|
@ -35,43 +32,15 @@ import com.liferay.portal.service.UserLocalServiceUtil;
|
|||
@SuppressWarnings("serial")
|
||||
public class QuestionsServiceImpl extends RemoteServiceServlet implements QuestionsService {
|
||||
private static final Logger _log = LoggerFactory.getLogger(QuestionsServiceImpl.class);
|
||||
private static final String TEST_USER = "test.user";
|
||||
|
||||
/**
|
||||
* the current ASLSession
|
||||
* @return the session
|
||||
*/
|
||||
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 and Running OUTSIDE PORTAL");
|
||||
user = getDevelopmentUser();
|
||||
}
|
||||
return SessionManager.getInstance().getASLSession(sessionID, user);
|
||||
}
|
||||
/**
|
||||
* when packaging test will fail if the user is not set to test.user
|
||||
* @return .
|
||||
*/
|
||||
public String getDevelopmentUser() {
|
||||
String user = TEST_USER;
|
||||
user = "massimiliano.assante";
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<GroupDTO> getGroups() {
|
||||
ArrayList<GroupDTO> toReturn = new ArrayList<>();
|
||||
ASLSession session = getASLSession();
|
||||
if (session.getUsername().compareTo(TEST_USER) == 0) {
|
||||
_log.error("User is NULL, session expired?");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
if (isWithinPortal()) {
|
||||
try {
|
||||
|
||||
long vreGroupId = session.getGroupId();
|
||||
long vreGroupId = PortalContext.getConfiguration().getCurrentGroupId(getThreadLocalRequest());
|
||||
String vreFriendlyURL = new LiferayGroupManager().getGroup(vreGroupId).getFriendlyURL();
|
||||
StringBuffer pageToRedirectURL= new StringBuffer(GCubePortalConstants.PREFIX_GROUP_URL)
|
||||
.append(vreFriendlyURL)
|
||||
|
@ -84,7 +53,7 @@ public class QuestionsServiceImpl extends RemoteServiceServlet implements Questi
|
|||
managerRedirectURL += new String(Base64.encodeBase64(("-100").getBytes()));
|
||||
|
||||
toReturn.add(new GroupDTO(true, "View Managers", "No Desc", managerRedirectURL));
|
||||
List<GCubeTeam> groups = new LiferayRoleManager().listTeamsByGroup(getCurrentGroupID());
|
||||
List<GCubeTeam> groups = new LiferayRoleManager().listTeamsByGroup(vreGroupId);
|
||||
for (GCubeTeam g : groups) {
|
||||
String encodedTeamId = new String(Base64.encodeBase64((""+g.getTeamId()).getBytes()));
|
||||
String teamRedirectURL = pageToRedirectURL+encodedTeamId;
|
||||
|
@ -124,24 +93,7 @@ public class QuestionsServiceImpl extends RemoteServiceServlet implements Questi
|
|||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the current group ID
|
||||
*
|
||||
* @return the current group ID or null if an exception is thrown
|
||||
* @throws Exception
|
||||
* @throws CurrentGroupRetrievalException
|
||||
*/
|
||||
private long getCurrentGroupID(){
|
||||
GroupManager groupM = new LiferayGroupManager();
|
||||
ASLSession session = getASLSession();
|
||||
_log.debug("The current group NAME is --> " + session.getGroupName());
|
||||
try {
|
||||
return groupM.getGroupId(session.getGroupName());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
|
||||
package org.gcube.portlets.user.questions.server.portlet;
|
||||
|
||||
import javax.portlet.GenericPortlet;
|
||||
import javax.portlet.ActionRequest;
|
||||
import javax.portlet.RenderRequest;
|
||||
import javax.portlet.ActionResponse;
|
||||
import javax.portlet.RenderResponse;
|
||||
import javax.portlet.PortletException;
|
||||
import java.io.IOException;
|
||||
import javax.portlet.PortletRequestDispatcher;
|
||||
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
import javax.portlet.ActionRequest;
|
||||
import javax.portlet.ActionResponse;
|
||||
import javax.portlet.GenericPortlet;
|
||||
import javax.portlet.PortletException;
|
||||
import javax.portlet.PortletRequestDispatcher;
|
||||
import javax.portlet.RenderRequest;
|
||||
import javax.portlet.RenderResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -19,7 +18,6 @@ import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
|||
public class VREManagersPortlet extends GenericPortlet {
|
||||
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
|
||||
response.setContentType("text/html");
|
||||
ScopeHelper.setContext(request);
|
||||
PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/VREManagers_view.jsp");
|
||||
dispatcher.include(request, response);
|
||||
}
|
||||
|
|
|
@ -1,30 +1,33 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<portlet-app
|
||||
version="2.0"
|
||||
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
|
||||
>
|
||||
<portlet>
|
||||
<portlet-name>VRESettings</portlet-name>
|
||||
<display-name>VRE Settings</display-name>
|
||||
<portlet-class>org.gcube.portlets.user.questions.server.portlet.VREManagersPortlet</portlet-class>
|
||||
<init-param>
|
||||
<name>view-jsp</name>
|
||||
<value>/view.jsp</value>
|
||||
</init-param>
|
||||
<expiration-cache>0</expiration-cache>
|
||||
<supports>
|
||||
<mime-type>text/html</mime-type>
|
||||
</supports>
|
||||
<portlet-info>
|
||||
<title>VRE Managers and Groups</title>
|
||||
<short-title>VRE Managers and Groups</short-title>
|
||||
<keywords>VRE Managers and Groups</keywords>
|
||||
</portlet-info>
|
||||
<security-role-ref>
|
||||
<role-name>administrator</role-name>
|
||||
</security-role-ref>
|
||||
</portlet>
|
||||
</portlet-app>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<portlet-app version="2.0"
|
||||
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
|
||||
<portlet>
|
||||
<portlet-name>VRESettings</portlet-name>
|
||||
<display-name>VRE Settings</display-name>
|
||||
<portlet-class>org.gcube.portlets.user.questions.server.portlet.VREManagersPortlet</portlet-class>
|
||||
<init-param>
|
||||
<name>view-jsp</name>
|
||||
<value>/view.jsp</value>
|
||||
</init-param>
|
||||
<expiration-cache>0</expiration-cache>
|
||||
<supports>
|
||||
<mime-type>text/html</mime-type>
|
||||
</supports>
|
||||
<portlet-info>
|
||||
<title>VRE Managers and Groups</title>
|
||||
<short-title>VRE Managers and Groups</short-title>
|
||||
<keywords>VRE, VRE Managers, Groups</keywords>
|
||||
</portlet-info>
|
||||
<portlet-preferences>
|
||||
<preference>
|
||||
<name>portletSetupShowBorders</name>
|
||||
<value>true</value>
|
||||
</preference>
|
||||
</portlet-preferences>
|
||||
<security-role-ref>
|
||||
<role-name>administrator</role-name>
|
||||
</security-role-ref>
|
||||
</portlet>
|
||||
</portlet-app>
|
||||
|
|
|
@ -1,21 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
|
||||
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
version="3.0">
|
||||
|
||||
<!-- Servlets -->
|
||||
<servlet>
|
||||
<servlet-name>groupServlet</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.user.questions.server.QuestionsServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>groupServlet</servlet-name>
|
||||
<url-pattern>/questions/getgroups</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
|
||||
</web-app>
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
|
||||
<servlet>
|
||||
<servlet-name>groupServlet</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.user.questions.server.QuestionsServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>groupServlet</servlet-name>
|
||||
<url-pattern>/questions/getgroups</url-pattern>
|
||||
</servlet-mapping>
|
||||
<filter>
|
||||
<filter-name>LogFilter</filter-name>
|
||||
<filter-class>
|
||||
org.gcube.portlets.user.questions.server.LogFilter
|
||||
</filter-class>
|
||||
<init-param>
|
||||
<param-name>test-param</param-name>
|
||||
<param-value>This parameter is for testing.</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
<filter-mapping>
|
||||
<filter-name>LogFilter</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
</web-app>
|
Loading…
Reference in New Issue