diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
index 2131e1b..5fe3680 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -4,9 +4,6 @@
-
- uses
-
diff --git a/pom.xml b/pom.xml
index 4478248..d0ba0ae 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
org.gcube.portlets.gcubeckan
gcube-ckan-datacatalog
war
- 1.2.2-SNAPSHOT
+ 1.2.1-SNAPSHOT
gCube CKAN Data Catalog
The gCube CKAN Data Catalog portlet
diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/CkanEventHandlerManager.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/CkanEventHandlerManager.java
index 93b4a8c..e305af3 100644
--- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/CkanEventHandlerManager.java
+++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/CkanEventHandlerManager.java
@@ -152,7 +152,6 @@ public class CkanEventHandlerManager {
@Override
public void onShowGroups(ShowGroupsEvent showGroupsEvent) {
- //String request = getCkanRequest("/dashboard/groups", null);
//panel.instanceCkanFrame(request);
if(showGroupsEvent.isOwnOnly())
panel.showGroups();
@@ -213,9 +212,9 @@ public class CkanEventHandlerManager {
* @return the ckan request
*/
private String getCkanRequest(String pathInfo, String query){
- CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(panel.getBaseURLCKANConnector(),"");
- if(panel.getGcubeTokenValueToCKANConnector() != null)
- ckan.addGubeToken(panel.getGcubeTokenValueToCKANConnector());
+ CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(panel.getCatalogueUrl(),"");
+ /*if(panel.getGcubeTokenValueToCKANConnector() != null)
+ ckan.addGubeToken(panel.getGcubeTokenValueToCKANConnector());*/
pathInfo = CkanConnectorAccessPoint.checkNullString(pathInfo);
query = CkanConnectorAccessPoint.checkNullString(query);
ckan.addPathInfo(pathInfo);
diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/GcubeCkanDataCatalogService.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/GcubeCkanDataCatalogService.java
index c8e02e7..c967522 100644
--- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/GcubeCkanDataCatalogService.java
+++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/GcubeCkanDataCatalogService.java
@@ -60,12 +60,12 @@ public interface GcubeCkanDataCatalogService extends RemoteService {
*/
String logoutFromCkanURL();
- /**
- * Remove auth cookie for ckan of this user.
- *
- * @return the string
- */
- String logoutURIFromCkan();
+ // /**
+ // * Remove auth cookie for ckan of this user.
+ // *
+ // * @return the string
+ // */
+ // String logoutURIFromCkan();
/**
* Check if the there is a user logged in.
diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/GcubeCkanDataCatalogServiceAsync.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/GcubeCkanDataCatalogServiceAsync.java
index bfd6b36..9892a37 100644
--- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/GcubeCkanDataCatalogServiceAsync.java
+++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/GcubeCkanDataCatalogServiceAsync.java
@@ -38,8 +38,8 @@ public interface GcubeCkanDataCatalogServiceAsync {
* @return the c kan connector
*/
void getCKanConnector(
- String pathInfoParameters, String queryStringParameters,
- AsyncCallback callback);
+ String pathInfoParameters, String queryStringParameters,
+ AsyncCallback callback);
/**
* Logout from ckan url.
@@ -48,12 +48,12 @@ public interface GcubeCkanDataCatalogServiceAsync {
*/
void logoutFromCkanURL(AsyncCallback callback);
- /**
- * Logout uri from ckan.
- *
- * @param callback the callback
- */
- void logoutURIFromCkan(AsyncCallback callback);
+ // /**
+ // * Logout uri from ckan.
+ // *
+ // * @param callback the callback
+ // */
+ // void logoutURIFromCkan(AsyncCallback callback);
/**
* Gets the ckan organizations names and urls for user.
@@ -63,7 +63,7 @@ public interface GcubeCkanDataCatalogServiceAsync {
*/
void getCkanOrganizationsNamesAndUrlsForUser(
AsyncCallback> callback);
-
+
/**
* Retrieve the list of groups to whom the user belongs and their urls.
*
diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/CkanGroupsPanel.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/CkanGroupsPanel.java
index 776c9f3..0ed5c5c 100644
--- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/CkanGroupsPanel.java
+++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/CkanGroupsPanel.java
@@ -121,8 +121,8 @@ public class CkanGroupsPanel extends VerticalPanel{
* @return
*/
private String getCkanRequest(String pathInfo, String query){
- CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(father.getBaseURLCKANConnector(), "");
- ckan.addGubeToken(father.getGcubeTokenValueToCKANConnector());
+ CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(father.getCatalogueUrl(), "");
+ //ckan.addGubeToken(father.getGcubeTokenValueToCKANConnector());
pathInfo = CkanConnectorAccessPoint.checkNullString(pathInfo);
query = CkanConnectorAccessPoint.checkNullString(query);
ckan.addPathInfo(pathInfo);
diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/CkanOrganizationsPanel.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/CkanOrganizationsPanel.java
index 7d5afa2..be30281 100644
--- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/CkanOrganizationsPanel.java
+++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/CkanOrganizationsPanel.java
@@ -121,8 +121,8 @@ public class CkanOrganizationsPanel extends VerticalPanel{
* @return
*/
private String getCkanRequest(String pathInfo, String query){
- CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(father.getBaseURLCKANConnector(), "");
- ckan.addGubeToken(father.getGcubeTokenValueToCKANConnector());
+ CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(father.getCatalogueUrl(), "");
+ //ckan.addGubeToken(father.getGcubeTokenValueToCKANConnector());
pathInfo = CkanConnectorAccessPoint.checkNullString(pathInfo);
query = CkanConnectorAccessPoint.checkNullString(query);
ckan.addPathInfo(pathInfo);
diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/GCubeCkanDataCatalogPanel.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/GCubeCkanDataCatalogPanel.java
index 21a10cf..0e939a2 100644
--- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/GCubeCkanDataCatalogPanel.java
+++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/GCubeCkanDataCatalogPanel.java
@@ -112,7 +112,6 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
if(!ckan.isOutsideFromPortal()){
-
// MANAGE CKAN MANAGEMENT PANEL ACCORDING TO MY ROLE
GCubeCkanDataCatalog.service.getMyRole(new AsyncCallback() {
@@ -326,6 +325,14 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
protected native void postMessage(String msg) /*-{
$wnd.postMessage(msg, "*");
}-*/;
+
+ /**
+ * Print a message
+ * @param string
+ */
+ protected native void printString(String string) /*-{
+ console.log(string);
+ }-*/;
/**
* Listen for post message.
@@ -426,6 +433,16 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
return ckanAccessPoint.getBaseUrlWithContext();
}
+
+ /**
+ * Return the catalogue url (e.g. http://ckan-d-d4s.d4science.org:443/)
+ * @return
+ */
+ public String getCatalogueUrl(){
+
+ printString("Base url for iframe is " + ckanAccessPoint.getCatalogueBaseUrl());
+ return ckanAccessPoint.getCatalogueBaseUrl();
+ }
/**
* Gets the gcube token value to ckan connector.
diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GcubeCkanDataCatalogServiceImpl.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GcubeCkanDataCatalogServiceImpl.java
index 7ccc966..00a572f 100644
--- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GcubeCkanDataCatalogServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GcubeCkanDataCatalogServiceImpl.java
@@ -53,7 +53,6 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
public static String CKANCONNECTORCONTEXT = "CkanConnectorContext";
public static String CKANCONNECTORLOGOUT = "CkanConnectorLogout";
private static final String GRSF_ADMIN_ROLE = "GRSF-Admin";
- //private static Logger logger = LoggerFactory.getLogger(GcubeCkanDataCatalogServiceImpl.class);
private static final Log logger = LogFactoryUtil.getLog(GcubeCkanDataCatalogServiceImpl.class);
/**
@@ -293,23 +292,23 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
return toReturn;
}
- @Override
- public String logoutURIFromCkan() {
- String username = SessionUtil.getCurrentUser(getThreadLocalRequest()).getUsername();
-
- // get the scope from session
- String scopePerCurrentUrl = SessionUtil.getScopeFromClientUrl(getThreadLocalRequest());
-
- CkanConnectorAccessPoint ckanAP = SessionUtil.getCkanAccessPoint(this.getThreadLocalRequest().getSession(), scopePerCurrentUrl);
- logger.info("Logout from CKAN for: "+username +" by token: "+ckanAP.getGcubeTokenValue());
-
- String ckanConnectorLogut = getServletContext().getInitParameter(CKANCONNECTORLOGOUT);
- logger.debug(CKANCONNECTORLOGOUT + " is: "+ckanConnectorLogut);
-
- CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(ckanAP.getBaseUrl(), ckanConnectorLogut);
- ckan.addGubeToken(ckanAP.getGcubeTokenValue());
- return ckan.buildURI();
- }
+ // @Override
+ // public String logoutURIFromCkan() {
+ // String username = SessionUtil.getCurrentUser(getThreadLocalRequest()).getUsername();
+ //
+ // // get the scope from session
+ // String scopePerCurrentUrl = SessionUtil.getScopeFromClientUrl(getThreadLocalRequest());
+ //
+ // CkanConnectorAccessPoint ckanAP = SessionUtil.getCkanAccessPoint(this.getThreadLocalRequest().getSession(), scopePerCurrentUrl);
+ // logger.info("Logout from CKAN for: "+username +" by token: "+ckanAP.getGcubeTokenValue());
+ //
+ // String ckanConnectorLogut = getServletContext().getInitParameter(CKANCONNECTORLOGOUT);
+ // logger.debug(CKANCONNECTORLOGOUT + " is: "+ckanConnectorLogut);
+ //
+ // CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(ckanAP.getBaseUrl(), ckanConnectorLogut);
+ // ckan.addGubeToken(ckanAP.getGcubeTokenValue());
+ // return ckan.buildURI();
+ // }
/* (non-Javadoc)
@@ -317,7 +316,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
*/
@Override
public String logoutFromCkanURL() {
-
+
// check if the portlet is accessed from outside the portal
if(outsidePortal())
return null;
@@ -350,63 +349,63 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
/*HttpSession httpSession = this.getThreadLocalRequest().getSession();
- ASLSession session = getASLSession(httpSession);
- String username = session.getUsername();
- // get the scope from session
- String scopePerCurrentUrl = (String)this.getThreadLocalRequest().getSession().getAttribute(SessionCatalogueAttributes.SCOPE_CLIENT_PORTLET_URL);
- CkanConnectorAccessPoint ckanAP = SessionUtil.getCkanAccessPoint(this.getThreadLocalRequest().getSession(), scopePerCurrentUrl);
- // String token = getGcubeSecurityToken();
- logger.info("Logout from CKAN for: "+username +" by token: "+ckanAP.getGcubeTokenValue());
+ ASLSession session = getASLSession(httpSession);
+ String username = session.getUsername();
+ // get the scope from session
+ String scopePerCurrentUrl = (String)this.getThreadLocalRequest().getSession().getAttribute(SessionCatalogueAttributes.SCOPE_CLIENT_PORTLET_URL);
+ CkanConnectorAccessPoint ckanAP = SessionUtil.getCkanAccessPoint(this.getThreadLocalRequest().getSession(), scopePerCurrentUrl);
+ // String token = getGcubeSecurityToken();
+ logger.info("Logout from CKAN for: "+username +" by token: "+ckanAP.getGcubeTokenValue());
- String ckanConnectorLogut = getServletContext().getInitParameter(CKANCONNECTORLOGOUT);
- logger.debug(CKANCONNECTORLOGOUT + " is: "+ckanConnectorLogut);
+ String ckanConnectorLogut = getServletContext().getInitParameter(CKANCONNECTORLOGOUT);
+ logger.debug(CKANCONNECTORLOGOUT + " is: "+ckanConnectorLogut);
- CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(ckanAP.getBaseUrl(), ckanConnectorLogut);
- ckan.addPathInfo(ckanConnectorLogut);
- ckan.addGubeToken(ckanAP.getGcubeTokenValue());
- URL url;
- try {
- String deleteURI = ckan.buildURI();
- logger.debug("Perfoming HTTP delete to URI: "+deleteURI);
- url = new URL(deleteURI);
- HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
- httpCon.setDoOutput(true);
- httpCon.setRequestProperty("Content-Type", "application/x-www-form-urlencoded" );
- httpCon.setRequestMethod("DELETE");
- httpCon.connect();
+ CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(ckanAP.getBaseUrl(), ckanConnectorLogut);
+ ckan.addPathInfo(ckanConnectorLogut);
+ ckan.addGubeToken(ckanAP.getGcubeTokenValue());
+ URL url;
+ try {
+ String deleteURI = ckan.buildURI();
+ logger.debug("Perfoming HTTP delete to URI: "+deleteURI);
+ url = new URL(deleteURI);
+ HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
+ httpCon.setDoOutput(true);
+ httpCon.setRequestProperty("Content-Type", "application/x-www-form-urlencoded" );
+ httpCon.setRequestMethod("DELETE");
+ httpCon.connect();
- HttpServletResponse response = this.getThreadLocalResponse();
+ HttpServletResponse response = this.getThreadLocalResponse();
- if(httpCon.getResponseCode()==HttpStatus.SC_OK){
- response.setContentLength(httpCon.getContentLength());
- Map> map = httpCon.getHeaderFields();
- for (String key : map.keySet()) {
- String hf = httpCon.getHeaderField(key);
- logger.trace("key: "+key +", value: "+hf);
- if(key==null){
- logger.trace("skyp key: "+key +", value: "+hf);
- }else
- response.setHeader(key,hf);
+ if(httpCon.getResponseCode()==HttpStatus.SC_OK){
+ response.setContentLength(httpCon.getContentLength());
+ Map> map = httpCon.getHeaderFields();
+ for (String key : map.keySet()) {
+ String hf = httpCon.getHeaderField(key);
+ logger.trace("key: "+key +", value: "+hf);
+ if(key==null){
+ logger.trace("skyp key: "+key +", value: "+hf);
+ }else
+ response.setHeader(key,hf);
+ }
+
+ response.setContentLength(httpCon.getContentLength());
+ String encoding = httpCon.getContentEncoding();
+ encoding = encoding == null ? UTF_8 : encoding;
+ response.setCharacterEncoding(encoding);
+ response.setStatus(HttpStatus.SC_OK);
+
+ InputStream in = httpCon.getInputStream();
+ ServletOutputStream out = response.getOutputStream();
+ IOUtils.copy(in, out);
+ logger.info("Logout Completed, response code: "+HttpStatus.SC_OK);
+
+ }else{
+ logger.warn("An error occurred during perfoming CKAN logout, Response status is: "+httpCon.getResponseCode());
}
-
- response.setContentLength(httpCon.getContentLength());
- String encoding = httpCon.getContentEncoding();
- encoding = encoding == null ? UTF_8 : encoding;
- response.setCharacterEncoding(encoding);
- response.setStatus(HttpStatus.SC_OK);
-
- InputStream in = httpCon.getInputStream();
- ServletOutputStream out = response.getOutputStream();
- IOUtils.copy(in, out);
- logger.info("Logout Completed, response code: "+HttpStatus.SC_OK);
-
- }else{
- logger.warn("An error occurred during perfoming CKAN logout, Response status is: "+httpCon.getResponseCode());
}
- }
- catch (IOException e) {
- logger.error("An error occured during performing Logout from CKAN for: "+username +" by token: "+ckanAP.getGcubeTokenValue(), e);
- }*/
+ catch (IOException e) {
+ logger.error("An error occured during performing Logout from CKAN for: "+username +" by token: "+ckanAP.getGcubeTokenValue(), e);
+ }*/
}
@Override
diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/shared/CkanConnectorAccessPoint.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/shared/CkanConnectorAccessPoint.java
index f022357..681f478 100644
--- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/shared/CkanConnectorAccessPoint.java
+++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/shared/CkanConnectorAccessPoint.java
@@ -35,6 +35,7 @@ public class CkanConnectorAccessPoint implements Serializable{
private Map mapVresRoles;
private String serverviceContext;
private boolean outsideFromPortal = false;
+ private String catalogueBaseUrl = null;
/**
* Instantiates a new ckan connector access point.
@@ -51,6 +52,7 @@ public class CkanConnectorAccessPoint implements Serializable{
*/
public CkanConnectorAccessPoint(String baseUrl, String servericeContext){
this.baseUrl = baseUrl;
+ this.catalogueBaseUrl = baseUrl.split("ckan-connector")[0];
this.serverviceContext = servericeContext;
}
@@ -261,13 +263,17 @@ public class CkanConnectorAccessPoint implements Serializable{
this.outsideFromPortal = outsideFromPortal;
}
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
+ /**
+ *
+ * @return the catalogue url
*/
+ public String getCatalogueBaseUrl() {
+ return catalogueBaseUrl;
+ }
+
+
@Override
public String toString() {
-
StringBuilder builder = new StringBuilder();
builder.append("CkanConnectorAccessPoint [baseUrl=");
builder.append(baseUrl);
@@ -275,12 +281,16 @@ public class CkanConnectorAccessPoint implements Serializable{
builder.append(pathInfoParameter);
builder.append(", queryStringParameters=");
builder.append(queryStringParameters);
+ builder.append(", gcubeTokenValue=");
+ builder.append(gcubeTokenValue);
builder.append(", mapVresRoles=");
builder.append(mapVresRoles);
builder.append(", serverviceContext=");
builder.append(serverviceContext);
builder.append(", outsideFromPortal=");
builder.append(outsideFromPortal);
+ builder.append(", catalogueBaseUrl=");
+ builder.append(catalogueBaseUrl);
builder.append("]");
return builder.toString();
}