fixed path info redirect

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@129184 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-06-20 14:05:58 +00:00
parent 67faf855c2
commit a1f5e29d65
4 changed files with 30 additions and 62 deletions

View File

@ -14,29 +14,11 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("ckandatacatalogue") @RemoteServiceRelativePath("ckandatacatalogue")
public interface GcubeCkanDataCatalogService extends RemoteService { public interface GcubeCkanDataCatalogService extends RemoteService {
/**
* Gets the c kan connector.
*
* @param pathInfoParameters the path info parameters
* @param queryStringParameters the query string parameters
* @return the c kan connector
* @throws Exception
*/
String getCKanConnector( String getCKanConnector(
String pathInfoParameters, String queryStringParameters) throws Exception; String pathInfoParameters, String queryStringParameters) throws Exception;
/**
* Gets the my role.
*
* @return the my role
* @throws Exception the exception
*/
CkanRole getMyRole() throws Exception; CkanRole getMyRole() throws Exception;
/**
* Asks who is the current user.
*
* @return the user
*/
String getUser(); String getUser();
} }

View File

@ -16,31 +16,13 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
*/ */
public interface GcubeCkanDataCatalogServiceAsync { public interface GcubeCkanDataCatalogServiceAsync {
/**
* Gets the my role.
*
* @param callback the callback
* @return the my role
*/
void getMyRole(AsyncCallback<CkanRole> callback); void getMyRole(AsyncCallback<CkanRole> callback);
/**
* Gets the user.
*
* @param callback the callback
* @return the user
*/
void getUser(AsyncCallback<String> callback); void getUser(AsyncCallback<String> callback);
/**
* Gets the c kan connector.
*
* @param queryStringParameters the query string parameters
* @param pathInfoParameters the path info parameters
* @param callback the callback
* @return the c kan connector
*/
void getCKanConnector( void getCKanConnector(
String queryStringParameters, String pathInfoParameters, String pathInfoParameters, String queryStringParameters,
AsyncCallback<String> callback); AsyncCallback<String> callback);
} }

View File

@ -5,7 +5,6 @@ package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.view;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GCubeCkanDataCatalog; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GCubeCkanDataCatalog;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.resource.CkanPortletResources; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.resource.CkanPortletResources;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
import com.google.gwt.core.shared.GWT; import com.google.gwt.core.shared.GWT;
import com.google.gwt.event.logical.shared.ResizeEvent; import com.google.gwt.event.logical.shared.ResizeEvent;
@ -46,8 +45,8 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate{
this.eventBus = eventManager; this.eventBus = eventManager;
managementPanel = new CkanMetadataManagementPanel(eventBus); managementPanel = new CkanMetadataManagementPanel(eventBus);
initPanel(); initPanel();
final String pathParameter = Window.Location.getParameter(GCubeCkanDataCatalog.GET_PATH_PARAMETER); String pathParameter = Window.Location.getParameter(GCubeCkanDataCatalog.GET_PATH_PARAMETER);
final String queryParameter = Window.Location.getParameter(GCubeCkanDataCatalog.GET_QUERY_PARAMETER); String queryParameter = Window.Location.getParameter(GCubeCkanDataCatalog.GET_QUERY_PARAMETER);
GCubeCkanDataCatalog.service.getCKanConnector(pathParameter, queryParameter, new AsyncCallback<String>() { GCubeCkanDataCatalog.service.getCKanConnector(pathParameter, queryParameter, new AsyncCallback<String>() {
@ -68,7 +67,7 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate{
//MANAGE CKAN MANAGEMENT PANEL ACCORDING TO MY ROLE //MANAGE CKAN MANAGEMENT PANEL ACCORDING TO MY ROLE
GCubeCkanDataCatalog.service.getMyRole(new AsyncCallback<CkanRole>() { /*GCubeCkanDataCatalog.service.getMyRole(new AsyncCallback<CkanRole>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -94,7 +93,7 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate{
break; break;
} }
} }
}); });*/
Window.addResizeHandler(new ResizeHandler() { Window.addResizeHandler(new ResizeHandler() {

View File

@ -81,13 +81,14 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
@Override @Override
public String getCKanConnector(String pathInfoParameters, String queryStringParameters) throws Exception { public String getCKanConnector(String pathInfoParameters, String queryStringParameters) throws Exception {
logger.info("getCKanConnector [pathInfo: "+pathInfoParameters + ", query: "+queryStringParameters+"]"); logger.info("getCKanConnector [pathInfo: "+pathInfoParameters + ", query: "+queryStringParameters+"]");
if(Base64.isBase64(queryStringParameters.getBytes())){
byte[] valueDecoded=Base64.decodeBase64(queryStringParameters.getBytes());
queryStringParameters = new String(valueDecoded);
logger.info("queryStringParameters detected like Base64 and decoded like: "+queryStringParameters);
}
try{ try{
if(queryStringParameters!=null && Base64.isBase64(queryStringParameters.getBytes())){
byte[] valueDecoded=Base64.decodeBase64(queryStringParameters.getBytes());
queryStringParameters = new String(valueDecoded);
logger.info("queryStringParameters detected like Base64 and decoded like: "+queryStringParameters);
}
String ckanContext = getServletContext().getInitParameter(CKANCONNECTORCONTEXT); String ckanContext = getServletContext().getInitParameter(CKANCONNECTORCONTEXT);
logger.debug(CKANCONNECTORCONTEXT + " is: "+ckanContext); logger.debug(CKANCONNECTORCONTEXT + " is: "+ckanContext);
@ -99,19 +100,12 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
ckanConnectorUri = ckanConnectorUri.contains(PORT_HTTP)?ckanConnectorUri.replace(PORT_HTTP, PORT_HTTPS):ckanConnectorUri; ckanConnectorUri = ckanConnectorUri.contains(PORT_HTTP)?ckanConnectorUri.replace(PORT_HTTP, PORT_HTTPS):ckanConnectorUri;
ckanConnectorUri+=ckanContext; ckanConnectorUri+=ckanContext;
logger.debug("CKanConnector URI + Context: "+ckanConnectorUri); logger.debug("CKanConnector URI + Context: "+ckanConnectorUri);
logger.debug("adding gcube token parameter..."); logger.debug("adding parameters...");
if(SessionUtil.isIntoPortal()){
ckanConnectorUri+="?"+GCUBE_TOKEN+"="+getGcubeSecurityToken();
}else{
logger.warn("******** Using TEST_USER security token!!!");
ckanConnectorUri+="?"+GCUBE_TOKEN+"="+TEST_SEC_TOKEN;
}
String fullPath = getCkanConnectorParameters(pathInfoParameters, queryStringParameters); String fullPath = getCkanConnectorParameters(pathInfoParameters, queryStringParameters);
ckanConnectorUri += ckanConnectorUri+fullPath; ckanConnectorUri = ckanConnectorUri+fullPath;
logger.info("returning ckanConnectorUri: "+ckanConnectorUri); logger.info("returning ckanConnectorUri: "+ckanConnectorUri);
return ckanConnectorUri; return ckanConnectorUri;
// return "http://ckan-d-d4s.d4science.org"; // return "http://ckan-d-d4s.d4science.org";
}catch(Exception e ){ }catch(Exception e ){
String message = "Sorry an error occurred during contacting gCube Ckan Data Catalogue"; String message = "Sorry an error occurred during contacting gCube Ckan Data Catalogue";
logger.error(message, e); logger.error(message, e);
@ -120,6 +114,8 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
} }
/** /**
* Gets the ckan connector parameters. * Gets the ckan connector parameters.
* *
@ -134,7 +130,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
String pathInfo = ""; String pathInfo = "";
if(pathInfoParameters!=null && !pathInfoParameters.isEmpty()){ if(pathInfoParameters!=null && !pathInfoParameters.isEmpty()){
pathInfo="/"+pathInfoParameters; pathInfo=pathInfoParameters.startsWith("/")?pathInfoParameters:"/"+pathInfoParameters;
} }
String queryString =""; String queryString ="";
@ -142,7 +138,16 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
queryString = "?"+queryStringParameters; queryString = "?"+queryStringParameters;
} }
String gcubeTokenParameter = null;
if(SessionUtil.isIntoPortal()){
gcubeTokenParameter = GCUBE_TOKEN+"="+getGcubeSecurityToken();
}else{
logger.warn("******** Using TEST_USER security token!!!");
gcubeTokenParameter = GCUBE_TOKEN+"="+TEST_SEC_TOKEN;
}
queryString = queryString.isEmpty()?"?"+ckanHideHeader:"&"+ckanHideHeader; queryString = queryString.isEmpty()?"?"+ckanHideHeader:"&"+ckanHideHeader;
queryString+="&"+gcubeTokenParameter;
return pathInfo+queryString; return pathInfo+queryString;
} }