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:
parent
835def2d71
commit
eb23d0318c
1
.project
1
.project
|
@ -46,6 +46,7 @@
|
|||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</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.jsdt.core.jsNature</nature>
|
||||
<nature>com.google.gwt.eclipse.core.gwtNature</nature>
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
entryPointModules=
|
||||
entryPointModules=org.gcube.portlets.gcubeckan.gcubeckandatacatalog.GCubeCkanDataCatalog
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
<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/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>
|
||||
</dependent-module>
|
||||
<property name="context-root" value="gcube-ckan-datacatalog"/>
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
|
||||
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client;
|
||||
|
||||
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.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.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.ShowHomeEventHandler;
|
||||
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.ShowUserOrganizationsEventHandler;
|
||||
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 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.rpc.AsyncCallback;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* @author Costantino Perciante costantino.perciante@isti.cnr.it
|
||||
* Jun 10, 2016
|
||||
* @author Costantino Perciante costantino.perciante@isti.cnr.it Jun 10, 2016
|
||||
*/
|
||||
public class CkanEventHandlerManager {
|
||||
|
||||
|
@ -39,193 +42,235 @@ public class CkanEventHandlerManager {
|
|||
bind();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param panel the panel to set
|
||||
* @param panel
|
||||
* the panel to set
|
||||
*/
|
||||
public void setPanel(GCubeCkanDataCatalogPanel panel) {
|
||||
|
||||
this.panel = panel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void bind() {
|
||||
|
||||
|
||||
// bind on show home event
|
||||
eventBus.addHandler(ShowHomeEvent.TYPE, new ShowHomeEventHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onShowHome(ShowHomeEvent showHomeEvent) {
|
||||
|
||||
// redirect
|
||||
String baseUrlCkanConnector = panel.getBaseURLCKANConnector();
|
||||
panel.instanceCkanFrame(baseUrlCkanConnector);
|
||||
|
||||
|
||||
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint( panel.getBaseURLCKANConnector());
|
||||
ckan.addGubeToken(panel.getGcubeTokenValueToCKANConnector());
|
||||
panel.instanceCkanFrame(ckan.buildURI());
|
||||
}
|
||||
});
|
||||
|
||||
// bind on insert metadata
|
||||
eventBus.addHandler(InsertMetadataEvent.TYPE, new InsertMetadataEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onInsertMetadata(InsertMetadataEvent loadSelecteReleaseEvent) {
|
||||
@Override
|
||||
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
|
||||
GCubeCkanDataCatalog.service.getUser(new AsyncCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String username) {
|
||||
|
||||
@Override
|
||||
public void onSuccess(String username) {
|
||||
|
||||
if(username != null){
|
||||
modal.setTitle("Publish Product");
|
||||
modal.addStyleName("insert-metadata-modal-style");
|
||||
modal.add(new CreateDatasetForm(username));
|
||||
modal.setCloseVisible(true);
|
||||
modal.show();
|
||||
if (username != null) {
|
||||
modal.setTitle("Publish Product");
|
||||
modal.addStyleName("insert-metadata-modal-style");
|
||||
modal.add(new CreateDatasetForm(username));
|
||||
modal.setCloseVisible(true);
|
||||
modal.show();
|
||||
}
|
||||
else
|
||||
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
|
||||
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(EditMetadataEvent.TYPE, new EditMetadataEventHandler() {
|
||||
eventBus.addHandler(IFrameInstanciedEvent.TYPE, new IFrameInstanciedEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onEditMetadata(EditMetadataEvent editMetadataEvent) {
|
||||
// TODO Auto-generated method stub
|
||||
public void onNewInstance(IFrameInstanciedEvent iFrameInstanciedEent) {
|
||||
|
||||
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
|
||||
*/
|
||||
public HandlerManager getEventBus() {
|
||||
|
||||
return eventBus;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
|
||||
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 com.google.gwt.core.client.EntryPoint;
|
||||
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;
|
||||
|
||||
|
||||
|
@ -27,6 +30,29 @@ public class GCubeCkanDataCatalog implements EntryPoint {
|
|||
* This is the entry point method.
|
||||
*/
|
||||
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());
|
||||
eventManager.setPanel(panel);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client;
|
||||
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
|
||||
|
||||
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 {
|
||||
|
||||
|
||||
String getCKanConnector(
|
||||
CkanConnectorAccessPoint getCKanConnector(
|
||||
String pathInfoParameters, String queryStringParameters) throws Exception;
|
||||
|
||||
CkanRole getMyRole() throws Exception;
|
||||
|
||||
String getUser();
|
||||
|
||||
void logoutFromCkan();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client;
|
||||
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
@ -24,5 +25,12 @@ public interface GcubeCkanDataCatalogServiceAsync {
|
|||
|
||||
void getCKanConnector(
|
||||
String pathInfoParameters, String queryStringParameters,
|
||||
AsyncCallback<String> callback);
|
||||
AsyncCallback<CkanConnectorAccessPoint> callback);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void logoutFromCkan(AsyncCallback<Void> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -3,10 +3,13 @@
|
|||
*/
|
||||
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.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.dom.client.LoadEvent;
|
||||
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.Frame;
|
||||
|
||||
|
@ -20,14 +23,24 @@ import com.google.gwt.user.client.ui.Frame;
|
|||
public class CkanFramePanel extends FlowPanel{
|
||||
|
||||
private Frame frame;
|
||||
private HandlerManager eventBus;
|
||||
|
||||
|
||||
/**
|
||||
* 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)/*-{
|
||||
console.log(msg);
|
||||
}-*/;
|
||||
|
@ -39,7 +52,7 @@ public class CkanFramePanel extends FlowPanel{
|
|||
* @return the frame
|
||||
*/
|
||||
public Frame instanceFrame(String ckanUrlConnector) {
|
||||
|
||||
GWT.log("Instancing new IFRAME with uri: "+ckanUrlConnector);
|
||||
try{
|
||||
if(frame != null)
|
||||
remove(frame);
|
||||
|
@ -65,13 +78,18 @@ public class CkanFramePanel extends FlowPanel{
|
|||
}
|
||||
}else
|
||||
GWT.log("List Header by tag name is null");*/
|
||||
|
||||
}
|
||||
});
|
||||
add(frame);
|
||||
eventBus.fireEvent(new IFrameInstanciedEvent());
|
||||
return frame;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* Gets the frame.
|
||||
*
|
||||
* @return the frame
|
||||
*/
|
||||
public Frame getFrame() {
|
||||
return frame;
|
||||
|
|
|
@ -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.resource.CkanPortletResources;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
|
||||
|
||||
import com.google.gwt.core.shared.GWT;
|
||||
|
@ -30,11 +31,12 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate{
|
|||
|
||||
private CkanMetadataManagementPanel managementPanel;
|
||||
private ScrollPanel centerScrollable = new ScrollPanel();
|
||||
private CkanFramePanel ckanFramePanel = new CkanFramePanel();
|
||||
private CkanFramePanel ckanFramePanel;
|
||||
private Image loading = new Image(CkanPortletResources.ICONS.loading());
|
||||
private RootPanel rootPanel;
|
||||
private HandlerManager eventBus;
|
||||
private String baseURLCKANConnector;
|
||||
private String gCubeTokeValue;
|
||||
|
||||
/**
|
||||
* Instantiates a new g cube ckan data catalog panel.
|
||||
|
@ -45,20 +47,21 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate{
|
|||
public GCubeCkanDataCatalogPanel(RootPanel rootPanel, HandlerManager eventManager){
|
||||
this.rootPanel = rootPanel;
|
||||
this.eventBus = eventManager;
|
||||
ckanFramePanel = new CkanFramePanel(eventBus);
|
||||
managementPanel = new CkanMetadataManagementPanel(eventBus);
|
||||
initPanel();
|
||||
String pathParameter = Window.Location.getParameter(GCubeCkanDataCatalog.GET_PATH_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
|
||||
public void onSuccess(String ckanUrlConnector) {
|
||||
GWT.log("Instancing CKAN iframe with url: "+ckanUrlConnector);
|
||||
baseURLCKANConnector = ckanUrlConnector;
|
||||
instanceCkanFrame(baseURLCKANConnector);
|
||||
public void onSuccess(CkanConnectorAccessPoint ckan) {
|
||||
// GWT.log("Instancing CKAN iframe with url: "+uriToCkan);
|
||||
baseURLCKANConnector = ckan.getBaseUrl();
|
||||
gCubeTokeValue = ckan.getGcubeTokenValue();
|
||||
instanceCkanFrame(ckan.buildURI());
|
||||
GCubeCkanDataCatalogPanel.this.rootPanel.remove(loading);
|
||||
updateSize();
|
||||
}
|
||||
|
||||
@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){
|
||||
managementPanel.showInsertAndEditProductButtons(show);
|
||||
|
@ -189,10 +194,22 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate{
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the base urlckan connector.
|
||||
*
|
||||
* @return the baseURLCKANConnector
|
||||
*/
|
||||
public String getBaseURLCKANConnector() {
|
||||
return baseURLCKANConnector;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the gcube token value to ckan connector.
|
||||
*
|
||||
* @return the gcube token value to ckan connector
|
||||
*/
|
||||
public String getGcubeTokenValueToCKANConnector() {
|
||||
return gCubeTokeValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.gcube.datacatalogue.ckanutillibrary.models.CkanRolesIntoLiferay;
|
|||
import org.gcube.datacatalogue.ckanutillibrary.models.RolesIntoOrganization;
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
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.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.RoleManager;
|
||||
|
@ -37,14 +38,13 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
|||
@SuppressWarnings("serial")
|
||||
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_HTTPS = ":443";
|
||||
private static final String GCUBE_TOKEN_PARAMETER = "gcube-token";
|
||||
private static final String HTTPS = "https";
|
||||
private static final String HTTP = "http";
|
||||
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;
|
||||
private static Logger logger = LoggerFactory.getLogger(GcubeCkanDataCatalogServiceImpl.class);
|
||||
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)
|
||||
*/
|
||||
@Override
|
||||
public String getCKanConnector(String pathInfoParameters, String queryStringParameters) throws Exception {
|
||||
logger.info("getCKanConnector [pathInfo: "+pathInfoParameters + ", query: "+queryStringParameters+"]");
|
||||
public CkanConnectorAccessPoint getCKanConnector(String pathInfoParameter, String queryStringParameters) throws Exception {
|
||||
logger.info("getCKanConnector [pathInfo: "+pathInfoParameter + ", query: "+queryStringParameters+"]");
|
||||
try{
|
||||
|
||||
if(queryStringParameters!=null && Base64.isBase64(queryStringParameters.getBytes())){
|
||||
|
@ -102,10 +102,9 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
ckanConnectorUri+=ckanContext;
|
||||
logger.debug("CKanConnector URI + Context: "+ckanConnectorUri);
|
||||
logger.debug("adding parameters...");
|
||||
String fullPath = getCkanConnectorParameters(pathInfoParameters, queryStringParameters);
|
||||
ckanConnectorUri = ckanConnectorUri+fullPath;
|
||||
logger.info("returning ckanConnectorUri: "+ckanConnectorUri);
|
||||
return ckanConnectorUri;
|
||||
CkanConnectorAccessPoint ckAP = getCkanConnectorAccessPoint(ckanConnectorUri, pathInfoParameter, queryStringParameters);
|
||||
logger.info("returning ckanConnectorUri: "+ckAP);
|
||||
return ckAP;
|
||||
// return "http://ckan-d-d4s.d4science.org";
|
||||
}catch(Exception e ){
|
||||
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.
|
||||
*
|
||||
* @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
|
||||
* @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);
|
||||
logger.debug(CKANHIDEHEADER + " is: "+ckanHideHeader);
|
||||
// String ckanHideHeader = getServletContext().getInitParameter(CKANHIDEHEADER);
|
||||
// logger.debug(CKANHIDEHEADER + " is: "+ckanHideHeader);
|
||||
|
||||
String pathInfo = "";
|
||||
if(pathInfoParameters!=null && !pathInfoParameters.isEmpty()){
|
||||
pathInfo=pathInfoParameters.startsWith("/")?pathInfoParameters:"/"+pathInfoParameters;
|
||||
}
|
||||
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(ckanConnectorBaseUrl);
|
||||
|
||||
String queryString ="";
|
||||
if(queryStringParameters!=null && !queryStringParameters.isEmpty()){
|
||||
queryString = "?"+queryStringParameters;
|
||||
}
|
||||
//
|
||||
// String pathInfo = "";
|
||||
// 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()){
|
||||
gcubeTokenParameter = GCUBE_TOKEN_PARAMETER+"="+getGcubeSecurityToken();
|
||||
gcubeTokenValue = getGcubeSecurityToken();
|
||||
}else{
|
||||
logger.warn("******** Using TEST_USER security token!!!");
|
||||
gcubeTokenParameter = GCUBE_TOKEN_PARAMETER+"="+TEST_SEC_TOKEN;
|
||||
gcubeTokenValue = TEST_SEC_TOKEN;
|
||||
}
|
||||
|
||||
//ADDING CKAN HH (HIDE HEADER PARAMETER)
|
||||
queryString = queryString.isEmpty()?"?"+ckanHideHeader:"&"+ckanHideHeader;
|
||||
//ADDING GCUBE TOKEN PARAMETER
|
||||
queryString+="&"+gcubeTokenParameter;
|
||||
ckan.addGubeToken(gcubeTokenValue);
|
||||
// ckan.addGenericParameter(ckanHideHeader, "true");
|
||||
|
||||
// //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
|
||||
if(!SessionUtil.isIntoPortal()){
|
||||
return ckan;
|
||||
}
|
||||
|
||||
ASLSession session = getASLSession(this.getThreadLocalRequest().getSession());
|
||||
List<String> listVres = UserUtil.getListVreForUser(session.getUserEmailAddress());
|
||||
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
|
||||
}
|
||||
// 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
|
||||
// }
|
||||
|
||||
logger.debug("List of VREs contains: " +vres);
|
||||
if(vres.length()>0){
|
||||
queryString+="&"+LIST_OF_VRES_PARAMETER+"="+vres;
|
||||
}
|
||||
// logger.debug("List of VREs contains: " +vres);
|
||||
// if(vres.length()>0){
|
||||
// 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){
|
||||
case CkanRolesIntoLiferay.CATALOG_ADMIN: return CkanRole.ADMIN;
|
||||
case CkanRolesIntoLiferay.CATALOG_EDITOR: return CkanRole.EDITOR;
|
||||
case CkanRolesIntoLiferay.CATALOG_MEMBER: ;
|
||||
case CkanRolesIntoLiferay.CATALOG_MEMBER: return CkanRole.MEMBER;
|
||||
default : return CkanRole.MEMBER;
|
||||
}
|
||||
}
|
||||
|
@ -360,4 +386,21 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
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);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -10,10 +10,16 @@
|
|||
<param-value>/gcube/service/connect</param-value>
|
||||
</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>
|
||||
<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=true</param-value>
|
||||
<description>ckan connector logout from CKAN</description>
|
||||
<param-name>CkanConnectorLogout</param-name>
|
||||
<param-value>/gcube/service/connect</param-value>
|
||||
</context-param>
|
||||
|
||||
<!-- Servlets -->
|
||||
|
|
Loading…
Reference in New Issue