Improving catalogue configuration management
This commit is contained in:
parent
117905ff7e
commit
5194e734aa
|
@ -1,4 +1,4 @@
|
|||
target
|
||||
.classpath
|
||||
.project
|
||||
/.DS_Store
|
||||
/**/.DS_Store
|
||||
|
|
|
@ -3,8 +3,10 @@ package org.gcube.gcat;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.gcat.configuration.isproxies.FacetBasedISConfigurationProxy;
|
||||
import org.gcube.gcat.configuration.isproxies.FacetBasedISConfigurationProxyFactory;
|
||||
import org.gcube.gcat.configuration.CatalogueConfigurationFactory;
|
||||
import org.gcube.gcat.configuration.isproxies.impl.FacetBasedISConfigurationProxy;
|
||||
import org.gcube.gcat.configuration.isproxies.impl.FacetBasedISConfigurationProxyFactory;
|
||||
import org.gcube.gcat.configuration.isproxies.impl.GCoreISConfigurationProxyFactory;
|
||||
import org.gcube.gcat.rest.RequestFilter;
|
||||
import org.gcube.smartgears.ApplicationManager;
|
||||
import org.gcube.smartgears.ContextProvider;
|
||||
|
@ -22,6 +24,8 @@ public class GCatInitializator implements ApplicationManager {
|
|||
*/
|
||||
private static Logger logger = LoggerFactory.getLogger(GCatInitializator.class);
|
||||
|
||||
public static boolean initialised;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* The method discover the plugins available on classpath and their own
|
||||
|
@ -49,8 +53,17 @@ public class GCatInitializator implements ApplicationManager {
|
|||
ApplicationContext applicationContext = ContextProvider.get();
|
||||
String gcatEServiceID = applicationContext.id();
|
||||
|
||||
|
||||
try {
|
||||
FacetBasedISConfigurationProxy facetBasedISConfigurationProxy = FacetBasedISConfigurationProxyFactory.getInstance(context);
|
||||
FacetBasedISConfigurationProxyFactory fbigcpf = new FacetBasedISConfigurationProxyFactory();
|
||||
FacetBasedISConfigurationProxy facetBasedISConfigurationProxy = fbigcpf.getInstance(context);
|
||||
if(!initialised) {
|
||||
CatalogueConfigurationFactory.addISConfigurationProxyFactory(fbigcpf);
|
||||
GCoreISConfigurationProxyFactory gcigcpf = new GCoreISConfigurationProxyFactory();
|
||||
CatalogueConfigurationFactory.addISConfigurationProxyFactory(gcigcpf);
|
||||
facetBasedISConfigurationProxy.installQueryTemplate();
|
||||
initialised = true;
|
||||
}
|
||||
facetBasedISConfigurationProxy.setGcatEServiceID(gcatEServiceID);
|
||||
facetBasedISConfigurationProxy.createCallsForToVirtualService();
|
||||
}catch (Exception e) {
|
||||
|
@ -58,6 +71,8 @@ public class GCatInitializator implements ApplicationManager {
|
|||
logger.trace("Gcat is not configured through the Facet Based IS in context {}. The reason is:\n", context, e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
logger.trace(
|
||||
"\n-------------------------------------------------------\n"
|
||||
+ "GCat Started Successfully on context {}\n"
|
||||
|
@ -97,7 +112,8 @@ public class GCatInitializator implements ApplicationManager {
|
|||
ApplicationContext applicationContext = ContextProvider.get();
|
||||
String gcatEServiceID = applicationContext.id();
|
||||
|
||||
FacetBasedISConfigurationProxy facetBasedISConfigurationProxy = FacetBasedISConfigurationProxyFactory.getInstance(context);
|
||||
FacetBasedISGcatConfigurationProxyFactory fbigcpf = new FacetBasedISGcatConfigurationProxyFactory();
|
||||
FacetBasedGcatISConfigurationProxy facetBasedISConfigurationProxy = fbigcpf.getInstance(context);
|
||||
facetBasedISConfigurationProxy.setGcatEServiceID(gcatEServiceID);
|
||||
try {
|
||||
facetBasedISConfigurationProxy.deleteCallsForToVirtualService();
|
||||
|
|
|
@ -1,58 +1,114 @@
|
|||
package org.gcube.gcat.configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.authorization.utils.manager.SecretManager;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.gcat.configuration.isproxies.GCoreISConfigurationProxy;
|
||||
import org.gcube.gcat.configuration.isproxies.GCoreISConfigurationProxyFactory;
|
||||
import org.gcube.gcat.configuration.isproxies.FacetBasedISConfigurationProxyFactory;
|
||||
import org.gcube.gcat.configuration.isproxies.FacetBasedISConfigurationProxy;
|
||||
import org.gcube.common.authorization.utils.secret.Secret;
|
||||
import org.gcube.gcat.configuration.isproxies.ISConfigurationProxy;
|
||||
import org.gcube.gcat.configuration.isproxies.ISConfigurationProxyFactory;
|
||||
import org.gcube.gcat.configuration.isproxies.impl.FacetBasedISConfigurationProxyFactory;
|
||||
import org.gcube.gcat.configuration.isproxies.impl.GCoreISConfigurationProxyFactory;
|
||||
import org.gcube.gcat.configuration.service.ServiceCatalogueConfiguration;
|
||||
import org.gcube.gcat.persistence.ckan.CKANUserCache;
|
||||
import org.gcube.gcat.utils.Constants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class CatalogueConfigurationFactory {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CatalogueConfigurationFactory.class);
|
||||
|
||||
private static final Map<String, ServiceCatalogueConfiguration> catalogueConfigurations;
|
||||
|
||||
private static List<ISConfigurationProxyFactory<?>> factories;
|
||||
|
||||
static {
|
||||
catalogueConfigurations = new HashMap<>();
|
||||
factories = new ArrayList<>();
|
||||
}
|
||||
|
||||
private static List<ISConfigurationProxyFactory<?>> getFactories(){
|
||||
if(factories.size()==0) {
|
||||
factories.add(new FacetBasedISConfigurationProxyFactory());
|
||||
factories.add(new GCoreISConfigurationProxyFactory());
|
||||
}
|
||||
return factories;
|
||||
}
|
||||
|
||||
public static void addISConfigurationProxyFactory(ISConfigurationProxyFactory<?> icpf) {
|
||||
factories.add(icpf);
|
||||
}
|
||||
|
||||
private static ServiceCatalogueConfiguration load(String context) {
|
||||
ServiceCatalogueConfiguration serviceCatalogueConfiguration = null;
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
try {
|
||||
FacetBasedISConfigurationProxy facetBasedISConfigurationProxy = FacetBasedISConfigurationProxyFactory.getInstance(context);
|
||||
serviceCatalogueConfiguration = facetBasedISConfigurationProxy.getCatalogueConfiguration();
|
||||
} catch(Throwable e){
|
||||
GCoreISConfigurationProxy gCoreISConfigurationProxy = GCoreISConfigurationProxyFactory.getInstance();
|
||||
serviceCatalogueConfiguration = gCoreISConfigurationProxy.getCatalogueConfiguration();
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
secretManager.startSession(secret);
|
||||
|
||||
for(ISConfigurationProxyFactory<?> icpf : getFactories()) {
|
||||
try {
|
||||
ISConfigurationProxy<?> icp = icpf.getInstance(context);
|
||||
|
||||
serviceCatalogueConfiguration = icp.getCatalogueConfiguration();
|
||||
logger.trace("The configuration has been read using {}.", icp.getClass().getSimpleName());
|
||||
}catch(Exception e){
|
||||
logger.warn("{} cannot be used to read {}. Reason is {}", icpf.getClass().getSimpleName(), ServiceCatalogueConfiguration.class.getSimpleName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
} catch(Exception e) {
|
||||
logger.error("Unable to start session. Reason is " + e.getMessage());
|
||||
} finally {
|
||||
secretManager.endSession();
|
||||
}
|
||||
|
||||
if(serviceCatalogueConfiguration==null) {
|
||||
throw new RuntimeException("Unable to load " + ServiceCatalogueConfiguration.class.getSimpleName() + " by using configured " + ISConfigurationProxyFactory.class.getSimpleName() + " i.e. " + getFactories());
|
||||
}
|
||||
return serviceCatalogueConfiguration;
|
||||
}
|
||||
|
||||
private static void purgeFromIS(String context) {
|
||||
FacetBasedISConfigurationProxy restISConfigurationProxy = FacetBasedISConfigurationProxyFactory.getInstance(context);
|
||||
restISConfigurationProxy.delete();
|
||||
|
||||
GCoreISConfigurationProxy gCoreISConfigurationProxy = GCoreISConfigurationProxyFactory.getInstance();
|
||||
gCoreISConfigurationProxy.delete();
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
try {
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
secretManager.startSession(secret);
|
||||
for(ISConfigurationProxyFactory<?> icpf : getFactories()) {
|
||||
ISConfigurationProxy<?> icp = icpf.getInstance(context);
|
||||
icp.delete();
|
||||
}
|
||||
} catch(Exception e) {
|
||||
logger.error("Unable to start session. Reason is " + e.getMessage());
|
||||
} finally {
|
||||
secretManager.endSession();
|
||||
}
|
||||
}
|
||||
|
||||
private static void createOrUpdateOnIS(String context, ServiceCatalogueConfiguration catalogueConfiguration) throws Exception {
|
||||
FacetBasedISConfigurationProxy restISConfigurationProxy = FacetBasedISConfigurationProxyFactory.getInstance(context);
|
||||
restISConfigurationProxy.setCatalogueConfiguration(catalogueConfiguration);
|
||||
restISConfigurationProxy.createOrUpdateOnIS();
|
||||
|
||||
GCoreISConfigurationProxy gCoreISConfigurationProxy = GCoreISConfigurationProxyFactory.getInstance();
|
||||
gCoreISConfigurationProxy.setCatalogueConfiguration(catalogueConfiguration);
|
||||
gCoreISConfigurationProxy.createOrUpdateOnIS();
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
try {
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
secretManager.startSession(secret);
|
||||
|
||||
for(ISConfigurationProxyFactory<?> icpf : getFactories()) {
|
||||
ISConfigurationProxy<?> icp = icpf.getInstance(context);
|
||||
icp.setCatalogueConfiguration(catalogueConfiguration);
|
||||
icp.createOrUpdateOnIS();
|
||||
}
|
||||
|
||||
} finally {
|
||||
secretManager.endSession();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public synchronized static ServiceCatalogueConfiguration getInstance() {
|
||||
String context = SecretManagerProvider.instance.get().getContext();
|
||||
ServiceCatalogueConfiguration catalogueConfiguration = catalogueConfigurations.get(context);
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
package org.gcube.gcat.configuration.isproxies;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
|
||||
public class FacetBasedISConfigurationProxyFactory {
|
||||
|
||||
private static final Map<String, FacetBasedISConfigurationProxy> isConfigurationProxies;
|
||||
|
||||
static {
|
||||
isConfigurationProxies = new HashMap<>();
|
||||
}
|
||||
|
||||
private static FacetBasedISConfigurationProxy find(String context) {
|
||||
FacetBasedISConfigurationProxy isConfigurationProxy = new FacetBasedISConfigurationProxy(context);
|
||||
return isConfigurationProxy;
|
||||
}
|
||||
|
||||
public synchronized static FacetBasedISConfigurationProxy getInstance(String context) {
|
||||
FacetBasedISConfigurationProxy isConfigurationProxy = isConfigurationProxies.get(context);
|
||||
if(isConfigurationProxy == null) {
|
||||
isConfigurationProxy = find(context);
|
||||
isConfigurationProxies.put(context, isConfigurationProxy);
|
||||
}
|
||||
return isConfigurationProxy;
|
||||
}
|
||||
|
||||
public static FacetBasedISConfigurationProxy getInstance() {
|
||||
String context = SecretManagerProvider.instance.get().getContext();
|
||||
return getInstance(context);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package org.gcube.gcat.configuration.isproxies;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
|
||||
public class GCoreISConfigurationProxyFactory {
|
||||
|
||||
private static final Map<String, GCoreISConfigurationProxy> isConfigurationProxies;
|
||||
|
||||
static {
|
||||
isConfigurationProxies = new HashMap<>();
|
||||
}
|
||||
|
||||
private static GCoreISConfigurationProxy find(String context) {
|
||||
GCoreISConfigurationProxy isConfigurationProxy = new GCoreISConfigurationProxy(context);
|
||||
return isConfigurationProxy;
|
||||
}
|
||||
|
||||
public synchronized static GCoreISConfigurationProxy getInstance(String context) {
|
||||
GCoreISConfigurationProxy isConfigurationProxy = isConfigurationProxies.get(context);
|
||||
if(isConfigurationProxy == null) {
|
||||
isConfigurationProxy = find(context);
|
||||
isConfigurationProxies.put(context, isConfigurationProxy);
|
||||
}
|
||||
return isConfigurationProxy;
|
||||
}
|
||||
|
||||
public static GCoreISConfigurationProxy getInstance() {
|
||||
String context = SecretManagerProvider.instance.get().getContext();
|
||||
return getInstance(context);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package org.gcube.gcat.configuration.isproxies;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public abstract class ISConfigurationProxyFactory<ISCP extends ISConfigurationProxy<?>> {
|
||||
|
||||
protected final Map<String, ISCP> isConfigurationProxies;
|
||||
|
||||
public ISConfigurationProxyFactory() {
|
||||
this.isConfigurationProxies = new HashMap<>();
|
||||
}
|
||||
|
||||
protected abstract ISCP newInstance(String context);
|
||||
|
||||
public synchronized ISCP getInstance(String context) {
|
||||
ISCP isConfigurationProxy = isConfigurationProxies.get(context);
|
||||
if(isConfigurationProxy == null) {
|
||||
isConfigurationProxy = newInstance(context);
|
||||
isConfigurationProxies.put(context, isConfigurationProxy);
|
||||
}
|
||||
return isConfigurationProxy;
|
||||
}
|
||||
|
||||
public ISCP getInstance() {
|
||||
String context = SecretManagerProvider.instance.get().getContext();
|
||||
return getInstance(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.gcat.configuration.isproxies;
|
||||
package org.gcube.gcat.configuration.isproxies.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
|
@ -18,6 +18,7 @@ import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
|||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.gcube.gcat.api.configuration.CatalogueConfiguration;
|
||||
import org.gcube.gcat.configuration.isproxies.ISConfigurationProxy;
|
||||
import org.gcube.gcat.configuration.service.FacetBasedISServiceCatalogueConfiguration;
|
||||
import org.gcube.gcat.configuration.service.ServiceCKANDB;
|
||||
import org.gcube.gcat.configuration.service.ServiceCatalogueConfiguration;
|
||||
|
@ -60,61 +61,52 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(FacetBasedISConfigurationProxy.class);
|
||||
|
||||
public static final String QUERY_TEMPLATE_DIRECTORY_NAME = "query-template";
|
||||
public static final String GCAT_ESERVICE_UUID_VARNAME = "$uuid";
|
||||
public static final String GET_CALLS_FOR_QUERY_TEMPLATE_FILENAME = "01-get-calls-for-query-template.json";
|
||||
public final String QUERY_TEMPLATE_DIRECTORY_NAME = "query-template";
|
||||
public final String GCAT_ESERVICE_UUID_VARNAME = "$uuid";
|
||||
public final String GET_CALLS_FOR_QUERY_TEMPLATE_FILENAME = "01-get-calls-for-query-template.json";
|
||||
|
||||
public static final String QUERY_DIRECTORY_NAME = "query";
|
||||
public static final String GET_CATALOGUE_VIRTUAL_SERVICE_FILENAME = "01-get-catalogue-virtual-service.json";
|
||||
public static final String GET_GCAT_CONFIGURATION_FILENAME = "02-get-gcat-configuration.json";
|
||||
public static final String GET_SIMPLE_FACET_OF_GCAT_CONFIGURATION_FILENAME = "03-get-simple-facet-of-gcat-configuration.json";
|
||||
public static final String GET_ACCESS_POINT_FACET_OF_CKAN_SERVICE_FILENAME = "05-get-access-point-facet-of-ckan-service.json";
|
||||
public static final String GET_ACCESS_POINT_FACET_OF_POSTGRES_CKAN_DB_FILENAME = "07-get-access-point-facet-of-postgres-ckan-db.json";
|
||||
public static final String GET_ACCESS_POINT_FACET_OF_SOLR_SERVICE_FILENAME = "09-get-access-point-facet-of-solr-service.json";
|
||||
|
||||
private static String queryTemplateName;
|
||||
|
||||
static {
|
||||
try {
|
||||
ResourceRegistryQueryTemplateClient rrqtc = ResourceRegistryQueryTemplateClientFactory.create();
|
||||
queryTemplateName = null;
|
||||
queryTemplateName = installQueryTemplate(rrqtc);
|
||||
} catch (Throwable e) {
|
||||
logger.error("Unable to install gcat Query Template on FacetBased IS.", e);
|
||||
}
|
||||
}
|
||||
public final String QUERY_DIRECTORY_NAME = "query";
|
||||
public final String GET_CATALOGUE_VIRTUAL_SERVICE_FILENAME = "01-get-catalogue-virtual-service.json";
|
||||
public final String GET_GCAT_CONFIGURATION_FILENAME = "02-get-gcat-configuration.json";
|
||||
public final String GET_SIMPLE_FACET_OF_GCAT_CONFIGURATION_FILENAME = "03-get-simple-facet-of-gcat-configuration.json";
|
||||
public final String GET_ACCESS_POINT_FACET_OF_CKAN_SERVICE_FILENAME = "05-get-access-point-facet-of-ckan-service.json";
|
||||
public final String GET_ACCESS_POINT_FACET_OF_POSTGRES_CKAN_DB_FILENAME = "07-get-access-point-facet-of-postgres-ckan-db.json";
|
||||
public final String GET_ACCESS_POINT_FACET_OF_SOLR_SERVICE_FILENAME = "09-get-access-point-facet-of-solr-service.json";
|
||||
|
||||
protected QueryTemplate queryTemplate;
|
||||
|
||||
protected static QueryTemplate getQueryTemplate() throws Exception {
|
||||
File queryTemplateFile = getJsonQueryTemplateFromFile(GET_CALLS_FOR_QUERY_TEMPLATE_FILENAME);
|
||||
public QueryTemplate getQueryTemplateFromFile(String queryTemplateFilename) throws Exception {
|
||||
File queryTemplateFile = getJsonQueryTemplateFromFile(queryTemplateFilename);
|
||||
FileReader fileReader = new FileReader(queryTemplateFile);
|
||||
QueryTemplate queryTemplate = ElementMapper.unmarshal(QueryTemplate.class, fileReader);
|
||||
return queryTemplate;
|
||||
}
|
||||
|
||||
protected static String installQueryTemplate(ResourceRegistryQueryTemplateClient rrqtc) throws Exception {
|
||||
QueryTemplate queryTemplate = getQueryTemplate();
|
||||
public QueryTemplate installQueryTemplate() throws Exception {
|
||||
/*
|
||||
* Going to create/update the query template.
|
||||
* No need to test if exists and/or if is the last version.
|
||||
*/
|
||||
queryTemplate = rrqtc.update(queryTemplate);
|
||||
|
||||
return queryTemplate.getName();
|
||||
return queryTemplate;
|
||||
}
|
||||
|
||||
protected static File getFile(String directoryName, String filename) throws Exception {
|
||||
protected File getBaseDirectory(String directoryName) {
|
||||
URL directoryURL = FacetBasedISConfigurationProxy.class.getClassLoader().getResource(directoryName);
|
||||
// File directory = new File(directoryURL.toURI());
|
||||
File directory = new File(directoryURL.getPath());
|
||||
return directory;
|
||||
}
|
||||
|
||||
protected File getFile(String directoryName, String filename) throws Exception {
|
||||
File directory = getBaseDirectory(directoryName);
|
||||
return new File(directory, filename);
|
||||
}
|
||||
|
||||
protected static File getJsonQueryTemplateFromFile(String filename) throws Exception {
|
||||
protected File getJsonQueryTemplateFromFile(String filename) throws Exception {
|
||||
return getFile(QUERY_TEMPLATE_DIRECTORY_NAME, filename);
|
||||
}
|
||||
|
||||
protected static File getJsonQueryFromFile(String filename) throws Exception {
|
||||
protected File getJsonQueryFromFile(String filename) throws Exception {
|
||||
return getFile(QUERY_DIRECTORY_NAME, filename);
|
||||
}
|
||||
|
||||
|
@ -167,6 +159,7 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
|||
protected final ObjectMapper objectMapper;
|
||||
protected final ResourceRegistryClient resourceRegistryClient;
|
||||
protected final ResourceRegistryPublisher resourceRegistryPublisher;
|
||||
protected final ResourceRegistryQueryTemplateClient rrqtc;
|
||||
|
||||
/*
|
||||
* We need to keep this resource because we want to create
|
||||
|
@ -181,12 +174,18 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
|||
|
||||
public FacetBasedISConfigurationProxy(String context) {
|
||||
super(context);
|
||||
if(FacetBasedISConfigurationProxy.queryTemplateName==null) {
|
||||
throw new RuntimeException(FacetBasedISConfigurationProxy.class.getSimpleName() + " cannot be used");
|
||||
}
|
||||
objectMapper = new ObjectMapper();
|
||||
|
||||
resourceRegistryClient = ResourceRegistryClientFactory.create();
|
||||
resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
|
||||
rrqtc = ResourceRegistryQueryTemplateClientFactory.create();
|
||||
|
||||
try {
|
||||
queryTemplate = getQueryTemplateFromFile(GET_CALLS_FOR_QUERY_TEMPLATE_FILENAME);
|
||||
}catch(Exception e) {
|
||||
throw new RuntimeException(FacetBasedISConfigurationProxy.class.getSimpleName() + " cannot be used", e);
|
||||
}
|
||||
objectMapper = new ObjectMapper();
|
||||
|
||||
}
|
||||
|
||||
public VirtualService getVirtualService() {
|
||||
|
@ -206,7 +205,7 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
|||
ObjectNode objectNode = objectMapper.createObjectNode();
|
||||
objectNode.put(GCAT_ESERVICE_UUID_VARNAME, gcatEServiceID);
|
||||
|
||||
List<CallsFor<EService, VirtualService>> callsForList = rrqtc.run(queryTemplateName, objectNode);
|
||||
List<CallsFor<EService, VirtualService>> callsForList = rrqtc.run(queryTemplate.getName(), objectNode);
|
||||
return callsForList;
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package org.gcube.gcat.configuration.isproxies.impl;
|
||||
|
||||
import org.gcube.gcat.configuration.isproxies.ISConfigurationProxyFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class FacetBasedISConfigurationProxyFactory extends ISConfigurationProxyFactory<FacetBasedISConfigurationProxy> {
|
||||
|
||||
public FacetBasedISConfigurationProxyFactory() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FacetBasedISConfigurationProxy newInstance(String context) {
|
||||
return new FacetBasedISConfigurationProxy(context);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.gcat.configuration.isproxies;
|
||||
package org.gcube.gcat.configuration.isproxies.impl;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
@ -33,6 +33,7 @@ import org.gcube.common.resources.gcore.utils.Group;
|
|||
import org.gcube.gcat.api.GCatConstants;
|
||||
import org.gcube.gcat.api.configuration.CatalogueConfiguration;
|
||||
import org.gcube.gcat.configuration.Version;
|
||||
import org.gcube.gcat.configuration.isproxies.ISConfigurationProxy;
|
||||
import org.gcube.gcat.configuration.service.ServiceCKANDB;
|
||||
import org.gcube.gcat.configuration.service.ServiceCatalogueConfiguration;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisher;
|
|
@ -0,0 +1,23 @@
|
|||
package org.gcube.gcat.configuration.isproxies.impl;
|
||||
|
||||
import org.gcube.gcat.configuration.isproxies.ISConfigurationProxyFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class GCoreISConfigurationProxyFactory extends ISConfigurationProxyFactory<GCoreISConfigurationProxy> {
|
||||
|
||||
public GCoreISConfigurationProxyFactory() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GCoreISConfigurationProxy newInstance(String context) {
|
||||
GCoreISConfigurationProxy isConfigurationProxy = new GCoreISConfigurationProxy(context);
|
||||
return isConfigurationProxy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@ import javax.ws.rs.InternalServerErrorException;
|
|||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.gcube.gcat.configuration.isproxies.FacetBasedISConfigurationProxy;
|
||||
import org.gcube.gcat.configuration.isproxies.impl.FacetBasedISConfigurationProxy;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
|
||||
protected final CKANUser ckanUser;
|
||||
|
||||
protected final CatalogueConfiguration configuration;
|
||||
protected CatalogueConfiguration configuration;
|
||||
|
||||
protected boolean updateOperation;
|
||||
|
||||
|
@ -141,24 +141,28 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
protected boolean keepModerationExtraProperties;
|
||||
|
||||
public CKANPackage() {
|
||||
this(CatalogueConfigurationFactory.getInstance());
|
||||
}
|
||||
|
||||
protected CKANPackage(CatalogueConfiguration configuration) {
|
||||
super();
|
||||
|
||||
LIST = ITEM_LIST;
|
||||
CREATE = ITEM_CREATE;
|
||||
READ = ITEM_SHOW;
|
||||
UPDATE = ITEM_UPDATE;
|
||||
PATCH = ITEM_PATCH;
|
||||
DELETE = ITEM_DELETE;
|
||||
PURGE = ITEM_PURGE;
|
||||
managedResources = new ArrayList<CKANResource>();
|
||||
this.LIST = ITEM_LIST;
|
||||
this.CREATE = ITEM_CREATE;
|
||||
this.READ = ITEM_SHOW;
|
||||
this.UPDATE = ITEM_UPDATE;
|
||||
this.PATCH = ITEM_PATCH;
|
||||
this.DELETE = ITEM_DELETE;
|
||||
this.PURGE = ITEM_PURGE;
|
||||
|
||||
configuration = CatalogueConfigurationFactory.getInstance();
|
||||
this.managedResources = new ArrayList<CKANResource>();
|
||||
|
||||
ckanUser = CKANUserCache.getCurrrentCKANUser();
|
||||
this.configuration = configuration;
|
||||
|
||||
updateOperation = false;
|
||||
keepModerationExtraProperties = true;
|
||||
|
||||
this.ckanUser = CKANUserCache.getCurrrentCKANUser();
|
||||
|
||||
this.updateOperation = false;
|
||||
this.keepModerationExtraProperties = true;
|
||||
}
|
||||
|
||||
public void setKeepModerationExtraProperties(boolean keepModerationExtraProperties) {
|
||||
|
@ -364,7 +368,7 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
/*
|
||||
* When a client provides the 'capacity' field as 'private', the item is not counted in the
|
||||
* total number of items in the GUI. We want to avoid such a behavior
|
||||
* See https://support.d4science.org/issues/16410
|
||||
* See https://support.d4science.org/issues/16410
|
||||
*/
|
||||
objectNode.remove(CAPACITY_KEY);
|
||||
}
|
||||
|
|
|
@ -53,11 +53,15 @@ public class CKANPackageTrash {
|
|||
protected boolean ownOnly;
|
||||
|
||||
public CKANPackageTrash() {
|
||||
mapper = new ObjectMapper();
|
||||
ckanUser = CKANUserCache.getCurrrentCKANUser();
|
||||
configuration = CatalogueConfigurationFactory.getInstance();
|
||||
supportedOrganizations = configuration.getSupportedOrganizations();
|
||||
ownOnly = true;
|
||||
this(CatalogueConfigurationFactory.getInstance());
|
||||
}
|
||||
|
||||
protected CKANPackageTrash(CatalogueConfiguration configuration) {
|
||||
this.mapper = new ObjectMapper();
|
||||
this.ckanUser = CKANUserCache.getCurrrentCKANUser();
|
||||
this.configuration = configuration;
|
||||
this.supportedOrganizations = configuration.getSupportedOrganizations();
|
||||
this.ownOnly = true;
|
||||
}
|
||||
|
||||
public void setOwnOnly(boolean ownOnly) {
|
||||
|
|
|
@ -54,16 +54,23 @@ public class CKANUser extends CKAN {
|
|||
protected Role role;
|
||||
protected Boolean catalogueModerator;
|
||||
|
||||
protected CatalogueConfiguration configuration;
|
||||
|
||||
public CKANUser() {
|
||||
this(CatalogueConfigurationFactory.getInstance());
|
||||
}
|
||||
|
||||
protected CKANUser(CatalogueConfiguration configuration) {
|
||||
super();
|
||||
LIST = USER_LIST;
|
||||
CREATE = USER_CREATE;
|
||||
READ = USER_SHOW;
|
||||
UPDATE = USER_UPDATE;
|
||||
PATCH = null;
|
||||
DELETE = USER_DELETE;
|
||||
PURGE = null;
|
||||
catalogueModerator = null;
|
||||
this.LIST = USER_LIST;
|
||||
this.CREATE = USER_CREATE;
|
||||
this.READ = USER_SHOW;
|
||||
this.UPDATE = USER_UPDATE;
|
||||
this.PATCH = null;
|
||||
this.DELETE = USER_DELETE;
|
||||
this.PURGE = null;
|
||||
this.catalogueModerator = null;
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.gcat.configuration.isproxies;
|
||||
package org.gcube.gcat.configuration.isproxies.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -24,7 +24,8 @@ public class FacetBasedISConfigurationProxyTest extends ContextTest {
|
|||
@Ignore
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
FacetBasedISConfigurationProxy fbiscp = FacetBasedISConfigurationProxyFactory.getInstance();
|
||||
FacetBasedISConfigurationProxyFactory facetBasedISConfigurationProxyFactory = new FacetBasedISConfigurationProxyFactory();
|
||||
FacetBasedISConfigurationProxy fbiscp = facetBasedISConfigurationProxyFactory.getInstance();
|
||||
fbiscp.setGcatEServiceID("f00bbacd-92b8-46d7-b41c-828f71a78753");
|
||||
CallsFor<EService, VirtualService> callsFor = fbiscp.createCallsForToVirtualService();
|
||||
logger.debug("Created {}", ElementMapper.marshal(callsFor));
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.gcat.configuration.isproxies;
|
||||
package org.gcube.gcat.configuration.isproxies.impl;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
|
@ -236,7 +236,7 @@ public class GRSFUtilities extends ContextTest {
|
|||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
@Test
|
||||
public void manageOrganizations() throws JsonProcessingException {
|
||||
String context = SecretManagerProvider.instance.get().getContext();
|
||||
ScopeBean scopeBean = new ScopeBean(context);
|
||||
|
@ -260,7 +260,7 @@ public class GRSFUtilities extends ContextTest {
|
|||
node.put("name", org.toLowerCase());
|
||||
String json = objectMapper.writeValueAsString(node);
|
||||
try {
|
||||
// ckanOrganization.create(json);
|
||||
ckanOrganization.create(json);
|
||||
// ckanOrganization.purge();
|
||||
}catch (Exception e) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue