gcat/src/main/java/org/gcube/gcat/persistence/ckan/CKANUtility.java

39 lines
908 B
Java
Raw Normal View History

package org.gcube.gcat.persistence.ckan;
import javax.ws.rs.InternalServerErrorException;
2022-02-16 22:34:30 +01:00
import org.gcube.gcat.configuration.CatalogueConfigurationFactory;
2023-07-13 10:48:33 +02:00
import org.gcube.gcat.persistence.ckan.cache.CKANUserCache;
2022-02-16 22:34:30 +01:00
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class CKANUtility {
2022-06-01 11:04:50 +02:00
public static String getCkanURL() {
try {
return CatalogueConfigurationFactory.getInstance().getCkanURL();
} catch(Exception e) {
throw new InternalServerErrorException(e);
}
}
public static String getSysAdminAPI() {
try {
return CatalogueConfigurationFactory.getInstance().getSysAdminToken();
} catch(Exception e) {
throw new InternalServerErrorException(e);
}
}
public static String getApiKey() {
try {
2019-09-16 12:00:49 +02:00
CKANUser ckanUser = CKANUserCache.getCurrrentCKANUser();
return ckanUser.getApiKey();
2019-09-16 14:48:18 +02:00
} catch(Exception e) {
throw new InternalServerErrorException(e);
}
}
}