Merged with branch version task/19559

This commit is contained in:
Francesco Mangiacrapa 2020-07-03 17:15:11 +02:00
parent 3dfa8671b5
commit 2855d07340
10 changed files with 101 additions and 49 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/gcube-ckan-datacatalog-1.8.0-SNAPSHOT/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/gcube-ckan-datacatalog-1.9.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
@ -26,7 +26,7 @@
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/> <classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry excluding="**" kind="src" output="target/gcube-ckan-datacatalog-1.8.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources"> <classpathentry excluding="**" kind="src" output="target/gcube-ckan-datacatalog-1.9.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
@ -36,5 +36,5 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="target/gcube-ckan-datacatalog-1.8.0-SNAPSHOT/WEB-INF/classes"/> <classpathentry kind="output" path="target/gcube-ckan-datacatalog-1.9.0-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -1,5 +1,5 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
jarsExcludedFromWebInfLib= jarsExcludedFromWebInfLib=
lastWarOutDir=/home/francesco/git/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-1.8.0-SNAPSHOT lastWarOutDir=/home/francesco/git/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-1.9.0-SNAPSHOT
warSrcDir=src/main/webapp warSrcDir=src/main/webapp
warSrcDirIsOutput=false warSrcDirIsOutput=false

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> <?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="gcube-ckan-datacatalog-1.8.0-SNAPSHOT"> <wb-module deploy-name="gcube-ckan-datacatalog-1.9.0-SNAPSHOT">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/> <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<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"/>

View File

@ -4,7 +4,11 @@
All notable changes to this project will be documented in this file. 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). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.8.1] [r4.24.0] - 2020-06-18 ## [v1.9.0] [r4.24.0] - 2020-07-03
** Enhancements **
[#19559] Check and try to avoid the view per VRE configuration for Public and Gateway Catalogue
Just to include the dependencies [#18700] and [#19479] Just to include the dependencies [#18700] and [#19479]

View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.gcubeckan</groupId> <groupId>org.gcube.portlets.gcubeckan</groupId>
<artifactId>gcube-ckan-datacatalog</artifactId> <artifactId>gcube-ckan-datacatalog</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>1.8.1</version> <version>1.9.0</version>
<name>gCube CKAN Data Catalog</name> <name>gCube CKAN Data Catalog</name>
<description>The gCube CKAN Data Catalog portlet</description> <description>The gCube CKAN Data Catalog portlet</description>

View File

@ -23,13 +23,14 @@ public interface GcubeCkanDataCatalogService extends RemoteService {
/** /**
* Get the ckan connector access point. * Get the ckan connector access point.
* *
* @param browserLocationURL the browser location URL
* @param pathInfoParameters the path info parameters * @param pathInfoParameters the path info parameters
* @param queryStringParameters the query string parameters * @param queryStringParameters the query string parameters
* @return the c kan connector * @return the c kan connector
* @throws Exception the exception * @throws Exception the exception
*/ */
CkanConnectorAccessPoint getCKanConnector( 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. * Get the current role in CKAN for this user.
@ -75,9 +76,11 @@ public interface GcubeCkanDataCatalogService extends RemoteService {
boolean isManageProductEnabled(); 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);
/** /**

View File

@ -30,15 +30,16 @@ public interface GcubeCkanDataCatalogServiceAsync {
void getMyRole(AsyncCallback<RolesCkanGroupOrOrg> callback); void getMyRole(AsyncCallback<RolesCkanGroupOrOrg> 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 pathInfoParameters the path info parameters
* @param queryStringParameters the query string parameters * @param queryStringParameters the query string parameters
* @param callback the callback * @param callback the callback
* @return the c kan connector * @return the c kan connector
*/ */
void getCKanConnector( void getCKanConnector(
String pathInfoParameters, String queryStringParameters, String browserLocationURL, String pathInfoParameters, String queryStringParameters,
AsyncCallback<CkanConnectorAccessPoint> callback); AsyncCallback<CkanConnectorAccessPoint> callback);
/** /**
@ -73,12 +74,14 @@ public interface GcubeCkanDataCatalogServiceAsync {
*/ */
void isManageProductEnabled(AsyncCallback<Boolean> callback); void isManageProductEnabled(AsyncCallback<Boolean> 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 * @param callback the callback
*/ */
void isViewPerVREEnabled(AsyncCallback<String> callback); void isViewPerVREEnabled(String browserLocationURL, AsyncCallback<String> callback);
/** /**

View File

@ -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 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); 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, pathParameter, queryParameter,
new AsyncCallback<CkanConnectorAccessPoint>() { new AsyncCallback<CkanConnectorAccessPoint>() {
@ -122,10 +124,11 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
instanceCkanFrame(ckan.buildURI()); instanceCkanFrame(ckan.buildURI());
GCubeCkanDataCatalogPanel.this.rootPanel.remove(loading); GCubeCkanDataCatalogPanel.this.rootPanel.remove(loading);
String browserLocationURL = getBrowserLocationURL();
// check if view per organisation is enabled // check if view per organisation is enabled
//and performing some actions in this case (e.g. removed the management buttons, etc.) //and performing some actions in this case (e.g. removed the management buttons, etc.)
GCubeCkanDataCatalog.service.isViewPerVREEnabled(new AsyncCallback<String>() { GCubeCkanDataCatalog.service.isViewPerVREEnabled(browserLocationURL, new AsyncCallback<String>() {
@Override @Override
public void onSuccess(String result) { public void onSuccess(String result) {
@ -267,6 +270,26 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
listenForPostMessage(); 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(){ public static String getLatestSelectedProductIdentifier(){
return latestSelectedProductIdentifier; return latestSelectedProductIdentifier;

View File

@ -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) * @see org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GcubeCkanDataCatalogService#getCKanConnector(java.lang.String, java.lang.String)
*/ */
@Override @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+"]"); logger.info("getCKanConnector [pathInfo: "+pathInfoParameter + ", query: "+queryStringParameters+"]");
try{ try{
@ -106,10 +107,11 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
} }
if(pathInfoParameter == null || pathInfoParameter.isEmpty()){ 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); SessionUtil.saveCkanAccessPoint(this.getThreadLocalRequest().getSession(), scopePerCurrentUrl, ckAP);
logger.info("Built the URI to CKAN (connector in case of user logged): "+ckAP.buildURI()); logger.info("Built the URI to CKAN (connector in case of user logged): "+ckAP.buildURI());
logger.debug("returning ckanConnectorUri: "+ckAP); logger.debug("returning ckanConnectorUri: "+ckAP);
@ -125,13 +127,14 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
/** /**
* Gets the ckan connector access point. * Gets the ckan connector access point.
* *
* @param browserLocationURL the browser location URL
* @param pathInfoParameter the path info parameter * @param pathInfoParameter the path info parameter
* @param queryStringParameters the query string parameters * @param queryStringParameters the query string parameters
* @param scopePerCurrentUrl the scope per current url * @param scopePerCurrentUrl the scope per current url
* @return the ckan connector access point * @return the ckan connector access point
* @throws Exception the exception * @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()){ if(outsideLoginPortal()){
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(getCatalogue(scopePerCurrentUrl).getCatalogueUrl(),""); CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(getCatalogue(scopePerCurrentUrl).getCatalogueUrl(),"");
@ -186,7 +189,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
getThreadLocalRequest()).getEmail(), getThreadLocalRequest()).getEmail(),
scopePerCurrentUrl, scopePerCurrentUrl,
getCatalogue(scopePerCurrentUrl), getCatalogue(scopePerCurrentUrl),
isViewPerVREEnabled() != null, isViewPerVREEnabled(browserLocationURL) != null,
getThreadLocalRequest().getSession()); getThreadLocalRequest().getSession());
ckan.addListOfVREs(roleForVre); ckan.addListOfVREs(roleForVre);
@ -529,10 +532,11 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
/** /**
* Ask to liferay. * Ask to liferay.
* *
* @param browserLocationURL the browser location URL
* @return the string * @return the string
*/ */
@Override @Override
public String isViewPerVREEnabled(){ public String isViewPerVREEnabled(String browserLocationURL){
String toReturn = null; String toReturn = null;
String scopePerCurrentUrl = SessionUtil.getScopeFromClientUrl(getThreadLocalRequest());// the view per vre can be managed independently for each context SessionUtil.getScopeFromClientUrl(getThreadLocalRequest()); String scopePerCurrentUrl = SessionUtil.getScopeFromClientUrl(getThreadLocalRequest());// the view per vre can be managed independently for each context SessionUtil.getScopeFromClientUrl(getThreadLocalRequest());
@ -552,11 +556,22 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
GroupManager gm = new LiferayGroupManager(); GroupManager gm = new LiferayGroupManager();
enabled = (boolean) gm.readCustomAttr(gm.getGroupIdFromInfrastructureScope(scopePerCurrentUrl), VIEW_PER_ORGANIZATION_LIFERAY_CUSTOM_FIELD); enabled = (boolean) gm.readCustomAttr(gm.getGroupIdFromInfrastructureScope(scopePerCurrentUrl), VIEW_PER_ORGANIZATION_LIFERAY_CUSTOM_FIELD);
if(enabled){ if(enabled){
String groupName = gm.getGroup(gm.getGroupIdFromInfrastructureScope(scopePerCurrentUrl)).getGroupName().toLowerCase(); String groupName = gm.getGroup(gm.getGroupIdFromInfrastructureScope(scopePerCurrentUrl)).getGroupName().toLowerCase();
toReturn = "/organization_vre/" + groupName; logger.info("VRE name (toLowerCase) read by LF GroupManager is: "+groupName);
String secureVREName = "/"+groupName+"/";
if(browserLocationURL.toLowerCase().contains(secureVREName)){
//this should mean the caller (the location URL) is from VRE environment
logger.info("The browserLocationURL: "+browserLocationURL+ " contains the string /VRE name/ '"+secureVREName+"'. 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 string /VRE name/ '"+secureVREName+"'. The Catalogue Portlet should NOT be at VRE level. Ignoring configuration isViewPerVREEnabled");
}
} }
logger.debug("Read value for " + VIEW_PER_ORGANIZATION_LIFERAY_CUSTOM_FIELD + " is " + enabled + " and path is " + toReturn); logger.debug("Read value for " + VIEW_PER_ORGANIZATION_LIFERAY_CUSTOM_FIELD + " is " + enabled + " and path is " + toReturn);
}catch(Exception e){ }catch(Exception e){
logger.error("Failed to parse custom field value", e); logger.error("Failed to parse custom field value", e);
} }

View File

@ -1,26 +1,30 @@
//package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client; package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client;
//
//import com.google.gwt.junit.client.GWTTestCase;
// public class GwtTestGCubeCkanDataCatalog {
///**
// * GWT JUnit <b>integration</b> tests must extend GWTTestCase. private static String groupName = "sobigdatalab";
// * Using <code>"GwtTest*"</code> naming pattern exclude them from running with private static String browserLocationURL = "https://sobigdata.d4science.org/group/sobigdata-gateway/data-catalogue";
// * surefire during the test phase. /*
// * public static void main(String[] args) {
// * If you run the tests using the Maven command line, you will have to
// * navigate with your browser to a specific url given by Maven. String toReturn = null;
// * See https://gwt-maven-plugin.github.io/gwt-maven-plugin/user-guide/testing.html
// * for details. String secureVREName = "/" + groupName + "/";
// */ if (browserLocationURL.toLowerCase().contains(secureVREName)) {
//public class GwtTestGCubeCkanDataCatalog extends GWTTestCase { System.out.println("The browserLocationURL: " + browserLocationURL + " contains the VRE name '"
// + secureVREName
// /** + "' read by LF GroupManager. The Catalogue Portlet should be at VRE level, reading configuration isViewPerVREEnabled");
// * Must refer to a valid module that sources this class. toReturn = "/organization_vre/" + groupName;
// */ } else {
// public String getModuleName() { // this should mean the caller is out from VRE environment,so should be a public
// return "org.gcube.portlets.gcubeckan.gcubeckandatacatalog.GCubeCkanDataCatalogJUnit"; // or gateway catalogue
// } System.out.println("The browserLocationURL: " + browserLocationURL + " DOES NOT contain the VRE name '"
// + secureVREName
// + "' read by LF GroupManager. The Catalogue Portlet should NOT be at VRE level. Ignoring configuration isViewPerVREEnabled");
// }
//}
System.out.println("To return is: "+toReturn);
}*/
}