This commit is contained in:
Fabio Sinibaldi 2019-03-20 16:53:00 +00:00
parent a4182fc2e4
commit 65b21c680b
26 changed files with 893 additions and 3 deletions

View File

@ -10,4 +10,8 @@ public interface CataloguePlugin {
public CatalogueController instantiateController(CatalogueInstanceDescriptor desc) throws ControllerInstantiationFault;
public void init() throws Exception;
public void initInScope() throws Exception;
}

View File

@ -21,4 +21,9 @@ public interface CollectorPlugin<E extends CustomData>{
public DataCollector<E> getCollector();
public ControllerConfiguration getPublisherControllerConfiguration(String catalogueType)throws CatalogueNotSupportedException;;
public void init() throws Exception;
public void initInScope() throws Exception;
}

View File

@ -13,4 +13,7 @@ public class ControllerConfiguration {
return onClash;
}
public void setOnClash(PublishingPolicy onClash) {
this.onClash = onClash;
}
}

View File

@ -84,6 +84,14 @@ public class GCatController implements CatalogueController{
if(isCustomToken())
resetToken();
// setting default configuration
config=new ControllerConfiguration();
config.setOnClash(PublishingPolicy.UPDATE);
}catch(ControllerInstantiationFault e) {
throw e;
}

View File

@ -64,14 +64,20 @@ public class Interactions {
@Test
public void duplicates() {
try {
publish(getController(),"full.json");
publish(getController(),"full.json");
publish(getController(),"full.json");
publish(getController(),"full.json");
}catch(Exception e) {
Assert.fail(e.getMessage());
}
}
@Test(expected=WrongObjectFormatException.class)
public void empties() throws CatalogueInteractionException, WrongObjectFormatException, PublicationException, ControllerInstantiationFault {
publish(getController(),"empties.json");
}
@Test(expected=PublicationException.class)
public void missingProfile() throws CatalogueInteractionException, WrongObjectFormatException, PublicationException, ControllerInstantiationFault {
publish(getController(),"missingProfile.json");

View File

@ -0,0 +1,7 @@
{
"profile" : null,
"item" : null,
"resources" : [
null,
null]
}

View File

@ -0,0 +1,151 @@
{
"profile": "<metadataformat type=\"My Profile\">\r\n <metadatafield categoryref=\"category1\">\r\n <fieldName>Field 1<\/fieldName>\r\n <mandatory>false<\/mandatory>\r\n <dataType>String<\/dataType>\r\n <defaultValue \/>\r\n <note>Write something here<\/note>\r\n <validator \/>\r\n <tagging create=\"true\" separator=\"-\">onFieldName<\/tagging>\r\n <\/metadatafield>\r\n <metadatafield categoryref=\"category1\">\r\n <fieldName>Field 2<\/fieldName>\r\n <mandatory>false<\/mandatory>\r\n <dataType>Boolean<\/dataType>\r\n <defaultValue>true<\/defaultValue>\r\n <note>Set true or false to the checkbox<\/note>\r\n <validator \/>\r\n <\/metadatafield>\r\n <metadatafield categoryref=\"category2\">\r\n <fieldName>Field 3<\/fieldName>\r\n <mandatory>true<\/mandatory>\r\n <dataType>String<\/dataType>\r\n <defaultValue>A<\/defaultValue>\r\n <note>A listbox of values<\/note>\r\n <vocabulary isMultiSelection=\"true\">\r\n <vocabularyField>A3<\/vocabularyField>\r\n <vocabularyField>B3<\/vocabularyField>\r\n <vocabularyField>C3<\/vocabularyField>\r\n <vocabularyField>D3<\/vocabularyField>\r\n <vocabularyField>E3<\/vocabularyField>\r\n <vocabularyField>F3<\/vocabularyField>\r\n <\/vocabulary>\r\n <validator \/>\r\n <tagging create=\"true\" separator=\"-\">onValue<\/tagging>\r\n <\/metadatafield>\r\n <metadatafield categoryref=\"category2\">\r\n <fieldName>Field 4<\/fieldName>\r\n <mandatory>true<\/mandatory>\r\n <dataType>Number<\/dataType>\r\n <defaultValue>4<\/defaultValue>\r\n <validator \/>\r\n <\/metadatafield>\r\n<\/metadataformat>",
"item": {
"license_title": "Creative Commons Attribution Share-Alike 4.0",
"maintainer": null,
"searchable": "true",
"relationships_as_object": [],
"private": true,
"maintainer_email": null,
"num_tags": 2,
"metadata_created": "2019-03-19T15:03:28.482434",
"metadata_modified": "2019-03-19T15:03:30.676258",
"author": "luca_frosini",
"author_email": "luca.frosini@gcube.ckan.org",
"state": "active",
"version": null,
"creator_user_id": "287b2eec-4cd7-4e50-817f-e6dce19995c7",
"type": "dataset",
"tags": [
{
"vocabulary_id": null,
"state": "active",
"display_name": "Other",
"id": "8ca635e2-4f72-48ed-8460-6734e9070a00",
"name": "Other"
},
{
"vocabulary_id": null,
"state": "active",
"display_name": "REST",
"id": "3d481290-b3cd-466f-8142-51608c616e60",
"name": "REST"
}
],
"groups": [],
"license_id": "CC-BY-SA-4.0",
"extras": [
{
"key": "FSKX_model_parameters:Input Parameter",
"value": "standard desviation of Temperatures( sdTemp): 2.9 °c( Double)"
},
{
"key": "FSKX_model_parameters:Output Parameter",
"value": ""
},
{
"key": "FSKX_model_scope:Hazard",
"value": ""
},
{
"key": "FSKX_model_scope:Population",
"value": ""
},
{
"key": "FSKX_model_scope:Product",
"value": ""
},
{
"key": "Item URL",
"value": "http://data.d4science.org/ctlg/AGINFRAplusDev/my_first_restful_transaction_model"
},
{
"key": "Model Author",
"value": ""
},
{
"key": "Model Creator",
"value": ""
},
{
"key": "Model ID",
"value": ""
},
{
"key": "Model Language",
"value": "Other"
},
{
"key": "Population",
"value": "Italian"
},
{
"key": "ReadMe",
"value": ""
},
{
"key": "Reference Description",
"value": ""
},
{
"key": "Related Identifier",
"value": ""
},
{
"key": "system:type",
"value": "My Profile"
}
]
},
"resources": [
{
"cache_last_updated": null,
"cache_url": null,
"mimetype_inner": null,
"hash": "",
"description": "",
"format": "",
"url": "https://data.d4science.org/shub/E_MHpyWDlKS2hPRGhKNk9ackxMY25pMDhZWEs1Z2dCTWEyNkNzbTdyMjZveDlON1RTWW9xa1FvVnprT3liSmRncA==",
"created": "2019-03-19T14:33:45.724709",
"state": "active",
"last_modified": null,
"mimetype": "application/pdf",
"url_type": null,
"position": 0,
"revision_id": "ad5fbd19-fe67-4141-ad44-cf41d90b95fb",
"size": null,
"datastore_active": false,
"resource_type": null,
"name": "RESTful Transaction Model"},
{"cache_last_updated":null,
"cache_url":null,
"mimetype_inner":null,
"hash":"",
"description":"",
"format":"",
"url":"https://data.d4science.org/shub/E_MHpyWDlKS2hPRGhKNk9ackxMY25pMDhZWEs1Z2dCTWEyNkNzbTdyMjZveDlON1RTWW9xa1FvVnprT3liSmRncA==","created":"2019-03-19T14:33:45.724709","state":"active","last_modified":null,"mimetype":"application/pdf","url_type":null,"position":0,"revision_id":"ad5fbd19-fe67-4141-ad44-cf41d90b95fb",
"size":null,
"datastore_active":false,
"resource_type":null,
"name":"RESTful Transaction Model"},
{
"cache_last_updated": null,
"cache_url": null,
"mimetype_inner": null,
"hash": "",
"description": "",
"format": "",
"url": "https://data.d4science.org/shub/E_MHpyWDlKS2hPRGhKNk9ackxMY25pMDhZWEs1Z2dCTWEyNkNzbTdyMjZveDlON1RTWW9xa1FvVnprT3liSmRncA==",
"created": "2019-03-19T14:33:45.724709",
"state": "active",
"last_modified": null,
"mimetype": "application/pdf",
"url_type": null,
"position": 0,
"revision_id": "ad5fbd19-fe67-4141-ad44-cf41d90b95fb",
"size": null,
"datastore_active": false,
"resource_type": null,
"name": "RESTful Transaction Model2"
},null]
}

View File

@ -0,0 +1,123 @@
{
"profile": null,
"item": {
"license_title": "Creative Commons Attribution Share-Alike 4.0",
"maintainer": null,
"searchable": "true",
"relationships_as_object": [],
"private": true,
"maintainer_email": null,
"num_tags": 2,
"metadata_created": "2019-03-19T15:03:28.482434",
"metadata_modified": "2019-03-19T15:03:30.676258",
"author": "luca_frosini",
"author_email": "luca.frosini@gcube.ckan.org",
"state": "active",
"version": null,
"creator_user_id": "287b2eec-4cd7-4e50-817f-e6dce19995c7",
"type": "dataset",
"tags": [
{
"vocabulary_id": null,
"state": "active",
"display_name": "Other",
"id": "8ca635e2-4f72-48ed-8460-6734e9070a00",
"name": "Other"
},
{
"vocabulary_id": null,
"state": "active",
"display_name": "REST",
"id": "3d481290-b3cd-466f-8142-51608c616e60",
"name": "REST"
}
],
"groups": [],
"license_id": "CC-BY-SA-4.0",
"extras": [
{
"key": "FSKX_model_parameters:Input Parameter",
"value": "standard desviation of Temperatures( sdTemp): 2.9 °c( Double)"
},
{
"key": "FSKX_model_parameters:Output Parameter",
"value": ""
},
{
"key": "FSKX_model_scope:Hazard",
"value": ""
},
{
"key": "FSKX_model_scope:Population",
"value": ""
},
{
"key": "FSKX_model_scope:Product",
"value": ""
},
{
"key": "Item URL",
"value": "http://data.d4science.org/ctlg/AGINFRAplusDev/my_first_restful_transaction_model"
},
{
"key": "Model Author",
"value": ""
},
{
"key": "Model Creator",
"value": ""
},
{
"key": "Model ID",
"value": ""
},
{
"key": "Model Language",
"value": "Other"
},
{
"key": "Population",
"value": "Italian"
},
{
"key": "ReadMe",
"value": ""
},
{
"key": "Reference Description",
"value": ""
},
{
"key": "Related Identifier",
"value": ""
},
{
"key": "system:type",
"value": "SomeFakeProfile"
}
]
},
"resources": [
{
"cache_last_updated": null,
"cache_url": null,
"mimetype_inner": null,
"hash": "",
"description": "",
"format": "",
"url": "https://data.d4science.org/shub/E_MHpyWDlKS2hPRGhKNk9ackxMY25pMDhZWEs1Z2dCTWEyNkNzbTdyMjZveDlON1RTWW9xa1FvVnprT3liSmRncA==",
"created": "2019-03-19T14:33:45.724709",
"state": "active",
"last_modified": null,
"mimetype": "application/pdf",
"url_type": null,
"position": 0,
"revision_id": "ad5fbd19-fe67-4141-ad44-cf41d90b95fb",
"size": null,
"datastore_active": false,
"resource_type": null,
"name": "RESTful Transaction Model"
},
null
]
}

View File

@ -0,0 +1,20 @@
{
"cache_last_updated": null,
"cache_url": null,
"mimetype_inner": null,
"hash": "",
"description": "",
"format": "",
"url": "https://data.d4science.org/shub/E_MHpyWDlKS2hPRGhKNk9ackxMY25pMDhZWEs1Z2dCTWEyNkNzbTdyMjZveDlON1RTWW9xa1FvVnprT3liSmRncA==",
"created": "2019-03-19T14:33:45.724709",
"state": "active",
"last_modified": null,
"mimetype": "application/pdf",
"url_type": null,
"position": 0,
"revision_id": "ad5fbd19-fe67-4141-ad44-cf41d90b95fb",
"size": null,
"datastore_active": false,
"resource_type": null,
"name": "RESTful Transaction Model"
}

View File

@ -0,0 +1,7 @@
{
"profile" : null,
"item" : null,
"resources" : [
null,
null]
}

View File

@ -0,0 +1,151 @@
{
"profile": "<metadataformat type=\"My Profile\">\r\n <metadatafield categoryref=\"category1\">\r\n <fieldName>Field 1<\/fieldName>\r\n <mandatory>false<\/mandatory>\r\n <dataType>String<\/dataType>\r\n <defaultValue \/>\r\n <note>Write something here<\/note>\r\n <validator \/>\r\n <tagging create=\"true\" separator=\"-\">onFieldName<\/tagging>\r\n <\/metadatafield>\r\n <metadatafield categoryref=\"category1\">\r\n <fieldName>Field 2<\/fieldName>\r\n <mandatory>false<\/mandatory>\r\n <dataType>Boolean<\/dataType>\r\n <defaultValue>true<\/defaultValue>\r\n <note>Set true or false to the checkbox<\/note>\r\n <validator \/>\r\n <\/metadatafield>\r\n <metadatafield categoryref=\"category2\">\r\n <fieldName>Field 3<\/fieldName>\r\n <mandatory>true<\/mandatory>\r\n <dataType>String<\/dataType>\r\n <defaultValue>A<\/defaultValue>\r\n <note>A listbox of values<\/note>\r\n <vocabulary isMultiSelection=\"true\">\r\n <vocabularyField>A3<\/vocabularyField>\r\n <vocabularyField>B3<\/vocabularyField>\r\n <vocabularyField>C3<\/vocabularyField>\r\n <vocabularyField>D3<\/vocabularyField>\r\n <vocabularyField>E3<\/vocabularyField>\r\n <vocabularyField>F3<\/vocabularyField>\r\n <\/vocabulary>\r\n <validator \/>\r\n <tagging create=\"true\" separator=\"-\">onValue<\/tagging>\r\n <\/metadatafield>\r\n <metadatafield categoryref=\"category2\">\r\n <fieldName>Field 4<\/fieldName>\r\n <mandatory>true<\/mandatory>\r\n <dataType>Number<\/dataType>\r\n <defaultValue>4<\/defaultValue>\r\n <validator \/>\r\n <\/metadatafield>\r\n<\/metadataformat>",
"item": {
"license_title": "Creative Commons Attribution Share-Alike 4.0",
"maintainer": null,
"searchable": "true",
"relationships_as_object": [],
"private": true,
"maintainer_email": null,
"num_tags": 2,
"metadata_created": "2019-03-19T15:03:28.482434",
"metadata_modified": "2019-03-19T15:03:30.676258",
"author": "luca_frosini",
"author_email": "luca.frosini@gcube.ckan.org",
"state": "active",
"version": null,
"creator_user_id": "287b2eec-4cd7-4e50-817f-e6dce19995c7",
"type": "dataset",
"tags": [
{
"vocabulary_id": null,
"state": "active",
"display_name": "Other",
"id": "8ca635e2-4f72-48ed-8460-6734e9070a00",
"name": "Other"
},
{
"vocabulary_id": null,
"state": "active",
"display_name": "REST",
"id": "3d481290-b3cd-466f-8142-51608c616e60",
"name": "REST"
}
],
"groups": [],
"license_id": "CC-BY-SA-4.0",
"extras": [
{
"key": "FSKX_model_parameters:Input Parameter",
"value": "standard desviation of Temperatures( sdTemp): 2.9 °c( Double)"
},
{
"key": "FSKX_model_parameters:Output Parameter",
"value": ""
},
{
"key": "FSKX_model_scope:Hazard",
"value": ""
},
{
"key": "FSKX_model_scope:Population",
"value": ""
},
{
"key": "FSKX_model_scope:Product",
"value": ""
},
{
"key": "Item URL",
"value": "http://data.d4science.org/ctlg/AGINFRAplusDev/my_first_restful_transaction_model"
},
{
"key": "Model Author",
"value": ""
},
{
"key": "Model Creator",
"value": ""
},
{
"key": "Model ID",
"value": ""
},
{
"key": "Model Language",
"value": "Other"
},
{
"key": "Population",
"value": "Italian"
},
{
"key": "ReadMe",
"value": ""
},
{
"key": "Reference Description",
"value": ""
},
{
"key": "Related Identifier",
"value": ""
},
{
"key": "system:type",
"value": "My Profile"
}
]
},
"resources": [
{
"cache_last_updated": null,
"cache_url": null,
"mimetype_inner": null,
"hash": "",
"description": "",
"format": "",
"url": "https://data.d4science.org/shub/E_MHpyWDlKS2hPRGhKNk9ackxMY25pMDhZWEs1Z2dCTWEyNkNzbTdyMjZveDlON1RTWW9xa1FvVnprT3liSmRncA==",
"created": "2019-03-19T14:33:45.724709",
"state": "active",
"last_modified": null,
"mimetype": "application/pdf",
"url_type": null,
"position": 0,
"revision_id": "ad5fbd19-fe67-4141-ad44-cf41d90b95fb",
"size": null,
"datastore_active": false,
"resource_type": null,
"name": "RESTful Transaction Model"},
{"cache_last_updated":null,
"cache_url":null,
"mimetype_inner":null,
"hash":"",
"description":"",
"format":"",
"url":"https://data.d4science.org/shub/E_MHpyWDlKS2hPRGhKNk9ackxMY25pMDhZWEs1Z2dCTWEyNkNzbTdyMjZveDlON1RTWW9xa1FvVnprT3liSmRncA==","created":"2019-03-19T14:33:45.724709","state":"active","last_modified":null,"mimetype":"application/pdf","url_type":null,"position":0,"revision_id":"ad5fbd19-fe67-4141-ad44-cf41d90b95fb",
"size":null,
"datastore_active":false,
"resource_type":null,
"name":"RESTful Transaction Model"},
{
"cache_last_updated": null,
"cache_url": null,
"mimetype_inner": null,
"hash": "",
"description": "",
"format": "",
"url": "https://data.d4science.org/shub/E_MHpyWDlKS2hPRGhKNk9ackxMY25pMDhZWEs1Z2dCTWEyNkNzbTdyMjZveDlON1RTWW9xa1FvVnprT3liSmRncA==",
"created": "2019-03-19T14:33:45.724709",
"state": "active",
"last_modified": null,
"mimetype": "application/pdf",
"url_type": null,
"position": 0,
"revision_id": "ad5fbd19-fe67-4141-ad44-cf41d90b95fb",
"size": null,
"datastore_active": false,
"resource_type": null,
"name": "RESTful Transaction Model2"
},null]
}

View File

@ -0,0 +1,123 @@
{
"profile": null,
"item": {
"license_title": "Creative Commons Attribution Share-Alike 4.0",
"maintainer": null,
"searchable": "true",
"relationships_as_object": [],
"private": true,
"maintainer_email": null,
"num_tags": 2,
"metadata_created": "2019-03-19T15:03:28.482434",
"metadata_modified": "2019-03-19T15:03:30.676258",
"author": "luca_frosini",
"author_email": "luca.frosini@gcube.ckan.org",
"state": "active",
"version": null,
"creator_user_id": "287b2eec-4cd7-4e50-817f-e6dce19995c7",
"type": "dataset",
"tags": [
{
"vocabulary_id": null,
"state": "active",
"display_name": "Other",
"id": "8ca635e2-4f72-48ed-8460-6734e9070a00",
"name": "Other"
},
{
"vocabulary_id": null,
"state": "active",
"display_name": "REST",
"id": "3d481290-b3cd-466f-8142-51608c616e60",
"name": "REST"
}
],
"groups": [],
"license_id": "CC-BY-SA-4.0",
"extras": [
{
"key": "FSKX_model_parameters:Input Parameter",
"value": "standard desviation of Temperatures( sdTemp): 2.9 °c( Double)"
},
{
"key": "FSKX_model_parameters:Output Parameter",
"value": ""
},
{
"key": "FSKX_model_scope:Hazard",
"value": ""
},
{
"key": "FSKX_model_scope:Population",
"value": ""
},
{
"key": "FSKX_model_scope:Product",
"value": ""
},
{
"key": "Item URL",
"value": "http://data.d4science.org/ctlg/AGINFRAplusDev/my_first_restful_transaction_model"
},
{
"key": "Model Author",
"value": ""
},
{
"key": "Model Creator",
"value": ""
},
{
"key": "Model ID",
"value": ""
},
{
"key": "Model Language",
"value": "Other"
},
{
"key": "Population",
"value": "Italian"
},
{
"key": "ReadMe",
"value": ""
},
{
"key": "Reference Description",
"value": ""
},
{
"key": "Related Identifier",
"value": ""
},
{
"key": "system:type",
"value": "SomeFakeProfile"
}
]
},
"resources": [
{
"cache_last_updated": null,
"cache_url": null,
"mimetype_inner": null,
"hash": "",
"description": "",
"format": "",
"url": "https://data.d4science.org/shub/E_MHpyWDlKS2hPRGhKNk9ackxMY25pMDhZWEs1Z2dCTWEyNkNzbTdyMjZveDlON1RTWW9xa1FvVnprT3liSmRncA==",
"created": "2019-03-19T14:33:45.724709",
"state": "active",
"last_modified": null,
"mimetype": "application/pdf",
"url_type": null,
"position": 0,
"revision_id": "ad5fbd19-fe67-4141-ad44-cf41d90b95fb",
"size": null,
"datastore_active": false,
"resource_type": null,
"name": "RESTful Transaction Model"
},
null
]
}

View File

@ -0,0 +1,20 @@
{
"cache_last_updated": null,
"cache_url": null,
"mimetype_inner": null,
"hash": "",
"description": "",
"format": "",
"url": "https://data.d4science.org/shub/E_MHpyWDlKS2hPRGhKNk9ackxMY25pMDhZWEs1Z2dCTWEyNkNzbTdyMjZveDlON1RTWW9xa1FvVnprT3liSmRncA==",
"created": "2019-03-19T14:33:45.724709",
"state": "active",
"last_modified": null,
"mimetype": "application/pdf",
"url_type": null,
"position": 0,
"revision_id": "ad5fbd19-fe67-4141-ad44-cf41d90b95fb",
"size": null,
"datastore_active": false,
"resource_type": null,
"name": "RESTful Transaction Model"
}

View File

@ -12,4 +12,11 @@ public class ServiceConstants {
public static final String EXECUTION_ID_PARAMETER="executionId";
}
public static interface Capabilities{
public static final String PATH="capabilities";
public static final String COLLECTORS_PATH="collectors";
public static final String CATALOGUES_PATH="catalogues";
}
}

View File

@ -14,4 +14,6 @@ public interface CatalogueControllersManager {
public void init() throws InternalError;
public void initInScope() throws InternalError;
}

View File

@ -12,4 +12,7 @@ public interface CollectorsManager {
public CollectorPlugin<?> getPluginById(String collectorId) throws CollectorNotFound;
public void init() throws InternalError;
public void initInScope() throws InternalError;
}

View File

@ -0,0 +1,80 @@
package org.gcube.data.publishing.gCatFeeder.service.engine.impl;
import java.util.Map.Entry;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import javax.inject.Singleton;
import org.gcube.data.publishing.gCatFeeder.catalogues.CataloguePlugin;
import org.gcube.data.publishing.gCatFeeder.service.engine.CatalogueControllersManager;
import org.gcube.data.publishing.gCatFeeder.service.model.fault.CataloguePluginNotFound;
import org.gcube.data.publishing.gCatFeeder.service.model.fault.InternalError;
import org.gcube.data.publishing.gCatFeeder.utils.ContextUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Singleton
public class CatalogueControllersManagerImpl implements CatalogueControllersManager {
private static final Logger log= LoggerFactory.getLogger(CatalogueControllersManagerImpl.class);
private ServiceLoader<CataloguePlugin> cataloguePluginsLoader = null;
private ConcurrentHashMap<String,CataloguePlugin> availablePlugins=null;
public CatalogueControllersManagerImpl() {
//load plugins
log.debug("Loading catalogue plugins...");
cataloguePluginsLoader=ServiceLoader.load(CataloguePlugin.class);
for(CataloguePlugin plugin:cataloguePluginsLoader) {
log.debug("Loading {} ",plugin.getClass());
log.debug("Descriptor {} ",plugin.getDescriptor());
availablePlugins.put(plugin.getDescriptor().getId(), plugin);
}
log.trace("Loaded {} catalogue plugins ",availablePlugins.size());
}
@Override
public Set<String> getAvailableControllers() {
return availablePlugins.keySet();
}
@Override
public CataloguePlugin getPluginById(String pluginId) throws CataloguePluginNotFound {
if(availablePlugins.containsKey(pluginId)) return availablePlugins.get(pluginId);
else throw new CataloguePluginNotFound("Catalogue plugin "+pluginId+" not available.");
}
@Override
public void init() throws InternalError {
log.trace("Static initialization...");
for(Entry<String,CataloguePlugin> entry:availablePlugins.entrySet()) {
log.debug("Static initialization for : {} ",entry.getKey());
try {
entry.getValue().init();
}catch(Throwable t) {
log.error("Unexpected exception while initializing {} ",entry.getKey(),t);
}
}
}
@Override
public void initInScope() throws InternalError {
log.trace("Initialization under scope {} ",ContextUtils.getCurrentScope());
for(Entry<String,CataloguePlugin> entry:availablePlugins.entrySet()) {
log.debug("Scope initialization for : {} ",entry.getKey());
try {
entry.getValue().initInScope();
}catch(Throwable t) {
log.error("Unexpected exception while initializing {} ",entry.getKey(),t);
}
}
}
}

View File

@ -0,0 +1,83 @@
package org.gcube.data.publishing.gCatFeeder.service.engine.impl;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import javax.inject.Singleton;
import org.gcube.data.publishing.gCatFeeder.catalogues.CataloguePlugin;
import org.gcube.data.publishing.gCatFeeder.service.engine.CollectorsManager;
import org.gcube.data.publishing.gCatFeeder.service.model.fault.CataloguePluginNotFound;
import org.gcube.data.publishing.gCatFeeder.service.model.fault.CollectorNotFound;
import org.gcube.data.publishing.gCatFeeder.service.model.fault.InternalError;
import org.gcube.data.publishing.gCatFeeder.utils.ContextUtils;
import org.gcube.data.publishing.gCatfeeder.collectors.CollectorPlugin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Singleton
public class CollectorsManagerImpl implements CollectorsManager {
private static final Logger log= LoggerFactory.getLogger(CollectorsManagerImpl.class);
private ServiceLoader<CollectorPlugin> collectorPluginsLoader = null;
private ConcurrentHashMap<String,CollectorPlugin> availablePlugins=null;
public CollectorsManagerImpl() {
//load plugins
log.debug("Loading collector plugins...");
collectorPluginsLoader=ServiceLoader.load(CollectorPlugin.class);
for(CollectorPlugin plugin:collectorPluginsLoader) {
log.debug("Loading {} ",plugin.getClass());
log.debug("Descriptor {} ",plugin.getDescriptor());
availablePlugins.put(plugin.getDescriptor().getName(), plugin);
}
log.trace("Loaded {} collector plugins ",availablePlugins.size());
}
@Override
public Set<String> getAvailableCollectors() {
return availablePlugins.keySet();
}
@Override
public CollectorPlugin<?> getPluginById(String collectorId) throws CollectorNotFound {
if(availablePlugins.containsKey(collectorId)) return availablePlugins.get(collectorId);
else throw new CollectorNotFound("Collector plugin "+collectorId+" not available.");
}
@Override
public void init() throws InternalError {
log.trace("Static initialization...");
for(Entry<String,CollectorPlugin> entry:availablePlugins.entrySet()) {
log.debug("Static initialization for : {} ",entry.getKey());
try {
entry.getValue().init();
}catch(Throwable t) {
log.error("Unexpected exception while initializing {} ",entry.getKey(),t);
}
}
}
@Override
public void initInScope() throws InternalError {
log.trace("Initialization under scope {} ",ContextUtils.getCurrentScope());
for(Entry<String,CollectorPlugin> entry:availablePlugins.entrySet()) {
log.debug("Scope initialization for : {} ",entry.getKey());
try {
entry.getValue().initInScope();
}catch(Throwable t) {
log.error("Unexpected exception while initializing {} ",entry.getKey(),t);
}
}
}
}

View File

@ -1,6 +1,5 @@
package org.gcube.data.publishing.gCatFeeder.service.engine.impl;
import java.io.File;
import java.io.Serializable;
import java.time.Instant;
import java.util.Set;
@ -11,7 +10,9 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.data.publishing.gCatFeeder.catalogues.CatalogueController;
import org.gcube.data.publishing.gCatFeeder.catalogues.CataloguePlugin;
import org.gcube.data.publishing.gCatFeeder.catalogues.model.PublishReport;
import org.gcube.data.publishing.gCatFeeder.catalogues.model.faults.CatalogueInteractionException;
import org.gcube.data.publishing.gCatFeeder.catalogues.model.faults.ControllerInstantiationFault;
import org.gcube.data.publishing.gCatFeeder.catalogues.model.faults.PublicationException;
import org.gcube.data.publishing.gCatFeeder.catalogues.model.faults.WrongObjectFormatException;
import org.gcube.data.publishing.gCatFeeder.model.CatalogueFormatData;
import org.gcube.data.publishing.gCatFeeder.model.CatalogueInstanceDescriptor;
@ -184,6 +185,10 @@ public class ExecutionTask implements Runnable {
PublishReport itemReport=controller.publishItem(item);
}catch(WrongObjectFormatException e) {
catalogueReport.getPublishedRecords().add(new PublishReport(false,"Wrong format : "+e.getMessage()));
} catch (CatalogueInteractionException e) {
catalogueReport.getPublishedRecords().add(new PublishReport(false,"Error while communicating with catalogue : "+e.getMessage()));
} catch (PublicationException e) {
catalogueReport.getPublishedRecords().add(new PublishReport(false,"Publication error : "+e.getMessage()));
}
}

View File

@ -0,0 +1,5 @@
package org.gcube.data.publishing.gCatFeeder.service.model;
public class CapabilitiesBean {
}

View File

@ -0,0 +1,74 @@
package org.gcube.data.publishing.gCatFeeder.service.rest;
import java.util.ArrayList;
import java.util.Collection;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.gcube.data.publishing.gCatFeeder.catalogues.model.CataloguePluginDescriptor;
import org.gcube.data.publishing.gCatFeeder.service.GCatFeederManager;
import org.gcube.data.publishing.gCatFeeder.service.ServiceConstants;
import org.gcube.data.publishing.gCatFeeder.service.engine.CatalogueControllersManager;
import org.gcube.data.publishing.gCatFeeder.service.engine.CollectorsManager;
import org.gcube.data.publishing.gCatfeeder.collectors.model.PluginDescriptor;
import org.gcube.smartgears.annotations.ManagedBy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ManagedBy(GCatFeederManager.class)
@Path(ServiceConstants.Executions.PATH)
public class Capabilities {
private static final Logger log= LoggerFactory.getLogger(Capabilities.class);
@Inject
private CatalogueControllersManager catalogues;
@Inject
private CollectorsManager collectors;
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path(ServiceConstants.Capabilities.COLLECTORS_PATH)
public Response getCollectorCapabilities() {
try {
ArrayList<PluginDescriptor> toReturn=new ArrayList<>();
for(String s:collectors.getAvailableCollectors()) {
toReturn.add(collectors.getPluginById(s).getDescriptor());
}
GenericEntity<Collection<PluginDescriptor>> entity=new GenericEntity<Collection<PluginDescriptor>>(toReturn) {};
return Response.ok(entity).build();
}catch(Throwable t) {
log.warn("Unexpected Exception ",t);
throw new WebApplicationException("Unexpected Exception.", t,Response.Status.INTERNAL_SERVER_ERROR);
}
}
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path(ServiceConstants.Capabilities.CATALOGUES_PATH)
public Response getCataloguesCapabilities() {
try {
ArrayList<CataloguePluginDescriptor> toReturn=new ArrayList<>();
for(String s:catalogues.getAvailableControllers()) {
toReturn.add(catalogues.getPluginById(s).getDescriptor());
}
GenericEntity<Collection<CataloguePluginDescriptor>> entity=new GenericEntity<Collection<CataloguePluginDescriptor>>(toReturn) {};
return Response.ok(entity).build();
}catch(Throwable t) {
log.warn("Unexpected Exception ",t);
throw new WebApplicationException("Unexpected Exception.", t,Response.Status.INTERNAL_SERVER_ERROR);
}
}
}

View File

@ -13,6 +13,7 @@ import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.gcube.data.publishing.gCatFeeder.service.GCatFeederManager;
import org.gcube.data.publishing.gCatFeeder.service.ServiceConstants;
import org.gcube.data.publishing.gCatFeeder.service.engine.FeederEngine;
import org.gcube.data.publishing.gCatFeeder.service.model.ExecutionDescriptor;
@ -21,9 +22,11 @@ import org.gcube.data.publishing.gCatFeeder.service.model.ExecutionRequest;
import org.gcube.data.publishing.gCatFeeder.service.model.fault.ElementNotFound;
import org.gcube.data.publishing.gCatFeeder.service.model.fault.InvalidRequest;
import org.gcube.data.publishing.gCatFeeder.service.model.fault.PersistenceError;
import org.gcube.smartgears.annotations.ManagedBy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ManagedBy(GCatFeederManager.class)
@Path(ServiceConstants.Executions.PATH)
public class Executions {