diff --git a/CHANGELOG.md b/CHANGELOG.md
index c2eaefe..b0d4d4c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,12 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [v1.9.0] [r4.25.0] - 2020-07-01
+
+** Enhancements **
+
+[#19559] Check and try to avoid the view per VRE configuration for Public and Gateway Catalogue
+
## [v1.8.1] [r4.24.0] - 2020-06-18
Just to include the dependencies [#18700] and [#19479]
diff --git a/pom.xml b/pom.xml
index 937289e..95b0c57 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,7 +14,7 @@
org.gcube.portlets.gcubeckan
gcube-ckan-datacatalog
war
- 1.8.1
+ 1.9.0-SNAPSHOT
gCube CKAN Data Catalog
The gCube CKAN Data Catalog portlet
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 1b4a5fb..1f3ba95 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
@@ -23,13 +23,14 @@ public interface GcubeCkanDataCatalogService extends RemoteService {
/**
* Get the ckan connector access point.
*
+ * @param browserLocationURL the browser location URL
* @param pathInfoParameters the path info parameters
* @param queryStringParameters the query string parameters
* @return the c kan connector
* @throws Exception the exception
*/
CkanConnectorAccessPoint getCKanConnector(
- String pathInfoParameters, String queryStringParameters) throws Exception;
+ String browserLocationURL, String pathInfoParameters, String queryStringParameters) throws Exception;
/**
* Get the current role in CKAN for this user.
@@ -75,9 +76,11 @@ public interface GcubeCkanDataCatalogService extends RemoteService {
boolean isManageProductEnabled();
/**
- * Check if the management panels but publish/share link must be removed
+ * Check if the view per VRE is enabled, so the management panels but publish/share link must be removed.
+ * @param browserLocationURL the browser location URL
+ * @return the string
*/
- String isViewPerVREEnabled();
+ String isViewPerVREEnabled(String browserLocationURL);
/**
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 eeedcb7..92796bc 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
@@ -30,15 +30,16 @@ public interface GcubeCkanDataCatalogServiceAsync {
void getMyRole(AsyncCallback callback);
/**
- * Gets the c kan connector.
+ * Gets the CKAN connector.
*
+ * @param browserLocationURL the browser location URL that performs the call
* @param pathInfoParameters the path info parameters
* @param queryStringParameters the query string parameters
* @param callback the callback
* @return the c kan connector
*/
void getCKanConnector(
- String pathInfoParameters, String queryStringParameters,
+ String browserLocationURL, String pathInfoParameters, String queryStringParameters,
AsyncCallback callback);
/**
@@ -73,12 +74,14 @@ public interface GcubeCkanDataCatalogServiceAsync {
*/
void isManageProductEnabled(AsyncCallback callback);
+
/**
- * check if the view per vre is enabled.
+ * Checks if is view per VRE enabled.
*
+ * @param browserLocationURL the browser location URL
* @param callback the callback
*/
- void isViewPerVREEnabled(AsyncCallback callback);
+ void isViewPerVREEnabled(String browserLocationURL, 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 794e2b8..6b34968 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
@@ -99,7 +99,9 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
String pathParameter = paramsMap.get(GCubeCkanDataCatalog.GET_PATH_PARAMETER); //Window.Location.getParameter(GCubeCkanDataCatalog.GET_PATH_PARAMETER);
String queryParameter = paramsMap.get(GCubeCkanDataCatalog.GET_QUERY_PARAMETER);// Window.Location.getParameter(GCubeCkanDataCatalog.GET_QUERY_PARAMETER);
- GCubeCkanDataCatalog.service.getCKanConnector(
+ String browserLocationURL = getBrowserLocationURL();
+
+ GCubeCkanDataCatalog.service.getCKanConnector(browserLocationURL,
pathParameter, queryParameter,
new AsyncCallback() {
@@ -122,10 +124,11 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
instanceCkanFrame(ckan.buildURI());
GCubeCkanDataCatalogPanel.this.rootPanel.remove(loading);
+ String browserLocationURL = getBrowserLocationURL();
// check if view per organisation is enabled
//and performing some actions in this case (e.g. removed the management buttons, etc.)
- GCubeCkanDataCatalog.service.isViewPerVREEnabled(new AsyncCallback() {
+ GCubeCkanDataCatalog.service.isViewPerVREEnabled(browserLocationURL, new AsyncCallback() {
@Override
public void onSuccess(String result) {
@@ -267,6 +270,26 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
listenForPostMessage();
}
+
+
+ /**
+ * Gets the browser location URL.
+ *
+ * @return the browser location URL
+ */
+ public String getBrowserLocationURL() {
+
+ String browserLocationURL = null;
+
+ try {
+ browserLocationURL = Window.Location.getHref();
+ }catch (Exception e) {
+ // silent
+ }
+
+ GWT.log("Returning browserLocationURL: "+browserLocationURL);
+ return browserLocationURL;
+ }
public static String getLatestSelectedProductIdentifier(){
return latestSelectedProductIdentifier;
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 233e050..c3232fc 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
@@ -81,7 +81,8 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
* @see org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GcubeCkanDataCatalogService#getCKanConnector(java.lang.String, java.lang.String)
*/
@Override
- public CkanConnectorAccessPoint getCKanConnector(String pathInfoParameter, String queryStringParameters) throws Exception {
+ public CkanConnectorAccessPoint getCKanConnector(String browserLocationURL, String pathInfoParameter, String queryStringParameters) throws Exception {
+ logger.info("getCKanConnector [browserLocationURL: "+browserLocationURL+ " ]");
logger.info("getCKanConnector [pathInfo: "+pathInfoParameter + ", query: "+queryStringParameters+"]");
try{
@@ -106,10 +107,11 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
}
if(pathInfoParameter == null || pathInfoParameter.isEmpty()){
- pathInfoParameter = isViewPerVREEnabled();
+ //pathInfoParameter is null or empty, in this case we are pointing to the Catalogue Home
+ pathInfoParameter = isViewPerVREEnabled(browserLocationURL);
}
- CkanConnectorAccessPoint ckAP = getCkanConnectorAccessPoint(pathInfoParameter, queryStringParameters, scopePerCurrentUrl);
+ CkanConnectorAccessPoint ckAP = getCkanConnectorAccessPoint(browserLocationURL, pathInfoParameter, queryStringParameters, scopePerCurrentUrl);
SessionUtil.saveCkanAccessPoint(this.getThreadLocalRequest().getSession(), scopePerCurrentUrl, ckAP);
logger.info("Built the URI to CKAN (connector in case of user logged): "+ckAP.buildURI());
logger.debug("returning ckanConnectorUri: "+ckAP);
@@ -125,13 +127,14 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
/**
* Gets the ckan connector access point.
*
+ * @param browserLocationURL the browser location URL
* @param pathInfoParameter the path info parameter
* @param queryStringParameters the query string parameters
* @param scopePerCurrentUrl the scope per current url
* @return the ckan connector access point
* @throws Exception the exception
*/
- private CkanConnectorAccessPoint getCkanConnectorAccessPoint(String pathInfoParameter, String queryStringParameters, String scopePerCurrentUrl) throws Exception {
+ private CkanConnectorAccessPoint getCkanConnectorAccessPoint(String browserLocationURL, String pathInfoParameter, String queryStringParameters, String scopePerCurrentUrl) throws Exception {
if(outsideLoginPortal()){
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(getCatalogue(scopePerCurrentUrl).getCatalogueUrl(),"");
@@ -186,7 +189,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
getThreadLocalRequest()).getEmail(),
scopePerCurrentUrl,
getCatalogue(scopePerCurrentUrl),
- isViewPerVREEnabled() != null,
+ isViewPerVREEnabled(browserLocationURL) != null,
getThreadLocalRequest().getSession());
ckan.addListOfVREs(roleForVre);
@@ -529,10 +532,11 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
/**
* Ask to liferay.
*
+ * @param browserLocationURL the browser location URL
* @return the string
*/
@Override
- public String isViewPerVREEnabled(){
+ public String isViewPerVREEnabled(String browserLocationURL){
String toReturn = null;
String scopePerCurrentUrl = SessionUtil.getScopeFromClientUrl(getThreadLocalRequest());// the view per vre can be managed independently for each context SessionUtil.getScopeFromClientUrl(getThreadLocalRequest());
@@ -552,11 +556,20 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
GroupManager gm = new LiferayGroupManager();
enabled = (boolean) gm.readCustomAttr(gm.getGroupIdFromInfrastructureScope(scopePerCurrentUrl), VIEW_PER_ORGANIZATION_LIFERAY_CUSTOM_FIELD);
+
if(enabled){
String groupName = gm.getGroup(gm.getGroupIdFromInfrastructureScope(scopePerCurrentUrl)).getGroupName().toLowerCase();
- toReturn = "/organization_vre/" + groupName;
+ //this should mean the caller (the location URL) is from VRE environment
+ if(browserLocationURL.toLowerCase().contains(groupName)){
+ logger.info("The browserLocationURL: "+browserLocationURL+ " contains the OrgName '"+groupName+"' read by LF GroupManager. The Catalogue Portlet should be at VRE level, reading configuration isViewPerVREEnabled");
+ toReturn = "/organization_vre/" + groupName;
+ }else {
+ //this should mean the caller is out from VRE environment,so should be a public or gateway catalogue
+ logger.info("The browserLocationURL: "+browserLocationURL+ " DOES NOT contain the OrgName '"+groupName+"' read by LF GroupManager. Ignoring configuration isViewPerVREEnabled");
+ }
}
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);
}