grsf-publisher-ws/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/HelperMethods.java

39 lines
945 B
Java

package org.gcube.data_catalogue.grsf_publish_ws.utils;
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogueFactory;
/**
* Helper methods
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public abstract class HelperMethods {
/**
* Convert a group name to its id on ckan
* @param origName
* @return
*/
public static String getGroupNameOnCkan(String origName){
if(origName == null)
throw new IllegalArgumentException("origName cannot be null");
return origName.trim().toLowerCase().replaceAll("[^A-Za-z0-9_.]", "_");
}
/**
* Retrieve the running instance of the data catalogue for this scope
* @return
* @throws Exception
*/
public static DataCatalogue getDataCatalogueRunningInstance(String scope) throws Exception{
return DataCatalogueFactory.getFactory().getUtilsPerScope(scope);
}
}