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/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="context-root" value="top-topics"/>
|
||||
</wb-module>
|
||||
|
|
38
pom.xml
38
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>top-topics</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>2.0.2-SNAPSHOT</version>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<name>Top Topics Portlet</name>
|
||||
<description>
|
||||
Top Topics Portlet shows the top topics in the scope where is deployed.
|
||||
|
@ -61,6 +61,11 @@
|
|||
<version>${gwtVersion}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common.portal</groupId>
|
||||
<artifactId>portal-manager</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-dev</artifactId>
|
||||
|
@ -70,19 +75,8 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>gcube-widgets</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</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>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>social-networking-library</artifactId>
|
||||
|
@ -91,7 +85,6 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.dvos</groupId>
|
||||
<artifactId>usermanagement-core</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -103,15 +96,14 @@
|
|||
<artifactId>commons-codec</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.gcube.core</groupId> -->
|
||||
<!-- <artifactId>common-scope-maps</artifactId> -->
|
||||
<!-- <scope>compile</scope> -->
|
||||
<!-- </dependency> -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-scope-maps</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>portal-service</artifactId>
|
||||
<version>${liferayVersion}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -123,6 +115,14 @@
|
|||
<groupId>com.github.gwtbootstrap</groupId>
|
||||
<artifactId>gwt-bootstrap</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
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 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;
|
||||
/**
|
||||
*
|
||||
|
@ -15,15 +12,7 @@ import com.google.gwt.user.client.ui.RootPanel;
|
|||
public class TopTopics implements EntryPoint {
|
||||
|
||||
public void onModuleLoad() {
|
||||
ClientScopeHelper.getService().setScope(Location.getHref(), new AsyncCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean result) {
|
||||
RootPanel.get("Trending-Topics-Container").add(new TopicsPanel());
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
}
|
||||
});
|
||||
RootPanel.get("Trending-Topics-Container").add(new TopicsPanel());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,9 +11,7 @@ import java.util.Map.Entry;
|
|||
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.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.portal.databook.client.GCubeSocialNetworking;
|
||||
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
||||
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 {
|
||||
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 double FRESHNESS_FACTOR = 0.4;
|
||||
private static final double NORMALIZED_SCORE_FACTOR = 0.6;
|
||||
|
@ -66,30 +62,7 @@ public class TopicServiceImpl extends RemoteServiceServlet implements TopicServi
|
|||
public void destroy() {
|
||||
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
|
||||
|
@ -97,15 +70,8 @@ public class TopicServiceImpl extends RemoteServiceServlet implements TopicServi
|
|||
@Override
|
||||
public HashtagsWrapper getHashtags() {
|
||||
|
||||
ASLSession session = getASLSession();
|
||||
String userName = session.getUsername();
|
||||
|
||||
if (userName.compareTo(TEST_USER) == 0) {
|
||||
logger.debug("Found " + userName + " returning nothing");
|
||||
return null;
|
||||
}
|
||||
|
||||
String currentScope = session.getScope();
|
||||
String userName = PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest()).getUsername();
|
||||
String currentScope = PortalContext.getConfiguration().getCurrentScope(getThreadLocalRequest());
|
||||
boolean isInfrastructure = isInfrastructureScope(currentScope);
|
||||
|
||||
// get the reference time
|
||||
|
|
|
@ -10,12 +10,9 @@ import javax.portlet.PortletRequestDispatcher;
|
|||
import javax.portlet.RenderRequest;
|
||||
import javax.portlet.RenderResponse;
|
||||
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
|
||||
public class TopicsPortlet 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/Topics_view.jsp");
|
||||
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