Reorganizing code to properly support new and old IS
This commit is contained in:
parent
08530b490f
commit
335837e17c
|
@ -5,6 +5,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||||
import org.gcube.gcat.configuration.isproxies.GCoreISConfigurationProxy;
|
import org.gcube.gcat.configuration.isproxies.GCoreISConfigurationProxy;
|
||||||
|
import org.gcube.gcat.configuration.isproxies.RestISConfigurationProxy;
|
||||||
import org.gcube.gcat.configuration.service.ServiceCatalogueConfiguration;
|
import org.gcube.gcat.configuration.service.ServiceCatalogueConfiguration;
|
||||||
import org.gcube.gcat.persistence.ckan.CKANUserCache;
|
import org.gcube.gcat.persistence.ckan.CKANUserCache;
|
||||||
|
|
||||||
|
@ -19,10 +20,30 @@ public class CatalogueConfigurationFactory {
|
||||||
catalogueConfigurations = new HashMap<>();
|
catalogueConfigurations = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static ServiceCatalogueConfiguration load(String context) {
|
private static ServiceCatalogueConfiguration load(String context) {
|
||||||
|
RestISConfigurationProxy restISConfigurationProxy = new RestISConfigurationProxy(context);
|
||||||
|
ServiceCatalogueConfiguration serviceCatalogueConfiguration = restISConfigurationProxy.getCatalogueConfiguration();
|
||||||
|
if(serviceCatalogueConfiguration == null) {
|
||||||
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context);
|
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context);
|
||||||
return gCoreISConfigurationProxy.getCatalogueConfiguration();
|
serviceCatalogueConfiguration = gCoreISConfigurationProxy.getCatalogueConfiguration();
|
||||||
}
|
}
|
||||||
|
return serviceCatalogueConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void purgeFromIS(String context) {
|
||||||
|
RestISConfigurationProxy restISConfigurationProxy = new RestISConfigurationProxy(context);
|
||||||
|
restISConfigurationProxy.delete();
|
||||||
|
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context);
|
||||||
|
gCoreISConfigurationProxy.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void createOrUpdateOnIS(String context, ServiceCatalogueConfiguration catalogueConfiguration) throws Exception {
|
||||||
|
RestISConfigurationProxy restISConfigurationProxy = new RestISConfigurationProxy(context,catalogueConfiguration);
|
||||||
|
restISConfigurationProxy.createOrUpdateOnIS();
|
||||||
|
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context, catalogueConfiguration);
|
||||||
|
gCoreISConfigurationProxy.createOrUpdateOnIS();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public synchronized static ServiceCatalogueConfiguration getInstance() {
|
public synchronized static ServiceCatalogueConfiguration getInstance() {
|
||||||
String context = SecretManagerProvider.instance.get().getContext();
|
String context = SecretManagerProvider.instance.get().getContext();
|
||||||
|
@ -45,17 +66,14 @@ public class CatalogueConfigurationFactory {
|
||||||
// Remove the resource from IS
|
// Remove the resource from IS
|
||||||
String context = SecretManagerProvider.instance.get().getContext();
|
String context = SecretManagerProvider.instance.get().getContext();
|
||||||
catalogueConfigurations.remove(context);
|
catalogueConfigurations.remove(context);
|
||||||
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context);
|
purgeFromIS(context);
|
||||||
gCoreISConfigurationProxy.delete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static ServiceCatalogueConfiguration createOrUpdate(ServiceCatalogueConfiguration catalogueConfiguration) throws Exception {
|
public synchronized static ServiceCatalogueConfiguration createOrUpdate(ServiceCatalogueConfiguration catalogueConfiguration) throws Exception {
|
||||||
String context = SecretManagerProvider.instance.get().getContext();
|
String context = SecretManagerProvider.instance.get().getContext();
|
||||||
catalogueConfigurations.remove(context);
|
catalogueConfigurations.remove(context);
|
||||||
|
|
||||||
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context, catalogueConfiguration);
|
createOrUpdateOnIS(context, catalogueConfiguration);
|
||||||
catalogueConfiguration = gCoreISConfigurationProxy.createOrUpdateOnIS();
|
|
||||||
|
|
||||||
catalogueConfigurations.put(context, catalogueConfiguration);
|
catalogueConfigurations.put(context, catalogueConfiguration);
|
||||||
|
|
||||||
// The supported organizations could be changed we need to empty the user cache for the context
|
// The supported organizations could be changed we need to empty the user cache for the context
|
||||||
|
|
|
@ -63,6 +63,6 @@ public abstract class ISConfigurationProxy<ISResource extends Object> {
|
||||||
|
|
||||||
protected abstract ServiceCatalogueConfiguration updateOnIS(ISResource isResource) throws Exception;
|
protected abstract ServiceCatalogueConfiguration updateOnIS(ISResource isResource) throws Exception;
|
||||||
|
|
||||||
protected abstract void delete();
|
public abstract void delete();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class RestISConfigurationProxy extends ISConfigurationProxy<Configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void delete() {
|
public void delete() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue