Porting naming to allow usage of gcat from other services as library
This commit is contained in:
parent
5194e734aa
commit
ce8f089de8
|
@ -64,7 +64,7 @@ public class GCatInitializator implements ApplicationManager {
|
||||||
facetBasedISConfigurationProxy.installQueryTemplate();
|
facetBasedISConfigurationProxy.installQueryTemplate();
|
||||||
initialised = true;
|
initialised = true;
|
||||||
}
|
}
|
||||||
facetBasedISConfigurationProxy.setGcatEServiceID(gcatEServiceID);
|
facetBasedISConfigurationProxy.setServiceEServiceID(gcatEServiceID);
|
||||||
facetBasedISConfigurationProxy.createCallsForToVirtualService();
|
facetBasedISConfigurationProxy.createCallsForToVirtualService();
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
logger.warn("Gcat is not configured through the Facet Based IS in context {}. Please create/addToContext the expected resources ASAP. The Gcore IS will be used.", context);
|
logger.warn("Gcat is not configured through the Facet Based IS in context {}. Please create/addToContext the expected resources ASAP. The Gcore IS will be used.", context);
|
||||||
|
|
|
@ -62,18 +62,19 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
||||||
private static Logger logger = LoggerFactory.getLogger(FacetBasedISConfigurationProxy.class);
|
private static Logger logger = LoggerFactory.getLogger(FacetBasedISConfigurationProxy.class);
|
||||||
|
|
||||||
public final String QUERY_TEMPLATE_DIRECTORY_NAME = "query-template";
|
public final String QUERY_TEMPLATE_DIRECTORY_NAME = "query-template";
|
||||||
public final String GCAT_ESERVICE_UUID_VARNAME = "$uuid";
|
public final String SERVICE_ESERVICE_UUID_VARNAME = "$uuid";
|
||||||
public final String GET_CALLS_FOR_QUERY_TEMPLATE_FILENAME = "01-get-calls-for-query-template.json";
|
public final String GET_CALLS_FOR_QUERY_TEMPLATE_FILENAME = "01-get-calls-for-query-template.json";
|
||||||
|
|
||||||
public final String QUERY_DIRECTORY_NAME = "query";
|
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_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_CATALOGUE_CONFIGURATION_FILENAME = "02-get-catalogue-configuration.json";
|
||||||
public final String GET_SIMPLE_FACET_OF_GCAT_CONFIGURATION_FILENAME = "03-get-simple-facet-of-gcat-configuration.json";
|
public final String GET_SIMPLE_FACET_OF_CATALOGUE_CONFIGURATION_FILENAME = "03-get-simple-facet-of-catalogue-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_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_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";
|
public final String GET_ACCESS_POINT_FACET_OF_SOLR_SERVICE_FILENAME = "09-get-access-point-facet-of-solr-service.json";
|
||||||
|
|
||||||
protected QueryTemplate queryTemplate;
|
protected QueryTemplate queryTemplate;
|
||||||
|
protected String serviceName;
|
||||||
|
|
||||||
public QueryTemplate getQueryTemplateFromFile(String queryTemplateFilename) throws Exception {
|
public QueryTemplate getQueryTemplateFromFile(String queryTemplateFilename) throws Exception {
|
||||||
File queryTemplateFile = getJsonQueryTemplateFromFile(queryTemplateFilename);
|
File queryTemplateFile = getJsonQueryTemplateFromFile(queryTemplateFilename);
|
||||||
|
@ -111,12 +112,12 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Configuration
|
// Configuration
|
||||||
// ----------------------
|
// ---------------------------
|
||||||
// IsCustomizedBy | |
|
// IsCustomizedBy | |
|
||||||
// -----------------> | gcat-configuration |
|
// -----------------> | catalogue-configuration |
|
||||||
// / | |
|
// / | |
|
||||||
// / ----------------------
|
// / ---------------------------
|
||||||
// EService VirtualService /
|
// EService VirtualService /
|
||||||
// ------------ -----------------------------
|
// ------------ -----------------------------
|
||||||
// | | CallsFor | |
|
// | | CallsFor | |
|
||||||
|
@ -170,11 +171,13 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
||||||
|
|
||||||
protected SimpleFacet configurationSimpleFacet;
|
protected SimpleFacet configurationSimpleFacet;
|
||||||
|
|
||||||
protected String gcatEServiceID;
|
protected String serviceEServiceID;
|
||||||
|
|
||||||
public FacetBasedISConfigurationProxy(String context) {
|
public FacetBasedISConfigurationProxy(String context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
|
||||||
|
serviceName = "gcat";
|
||||||
|
|
||||||
resourceRegistryClient = ResourceRegistryClientFactory.create();
|
resourceRegistryClient = ResourceRegistryClientFactory.create();
|
||||||
resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
|
resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
|
||||||
rrqtc = ResourceRegistryQueryTemplateClientFactory.create();
|
rrqtc = ResourceRegistryQueryTemplateClientFactory.create();
|
||||||
|
@ -184,8 +187,7 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
throw new RuntimeException(FacetBasedISConfigurationProxy.class.getSimpleName() + " cannot be used", e);
|
throw new RuntimeException(FacetBasedISConfigurationProxy.class.getSimpleName() + " cannot be used", e);
|
||||||
}
|
}
|
||||||
objectMapper = new ObjectMapper();
|
objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public VirtualService getVirtualService() {
|
public VirtualService getVirtualService() {
|
||||||
|
@ -195,15 +197,15 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
||||||
return virtualService;
|
return virtualService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGcatEServiceID(String gcatEServiceID) {
|
public void setServiceEServiceID(String serviceEServiceID) {
|
||||||
this.gcatEServiceID = gcatEServiceID;
|
this.serviceEServiceID = serviceEServiceID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CallsFor<EService, VirtualService>> getCallsForToVirtualService() throws Exception {
|
public List<CallsFor<EService, VirtualService>> getCallsForToVirtualService() throws Exception {
|
||||||
ResourceRegistryQueryTemplateClient rrqtc = ResourceRegistryQueryTemplateClientFactory.create();
|
ResourceRegistryQueryTemplateClient rrqtc = ResourceRegistryQueryTemplateClientFactory.create();
|
||||||
|
|
||||||
ObjectNode objectNode = objectMapper.createObjectNode();
|
ObjectNode objectNode = objectMapper.createObjectNode();
|
||||||
objectNode.put(GCAT_ESERVICE_UUID_VARNAME, gcatEServiceID);
|
objectNode.put(SERVICE_ESERVICE_UUID_VARNAME, serviceEServiceID);
|
||||||
|
|
||||||
List<CallsFor<EService, VirtualService>> callsForList = rrqtc.run(queryTemplate.getName(), objectNode);
|
List<CallsFor<EService, VirtualService>> callsForList = rrqtc.run(queryTemplate.getName(), objectNode);
|
||||||
return callsForList;
|
return callsForList;
|
||||||
|
@ -228,11 +230,11 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
||||||
|
|
||||||
int size = callsForList.size();
|
int size = callsForList.size();
|
||||||
|
|
||||||
UUID gcatEServiceUUID = UUID.fromString(gcatEServiceID);
|
UUID serviceEServiceUUID = UUID.fromString(serviceEServiceID);
|
||||||
|
|
||||||
if(size>1) {
|
if(size>1) {
|
||||||
logger.warn("There are {} instances of {} relation beetween gcat Eservice with UUID {} and the {} (catalogue-virtual-service). This is very strange because there should be only one. We are going to delete them and recreated a new one.",
|
logger.warn("There are {} instances of {} relation beetween {} Eservice with UUID {} and the {} (catalogue-virtual-service). This is very strange because there should be only one. We are going to delete them and recreated a new one.",
|
||||||
callsForList.size(), CallsFor.NAME, gcatEServiceID, VirtualService.NAME);
|
callsForList.size(), CallsFor.NAME, serviceName, serviceEServiceID, VirtualService.NAME);
|
||||||
logger.trace("{} relation instances that are going to be deleted are {}",
|
logger.trace("{} relation instances that are going to be deleted are {}",
|
||||||
CallsFor.NAME, ElementMapper.marshal(callsForList));
|
CallsFor.NAME, ElementMapper.marshal(callsForList));
|
||||||
deleteCallsForToVirtualService(callsForList);
|
deleteCallsForToVirtualService(callsForList);
|
||||||
|
@ -240,21 +242,21 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
||||||
}
|
}
|
||||||
|
|
||||||
if(size==0) {
|
if(size==0) {
|
||||||
logger.info("Going to create {} between {} (gcat with UUID={}) and the {}",
|
logger.info("Going to create {} between {} ({} with UUID={}) and the {}",
|
||||||
CallsFor.NAME, EService.NAME, gcatEServiceID, VirtualService.NAME);
|
CallsFor.NAME, EService.NAME, serviceName, serviceEServiceID, VirtualService.NAME);
|
||||||
PropagationConstraint propagationConstraint = new PropagationConstraintImpl();
|
PropagationConstraint propagationConstraint = new PropagationConstraintImpl();
|
||||||
propagationConstraint.setAddConstraint(AddConstraint.unpropagate);
|
propagationConstraint.setAddConstraint(AddConstraint.unpropagate);
|
||||||
propagationConstraint.setRemoveConstraint(RemoveConstraint.keep);
|
propagationConstraint.setRemoveConstraint(RemoveConstraint.keep);
|
||||||
propagationConstraint.setDeleteConstraint(DeleteConstraint.keep);
|
propagationConstraint.setDeleteConstraint(DeleteConstraint.keep);
|
||||||
EService gcatEService = new EServiceImpl();
|
EService serviceEService = new EServiceImpl();
|
||||||
gcatEService.setID(gcatEServiceUUID);
|
serviceEService.setID(serviceEServiceUUID);
|
||||||
VirtualService virtualService = queryVirtualService();
|
VirtualService virtualService = queryVirtualService();
|
||||||
callsFor = new CallsForImpl<EService, VirtualService>(gcatEService, virtualService, propagationConstraint);
|
callsFor = new CallsForImpl<EService, VirtualService>(serviceEService, virtualService, propagationConstraint);
|
||||||
callsFor = resourceRegistryPublisher.create(callsFor);
|
callsFor = resourceRegistryPublisher.create(callsFor);
|
||||||
}else if(size==1){
|
}else if(size==1){
|
||||||
callsFor = callsForList.get(0);
|
callsFor = callsForList.get(0);
|
||||||
logger.info("{} between {} (gcat with UUID={}) and the {} exists.\n{}",
|
logger.info("{} between {} ({} with UUID={}) and the {} exists.\n{}",
|
||||||
CallsFor.NAME, EService.NAME, gcatEServiceID, VirtualService.NAME, ElementMapper.marshal(callsFor));
|
CallsFor.NAME, EService.NAME, serviceName, serviceEServiceID, VirtualService.NAME, ElementMapper.marshal(callsFor));
|
||||||
}
|
}
|
||||||
|
|
||||||
return callsFor;
|
return callsFor;
|
||||||
|
@ -309,13 +311,13 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Configuration queryGcatConfiguration() throws Exception {
|
protected Configuration queryServiceConfiguration() throws Exception {
|
||||||
Configuration configuration = (Configuration) queryEntity(GET_GCAT_CONFIGURATION_FILENAME);
|
Configuration configuration = (Configuration) queryEntity(GET_CATALOGUE_CONFIGURATION_FILENAME);
|
||||||
return configuration;
|
return configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SimpleFacet queryConfigurationSimpleFacet() throws Exception {
|
protected SimpleFacet queryConfigurationSimpleFacet() throws Exception {
|
||||||
SimpleFacet configurationSimpleFacet = (SimpleFacet) queryEntity(GET_SIMPLE_FACET_OF_GCAT_CONFIGURATION_FILENAME);
|
SimpleFacet configurationSimpleFacet = (SimpleFacet) queryEntity(GET_SIMPLE_FACET_OF_CATALOGUE_CONFIGURATION_FILENAME);
|
||||||
return configurationSimpleFacet;
|
return configurationSimpleFacet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,8 +485,8 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
||||||
protected ServiceCatalogueConfiguration createOnIS() throws Exception {
|
protected ServiceCatalogueConfiguration createOnIS() throws Exception {
|
||||||
UUID uuid = configurationSimpleFacet.getID();
|
UUID uuid = configurationSimpleFacet.getID();
|
||||||
if(uuid==null) {
|
if(uuid==null) {
|
||||||
Configuration gcatConfiguration = queryGcatConfiguration();
|
Configuration configuration = queryServiceConfiguration();
|
||||||
ConsistsOf<Configuration, SimpleFacet> co = new ConsistsOfImpl<>(gcatConfiguration, configurationSimpleFacet);
|
ConsistsOf<Configuration, SimpleFacet> co = new ConsistsOfImpl<>(configuration, configurationSimpleFacet);
|
||||||
co = resourceRegistryPublisher.create(co);
|
co = resourceRegistryPublisher.create(co);
|
||||||
configurationSimpleFacet = co.getTarget();
|
configurationSimpleFacet = co.getTarget();
|
||||||
setConfigurationInfoFromSimpleFacet(configurationSimpleFacet, catalogueConfiguration);
|
setConfigurationInfoFromSimpleFacet(configurationSimpleFacet, catalogueConfiguration);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"@class": "IsIdentifiedBy",
|
"@class": "IsIdentifiedBy",
|
||||||
"target": {
|
"target": {
|
||||||
"@class": "IdentifierFacet",
|
"@class": "IdentifierFacet",
|
||||||
"value": "gcat-configuration"
|
"value": "catalogue-configuration"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
|
@ -1,10 +1,10 @@
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
----------------------
|
---------------------------
|
||||||
IsCustomizedBy | |
|
IsCustomizedBy | |
|
||||||
-----------------> | gcat-configuration |
|
-----------------> | catalogue-configuration |
|
||||||
/ | |
|
/ | |
|
||||||
/ ----------------------
|
/ ---------------------------
|
||||||
EService VirtualService /
|
EService VirtualService /
|
||||||
------------ -----------------------------
|
------------ -----------------------------
|
||||||
| | CallsFor | |
|
| | CallsFor | |
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class FacetBasedISConfigurationProxyTest extends ContextTest {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
FacetBasedISConfigurationProxyFactory facetBasedISConfigurationProxyFactory = new FacetBasedISConfigurationProxyFactory();
|
FacetBasedISConfigurationProxyFactory facetBasedISConfigurationProxyFactory = new FacetBasedISConfigurationProxyFactory();
|
||||||
FacetBasedISConfigurationProxy fbiscp = facetBasedISConfigurationProxyFactory.getInstance();
|
FacetBasedISConfigurationProxy fbiscp = facetBasedISConfigurationProxyFactory.getInstance();
|
||||||
fbiscp.setGcatEServiceID("f00bbacd-92b8-46d7-b41c-828f71a78753");
|
fbiscp.setServiceEServiceID("f00bbacd-92b8-46d7-b41c-828f71a78753");
|
||||||
CallsFor<EService, VirtualService> callsFor = fbiscp.createCallsForToVirtualService();
|
CallsFor<EService, VirtualService> callsFor = fbiscp.createCallsForToVirtualService();
|
||||||
logger.debug("Created {}", ElementMapper.marshal(callsFor));
|
logger.debug("Created {}", ElementMapper.marshal(callsFor));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue