From 533f73b8368e242fc695c56ce76bf146d0e4ec95 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Fri, 1 Dec 2017 17:06:25 +0000 Subject: [PATCH] give high priority to path if it is already set when the user lands on the catalogue git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@159006 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/GcubeCkanDataCatalogService.java | 2 +- .../GcubeCkanDataCatalogServiceAsync.java | 2 +- .../view/GCubeCkanDataCatalogPanel.java | 11 ++++--- .../GcubeCkanDataCatalogServiceImpl.java | 29 ++++++++----------- 4 files changed, 21 insertions(+), 23 deletions(-) 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 0ae0a7f..61e8c04 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 @@ -83,5 +83,5 @@ public interface GcubeCkanDataCatalogService extends RemoteService { /** * Check if the management panels but publish/share link must be removed */ - boolean isViewPerVREEnabled(); + String isViewPerVREEnabled(); } 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 009d448..fdf79ff 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 @@ -85,5 +85,5 @@ public interface GcubeCkanDataCatalogServiceAsync { */ void isManageProductEnabled(AsyncCallback callback); - void isViewPerVREEnabled(AsyncCallback callback); + void isViewPerVREEnabled(AsyncCallback callback); } 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 bf5edd0..1dc5251 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 @@ -151,14 +151,17 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate { }); // check if management buttons need to be removed - GCubeCkanDataCatalog.service.isViewPerVREEnabled(new AsyncCallback() { + GCubeCkanDataCatalog.service.isViewPerVREEnabled(new AsyncCallback() { @Override - public void onSuccess(Boolean result) { + public void onSuccess(String result) { - if(result){ + if(result != null && !result.isEmpty()){ // hide all management buttons managementPanel.removeGenericManagementButtons(); + + // set real relative path + ckanAccessPoint.addPathInfo(result); } } @@ -166,7 +169,7 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate { @Override public void onFailure(Throwable caught) { - + // ? } }); 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 cbb75b0..3d38e47 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 @@ -2,8 +2,6 @@ package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.server; import static org.gcube.common.authorization.client.Constants.authorizationService; -import java.net.URL; -import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -91,17 +89,11 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem queryStringParameters = new String(valueDecoded); logger.info("queryStringParameters detected like Base64 and decoded like: "+queryStringParameters); } - - if(pathInfoParameter == null || pathInfoParameter.isEmpty()){ - boolean viewEnabled = isViewPerVREEnabled(); - if(viewEnabled){ - GroupManager gm = new LiferayGroupManager(); - String groupName = gm.getGroup(gm.getGroupIdFromInfrastructureScope(scopePerCurrentUrl)).getGroupName().toLowerCase(); - pathInfoParameter = "/organization_vre/" + groupName; - } + if(pathInfoParameter == null || pathInfoParameter.isEmpty()){ + pathInfoParameter = isViewPerVREEnabled(); } - + CkanConnectorAccessPoint ckAP = getCkanConnectorAccessPoint(pathInfoParameter, queryStringParameters, scopePerCurrentUrl); SessionUtil.saveCkanAccessPoint(this.getThreadLocalRequest().getSession(), scopePerCurrentUrl, ckAP); logger.info("Builded URI to CKAN Connector: "+ckAP.buildURI()); @@ -556,20 +548,23 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem * @return */ @Override - public boolean isViewPerVREEnabled(){ + public String isViewPerVREEnabled(){ - boolean enabled = false; + String toReturn = null; String scopePerCurrentUrl = SessionUtil.getScopeFromClientUrl(getThreadLocalRequest()); - - + boolean enabled = false; try{ GroupManager gm = new LiferayGroupManager(); enabled = (boolean) gm.readCustomAttr(gm.getGroupIdFromInfrastructureScope(scopePerCurrentUrl), VIEW_PER_ORGANIZATION_LIFERAY_CUSTOM_FIELD); - logger.debug("Read value for " + VIEW_PER_ORGANIZATION_LIFERAY_CUSTOM_FIELD + " is " + enabled); + if(enabled){ + String groupName = gm.getGroup(gm.getGroupIdFromInfrastructureScope(scopePerCurrentUrl)).getGroupName().toLowerCase(); + toReturn = "/organization_vre/" + groupName; + } + logger.debug("Read value for " + VIEW_PER_ORGANIZATION_LIFERAY_CUSTOM_FIELD + " is " + enabled + " and path is " + toReturn); }catch(Exception e){ logger.error("Failed to parse custom field value", e); } - return enabled; + return toReturn; }