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
This commit is contained in:
Luca Frosini 2018-03-27 13:56:35 +00:00
parent 6e778b331e
commit 5bfd68274f
1 changed files with 15 additions and 6 deletions

View File

@ -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,18 +20,27 @@ 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)
@ -40,7 +50,6 @@ public class CatalogueUtilMethods {
public static String fromUsernameToCKanUsername(String username){
if(username == null)
return null;
return username.trim().replaceAll("\\.", "_");
}