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.gcat.configuration.isproxies.GCoreISConfigurationProxy;
|
||||
import org.gcube.gcat.configuration.isproxies.RestISConfigurationProxy;
|
||||
import org.gcube.gcat.configuration.service.ServiceCatalogueConfiguration;
|
||||
import org.gcube.gcat.persistence.ckan.CKANUserCache;
|
||||
|
||||
|
@ -19,11 +20,31 @@ public class CatalogueConfigurationFactory {
|
|||
catalogueConfigurations = new HashMap<>();
|
||||
}
|
||||
|
||||
protected static ServiceCatalogueConfiguration load(String context) {
|
||||
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context);
|
||||
return gCoreISConfigurationProxy.getCatalogueConfiguration();
|
||||
private static ServiceCatalogueConfiguration load(String context) {
|
||||
RestISConfigurationProxy restISConfigurationProxy = new RestISConfigurationProxy(context);
|
||||
ServiceCatalogueConfiguration serviceCatalogueConfiguration = restISConfigurationProxy.getCatalogueConfiguration();
|
||||
if(serviceCatalogueConfiguration == null) {
|
||||
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context);
|
||||
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() {
|
||||
String context = SecretManagerProvider.instance.get().getContext();
|
||||
ServiceCatalogueConfiguration catalogueConfiguration = catalogueConfigurations.get(context);
|
||||
|
@ -45,17 +66,14 @@ public class CatalogueConfigurationFactory {
|
|||
// Remove the resource from IS
|
||||
String context = SecretManagerProvider.instance.get().getContext();
|
||||
catalogueConfigurations.remove(context);
|
||||
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context);
|
||||
gCoreISConfigurationProxy.delete();
|
||||
purgeFromIS(context);
|
||||
}
|
||||
|
||||
public synchronized static ServiceCatalogueConfiguration createOrUpdate(ServiceCatalogueConfiguration catalogueConfiguration) throws Exception {
|
||||
String context = SecretManagerProvider.instance.get().getContext();
|
||||
catalogueConfigurations.remove(context);
|
||||
|
||||
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context, catalogueConfiguration);
|
||||
catalogueConfiguration = gCoreISConfigurationProxy.createOrUpdateOnIS();
|
||||
|
||||
createOrUpdateOnIS(context, catalogueConfiguration);
|
||||
catalogueConfigurations.put(context, catalogueConfiguration);
|
||||
|
||||
// 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 void delete();
|
||||
public abstract void delete();
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class RestISConfigurationProxy extends ISConfigurationProxy<Configuration
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void delete() {
|
||||
public void delete() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue