Updated functionalities bar in order to avoid browser refresh

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@129341 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-06-23 10:49:45 +00:00
parent 835def2d71
commit eb23d0318c
17 changed files with 742 additions and 208 deletions

View File

@ -46,6 +46,7 @@
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature> <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature> <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature> <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>com.google.gwt.eclipse.core.gwtNature</nature> <nature>com.google.gwt.eclipse.core.gwtNature</nature>

View File

@ -1,2 +1,2 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
entryPointModules= entryPointModules=org.gcube.portlets.gcubeckan.gcubeckandatacatalog.GCubeCkanDataCatalog

View File

@ -4,7 +4,10 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <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/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"/>
<dependent-module archiveName="workspace-tree-widget-6.13.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/WorkspaceTree/WorkspaceTree"> <dependent-module archiveName="workspace-sharing-widget-1.7.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/workspace-sharing-widget-TRUNK/workspace-sharing-widget-TRUNK">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="workspace-uploader-1.4.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/workspace-uploader-TRUNK/workspace-uploader-TRUNK">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<property name="context-root" value="gcube-ckan-datacatalog"/> <property name="context-root" value="gcube-ckan-datacatalog"/>

View File

@ -1,9 +1,14 @@
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client; package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.EditMetadataEvent; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.EditMetadataEvent;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.EditMetadataEventHandler; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.EditMetadataEventHandler;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.IFrameInstanciedEvent;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.IFrameInstanciedEventHandler;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.InsertMetadataEvent; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.InsertMetadataEvent;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.InsertMetadataEventHandler; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.InsertMetadataEventHandler;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.NotifyLogoutEvent;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.NotifyLogoutEventHandler;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowHomeEvent; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowHomeEvent;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowHomeEventHandler; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowHomeEventHandler;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowStatisticsEvent; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowStatisticsEvent;
@ -13,6 +18,7 @@ import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowUserDa
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowUserOrganizationsEvent; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowUserOrganizationsEvent;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowUserOrganizationsEventHandler; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowUserOrganizationsEventHandler;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.view.GCubeCkanDataCatalogPanel; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.view.GCubeCkanDataCatalogPanel;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.CreateDatasetForm; import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.CreateDatasetForm;
import com.github.gwtbootstrap.client.ui.Modal; import com.github.gwtbootstrap.client.ui.Modal;
@ -20,12 +26,9 @@ import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
/** /**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @author Costantino Perciante costantino.perciante@isti.cnr.it * @author Costantino Perciante costantino.perciante@isti.cnr.it Jun 10, 2016
* Jun 10, 2016
*/ */
public class CkanEventHandlerManager { public class CkanEventHandlerManager {
@ -39,16 +42,15 @@ public class CkanEventHandlerManager {
bind(); bind();
} }
/** /**
* @param panel the panel to set * @param panel
* the panel to set
*/ */
public void setPanel(GCubeCkanDataCatalogPanel panel) { public void setPanel(GCubeCkanDataCatalogPanel panel) {
this.panel = panel; this.panel = panel;
} }
private void bind() { private void bind() {
// bind on show home event // bind on show home event
@ -57,175 +59,218 @@ public class CkanEventHandlerManager {
@Override @Override
public void onShowHome(ShowHomeEvent showHomeEvent) { public void onShowHome(ShowHomeEvent showHomeEvent) {
// redirect CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint( panel.getBaseURLCKANConnector());
String baseUrlCkanConnector = panel.getBaseURLCKANConnector(); ckan.addGubeToken(panel.getGcubeTokenValueToCKANConnector());
panel.instanceCkanFrame(baseUrlCkanConnector); panel.instanceCkanFrame(ckan.buildURI());
} }
}); });
// bind on insert metadata // bind on insert metadata
eventBus.addHandler(InsertMetadataEvent.TYPE, new InsertMetadataEventHandler() { eventBus.addHandler(InsertMetadataEvent.TYPE, new InsertMetadataEventHandler() {
@Override @Override
public void onInsertMetadata(InsertMetadataEvent loadSelecteReleaseEvent) { public void onInsertMetadata(
InsertMetadataEvent loadSelecteReleaseEvent) {
final Modal modal = new Modal(true, true); final Modal modal = new Modal(true, true);
// request who's doing the insert
GCubeCkanDataCatalog.service.getUser(new AsyncCallback<String>() {
// request who's doing the insert @Override
GCubeCkanDataCatalog.service.getUser(new AsyncCallback<String>() { public void onSuccess(String username) {
@Override if (username != null) {
public void onSuccess(String username) { modal.setTitle("Publish Product");
modal.addStyleName("insert-metadata-modal-style");
if(username != null){ modal.add(new CreateDatasetForm(username));
modal.setTitle("Publish Product"); modal.setCloseVisible(true);
modal.addStyleName("insert-metadata-modal-style"); modal.show();
modal.add(new CreateDatasetForm(username)); }
modal.setCloseVisible(true); else
modal.show(); Window.alert("Please, logout and login again then retry.");
} }
else
Window.alert("Please, logout and login again then retry.");
@Override
public void onFailure(Throwable caught) {
Window.alert("Please, logout and login again then retry.");
}
});
}
});
// bind on edit (TODO)
eventBus.addHandler(
EditMetadataEvent.TYPE, new EditMetadataEventHandler() {
@Override
public void onEditMetadata(EditMetadataEvent editMetadataEvent) {
// TODO Auto-generated method stub
}
});
// show datasets event
eventBus.addHandler(
ShowUserDatasetsEvent.TYPE, new ShowUserDatasetsEventHandler() {
@Override
public void onShowDatasets(
ShowUserDatasetsEvent showUserDatasetsEvent) {
// // get the current path
// String currentPath = Window.Location.getHref();
//
// // check if the "path" parameter is already present
// String currentParameter =
// Window.Location.getParameter(GCubeCkanDataCatalog.GET_PATH_PARAMETER);
//
// // the final path must be
// String queryPar = "?" +
// GCubeCkanDataCatalog.GET_PATH_PARAMETER + "=" +
// "/dashboard/datasets";
//
// String finalPath;
//
// if(currentParameter == null){
// finalPath = currentPath + queryPar;
//
// }else{
//
// // remove from the first "path" on
// int index =
// currentPath.lastIndexOf("?"+GCubeCkanDataCatalog.GET_PATH_PARAMETER);
// String firstPartOfThePath = currentPath.substring(0,
// index);
// finalPath = firstPartOfThePath + queryPar;
//
// }
//
// // redirect
// Window.Location.assign(finalPath);
// redirect
// String baseUrlCkanConnector = panel.getBaseURLCKANConnector();
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint( panel.getBaseURLCKANConnector());
ckan.addGubeToken(panel.getGcubeTokenValueToCKANConnector());
ckan.addPathInfo("/dashboard/datasets");
panel.instanceCkanFrame(ckan.buildURI());
}
});
eventBus.addHandler(
ShowUserOrganizationsEvent.TYPE,
new ShowUserOrganizationsEventHandler() {
@Override
public void onShowOrganizations(
ShowUserOrganizationsEvent showUserDatasetsEvent) {
// get the current path
/*String currentPath = Window.Location.getHref();
// check if the "path" parameter is already present
String currentParameter =
Window.Location.getParameter(GCubeCkanDataCatalog.GET_PATH_PARAMETER);
// the final path must be
String queryPar =
"?" + GCubeCkanDataCatalog.GET_PATH_PARAMETER + "=" +
"/dashboard/organizations";
String finalPath;
if (currentParameter == null) {
finalPath = currentPath + queryPar;
} }
else {
// remove from the first "path" on
int index =
currentPath.lastIndexOf("?" +
GCubeCkanDataCatalog.GET_PATH_PARAMETER);
String firstPartOfThePath =
currentPath.substring(0, index);
finalPath = firstPartOfThePath + queryPar;
}
Window.Location.assign(finalPath);
*/
// redirect
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint( panel.getBaseURLCKANConnector());
ckan.addGubeToken(panel.getGcubeTokenValueToCKANConnector());
ckan.addPathInfo("/dashboard/organizations");
panel.instanceCkanFrame(ckan.buildURI());
}
});
// show statistics event
eventBus.addHandler(
ShowStatisticsEvent.TYPE, new ShowStatisticsEventHandler() {
@Override
public void onShowStatistics(
ShowStatisticsEvent showStatisticsEvent) {
// get the current path
/*String currentPath = Window.Location.getHref();
// check if the "path" parameter is already present
String currentParameter =
Window.Location.getParameter(GCubeCkanDataCatalog.GET_PATH_PARAMETER);
// the final path must be
String queryPar =
"?" + GCubeCkanDataCatalog.GET_PATH_PARAMETER + "=" +
"/stats";
String finalPath;
if (currentParameter == null) {
finalPath = currentPath + queryPar;
}
else {
// remove from the first "path" on
int index =
currentPath.lastIndexOf("?" +
GCubeCkanDataCatalog.GET_PATH_PARAMETER);
String firstPartOfThePath =
currentPath.substring(0, index);
finalPath = firstPartOfThePath + queryPar;
}
// redirect
Window.Location.assign(finalPath);*/
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint( panel.getBaseURLCKANConnector());
ckan.addGubeToken(panel.getGcubeTokenValueToCKANConnector());
ckan.addPathInfo("/stats");
panel.instanceCkanFrame(ckan.buildURI());
}
});
eventBus.addHandler(NotifyLogoutEvent.TYPE, new NotifyLogoutEventHandler() {
@Override
public void onLogout(NotifyLogoutEvent editMetadataEvent) {
GCubeCkanDataCatalog.service.logoutFromCkan(new AsyncCallback<Void>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
Window.alert("Please, logout and login again then retry."); // TODO Auto-generated method stub
}
@Override
public void onSuccess(Void result) {
// TODO Auto-generated method stub
} }
}); });
} }
}); });
// bind on edit (TODO) eventBus.addHandler(IFrameInstanciedEvent.TYPE, new IFrameInstanciedEventHandler() {
eventBus.addHandler(EditMetadataEvent.TYPE, new EditMetadataEventHandler() {
@Override @Override
public void onEditMetadata(EditMetadataEvent editMetadataEvent) { public void onNewInstance(IFrameInstanciedEvent iFrameInstanciedEent) {
// TODO Auto-generated method stub
panel.updateSize();
} }
}); });
// show datasets event
eventBus.addHandler(ShowUserDatasetsEvent.TYPE, new ShowUserDatasetsEventHandler() {
@Override
public void onShowDatasets(ShowUserDatasetsEvent showUserDatasetsEvent) {
// // get the current path
// String currentPath = Window.Location.getHref();
//
// // check if the "path" parameter is already present
// String currentParameter = Window.Location.getParameter(GCubeCkanDataCatalog.GET_PATH_PARAMETER);
//
// // the final path must be
// String queryPar = "?" + GCubeCkanDataCatalog.GET_PATH_PARAMETER + "=" + "/dashboard/datasets";
//
// String finalPath;
//
// if(currentParameter == null){
// finalPath = currentPath + queryPar;
//
// }else{
//
// // remove from the first "path" on
// int index = currentPath.lastIndexOf("?"+GCubeCkanDataCatalog.GET_PATH_PARAMETER);
// String firstPartOfThePath = currentPath.substring(0, index);
// finalPath = firstPartOfThePath + queryPar;
//
// }
//
// // redirect
// Window.Location.assign(finalPath);
// redirect
String baseUrlCkanConnector = panel.getBaseURLCKANConnector();
baseUrlCkanConnector += "/dashboard/datasets";
panel.instanceCkanFrame(baseUrlCkanConnector);
}
});
eventBus.addHandler(ShowUserOrganizationsEvent.TYPE, new ShowUserOrganizationsEventHandler() {
@Override
public void onShowOrganizations(
ShowUserOrganizationsEvent showUserDatasetsEvent) {
// get the current path
String currentPath = Window.Location.getHref();
// check if the "path" parameter is already present
String currentParameter = Window.Location.getParameter(GCubeCkanDataCatalog.GET_PATH_PARAMETER);
// the final path must be
String queryPar = "?" + GCubeCkanDataCatalog.GET_PATH_PARAMETER + "=" + "/dashboard/organizations";
String finalPath;
if(currentParameter == null){
finalPath = currentPath + queryPar;
}else{
// remove from the first "path" on
int index = currentPath.lastIndexOf("?"+GCubeCkanDataCatalog.GET_PATH_PARAMETER);
String firstPartOfThePath = currentPath.substring(0, index);
finalPath = firstPartOfThePath + queryPar;
}
// redirect
Window.Location.assign(finalPath);
}
});
// show statistics event
eventBus.addHandler(ShowStatisticsEvent.TYPE, new ShowStatisticsEventHandler() {
@Override
public void onShowStatistics(ShowStatisticsEvent showStatisticsEvent) {
// get the current path
String currentPath = Window.Location.getHref();
// check if the "path" parameter is already present
String currentParameter = Window.Location.getParameter(GCubeCkanDataCatalog.GET_PATH_PARAMETER);
// the final path must be
String queryPar = "?" + GCubeCkanDataCatalog.GET_PATH_PARAMETER + "=" + "/stats";
String finalPath;
if(currentParameter == null){
finalPath = currentPath + queryPar;
}else{
// remove from the first "path" on
int index = currentPath.lastIndexOf("?"+GCubeCkanDataCatalog.GET_PATH_PARAMETER);
String firstPartOfThePath = currentPath.substring(0, index);
finalPath = firstPartOfThePath + queryPar;
}
// redirect
Window.Location.assign(finalPath);
}
});
} }
/** /**
* @return * @return
*/ */
public HandlerManager getEventBus() { public HandlerManager getEventBus() {
return eventBus; return eventBus;
} }
} }

View File

@ -1,10 +1,13 @@
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client; package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.NotifyLogoutEvent;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.view.GCubeCkanDataCatalogPanel; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.view.GCubeCkanDataCatalogPanel;
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.shared.GWT; import com.google.gwt.core.shared.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.Window.ClosingEvent;
import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.RootPanel;
@ -27,6 +30,29 @@ public class GCubeCkanDataCatalog implements EntryPoint {
* This is the entry point method. * This is the entry point method.
*/ */
public void onModuleLoad() { public void onModuleLoad() {
// if (BrowserCloseDetector.get().wasClosed()) {
// GWT.log("Browser was closed.");
// }
// else {
// GWT.log("Refreshing or returning from another page.");
// }
// Window.addCloseHandler(new CloseHandler<Window>() {
//
// public void onClose(CloseEvent<Window> windowCloseEvent) {
//
// Window.alert("I'm closing");
// }
// });
Window.addWindowClosingHandler(new Window.ClosingHandler() {
@Override
public void onWindowClosing(ClosingEvent closingEvent) {
eventManager.getEventBus().fireEvent(new NotifyLogoutEvent());
}
});
GCubeCkanDataCatalogPanel panel = new GCubeCkanDataCatalogPanel(RootPanel.get(DIV_PORTLET_ID), eventManager.getEventBus()); GCubeCkanDataCatalogPanel panel = new GCubeCkanDataCatalogPanel(RootPanel.get(DIV_PORTLET_ID), eventManager.getEventBus());
eventManager.setPanel(panel); eventManager.setPanel(panel);
} }

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client; package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteService;
@ -15,10 +16,12 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
public interface GcubeCkanDataCatalogService extends RemoteService { public interface GcubeCkanDataCatalogService extends RemoteService {
String getCKanConnector( CkanConnectorAccessPoint getCKanConnector(
String pathInfoParameters, String queryStringParameters) throws Exception; String pathInfoParameters, String queryStringParameters) throws Exception;
CkanRole getMyRole() throws Exception; CkanRole getMyRole() throws Exception;
String getUser(); String getUser();
void logoutFromCkan();
} }

View File

@ -3,6 +3,7 @@
*/ */
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client; package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
@ -24,5 +25,12 @@ public interface GcubeCkanDataCatalogServiceAsync {
void getCKanConnector( void getCKanConnector(
String pathInfoParameters, String queryStringParameters, String pathInfoParameters, String queryStringParameters,
AsyncCallback<String> callback); AsyncCallback<CkanConnectorAccessPoint> callback);
/**
*
*/
void logoutFromCkan(AsyncCallback<Void> callback);
} }

View File

@ -0,0 +1,39 @@
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class NotifyLogoutEvent.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 23, 2016
*/
public class IFrameInstanciedEvent extends GwtEvent<IFrameInstanciedEventHandler> {
public static Type<IFrameInstanciedEventHandler> TYPE = new Type<IFrameInstanciedEventHandler>();
/**
* Instantiates a new insert metadata event.
*/
public IFrameInstanciedEvent() {
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
*/
@Override
public Type<IFrameInstanciedEventHandler> getAssociatedType() {
return TYPE;
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
*/
@Override
protected void dispatch(IFrameInstanciedEventHandler handler) {
handler.onNewInstance(this);
}
}

View File

@ -0,0 +1,23 @@
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface IFrameInstanciedEentHandler.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 23, 2016
*/
public interface IFrameInstanciedEventHandler extends EventHandler {
/**
* On new instance.
*
* @param iFrameInstanciedEent the i frame instancied eent
*/
void onNewInstance(IFrameInstanciedEvent iFrameInstanciedEent);
}

View File

@ -0,0 +1,39 @@
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class NotifyLogoutEvent.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 23, 2016
*/
public class NotifyLogoutEvent extends GwtEvent<NotifyLogoutEventHandler> {
public static Type<NotifyLogoutEventHandler> TYPE = new Type<NotifyLogoutEventHandler>();
/**
* Instantiates a new insert metadata event.
*/
public NotifyLogoutEvent() {
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
*/
@Override
public Type<NotifyLogoutEventHandler> getAssociatedType() {
return TYPE;
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
*/
@Override
protected void dispatch(NotifyLogoutEventHandler handler) {
handler.onLogout(this);
}
}

View File

@ -0,0 +1,22 @@
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface NotifyLogoutEventHandler.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 23, 2016
*/
public interface NotifyLogoutEventHandler extends EventHandler {
/**
* On logout.
*
* @param editMetadataEvent the edit metadata event
*/
void onLogout(NotifyLogoutEvent editMetadataEvent);
}

View File

@ -0,0 +1,40 @@
/**
*
*/
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.utility;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 23, 2016
*/
import com.google.gwt.user.client.Cookies;
import com.google.gwt.user.client.Window;
public class BrowserCloseDetector {
private static final String COOKIE = "ckan-browser-detector-closed";
private static BrowserCloseDetector instance;
private BrowserCloseDetector() {
Window.addWindowClosingHandler(new Window.ClosingHandler() {
public void onWindowClosing(Window.ClosingEvent closingEvent) {
Cookies.setCookie(COOKIE, "");
}
});
}
public static BrowserCloseDetector get() {
return instance == null
? instance = new BrowserCloseDetector() : instance;
}
public boolean wasClosed() {
return Cookies.getCookie(COOKIE) == null;
}
}

View File

@ -3,10 +3,13 @@
*/ */
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.view; package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.view;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.IFrameInstanciedEvent;
import com.google.gwt.core.shared.GWT; import com.google.gwt.core.shared.GWT;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.LoadEvent; import com.google.gwt.event.dom.client.LoadEvent;
import com.google.gwt.event.dom.client.LoadHandler; import com.google.gwt.event.dom.client.LoadHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Frame; import com.google.gwt.user.client.ui.Frame;
@ -20,14 +23,24 @@ import com.google.gwt.user.client.ui.Frame;
public class CkanFramePanel extends FlowPanel{ public class CkanFramePanel extends FlowPanel{
private Frame frame; private Frame frame;
private HandlerManager eventBus;
/** /**
* Instantiates a new ckan frame panel. * Instantiates a new ckan frame panel.
*
* @param eventBus the event bus
*/ */
public CkanFramePanel() { public CkanFramePanel(HandlerManager eventBus) {
this.eventBus = eventBus;
} }
/**
* Prints the.
*
* @param msg the msg
*/
private static native void print(String msg)/*-{ private static native void print(String msg)/*-{
console.log(msg); console.log(msg);
}-*/; }-*/;
@ -39,7 +52,7 @@ public class CkanFramePanel extends FlowPanel{
* @return the frame * @return the frame
*/ */
public Frame instanceFrame(String ckanUrlConnector) { public Frame instanceFrame(String ckanUrlConnector) {
GWT.log("Instancing new IFRAME with uri: "+ckanUrlConnector);
try{ try{
if(frame != null) if(frame != null)
remove(frame); remove(frame);
@ -65,13 +78,18 @@ public class CkanFramePanel extends FlowPanel{
} }
}else }else
GWT.log("List Header by tag name is null");*/ GWT.log("List Header by tag name is null");*/
} }
}); });
add(frame); add(frame);
eventBus.fireEvent(new IFrameInstanciedEvent());
return frame; return frame;
} }
/** /**
* @return * Gets the frame.
*
* @return the frame
*/ */
public Frame getFrame() { public Frame getFrame() {
return frame; return frame;

View File

@ -5,6 +5,7 @@ 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.CkanConnectorAccessPoint;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
import com.google.gwt.core.shared.GWT; import com.google.gwt.core.shared.GWT;
@ -30,11 +31,12 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate{
private CkanMetadataManagementPanel managementPanel; private CkanMetadataManagementPanel managementPanel;
private ScrollPanel centerScrollable = new ScrollPanel(); private ScrollPanel centerScrollable = new ScrollPanel();
private CkanFramePanel ckanFramePanel = new CkanFramePanel(); private CkanFramePanel ckanFramePanel;
private Image loading = new Image(CkanPortletResources.ICONS.loading()); private Image loading = new Image(CkanPortletResources.ICONS.loading());
private RootPanel rootPanel; private RootPanel rootPanel;
private HandlerManager eventBus; private HandlerManager eventBus;
private String baseURLCKANConnector; private String baseURLCKANConnector;
private String gCubeTokeValue;
/** /**
* Instantiates a new g cube ckan data catalog panel. * Instantiates a new g cube ckan data catalog panel.
@ -45,20 +47,21 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate{
public GCubeCkanDataCatalogPanel(RootPanel rootPanel, HandlerManager eventManager){ public GCubeCkanDataCatalogPanel(RootPanel rootPanel, HandlerManager eventManager){
this.rootPanel = rootPanel; this.rootPanel = rootPanel;
this.eventBus = eventManager; this.eventBus = eventManager;
ckanFramePanel = new CkanFramePanel(eventBus);
managementPanel = new CkanMetadataManagementPanel(eventBus); managementPanel = new CkanMetadataManagementPanel(eventBus);
initPanel(); initPanel();
String pathParameter = Window.Location.getParameter(GCubeCkanDataCatalog.GET_PATH_PARAMETER); String pathParameter = Window.Location.getParameter(GCubeCkanDataCatalog.GET_PATH_PARAMETER);
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<CkanConnectorAccessPoint>() {
@Override @Override
public void onSuccess(String ckanUrlConnector) { public void onSuccess(CkanConnectorAccessPoint ckan) {
GWT.log("Instancing CKAN iframe with url: "+ckanUrlConnector); // GWT.log("Instancing CKAN iframe with url: "+uriToCkan);
baseURLCKANConnector = ckanUrlConnector; baseURLCKANConnector = ckan.getBaseUrl();
instanceCkanFrame(baseURLCKANConnector); gCubeTokeValue = ckan.getGcubeTokenValue();
instanceCkanFrame(ckan.buildURI());
GCubeCkanDataCatalogPanel.this.rootPanel.remove(loading); GCubeCkanDataCatalogPanel.this.rootPanel.remove(loading);
updateSize();
} }
@Override @Override
@ -141,7 +144,9 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate{
} }
/** /**
* show or hide edit/insert buttons according to the role * show or hide edit/insert buttons according to the role.
*
* @param show the show
*/ */
public void showEditInsertButtons(boolean show){ public void showEditInsertButtons(boolean show){
managementPanel.showInsertAndEditProductButtons(show); managementPanel.showInsertAndEditProductButtons(show);
@ -189,10 +194,22 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate{
} }
/** /**
* Gets the base urlckan connector.
*
* @return the baseURLCKANConnector * @return the baseURLCKANConnector
*/ */
public String getBaseURLCKANConnector() { public String getBaseURLCKANConnector() {
return baseURLCKANConnector; return baseURLCKANConnector;
} }
/**
* Gets the gcube token value to ckan connector.
*
* @return the gcube token value to ckan connector
*/
public String getGcubeTokenValueToCKANConnector() {
return gCubeTokeValue;
}
} }

View File

@ -16,6 +16,7 @@ import org.gcube.datacatalogue.ckanutillibrary.models.CkanRolesIntoLiferay;
import org.gcube.datacatalogue.ckanutillibrary.models.RolesIntoOrganization; import org.gcube.datacatalogue.ckanutillibrary.models.RolesIntoOrganization;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GcubeCkanDataCatalogService; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GcubeCkanDataCatalogService;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.RoleManager; import org.gcube.vomanagement.usermanagement.RoleManager;
@ -37,14 +38,13 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implements GcubeCkanDataCatalogService { public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implements GcubeCkanDataCatalogService {
private static final String LIST_OF_VRES_PARAMETER = "listOfVres";
private static final String PORT_HTTP = ":80"; private static final String PORT_HTTP = ":80";
private static final String PORT_HTTPS = ":443"; private static final String PORT_HTTPS = ":443";
private static final String GCUBE_TOKEN_PARAMETER = "gcube-token";
private static final String HTTPS = "https"; private static final String HTTPS = "https";
private static final String HTTP = "http"; private static final String HTTP = "http";
public static String CKANCONNECTORCONTEXT = "CkanConnectorContext"; public static String CKANCONNECTORCONTEXT = "CkanConnectorContext";
public static String CKANHIDEHEADER = "CkanHideHeader"; // public static String CKANHIDEHEADER = "CkanHideHeader";
public static String CKANCONNECTORLOGOUT = "CkanConnectorLogout";
public static final String USERNAME_ATTRIBUTE = ScopeHelper.USERNAME_ATTRIBUTE; public static final String USERNAME_ATTRIBUTE = ScopeHelper.USERNAME_ATTRIBUTE;
private static Logger logger = LoggerFactory.getLogger(GcubeCkanDataCatalogServiceImpl.class); private static Logger logger = LoggerFactory.getLogger(GcubeCkanDataCatalogServiceImpl.class);
private final static String DEFAULT_ROLE = "OrganizationMember"; private final static String DEFAULT_ROLE = "OrganizationMember";
@ -80,8 +80,8 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
* @see org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GcubeCkanDataCatalogService#getCKanConnector(java.lang.String, java.lang.String) * @see org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GcubeCkanDataCatalogService#getCKanConnector(java.lang.String, java.lang.String)
*/ */
@Override @Override
public String getCKanConnector(String pathInfoParameters, String queryStringParameters) throws Exception { public CkanConnectorAccessPoint getCKanConnector(String pathInfoParameter, String queryStringParameters) throws Exception {
logger.info("getCKanConnector [pathInfo: "+pathInfoParameters + ", query: "+queryStringParameters+"]"); logger.info("getCKanConnector [pathInfo: "+pathInfoParameter + ", query: "+queryStringParameters+"]");
try{ try{
if(queryStringParameters!=null && Base64.isBase64(queryStringParameters.getBytes())){ if(queryStringParameters!=null && Base64.isBase64(queryStringParameters.getBytes())){
@ -102,10 +102,9 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
ckanConnectorUri+=ckanContext; ckanConnectorUri+=ckanContext;
logger.debug("CKanConnector URI + Context: "+ckanConnectorUri); logger.debug("CKanConnector URI + Context: "+ckanConnectorUri);
logger.debug("adding parameters..."); logger.debug("adding parameters...");
String fullPath = getCkanConnectorParameters(pathInfoParameters, queryStringParameters); CkanConnectorAccessPoint ckAP = getCkanConnectorAccessPoint(ckanConnectorUri, pathInfoParameter, queryStringParameters);
ckanConnectorUri = ckanConnectorUri+fullPath; logger.info("returning ckanConnectorUri: "+ckAP);
logger.info("returning ckanConnectorUri: "+ckanConnectorUri); return ckAP;
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";
@ -118,55 +117,82 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
/** /**
* Gets the ckan connector parameters. * Gets the ckan connector parameters.
* *
* @param pathInfoParameters the path info parameters * @param ckanConnectorBaseUrl the ckan connector base url
* @param pathInfoParameter the path info parameters
* @param queryStringParameters the query string parameters * @param queryStringParameters the query string parameters
* @return the ckan connector parameters * @return the ckan connector parameters
*/ */
private String getCkanConnectorParameters(String pathInfoParameters, String queryStringParameters) { private CkanConnectorAccessPoint getCkanConnectorAccessPoint(String ckanConnectorBaseUrl, String pathInfoParameter, String queryStringParameters) {
String ckanHideHeader = getServletContext().getInitParameter(CKANHIDEHEADER); // String ckanHideHeader = getServletContext().getInitParameter(CKANHIDEHEADER);
logger.debug(CKANHIDEHEADER + " is: "+ckanHideHeader); // logger.debug(CKANHIDEHEADER + " is: "+ckanHideHeader);
String pathInfo = ""; CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(ckanConnectorBaseUrl);
if(pathInfoParameters!=null && !pathInfoParameters.isEmpty()){
pathInfo=pathInfoParameters.startsWith("/")?pathInfoParameters:"/"+pathInfoParameters;
}
String queryString =""; //
if(queryStringParameters!=null && !queryStringParameters.isEmpty()){ // String pathInfo = "";
queryString = "?"+queryStringParameters; // if(pathInfoParameter!=null && !pathInfoParameter.isEmpty()){
} // pathInfo=pathInfoParameter.startsWith("/")?pathInfoParameter:"/"+pathInfoParameter;
// }
String gcubeTokenParameter = null; ckan.addPathInfo(pathInfoParameter);
ckan.addQueryString(queryStringParameters);
// String queryString ="";
// if(queryStringParameters!=null && !queryStringParameters.isEmpty()){
// queryString = "?"+queryStringParameters;
// }
// String gcubeTokenParameter = null;
// if(SessionUtil.isIntoPortal()){
// gcubeTokenParameter = GCUBE_TOKEN_PARAMETER+"="+getGcubeSecurityToken();
// }else{
// logger.warn("******** Using TEST_USER security token!!!");
// gcubeTokenParameter = GCUBE_TOKEN_PARAMETER+"="+TEST_SEC_TOKEN;
// }
String gcubeTokenValue = null;
if(SessionUtil.isIntoPortal()){ if(SessionUtil.isIntoPortal()){
gcubeTokenParameter = GCUBE_TOKEN_PARAMETER+"="+getGcubeSecurityToken(); gcubeTokenValue = getGcubeSecurityToken();
}else{ }else{
logger.warn("******** Using TEST_USER security token!!!"); logger.warn("******** Using TEST_USER security token!!!");
gcubeTokenParameter = GCUBE_TOKEN_PARAMETER+"="+TEST_SEC_TOKEN; gcubeTokenValue = TEST_SEC_TOKEN;
} }
//ADDING CKAN HH (HIDE HEADER PARAMETER) ckan.addGubeToken(gcubeTokenValue);
queryString = queryString.isEmpty()?"?"+ckanHideHeader:"&"+ckanHideHeader; // ckan.addGenericParameter(ckanHideHeader, "true");
//ADDING GCUBE TOKEN PARAMETER
queryString+="&"+gcubeTokenParameter; // //ADDING CKAN HH (HIDE HEADER PARAMETER)
// queryString = queryString.isEmpty()?"?"+ckanHideHeader:"&"+ckanHideHeader;
// //ADDING GCUBE TOKEN PARAMETER
// queryString+="&"+gcubeTokenParameter;
//ADDING LIST OF VRE TO WHICH USER BELONGS //ADDING LIST OF VRE TO WHICH USER BELONGS
if(!SessionUtil.isIntoPortal()){
return ckan;
}
ASLSession session = getASLSession(this.getThreadLocalRequest().getSession()); ASLSession session = getASLSession(this.getThreadLocalRequest().getSession());
List<String> listVres = UserUtil.getListVreForUser(session.getUserEmailAddress()); List<String> listVres = UserUtil.getListVreForUser(session.getUserEmailAddress());
String vres = ""; // String vres = "";
if(listVres!=null && listVres.size()>0){ // if(listVres!=null && listVres.size()>0){
for (String vre : listVres) { // for (String vre : listVres) {
vres+=vre+","; // vres+=vre+",";
} // }
vres = vres.substring(0, vres.length()-1).toLowerCase(); //remove last "," and to lower case. A CKAN Organization ID must be lower case // vres = vres.substring(0, vres.length()-1).toLowerCase(); //remove last "," and to lower case. A CKAN Organization ID must be lower case
} // }
logger.debug("List of VREs contains: " +vres); // logger.debug("List of VREs contains: " +vres);
if(vres.length()>0){ // if(vres.length()>0){
queryString+="&"+LIST_OF_VRES_PARAMETER+"="+vres; // queryString+="&"+LIST_OF_VRES_PARAMETER+"="+vres;
} // }
return pathInfo+queryString;
// ckan.addGubeToken(gcubeTokenParameter);
ckan.addListOfVREs(listVres);
return ckan;
} }
/** /**
@ -316,7 +342,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
switch(mainRole){ switch(mainRole){
case CkanRolesIntoLiferay.CATALOG_ADMIN: return CkanRole.ADMIN; case CkanRolesIntoLiferay.CATALOG_ADMIN: return CkanRole.ADMIN;
case CkanRolesIntoLiferay.CATALOG_EDITOR: return CkanRole.EDITOR; case CkanRolesIntoLiferay.CATALOG_EDITOR: return CkanRole.EDITOR;
case CkanRolesIntoLiferay.CATALOG_MEMBER: ; case CkanRolesIntoLiferay.CATALOG_MEMBER: return CkanRole.MEMBER;
default : return CkanRole.MEMBER; default : return CkanRole.MEMBER;
} }
} }
@ -360,4 +386,21 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
return token; return token;
} }
/* (non-Javadoc)
* @see org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GcubeCkanDataCatalogService#logoutFromCkan()
*/
@Override
public void logoutFromCkan() {
HttpSession httpSession = this.getThreadLocalRequest().getSession();
ASLSession session = getASLSession(httpSession);
String username = session.getUsername();
logger.debug("Logout from CKAN for: "+username);
String ckanConnectorLogut = getServletContext().getInitParameter(CKANCONNECTORLOGOUT);
logger.debug(CKANCONNECTORLOGOUT + " is: "+ckanConnectorLogut);
}
} }

View File

@ -0,0 +1,201 @@
/**
*
*/
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared;
import java.io.Serializable;
import java.util.List;
/**
* The Class CkanConnectorAccessPoint.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 23, 2016
*/
public class CkanConnectorAccessPoint implements Serializable{
/**
*
*/
private static final long serialVersionUID = 3771903616375335843L;
private static final String LIST_OF_VRES_PARAMETER = "listOfVres";
private static final String GCUBE_TOKEN_PARAMETER = "gcube-token";
private String baseUrl;
private String pathInfoParameter;
private String queryStringParameters;
private String gcubeTokenValue;
private List<String> listOfVRes;
/**
*
*/
public CkanConnectorAccessPoint() {
}
/**
* Instantiates a new ckan connector access point.
*
* @param baseUrl the base url
*/
public CkanConnectorAccessPoint(String baseUrl){
this.baseUrl = baseUrl;
}
/**
* Adds the generic parameter.
*
* @param key the key
* @param value the value
*/
public void addGenericParameter(String key, String value){
queryStringParameters=queryStringParameters==null?key+"="+value:queryStringParameters+"&"+key+"="+value;
}
/**
* Adds the query string.
*
* @param queryString the query string
*/
public void addQueryString(String queryString){
if(queryString==null || queryString.isEmpty())
return;
if(queryString.startsWith("&")){
queryString = queryString.substring(1, queryString.length()); //removes '&'
}
queryStringParameters=queryStringParameters==null?queryString:queryStringParameters+"&"+queryString;
}
/**
* Adds the gube token.
*
* @param value the value
*/
public void addGubeToken(String value){
this.gcubeTokenValue = value;
addGenericParameter(GCUBE_TOKEN_PARAMETER, value);
}
/**
* Adds the list of vr es.
*
* @param listVREs the list vr es
*/
public void addListOfVREs(List<String> listVREs){
this.listOfVRes = listVREs;
String vres = "";
if(listVREs!=null && listVREs.size()>0){
for (String vre : listVREs) {
vres+=vre+",";
}
vres = vres.substring(0, vres.length()-1).toLowerCase(); //remove last "," and to lower case. A CKAN Organization ID must be lower case
}
if(vres.length()>0){
addGenericParameter(LIST_OF_VRES_PARAMETER, vres);
}
}
/**
* Adds the path info.
*
* @param pathInfo the path info
*/
public void addPathInfo(String pathInfo){
pathInfoParameter = pathInfo;
}
/**
* Builds the uri to contact the CKAN Connector.
*
* @return the string
*/
public String buildURI(){
if(pathInfoParameter!=null && !pathInfoParameter.isEmpty())
pathInfoParameter=pathInfoParameter.startsWith("/")?pathInfoParameter:"/"+pathInfoParameter;
else
pathInfoParameter="";
if(queryStringParameters==null)
queryStringParameters="";
return baseUrl+pathInfoParameter+"?"+queryStringParameters;
}
/**
* @return the baseUrl
*/
public String getBaseUrl() {
return baseUrl;
}
/**
* @return the pathInfoParameter
*/
public String getPathInfoParameter() {
return pathInfoParameter;
}
/**
* @return the queryStringParameters
*/
public String getQueryStringParameters() {
return queryStringParameters;
}
/**
* @return the gcubeTokenValue
*/
public String getGcubeTokenValue() {
return gcubeTokenValue;
}
/**
* @return the listOfVRes
*/
public List<String> getListOfVRes() {
return listOfVRes;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("CkanConnectorAccessPoint [baseUrl=");
builder.append(baseUrl);
builder.append(", pathInfoParameter=");
builder.append(pathInfoParameter);
builder.append(", queryStringParameters=");
builder.append(queryStringParameters);
builder.append(", gcubeTokenValue=");
builder.append(gcubeTokenValue);
builder.append(", listOfVRes=");
builder.append(listOfVRes);
builder.append("]");
return builder.toString();
}
}

View File

@ -10,10 +10,16 @@
<param-value>/gcube/service/connect</param-value> <param-value>/gcube/service/connect</param-value>
</context-param> </context-param>
<!-- <context-param> -->
<!-- <description>Used like GET parameter in order to hide header section of CKAN template from gCube Portal</description> -->
<!-- <param-name>CkanHideHeader</param-name> -->
<!-- <param-value>hh</param-value> -->
<!-- </context-param> -->
<context-param> <context-param>
<description>Used like GET parameter in order to hide header section of CKAN template from gCube Portal</description> <description>ckan connector logout from CKAN</description>
<param-name>CkanHideHeader</param-name> <param-name>CkanConnectorLogout</param-name>
<param-value>hh=true</param-value> <param-value>/gcube/service/connect</param-value>
</context-param> </context-param>
<!-- Servlets --> <!-- Servlets -->