Updated isViewePerVreEnable. Now it depends on BrowserLocationURL
This commit is contained in:
parent
3dfa8671b5
commit
f77edbfa1d
|
@ -4,6 +4,12 @@
|
||||||
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.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
|
## [v1.8.1] [r4.24.0] - 2020-06-18
|
||||||
|
|
||||||
Just to include the dependencies [#18700] and [#19479]
|
Just to include the dependencies [#18700] and [#19479]
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -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-SNAPSHOT</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>
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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,20 @@ 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;
|
//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);
|
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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue