From 5bfd68274f98102e5e99a0f0fe2c36437445561c Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Tue, 27 Mar 2018 13:56:35 +0000 Subject: [PATCH] Added Deprecation and new methods git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@165467 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../server/utils/CatalogueUtilMethods.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/utils/CatalogueUtilMethods.java b/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/utils/CatalogueUtilMethods.java index 92c6fc8..9136507 100644 --- a/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/utils/CatalogueUtilMethods.java +++ b/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/utils/CatalogueUtilMethods.java @@ -3,6 +3,7 @@ package org.gcube.datacatalogue.ckanutillibrary.server.utils; import java.net.HttpURLConnection; import java.net.URL; +import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.impl.ScopeBean; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -19,19 +20,28 @@ public class CatalogueUtilMethods { /** * Maps the scope name to the ckan organization name + * Use getCKANOrganization() which uses current scope * @return */ + @Deprecated public static String getOrganizationNameFromScope(String scope){ - - if(scope == null || scope.isEmpty()) + if(scope == null || scope.isEmpty()) { throw new IllegalArgumentException("scope cannot be null"); - + } ScopeBean scopeBean = new ScopeBean(scope); return scopeBean.name().toLowerCase().replace(" ", "_").replace("-", "_"); } - - + + /** + * Get CKAN Organization name by using scope name + * + */ + public static String getCKANOrganization() { + ScopeBean scopeBean = new ScopeBean(ScopeProvider.instance.get()); + return scopeBean.name().toLowerCase().replace(" ", "_").replace("-", "_"); + } + /** * Ckan username has _ instead of . (that is, costantino.perciante -> costantino_perciante) * @param owner @@ -40,7 +50,6 @@ public class CatalogueUtilMethods { public static String fromUsernameToCKanUsername(String username){ if(username == null) return null; - return username.trim().replaceAll("\\.", "_"); }