From 0dc39399dd0bd5864f6cb802bdd74403384286e9 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Fri, 9 Nov 2018 10:35:22 +0000 Subject: [PATCH] Patched the method DataCatalogueImpl#gePortletUrl git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@174068 82a268e6-3cf1-43bd-a215-b396298e98cf --- distro/changelog.xml | 2 +- .../server/DataCatalogueImpl.java | 16 +++++++ .../server/DataCatalogueRunningCluster.java | 44 +++++++++---------- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/distro/changelog.xml b/distro/changelog.xml index 8a49ef5..3f221ef 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -2,7 +2,7 @@ - + Patched method DataCatalogueImpl#getPortletURL Added the possibility to deny social post on catalogue-ws #12514 diff --git a/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueImpl.java b/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueImpl.java index efc7e66..e3818d3 100644 --- a/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueImpl.java +++ b/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueImpl.java @@ -172,10 +172,26 @@ public class DataCatalogueImpl implements DataCatalogue{ @Override public String getPortletUrl() { + /* ScopeBean context = new ScopeBean(CONTEXT); String buildedUrl = PORTLET_URL_FOR_SCOPE.endsWith("/") ? PORTLET_URL_FOR_SCOPE : PORTLET_URL_FOR_SCOPE + "/"; buildedUrl += context.name().toLowerCase() + CATALOGUE_TAB_ENDING_URL; return buildedUrl; + */ + //PATCHED By Francesco + + ScopeBean context = new ScopeBean(CONTEXT); + + //CHECKING IF THE PORTLET URL CONTAINS THE VRE NAME INTO URL + if(PORTLET_URL_FOR_SCOPE.contains(context.name())){ + //THE PORLTET URL READ FROM GENERIC RESOUCE 'CkanPortlet' SHOULD BE ALREADY VALID + return PORTLET_URL_FOR_SCOPE; + }else{ + //ADDING VRE NAME AND THE SUFFIX 'CATALOGUE_TAB_ENDING_URL' TO URL + String buildedUrl = PORTLET_URL_FOR_SCOPE.endsWith("/") ? PORTLET_URL_FOR_SCOPE : PORTLET_URL_FOR_SCOPE + "/"; + buildedUrl += context.name().toLowerCase() + CATALOGUE_TAB_ENDING_URL; + return buildedUrl; + } } @Override diff --git a/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueRunningCluster.java b/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueRunningCluster.java index 7f6a0c2..052de54 100644 --- a/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueRunningCluster.java +++ b/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueRunningCluster.java @@ -54,7 +54,7 @@ public class DataCatalogueRunningCluster { // data catalogue info private final static String RUNTIME_CATALOGUE_RESOURCE_NAME = "CKanDataCatalogue"; - private final static String PLATFORM_CATALOGUE_NAME = "Tomcat"; + private final static String PLATFORM_CATALOGUE_NAME = "Tomcat"; // api key property for SYSADMIN private final static String API_KEY_PROPERTY = "API_KEY"; @@ -65,7 +65,7 @@ public class DataCatalogueRunningCluster { // property to retrieve the master service endpoint into the /root scope private final static String IS_MASTER_ROOT_KEY_PROPERTY = "IS_ROOT_MASTER"; // true, false.. missing means false as well private final static String IS_MANAGE_PRODUCT_ENABLED = "IS_MANAGE_PRODUCT_ENABLED"; // true, false.. missing means false as well (for GRSF records) - + private final static String SOCIAL_POST = "SOCIAL_POST"; private final static String ALERT_USERS_ON_POST_CREATION = "ALERT_USERS_ON_POST_CREATION"; private final static String SOLR_INDEX_ADDRESS = "SOLR_INDEX_ADDRESS"; @@ -74,7 +74,7 @@ public class DataCatalogueRunningCluster { private final static String URL_RESOLVER = "URL_RESOLVER"; // Other generic resource for delegating roles in groups to users - private final static String CATALOGUE_EXTENDING_ROLES = "CatalogueDelegateRoles"; + private final static String CATALOGUE_EXTENDING_ROLES = "CatalogueDelegateRoles"; // retrieved data private List datacatalogueUrls = new ArrayList(); @@ -92,7 +92,7 @@ public class DataCatalogueRunningCluster { private Map extendRoleInOrganization = new HashMap(0); // generic role key - public static final String CKAN_GENERIC_ROLE = "*"; + public static final String CKAN_GENERIC_ROLE = "*"; public static final String ROLE_ORGANIZATION_SEPARATOR = "|"; public static final String TUPLES_SEPARATOR = ","; @@ -148,8 +148,8 @@ public class DataCatalogueRunningCluster { /** * Evaluate the right configuration about ckan * @param resources - * @throws NoDataCatalogueRuntimeResourceException - * @throws ServiceEndPointException + * @throws NoDataCatalogueRuntimeResourceException + * @throws ServiceEndPointException */ private void evaluateRightConfigurationCatalogue( List resources) throws NoDataCatalogueRuntimeResourceException, ServiceEndPointException { @@ -170,7 +170,7 @@ public class DataCatalogueRunningCluster { Iterator accessPointIterator = res.profile().accessPoints().iterator(); while (accessPointIterator.hasNext()) { - ServiceEndpoint.AccessPoint accessPoint = (ServiceEndpoint.AccessPoint) accessPointIterator + ServiceEndpoint.AccessPoint accessPoint = accessPointIterator .next(); // get the is master property @@ -215,7 +215,7 @@ public class DataCatalogueRunningCluster { Iterator accessPointIterator = res.profile().accessPoints().iterator(); while (accessPointIterator.hasNext()) { - ServiceEndpoint.AccessPoint accessPoint = (ServiceEndpoint.AccessPoint) accessPointIterator + ServiceEndpoint.AccessPoint accessPoint = accessPointIterator .next(); // add this host @@ -230,7 +230,7 @@ public class DataCatalogueRunningCluster { catalogueEmail = accessPoint.propertyMap().get(CKAN_EMAIL_PROPERTY).value(); catalogueEmail = StringEncrypter.getEncrypter().decrypt(catalogueEmail); } - + // get the is manage product property Property entry = accessPoint.propertyMap().get(IS_MANAGE_PRODUCT_ENABLED); String isManageProduct = entry != null ? entry.value() : null; @@ -245,8 +245,8 @@ public class DataCatalogueRunningCluster { if(accessPoint.propertyMap().containsKey(SOCIAL_POST)) if(accessPoint.propertyMap().get(SOCIAL_POST).value().trim().equalsIgnoreCase("false")) socialPost = false; - - + + // retrieve option for user alert if(accessPoint.propertyMap().containsKey(ALERT_USERS_ON_POST_CREATION)) if(accessPoint.propertyMap().get(ALERT_USERS_ON_POST_CREATION).value().trim().equalsIgnoreCase("true")) @@ -295,7 +295,7 @@ public class DataCatalogueRunningCluster { Iterator accessPointIterator = res.profile().accessPoints().iterator(); while (accessPointIterator.hasNext()) { - ServiceEndpoint.AccessPoint accessPoint = (ServiceEndpoint.AccessPoint) accessPointIterator + ServiceEndpoint.AccessPoint accessPoint = accessPointIterator .next(); // get the is master property @@ -336,7 +336,7 @@ public class DataCatalogueRunningCluster { Iterator accessPointIterator = res.profile().accessPoints().iterator(); while (accessPointIterator.hasNext()) { - ServiceEndpoint.AccessPoint accessPoint = (ServiceEndpoint.AccessPoint) accessPointIterator + ServiceEndpoint.AccessPoint accessPoint = accessPointIterator .next(); // add this host @@ -391,7 +391,7 @@ public class DataCatalogueRunningCluster { List toReturn = client.submit(query); return toReturn; - } + } /** * Retrieve the url of the ckan portlet deployed into this scope @@ -411,7 +411,7 @@ public class DataCatalogueRunningCluster { DiscoveryClient client = client(); List appProfile = client.submit(q); - if (appProfile == null || appProfile.size() == 0) + if (appProfile == null || appProfile.size() == 0) throw new ApplicationProfileNotFoundException("Your applicationProfile is not registered in the infrastructure"); else { String elem = appProfile.get(0); @@ -424,13 +424,13 @@ public class DataCatalogueRunningCluster { if (currValue != null && currValue.size() > 0) { logger.debug("Portlet url found is " + currValue.get(0)); return currValue.get(0); - } + } } } catch (Exception e) { logger.error("Error while trying to fetch applicationProfile profile from the infrastructure", e); - } + } return null; @@ -438,9 +438,9 @@ public class DataCatalogueRunningCluster { /** * Parse the CatalogueDelegateRoles in this context - * @throws ParserConfigurationException - * @throws IOException - * @throws SAXException + * @throws ParserConfigurationException + * @throws IOException + * @throws SAXException */ private void parseExtendingRoles() throws ParserConfigurationException, SAXException, IOException { @@ -454,7 +454,7 @@ public class DataCatalogueRunningCluster { logger.debug("Resource for extending role has size " + appProfile.size()); - if (appProfile == null || appProfile.size() == 0) + if (appProfile == null || appProfile.size() == 0) return; else { String profile = appProfile.get(0); @@ -472,7 +472,7 @@ public class DataCatalogueRunningCluster { if(nodeI.getNodeType() == Node.ELEMENT_NODE) { - Element elem = (Element)nodeI; + Element elem = (Element)nodeI; String role = elem.getElementsByTagName("sourceRole").item(0).getTextContent(); String destOrg = elem.getElementsByTagName("destOrganization").item(0).getTextContent(); String sourceOrg = elem.getElementsByTagName("sourceOrganization").item(0).getTextContent();