Merged with branch version task/19559
This commit is contained in:
parent
3dfa8671b5
commit
2855d07340
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
@ -26,7 +26,7 @@
|
|||
</attributes>
|
||||
</classpathentry>
|
||||
<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>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -36,5 +36,5 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</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>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
eclipse.preferences.version=1
|
||||
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
|
||||
warSrcDirIsOutput=false
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?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="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
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.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]
|
||||
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -14,7 +14,7 @@
|
|||
<groupId>org.gcube.portlets.gcubeckan</groupId>
|
||||
<artifactId>gcube-ckan-datacatalog</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>1.8.1</version>
|
||||
<version>1.9.0</version>
|
||||
<name>gCube CKAN Data Catalog</name>
|
||||
<description>The gCube CKAN Data Catalog portlet</description>
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,15 +30,16 @@ public interface GcubeCkanDataCatalogServiceAsync {
|
|||
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 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<CkanConnectorAccessPoint> callback);
|
||||
|
||||
/**
|
||||
|
@ -73,12 +74,14 @@ public interface GcubeCkanDataCatalogServiceAsync {
|
|||
*/
|
||||
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
|
||||
*/
|
||||
void isViewPerVREEnabled(AsyncCallback<String> callback);
|
||||
void isViewPerVREEnabled(String browserLocationURL, AsyncCallback<String> callback);
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<CkanConnectorAccessPoint>() {
|
||||
|
||||
|
@ -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<String>() {
|
||||
GCubeCkanDataCatalog.service.isViewPerVREEnabled(browserLocationURL, new AsyncCallback<String>() {
|
||||
|
||||
@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;
|
||||
|
|
|
@ -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,22 @@ 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;
|
||||
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);
|
||||
|
||||
}catch(Exception e){
|
||||
logger.error("Failed to parse custom field value", e);
|
||||
}
|
||||
|
|
|
@ -1,26 +1,30 @@
|
|||
//package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client;
|
||||
//
|
||||
//import com.google.gwt.junit.client.GWTTestCase;
|
||||
//
|
||||
///**
|
||||
// * GWT JUnit <b>integration</b> tests must extend GWTTestCase.
|
||||
// * Using <code>"GwtTest*"</code> naming pattern exclude them from running with
|
||||
// * surefire during the test phase.
|
||||
// *
|
||||
// * 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.
|
||||
// * See https://gwt-maven-plugin.github.io/gwt-maven-plugin/user-guide/testing.html
|
||||
// * for details.
|
||||
// */
|
||||
//public class GwtTestGCubeCkanDataCatalog extends GWTTestCase {
|
||||
//
|
||||
// /**
|
||||
// * Must refer to a valid module that sources this class.
|
||||
// */
|
||||
// public String getModuleName() {
|
||||
// return "org.gcube.portlets.gcubeckan.gcubeckandatacatalog.GCubeCkanDataCatalogJUnit";
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client;
|
||||
|
||||
|
||||
public class GwtTestGCubeCkanDataCatalog {
|
||||
|
||||
private static String groupName = "sobigdatalab";
|
||||
private static String browserLocationURL = "https://sobigdata.d4science.org/group/sobigdata-gateway/data-catalogue";
|
||||
/*
|
||||
public static void main(String[] args) {
|
||||
|
||||
String toReturn = null;
|
||||
|
||||
String secureVREName = "/" + groupName + "/";
|
||||
if (browserLocationURL.toLowerCase().contains(secureVREName)) {
|
||||
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");
|
||||
toReturn = "/organization_vre/" + groupName;
|
||||
} else {
|
||||
// this should mean the caller is out from VRE environment,so should be a public
|
||||
// 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);
|
||||
}*/
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue