removed ASL Session, ported to gCube Client Context
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/top-topics@134135 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7e601bef24
commit
9d12a3d1d8
|
@ -5,6 +5,10 @@
|
||||||
<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="/src/main/resources"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
|
||||||
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
|
||||||
|
<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"/>
|
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||||
<property name="context-root" value="top-topics"/>
|
<property name="context-root" value="top-topics"/>
|
||||||
</wb-module>
|
</wb-module>
|
||||||
|
|
38
pom.xml
38
pom.xml
|
@ -13,7 +13,7 @@
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>top-topics</artifactId>
|
<artifactId>top-topics</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>2.0.2-SNAPSHOT</version>
|
<version>2.1.0-SNAPSHOT</version>
|
||||||
<name>Top Topics Portlet</name>
|
<name>Top Topics Portlet</name>
|
||||||
<description>
|
<description>
|
||||||
Top Topics Portlet shows the top topics in the scope where is deployed.
|
Top Topics Portlet shows the top topics in the scope where is deployed.
|
||||||
|
@ -61,6 +61,11 @@
|
||||||
<version>${gwtVersion}</version>
|
<version>${gwtVersion}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common.portal</groupId>
|
||||||
|
<artifactId>portal-manager</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.gwt</groupId>
|
<groupId>com.google.gwt</groupId>
|
||||||
<artifactId>gwt-dev</artifactId>
|
<artifactId>gwt-dev</artifactId>
|
||||||
|
@ -70,19 +75,8 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>gcube-widgets</artifactId>
|
<artifactId>gcube-widgets</artifactId>
|
||||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.portal</groupId>
|
|
||||||
<artifactId>custom-portal-handler</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
|
||||||
<artifactId>aslcore</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.portal</groupId>
|
<groupId>org.gcube.portal</groupId>
|
||||||
<artifactId>social-networking-library</artifactId>
|
<artifactId>social-networking-library</artifactId>
|
||||||
|
@ -91,7 +85,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.dvos</groupId>
|
<groupId>org.gcube.dvos</groupId>
|
||||||
<artifactId>usermanagement-core</artifactId>
|
<artifactId>usermanagement-core</artifactId>
|
||||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -103,15 +96,14 @@
|
||||||
<artifactId>commons-codec</artifactId>
|
<artifactId>commons-codec</artifactId>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- <dependency> -->
|
<dependency>
|
||||||
<!-- <groupId>org.gcube.core</groupId> -->
|
<groupId>org.gcube.core</groupId>
|
||||||
<!-- <artifactId>common-scope-maps</artifactId> -->
|
<artifactId>common-scope-maps</artifactId>
|
||||||
<!-- <scope>compile</scope> -->
|
<scope>compile</scope>
|
||||||
<!-- </dependency> -->
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.liferay.portal</groupId>
|
<groupId>com.liferay.portal</groupId>
|
||||||
<artifactId>portal-service</artifactId>
|
<artifactId>portal-service</artifactId>
|
||||||
<version>${liferayVersion}</version>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -123,6 +115,14 @@
|
||||||
<groupId>com.github.gwtbootstrap</groupId>
|
<groupId>com.github.gwtbootstrap</groupId>
|
||||||
<artifactId>gwt-bootstrap</artifactId>
|
<artifactId>gwt-bootstrap</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
package org.gcube.portlets.user.topics.client;
|
package org.gcube.portlets.user.topics.client;
|
||||||
|
|
||||||
import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper;
|
|
||||||
import org.gcube.portlets.user.topics.client.panel.TopicsPanel;
|
import org.gcube.portlets.user.topics.client.panel.TopicsPanel;
|
||||||
|
|
||||||
import com.google.gwt.core.client.EntryPoint;
|
import com.google.gwt.core.client.EntryPoint;
|
||||||
import com.google.gwt.user.client.Window.Location;
|
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
||||||
import com.google.gwt.user.client.ui.RootPanel;
|
import com.google.gwt.user.client.ui.RootPanel;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -15,15 +12,7 @@ import com.google.gwt.user.client.ui.RootPanel;
|
||||||
public class TopTopics implements EntryPoint {
|
public class TopTopics implements EntryPoint {
|
||||||
|
|
||||||
public void onModuleLoad() {
|
public void onModuleLoad() {
|
||||||
ClientScopeHelper.getService().setScope(Location.getHref(), new AsyncCallback<Boolean>() {
|
RootPanel.get("Trending-Topics-Container").add(new TopicsPanel());
|
||||||
@Override
|
|
||||||
public void onSuccess(Boolean result) {
|
|
||||||
RootPanel.get("Trending-Topics-Container").add(new TopicsPanel());
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,7 @@ import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.application.framework.core.session.SessionManager;
|
|
||||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
|
||||||
import org.gcube.portal.databook.client.GCubeSocialNetworking;
|
import org.gcube.portal.databook.client.GCubeSocialNetworking;
|
||||||
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
||||||
import org.gcube.portal.databook.server.DatabookStore;
|
import org.gcube.portal.databook.server.DatabookStore;
|
||||||
|
@ -41,8 +39,6 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
public class TopicServiceImpl extends RemoteServiceServlet implements TopicService {
|
public class TopicServiceImpl extends RemoteServiceServlet implements TopicService {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(TopicServiceImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(TopicServiceImpl.class);
|
||||||
|
|
||||||
public static final String TEST_USER = "test.user";
|
|
||||||
private static final String TEST_SCOPE = "/gcube/devsec/devVRE";
|
|
||||||
private static final int WINDOW_SIZE_IN_MONTHS = 6; // it must not exceed 12
|
private static final int WINDOW_SIZE_IN_MONTHS = 6; // it must not exceed 12
|
||||||
private static final double FRESHNESS_FACTOR = 0.4;
|
private static final double FRESHNESS_FACTOR = 0.4;
|
||||||
private static final double NORMALIZED_SCORE_FACTOR = 0.6;
|
private static final double NORMALIZED_SCORE_FACTOR = 0.6;
|
||||||
|
@ -66,30 +62,7 @@ public class TopicServiceImpl extends RemoteServiceServlet implements TopicServi
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
store.closeConnection();
|
store.closeConnection();
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 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) {
|
|
||||||
logger.warn("USER IS NULL setting test.user and Running OUTSIDE PORTAL");
|
|
||||||
user = getDevelopmentUser();
|
|
||||||
SessionManager.getInstance().getASLSession(sessionID, user).setScope(TEST_SCOPE);
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return trending hashtags
|
* return trending hashtags
|
||||||
|
@ -97,15 +70,8 @@ public class TopicServiceImpl extends RemoteServiceServlet implements TopicServi
|
||||||
@Override
|
@Override
|
||||||
public HashtagsWrapper getHashtags() {
|
public HashtagsWrapper getHashtags() {
|
||||||
|
|
||||||
ASLSession session = getASLSession();
|
String userName = PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest()).getUsername();
|
||||||
String userName = session.getUsername();
|
String currentScope = PortalContext.getConfiguration().getCurrentScope(getThreadLocalRequest());
|
||||||
|
|
||||||
if (userName.compareTo(TEST_USER) == 0) {
|
|
||||||
logger.debug("Found " + userName + " returning nothing");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String currentScope = session.getScope();
|
|
||||||
boolean isInfrastructure = isInfrastructureScope(currentScope);
|
boolean isInfrastructure = isInfrastructureScope(currentScope);
|
||||||
|
|
||||||
// get the reference time
|
// get the reference time
|
||||||
|
|
|
@ -10,12 +10,9 @@ import javax.portlet.PortletRequestDispatcher;
|
||||||
import javax.portlet.RenderRequest;
|
import javax.portlet.RenderRequest;
|
||||||
import javax.portlet.RenderResponse;
|
import javax.portlet.RenderResponse;
|
||||||
|
|
||||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
|
||||||
|
|
||||||
public class TopicsPortlet extends GenericPortlet {
|
public class TopicsPortlet extends GenericPortlet {
|
||||||
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
|
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
|
||||||
response.setContentType("text/html");
|
response.setContentType("text/html");
|
||||||
ScopeHelper.setContext(request);
|
|
||||||
PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/Topics_view.jsp");
|
PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/Topics_view.jsp");
|
||||||
dispatcher.include(request, response);
|
dispatcher.include(request, response);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
package org.gcube.portlets.user.topics.test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.topics.server.TopicServiceImpl;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class TestForDeploy {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUserIsTestUser() {
|
|
||||||
TopicServiceImpl serviceImpl = new TopicServiceImpl();
|
|
||||||
String username = serviceImpl.getDevelopmentUser();
|
|
||||||
System.out.println("username for deploy is: " + username);
|
|
||||||
assertTrue(username.compareTo(TopicServiceImpl.TEST_USER) == 0);
|
|
||||||
System.out.println("Test OK!");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue