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
This commit is contained in:
Costantino Perciante 2017-12-01 17:06:25 +00:00
parent 29a6b281b2
commit 533f73b836
4 changed files with 21 additions and 23 deletions

View File

@ -83,5 +83,5 @@ public interface GcubeCkanDataCatalogService extends RemoteService {
/** /**
* Check if the management panels but publish/share link must be removed * Check if the management panels but publish/share link must be removed
*/ */
boolean isViewPerVREEnabled(); String isViewPerVREEnabled();
} }

View File

@ -85,5 +85,5 @@ public interface GcubeCkanDataCatalogServiceAsync {
*/ */
void isManageProductEnabled(AsyncCallback<Boolean> callback); void isManageProductEnabled(AsyncCallback<Boolean> callback);
void isViewPerVREEnabled(AsyncCallback<Boolean> callback); void isViewPerVREEnabled(AsyncCallback<String> callback);
} }

View File

@ -151,14 +151,17 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
}); });
// check if management buttons need to be removed // check if management buttons need to be removed
GCubeCkanDataCatalog.service.isViewPerVREEnabled(new AsyncCallback<Boolean>() { GCubeCkanDataCatalog.service.isViewPerVREEnabled(new AsyncCallback<String>() {
@Override @Override
public void onSuccess(Boolean result) { public void onSuccess(String result) {
if(result){ if(result != null && !result.isEmpty()){
// hide all management buttons // hide all management buttons
managementPanel.removeGenericManagementButtons(); managementPanel.removeGenericManagementButtons();
// set real relative path
ckanAccessPoint.addPathInfo(result);
} }
} }
@ -166,7 +169,7 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
// ?
} }
}); });

View File

@ -2,8 +2,6 @@ package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.server;
import static org.gcube.common.authorization.client.Constants.authorizationService; import static org.gcube.common.authorization.client.Constants.authorizationService;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -91,17 +89,11 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
queryStringParameters = new String(valueDecoded); queryStringParameters = new String(valueDecoded);
logger.info("queryStringParameters detected like Base64 and decoded like: "+queryStringParameters); 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); CkanConnectorAccessPoint ckAP = getCkanConnectorAccessPoint(pathInfoParameter, queryStringParameters, scopePerCurrentUrl);
SessionUtil.saveCkanAccessPoint(this.getThreadLocalRequest().getSession(), scopePerCurrentUrl, ckAP); SessionUtil.saveCkanAccessPoint(this.getThreadLocalRequest().getSession(), scopePerCurrentUrl, ckAP);
logger.info("Builded URI to CKAN Connector: "+ckAP.buildURI()); logger.info("Builded URI to CKAN Connector: "+ckAP.buildURI());
@ -556,20 +548,23 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
* @return * @return
*/ */
@Override @Override
public boolean isViewPerVREEnabled(){ public String isViewPerVREEnabled(){
boolean enabled = false; String toReturn = null;
String scopePerCurrentUrl = SessionUtil.getScopeFromClientUrl(getThreadLocalRequest()); String scopePerCurrentUrl = SessionUtil.getScopeFromClientUrl(getThreadLocalRequest());
boolean enabled = false;
try{ try{
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);
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){ }catch(Exception e){
logger.error("Failed to parse custom field value", e); logger.error("Failed to parse custom field value", e);
} }
return enabled; return toReturn;
} }