Implementing gcat customization

This commit is contained in:
luca.frosini 2023-06-23 18:11:25 +02:00
parent 602058caee
commit 4aa17d0b5a
19 changed files with 599 additions and 7 deletions

2
.gitignore vendored
View File

@ -2,4 +2,4 @@
/.project
/.settings
/.classpath
/.DS_Store
/**/.DS_Store

22
pom.xml
View File

@ -29,7 +29,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-smartgears-bom</artifactId>
<version>2.4.0</version>
<version>2.5.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -104,14 +104,34 @@
<version>2.3.32</version>
</dependency>
<dependency>
<groupId>org.gcube.resource-management</groupId>
<artifactId>gcube-model</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.information-system</groupId>
<artifactId>resource-registry-api</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.information-system</groupId>
<artifactId>resource-registry-client</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.information-system</groupId>
<artifactId>resource-registry-publisher</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.information-system</groupId>
<artifactId>resource-registry-query-template-client</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.resources</groupId>
<artifactId>common-gcore-resources</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.resources</groupId>
<artifactId>registry-publisher</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>

View File

@ -3,8 +3,14 @@ package org.gcube.grsf.publisher;
import java.io.IOException;
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.gcat.configuration.CatalogueConfigurationFactory;
import org.gcube.grsf.publisher.configuration.isproxies.impl.GRSFFacetBasedISConfigurationProxy;
import org.gcube.grsf.publisher.configuration.isproxies.impl.GRSFFacetBasedISConfigurationProxyFactory;
import org.gcube.grsf.publisher.configuration.isproxies.impl.GRSFGCoreISConfigurationProxyFactory;
import org.gcube.grsf.publisher.rest.RequestFilter;
import org.gcube.smartgears.ApplicationManager;
import org.gcube.smartgears.ContextProvider;
import org.gcube.smartgears.context.application.ApplicationContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -20,6 +26,9 @@ public class GRSFInitializator implements ApplicationManager {
public static final String NAME = "GRSF Publisher";
public static boolean initialised;
/**
* {@inheritDoc}
* The method discover the plugins available on classpath and their own
@ -44,10 +53,26 @@ public class GRSFInitializator implements ApplicationManager {
+ "-------------------------------------------------------",
NAME, context);
/*
ApplicationContext applicationContext = ContextProvider.get();
String grsfEServiceID = applicationContext.id();
*/
try {
GRSFFacetBasedISConfigurationProxyFactory fbigcpf = new GRSFFacetBasedISConfigurationProxyFactory();
GRSFFacetBasedISConfigurationProxy facetBasedISConfigurationProxy = fbigcpf.getInstance(context);
if(!initialised) {
CatalogueConfigurationFactory.addISConfigurationProxyFactory(fbigcpf);
GRSFGCoreISConfigurationProxyFactory gcigcpf = new GRSFGCoreISConfigurationProxyFactory();
CatalogueConfigurationFactory.addISConfigurationProxyFactory(gcigcpf);
facetBasedISConfigurationProxy.installQueryTemplate();
initialised = true;
}
facetBasedISConfigurationProxy.setServiceEServiceID(grsfEServiceID);
facetBasedISConfigurationProxy.createCallsForToVirtualService();
}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.trace("Gcat is not configured through the Facet Based IS in context {}. The reason is:\n", context, e);
}
logger.trace(
"\n-------------------------------------------------------\n"

View File

@ -0,0 +1,59 @@
package org.gcube.grsf.publisher.configuration.isproxies.impl;
import java.io.File;
import java.net.URL;
import org.gcube.gcat.configuration.isproxies.impl.FacetBasedISConfigurationProxy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class GRSFFacetBasedISConfigurationProxy extends FacetBasedISConfigurationProxy {
private static Logger logger = LoggerFactory.getLogger(GRSFFacetBasedISConfigurationProxy.class);
public GRSFFacetBasedISConfigurationProxy(String context) {
super(context);
serviceName = "grsf-publisher";
}
protected File getBaseDirectory(String directoryName) {
URL directoryURL = GRSFFacetBasedISConfigurationProxy.class.getClassLoader().getResource(directoryName);
File directory = new File(directoryURL.getPath());
return directory;
}
//
// Configuration
// ---------------------------
// IsCustomizedBy | |
// -----------------> | catalogue-configuration |
// / | |
// / ---------------------------
// EService VirtualService /
// ------------ -----------------------------
// | | CallsFor | |
// | grsf | ------------> | catalogue-virtual-service |
// | | | |
// ------------ -----------------------------
// \ EService
// \ --------------------
// \ Uses | |
// \ ------------------> | postgres-ckan-db |
// \ / | |
// \ EService / --------------------
// \ -----------------
// \ CallsFor | |
// -------------> | ckan |
// | |
// ----------------- EService
// \ --------------------
// \ Uses | |
// ------------------> | solr |
// | |
// --------------------
}

View File

@ -0,0 +1,20 @@
package org.gcube.grsf.publisher.configuration.isproxies.impl;
import org.gcube.gcat.configuration.isproxies.ISConfigurationProxyFactory;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class GRSFFacetBasedISConfigurationProxyFactory extends ISConfigurationProxyFactory<GRSFFacetBasedISConfigurationProxy> {
public GRSFFacetBasedISConfigurationProxyFactory() {
super();
}
@Override
protected GRSFFacetBasedISConfigurationProxy newInstance(String context) {
return new GRSFFacetBasedISConfigurationProxy(context);
}
}

View File

@ -0,0 +1,16 @@
package org.gcube.grsf.publisher.configuration.isproxies.impl;
import org.gcube.gcat.configuration.isproxies.impl.GCoreISConfigurationProxy;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class GRSFGCoreISConfigurationProxy extends GCoreISConfigurationProxy {
public GRSFGCoreISConfigurationProxy(String context) {
super(context);
}
}

View File

@ -0,0 +1,23 @@
package org.gcube.grsf.publisher.configuration.isproxies.impl;
import org.gcube.gcat.configuration.isproxies.ISConfigurationProxyFactory;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class GRSFGCoreISConfigurationProxyFactory extends ISConfigurationProxyFactory<GRSFGCoreISConfigurationProxy> {
public GRSFGCoreISConfigurationProxyFactory() {
super();
}
@Override
protected GRSFGCoreISConfigurationProxy newInstance(String context) {
GRSFGCoreISConfigurationProxy isConfigurationProxy = new GRSFGCoreISConfigurationProxy(context);
return isConfigurationProxy;
}
}

View File

@ -0,0 +1,39 @@
{
"type" : "QueryTemplate",
"name" : "GCat-Get-CallsFor-to-VirtualService",
"description" : "The following query return all CallsFor relation from the EService of gcat identified by the UUID provided as parameter to the Virtual Service with name 'catalogue-virtual-service'. The content of the request to run this query template will be something like {\"$uuid\": \"335580b6-c164-4506-980a-21e5bcf8dbcf\"}",
"template" : {
"type" : "CallsFor",
"source" : {
"type" : "EService",
"id" : "$uuid",
"consistsOf" : [ {
"type" : "IsIdentifiedBy",
"target" : {
"type" : "SoftwareFacet",
"group" : "org.gcube.data-catalogue",
"name" : "gcat"
}
} ]
},
"target" : {
"type" : "VirtualService",
"consistsOf" : [ {
"type" : "IsIdentifiedBy",
"target" : {
"type" : "SoftwareFacet",
"group" : "org.gcube.data-catalogue",
"name" : "catalogue-virtual-service"
}
} ]
}
},
"templateVariables" : {
"$uuid" : {
"type": "TemplateVariable",
"name": "$uuid",
"description": "The uuid of the gCat EService, e.g. 335580b6-c164-4506-980a-21e5bcf8dbcf. Please note that the default value has no meaning but we need a valid value so that the query can be tested by the resource-registry service.",
"defaultValue": "335580b6-c164-4506-980a-21e5bcf8dbcf"
}
}
}

View File

@ -0,0 +1,13 @@
{
"@class": "VirtualService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "org.gcube.data-catalogue",
"name": "catalogue-virtual-service"
}
}
]
}

View File

@ -0,0 +1,30 @@
{
"@class": "Configuration",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "IdentifierFacet",
"value": "catalogue-configuration"
}
}
],
"isRelatedTo": [
{
"@class": "IsCustomizedBy",
"source": {
"@class": "VirtualService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "org.gcube.data-catalogue",
"name": "catalogue-virtual-service"
}
}
]
}
}
]
}

View File

@ -0,0 +1,36 @@
{
"@class": "SimpleFacet",
"_in": {
"@class": "ConsistsOf",
"source": {
"@class": "Configuration",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "IdentifierFacet",
"value": "gcat-configuration"
}
}
],
"isRelatedTo": [
{
"@class": "IsCustomizedBy",
"source": {
"@class": "VirtualService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "org.gcube.data-catalogue",
"name": "catalogue-virtual-service"
}
}
]
}
}
]
}
}
}

View File

@ -0,0 +1,31 @@
{
"@class": "EService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "ckan-organization",
"name": "ckan"
}
}
],
"isRelatedTo": [
{
"@class": "CallsFor",
"source": {
"@class": "VirtualService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "org.gcube.data-catalogue",
"name": "catalogue-virtual-service"
}
}
]
}
}
]
}

View File

@ -0,0 +1,37 @@
{
"@class": "AccessPointFacet",
"_in": {
"@class": "ConsistsOf",
"source": {
"@class": "EService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "ckan-organization",
"name": "ckan"
}
}
],
"isRelatedTo": [
{
"@class": "CallsFor",
"source": {
"@class": "VirtualService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "org.gcube.data-catalogue",
"name": "catalogue-virtual-service"
}
}
]
}
}
]
}
}
}

View File

@ -0,0 +1,49 @@
{
"@class": "EService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "org.postgresql",
"name": "postgresql"
}
}
],
"isRelatedTo": [
{
"@class": "Uses",
"source": {
"@class": "EService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "ckan-organization",
"name": "ckan"
}
}
],
"isRelatedTo": [
{
"@class": "CallsFor",
"source": {
"@class": "VirtualService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "org.gcube.data-catalogue",
"name": "catalogue-virtual-service"
}
}
]
}
}
]
}
}
]
}

View File

@ -0,0 +1,55 @@
{
"@class": "AccessPointFacet",
"_in": {
"@class": "ConsistsOf",
"source": {
"@class": "EService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "org.postgresql",
"name": "postgresql"
}
}
],
"isRelatedTo": [
{
"@class": "Uses",
"source": {
"@class": "EService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "ckan-organization",
"name": "ckan"
}
}
],
"isRelatedTo": [
{
"@class": "CallsFor",
"source": {
"@class": "VirtualService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "org.gcube.data-catalogue",
"name": "catalogue-virtual-service"
}
}
]
}
}
]
}
}
]
}
}
}

View File

@ -0,0 +1,49 @@
{
"@class": "EService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "org.apache.solr",
"name": "solr"
}
}
],
"isRelatedTo": [
{
"@class": "Uses",
"source": {
"@class": "EService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "ckan-organization",
"name": "ckan"
}
}
],
"isRelatedTo": [
{
"@class": "CallsFor",
"source": {
"@class": "VirtualService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "org.gcube.data-catalogue",
"name": "catalogue-virtual-service"
}
}
]
}
}
]
}
}
]
}

View File

@ -0,0 +1,55 @@
{
"@class": "AccessPointFacet",
"_in": {
"@class": "ConsistsOf",
"source": {
"@class": "EService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "org.apache.solr",
"name": "solr"
}
}
],
"isRelatedTo": [
{
"@class": "Uses",
"source": {
"@class": "EService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "ckan-organization",
"name": "ckan"
}
}
],
"isRelatedTo": [
{
"@class": "CallsFor",
"source": {
"@class": "VirtualService",
"consistsOf": [
{
"@class": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"group": "org.gcube.data-catalogue",
"name": "catalogue-virtual-service"
}
}
]
}
}
]
}
}
]
}
}
}

View File

@ -0,0 +1,31 @@
Configuration
---------------------------
IsCustomizedBy | |
-----------------> | catalogue-configuration |
/ | |
/ ---------------------------
EService VirtualService /
------------ -----------------------------
| | CallsFor | |
| grsf | ------------> | catalogue-virtual-service |
| | | |
------------ -----------------------------
\ EService
\ --------------------
\ Uses | |
\ ------------------> | postgres-ckan-db |
\ / | |
\ EService / --------------------
\ -----------------
\ CallsFor | |
-------------> | ckan |
| |
----------------- EService
\ --------------------
\ Uses | |
------------------> | solr |
| |
--------------------

View File

@ -59,7 +59,8 @@ public class RecordTest extends ContextTest {
outputTypeDir.mkdir();
// File[] sourceFiles = examplesDir.listFiles(dirnameFilter);
File[] sourceFiles = new File[] { new File(examplesDir, "grsf") };
// File[] sourceFiles = new File[] { new File(examplesDir, "grsf") };
File[] sourceFiles = new File[] { new File(examplesDir, "ram") };
for (File source : sourceFiles) {
@ -69,7 +70,9 @@ public class RecordTest extends ContextTest {
outputSourceDir.mkdir();
// File[] jsonFiles = source.listFiles(filenameFilter);
File[] jsonFiles = new File[] {new File(source,"88818c3f-7120-322b-9637-7c7d2e9fc1e5.json")};
// File[] jsonFiles = new File[] {new File(source,"88818c3f-7120-322b-9637-7c7d2e9fc1e5.json")};
File[] jsonFiles = new File[] {new File(source,"00702023-0e2d-345d-8b20-60580c107acd.json")};
// File[] jsonFiles = new File[] {new File(source,"88818c3f-7120-322b-9637-7c7d2e9fc1e5.json")};
for (File jsonFile : jsonFiles) {
ObjectMapper mapper = new ObjectMapper();
@ -95,7 +98,8 @@ public class RecordTest extends ContextTest {
return;
}
record.create(mapper.writeValueAsString(input));
record.setName(input.get("grsf_uuid").asText());
//String ret = record.create(mapper.writeValueAsString(input));
record.purge();
}