refs 6548: TDM - Migrate TabMan to new PortalContext

Task-Url: https://support.d4science.org/issues/6548

Updated to new PortalContext

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@141902 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-01-30 11:13:14 +00:00
parent 060ff47133
commit db8f542872
5 changed files with 21 additions and 170 deletions

View File

@ -1,21 +1,14 @@
package org.gcube.portlets.user.td.client;
import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper;
import org.gcube.portlets.user.td.client.ribbon.TabularDataRibbon;
import org.gcube.portlets.user.td.client.rpc.TabularDataService;
import org.gcube.portlets.user.td.client.rpc.TabularDataServiceAsync;
import org.gcube.portlets.user.td.mainboxwidget.client.MainBoxPanel;
import org.gcube.portlets.user.td.toolboxwidget.client.ToolBoxPanel;
import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
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.web.bindery.event.shared.EventBus;
import com.sencha.gxt.core.client.util.Margins;
@ -35,14 +28,6 @@ public class TabularDataPortlet implements EntryPoint {
private static final String JSP_TAG_ID = "tdp";
/**
* Create a remote service proxy to talk to the server-side Greeting
* service.
*/
@SuppressWarnings("unused")
private final TabularDataServiceAsync greetingService = GWT
.create(TabularDataService.class);
// Main Panel
private static BorderLayoutContainer mainPanelLayout;
@ -63,32 +48,12 @@ public class TabularDataPortlet implements EntryPoint {
// onModuleLoad2
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
loadScope();
loadMainPanel();
}
});
}
private void loadScope() {
ClientScopeHelper.getService().setScope(Location.getHref(),
new AsyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
if(result){
loadMainPanel();
} else {
UtilsGXT3.info("Attention", "ClientScopeHelper has returned a false value!");
}
}
@Override
public void onFailure(Throwable caught) {
UtilsGXT3.alert("Error", "Error setting scope: "+caught.getLocalizedMessage());
caught.printStackTrace();
}
});
}
private void loadMainPanel() {
TabularDataController controller = new TabularDataController();

View File

@ -1,15 +0,0 @@
package org.gcube.portlets.user.td.client.rpc;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
@RemoteServiceRelativePath("tds")
public interface TabularDataService extends RemoteService {
String greetServer(String name) throws IllegalArgumentException;
}

View File

@ -1,22 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.client.rpc;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface TabularDataServiceAsync {
/**
*
* @see org.gcube.portlets.user.td.client.rpc.TabularDataService#greetServer(java.lang.String)
*/
void greetServer(String name, AsyncCallback<String> callback);
}

View File

@ -1,79 +0,0 @@
package org.gcube.portlets.user.td.server;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;
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.portlets.user.td.client.rpc.TabularDataService;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.tdwx.datasource.td.TDXDataSourceFactory;
import org.gcube.portlets.user.tdwx.server.datasource.DataSourceXFactoryRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
//import org.gcube.portlets.user.td.ciw.server.CSVTDImporter;
//import org.gcube.portlets.user.td.importer.server.TabularDataImporterManager;
/**
* The server side implementation of the RPC service.
*/
@SuppressWarnings("serial")
public class TabularDataServiceImpl extends RemoteServiceServlet implements TabularDataService {
protected static Logger logger = LoggerFactory.getLogger(TabularDataServiceImpl.class);
/**
* {@inheritDoc}
*/
@Override
public void init() throws ServletException {
super.init();
/*System.out.println("initializing the TabularDataImportManager");
TabularDataImporterManager importerManager = new TabularDataImporterManager();
//importerManager.scanAvailableImporters();
importerManager.add(new CSVTDImporter());
importerManager.setupImporters();
*/
//register the demo csv target
//CSVTargetRegistry.getInstance().add(new DemoCSVTarget());
//System.out.println("Registered DemoCSVTarget");
//ScopeProvider.instance.get();
System.out.println("Fix JAXP: jdk.xml.entityExpansionLimit=0");
System.setProperty("jdk.xml.entityExpansionLimit", "0");
System.out.println("initializing TDXDataSourceFactory");
DataSourceXFactoryRegistry.getInstance().add(new TDXDataSourceFactory());
}
protected static ASLSession getAslSession(HttpSession httpSession)
{
String username = (String) httpSession.getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
if (username == null) {
logger.warn("no user found in session, using test one");
username = Constants.DEFAULT_USER;
String scope = Constants.DEFAULT_SCOPE;
httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, username);
ASLSession session = SessionManager.getInstance().getASLSession(httpSession.getId(), username);
session.setScope(scope);
return session;
} else {
return SessionManager.getInstance().getASLSession(httpSession.getId(), username);
}
}
/**
* {@inheritDoc}
*/
public String greetServer(String input) throws IllegalArgumentException {
getAslSession(this.getThreadLocalRequest().getSession());
return "Hello";
}
}

View File

@ -11,18 +11,19 @@ import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.common.portal.PortalContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Federico De Faveri defaveri@isti.cnr.it
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class TabularDataPortlet extends GenericPortlet {
protected Logger logger = LoggerFactory.getLogger(TabularDataPortlet.class);
protected Logger logger = LoggerFactory.getLogger(TabularDataPortlet.class);
/**
* JSP folder name
@ -32,24 +33,25 @@ public class TabularDataPortlet extends GenericPortlet {
/**
*
*/
public static final String VIEW_JSP = JSP_FOLDER + "TabularDataPortlet_view.jsp";
public static final String VIEW_JSP = JSP_FOLDER
+ "TabularDataPortlet_view.jsp";
/**
* @param request .
* @param response .
* @throws IOException .
* @throws PortletException .
*
*/
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
logger.trace("TabularDataPortlet loading from JSP: "+VIEW_JSP);
public void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
logger.trace("Loading from JSP: " + VIEW_JSP);
logger.trace("Setting user in session using PortalContext");
PortalContext.setUserInSession(request);
logger.trace("setting context using ScopeHelper");
ScopeHelper.setContext(request);
logger.trace("passing to the render");
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(VIEW_JSP);
logger.trace("Call: "+VIEW_JSP);
rd.include(request,response);
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(
VIEW_JSP);
logger.trace("Call: " + VIEW_JSP);
rd.include(request, response);
}
}