diff --git a/catalogue-plugin-framework/src/main/java/org/gcube/data/publishing/gCatFeeder/catalogues/CatalogueController.java b/catalogue-plugin-framework/src/main/java/org/gcube/data/publishing/gCatFeeder/catalogues/CatalogueController.java
index 4a0abe6..a36014c 100644
--- a/catalogue-plugin-framework/src/main/java/org/gcube/data/publishing/gCatFeeder/catalogues/CatalogueController.java
+++ b/catalogue-plugin-framework/src/main/java/org/gcube/data/publishing/gCatFeeder/catalogues/CatalogueController.java
@@ -1,12 +1,15 @@
package org.gcube.data.publishing.gCatFeeder.catalogues;
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.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.ControllerConfiguration;
public interface CatalogueController {
- public PublishReport publishItem(CatalogueFormatData toPublish) throws WrongObjectFormatException;
-
+ public PublishReport publishItem(CatalogueFormatData toPublish) throws WrongObjectFormatException,CatalogueInteractionException,PublicationException;
+ public void configure (ControllerConfiguration config);
}
diff --git a/catalogue-plugin-framework/src/main/java/org/gcube/data/publishing/gCatFeeder/catalogues/model/faults/CatalogueInteractionException.java b/catalogue-plugin-framework/src/main/java/org/gcube/data/publishing/gCatFeeder/catalogues/model/faults/CatalogueInteractionException.java
new file mode 100644
index 0000000..03037dd
--- /dev/null
+++ b/catalogue-plugin-framework/src/main/java/org/gcube/data/publishing/gCatFeeder/catalogues/model/faults/CatalogueInteractionException.java
@@ -0,0 +1,30 @@
+package org.gcube.data.publishing.gCatFeeder.catalogues.model.faults;
+
+public class CatalogueInteractionException extends PublicationException {
+
+ public CatalogueInteractionException() {
+ // TODO Auto-generated constructor stub
+ }
+
+ public CatalogueInteractionException(String message, Throwable cause, boolean enableSuppression,
+ boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ // TODO Auto-generated constructor stub
+ }
+
+ public CatalogueInteractionException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ public CatalogueInteractionException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ public CatalogueInteractionException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
diff --git a/ckan-controller-plugin/pom.xml b/ckan-controller-plugin/pom.xml
index 7da1f3d..623869d 100644
--- a/ckan-controller-plugin/pom.xml
+++ b/ckan-controller-plugin/pom.xml
@@ -18,11 +18,7 @@
-
- org.gcube.data-publishing
- gcat-client
- [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT]
-
+
diff --git a/ckan-controller-plugin/target/classes/META-INF/MANIFEST.MF b/ckan-controller-plugin/target/classes/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e2601c5
--- /dev/null
+++ b/ckan-controller-plugin/target/classes/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Built-By: fabio
+Build-Jdk: 1.8.0_201
+Created-By: Maven Integration for Eclipse
+
diff --git a/ckan-controller-plugin/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/ckan-controller-plugin/pom.properties b/ckan-controller-plugin/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/ckan-controller-plugin/pom.properties
new file mode 100644
index 0000000..a90cc11
--- /dev/null
+++ b/ckan-controller-plugin/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/ckan-controller-plugin/pom.properties
@@ -0,0 +1,7 @@
+#Generated by Maven Integration for Eclipse
+#Tue Mar 19 16:04:16 CET 2019
+version=1.0.0-SNAPSHOT
+groupId=org.gcube.data-publishing.gCat-Feeder
+m2e.projectName=ckan-controller-plugin
+m2e.projectLocation=/home/fabio/workspaces/DEV/gCat-Feeder-Suite/ckan-controller-plugin
+artifactId=ckan-controller-plugin
diff --git a/ckan-controller-plugin/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/ckan-controller-plugin/pom.xml b/ckan-controller-plugin/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/ckan-controller-plugin/pom.xml
new file mode 100644
index 0000000..623869d
--- /dev/null
+++ b/ckan-controller-plugin/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/ckan-controller-plugin/pom.xml
@@ -0,0 +1,26 @@
+
+ 4.0.0
+
+ org.gcube.data-publishing.gCat-Feeder
+ gCat-Feeder-Suite
+ 1.0.0-SNAPSHOT
+
+ ckan-controller-plugin
+ ckan-controller-plugin
+ controller plugin for gCat-Feeder aimed to publish metadata to CKAN catalogue
+
+
+
+
+ org.gcube.data-publishing.gCat-Feeder
+ catalogue-plugin-framework
+ [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ckan-controller-plugin/target/classes/org/gcube/data/publishing/gCatFeeder/catalogues/ckan/CKANController.class b/ckan-controller-plugin/target/classes/org/gcube/data/publishing/gCatFeeder/catalogues/ckan/CKANController.class
new file mode 100644
index 0000000..d9229fb
Binary files /dev/null and b/ckan-controller-plugin/target/classes/org/gcube/data/publishing/gCatFeeder/catalogues/ckan/CKANController.class differ
diff --git a/ckan-controller-plugin/target/classes/org/gcube/data/publishing/gCatFeeder/catalogues/ckan/CkanPlugin.class b/ckan-controller-plugin/target/classes/org/gcube/data/publishing/gCatFeeder/catalogues/ckan/CkanPlugin.class
new file mode 100644
index 0000000..c3e6317
Binary files /dev/null and b/ckan-controller-plugin/target/classes/org/gcube/data/publishing/gCatFeeder/catalogues/ckan/CkanPlugin.class differ
diff --git a/collectors-plugin-framework/src/main/java/org/gcube/data/publishing/gCatfeeder/collectors/CollectorPlugin.java b/collectors-plugin-framework/src/main/java/org/gcube/data/publishing/gCatfeeder/collectors/CollectorPlugin.java
index bddc249..09d17c7 100644
--- a/collectors-plugin-framework/src/main/java/org/gcube/data/publishing/gCatfeeder/collectors/CollectorPlugin.java
+++ b/collectors-plugin-framework/src/main/java/org/gcube/data/publishing/gCatfeeder/collectors/CollectorPlugin.java
@@ -3,6 +3,7 @@ package org.gcube.data.publishing.gCatfeeder.collectors;
import java.util.Set;
import org.gcube.data.publishing.gCatFeeder.model.CatalogueFormatData;
+import org.gcube.data.publishing.gCatFeeder.model.ControllerConfiguration;
import org.gcube.data.publishing.gCatfeeder.collectors.model.CustomData;
import org.gcube.data.publishing.gCatfeeder.collectors.model.PluginDescriptor;
import org.gcube.data.publishing.gCatfeeder.collectors.model.faults.CatalogueNotSupportedException;
@@ -18,4 +19,6 @@ public interface CollectorPlugin{
public DataTransformer extends CatalogueFormatData,E> getTransformerByCatalogueType(String catalogueType)throws CatalogueNotSupportedException;
public DataCollector getCollector();
+
+ public ControllerConfiguration getPublisherControllerConfiguration(String catalogueType)throws CatalogueNotSupportedException;;
}
diff --git a/commons/src/main/java/org/gcube/data/publishing/gCatFeeder/model/ControllerConfiguration.java b/commons/src/main/java/org/gcube/data/publishing/gCatFeeder/model/ControllerConfiguration.java
new file mode 100644
index 0000000..0e3dca1
--- /dev/null
+++ b/commons/src/main/java/org/gcube/data/publishing/gCatFeeder/model/ControllerConfiguration.java
@@ -0,0 +1,16 @@
+package org.gcube.data.publishing.gCatFeeder.model;
+
+
+public class ControllerConfiguration {
+
+ public static enum PublishingPolicy{
+ FAIL,UPDATE,SKIP
+ }
+
+ private PublishingPolicy onClash=PublishingPolicy.UPDATE;
+
+ public PublishingPolicy getOnClash() {
+ return onClash;
+ }
+
+}
diff --git a/gCat-Controller/pom.xml b/gCat-Controller/pom.xml
index 14a2673..08e4779 100644
--- a/gCat-Controller/pom.xml
+++ b/gCat-Controller/pom.xml
@@ -23,6 +23,14 @@
gcat-client
[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT]
+
+
+
+ org.gcube.data-publishing.gCat-Feeder
+ test-commons
+ [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT]
+ test
+
diff --git a/gCat-Controller/src/main/java/org/gcube/data/pu/GCatController.java b/gCat-Controller/src/main/java/org/gcube/data/pu/GCatController.java
deleted file mode 100644
index f2dee0c..0000000
--- a/gCat-Controller/src/main/java/org/gcube/data/pu/GCatController.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.gcube.data.pu;
-
-import org.gcube.data.publishing.gCatFeeder.catalogues.CatalogueController;
-import org.gcube.data.publishing.gCatFeeder.catalogues.model.PublishReport;
-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;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j
-public class GCatController implements CatalogueController{
-
-
- private static ObjectMapper mapper=new ObjectMapper();
-
-
- private CatalogueInstanceDescriptor desc;
-
- public GCatController(CatalogueInstanceDescriptor instance) {
- this.desc=instance;
- }
-
- /**
- * Expected structure
- *
- * {
- * "profile" : "",
- * "item" : "",
- * "resources" : [
- * "",
- * "",
- * ....]
- * }
- *
- * NB serialized resources are updated with "package_id" set as the published item id
- *
- *
- */
- @Override
- public PublishReport publishItem(CatalogueFormatData arg0) throws WrongObjectFormatException {
- log.debug("Publishing {} ",arg0);
- String serialized=arg0.toCatalogueFormat();
-
- }
-
-
-
-
-}
diff --git a/gCat-Controller/src/main/java/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatController.java b/gCat-Controller/src/main/java/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatController.java
new file mode 100644
index 0000000..2bcf672
--- /dev/null
+++ b/gCat-Controller/src/main/java/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatController.java
@@ -0,0 +1,371 @@
+package org.gcube.data.publishing.gCataFeeder.catalogues.gCat;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+
+import javax.ws.rs.WebApplicationException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
+import org.gcube.data.publishing.gCatFeeder.catalogues.CatalogueController;
+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;
+import org.gcube.data.publishing.gCatFeeder.model.ControllerConfiguration;
+import org.gcube.data.publishing.gCatFeeder.model.ControllerConfiguration.PublishingPolicy;
+import org.gcube.gcat.client.Item;
+import org.gcube.gcat.client.Profile;
+import org.gcube.gcat.client.Resource;
+import org.w3c.dom.Document;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class GCatController implements CatalogueController{
+
+
+ private static ObjectMapper mapper;
+
+
+
+ private static DocumentBuilderFactory factory;
+ private static DocumentBuilder builder;
+ private static XPathFactory xPathfactory;
+ private static XPath xpath;
+ private static XPathExpression expr;
+
+ static {
+ mapper=new ObjectMapper();
+ factory= DocumentBuilderFactory.newInstance();
+ xPathfactory = XPathFactory.newInstance();
+ xpath = xPathfactory.newXPath();
+
+
+
+
+ try {
+ builder= factory.newDocumentBuilder();
+ expr= xpath.compile("");
+ } catch (ParserConfigurationException | XPathExpressionException e) {
+ throw new RuntimeException("Unable to initialize Controller");
+ }
+
+ }
+
+ private CatalogueInstanceDescriptor desc;
+
+ private String callerToken=null;
+ private ControllerConfiguration config;
+
+ public GCatController(CatalogueInstanceDescriptor instance) throws ControllerInstantiationFault {
+ try{
+ this.desc=instance;
+
+ if(isCustomToken())
+ setCustomToken();
+
+ checkInstance();
+
+ if(isCustomToken())
+ resetToken();
+ }catch(ControllerInstantiationFault e) {
+ throw e;
+ }
+ }
+
+ @Override
+ public void configure(ControllerConfiguration config) {
+ this.config = config;
+ }
+
+ /**
+ * Expected structure
+ *
+ * {
+ * "profile" : "",
+ * "item" : "",
+ * "resources" : [
+ * "",
+ * "",
+ * ....]
+ * }
+ *
+ * NB serialized resources are updated with "package_id" set as the published item id
+ *
+ *
+ */
+ @Override
+ public PublishReport publishItem(CatalogueFormatData arg0) throws WrongObjectFormatException,CatalogueInteractionException,PublicationException{
+ log.debug("Publishing {} ",arg0);
+ String serialized=arg0.toCatalogueFormat();
+ try {
+ if(isCustomToken())
+ setCustomToken();
+
+ log.debug("Parsing data..");
+ JsonNode node=mapper.readTree(serialized);
+ if(!node.hasNonNull("item")) throw new WrongObjectFormatException("No \"item\" specified in serialized object");
+ JsonNode itemNode=node.path("item");
+ if(node.hasNonNull("profile")) {
+ log.debug("Publishing profile..");
+ String xmlProfile=node.path("profile").asText();
+ String profileName=getProfileName(xmlProfile);
+ createProfile(profileName, xmlProfile);
+ }
+
+ log.debug("Publishing Item..");
+ String itemResp=createItem(itemNode.asText());
+ String itemId = getId(itemResp);
+ log.debug("Pubilshed Item with ID {} ",itemId);
+
+ if(node.hasNonNull("resources")) {
+ log.debug("Pubilshing resources for {} ",itemId);
+ Iterator resIterator=node.path("resources").elements();
+ while(resIterator.hasNext()) {
+ JsonNode resNode=resIterator.next();
+ String resourceName=resNode.path("name").asText();
+ createResource(itemId, resourceName, resNode.asText());
+ }
+ }
+
+ return new PublishReport(true, itemId);
+
+ } catch(WrongObjectFormatException | PublicationException e) {
+ throw e;
+ } catch (Throwable e) {
+ throw new WrongObjectFormatException("Unable to read format ",e);
+ }finally{
+ if(isCustomToken())
+ resetToken();
+ }
+ }
+
+
+
+
+ private String createProfile(String profileName,String xmlProfile) throws WrongObjectFormatException, PublicationException{
+ Profile profile=null;
+ try{
+ if(isForcedUrl())
+ profile = new Profile(getForcedUrl());
+ else profile=new Profile();
+
+ // check if exists
+ boolean exists=false;
+
+ try {
+ profile.read(profileName);
+ exists=true;
+ }catch(Throwable t) {
+ exists=false;
+ }
+
+ switch(getOnClash()) {
+ case SKIP : return null;
+ case FAIL : {
+ if(exists) throw new PublicationException("Profile "+profileName+" already existing");
+ break;
+ }
+ case UPDATE : {
+ if(exists) return profile.update(profileName, xmlProfile);
+ break;
+ }
+ }
+ return profile.create(profileName, xmlProfile);
+ }catch(WebApplicationException e) {
+ handleWebException(e);
+ return null;
+ }catch(MalformedURLException e) {
+ throw new CatalogueInteractionException(e);
+ }
+
+ }
+
+
+ private String createResource(String itemId,String resourceName,String toCreate) throws WrongObjectFormatException, PublicationException{
+ Resource resource=null;
+ try{
+ if(isForcedUrl())
+ resource = new Resource(getForcedUrl());
+ else resource=new Resource();
+
+ // Try to create
+
+ try {
+ log.debug("Trying to create resource {} for package {} ",resourceName,itemId);
+ return resource.create(itemId, toCreate);
+ }catch(WebApplicationException e) {
+ // Conflict = resource already existing
+ if(e.getResponse().getStatus()==409) {
+ switch(getOnClash()) {
+ case SKIP : return null;
+ case FAIL : throw new PublicationException("Resource "+resourceName+" already existing");
+ case UPDATE : {
+ // Look for resource id
+ log.debug("Looking for resource with name {} under item {} ",resourceName,itemId);
+ String resourceList=resource.list(itemId);
+ JsonNode listNode=mapper.readTree(resourceList);
+ Iterator iterator=listNode.elements();
+ String resourceId=null;
+ while(iterator.hasNext()) {
+ JsonNode res=iterator.next();
+ if(res.path("name").asText().equals(resourceName)) {
+ resourceId=res.path("id").asText();
+ break;
+ }
+ }
+ log.debug("Found id {} for resource Name {} ",resourceId,resourceName);
+
+ return resource.update(itemId, resourceId, toCreate);
+ }
+ default : return null;
+ }
+ }else throw e;
+ }
+
+
+ }catch(WebApplicationException e) {
+ handleWebException(e);
+ return null;
+ }catch(MalformedURLException e) {
+ throw new CatalogueInteractionException(e);
+ }catch(IOException e) {
+ throw new CatalogueInteractionException(e);
+ }
+
+ }
+
+
+ private String createItem(String toCreate) throws WrongObjectFormatException, PublicationException{
+ Item item=null;
+ try{
+ if(isForcedUrl())
+ item = new Item(getForcedUrl());
+ else item=new Item();
+ return item.create(toCreate);
+ }catch(WebApplicationException e) {
+ handleWebException(e);
+ return null;
+ }catch(MalformedURLException e) {
+ throw new CatalogueInteractionException(e);
+ }
+
+ }
+
+
+
+
+
+
+ // instance utils
+
+ private PublishingPolicy getOnClash() {
+ return config.getOnClash();
+ }
+
+
+
+ private boolean isForcedUrl() {
+ return desc.getCustomToken()==null&&desc.getUrl()!=null;
+ }
+
+ private URL getForcedUrl() throws MalformedURLException {
+ return new URL(desc.getUrl());
+ }
+
+ private boolean isCustomToken() {
+ return desc.getCustomToken()!=null;
+ }
+
+ private void setCustomToken() {
+ callerToken=SecurityTokenProvider.instance.get();
+ SecurityTokenProvider.instance.set(desc.getCustomToken());
+ }
+
+ private void resetToken() {
+ SecurityTokenProvider.instance.set(callerToken);
+ }
+
+ private void checkInstance() throws ControllerInstantiationFault{
+ Item item=null;
+ try{
+ if(isForcedUrl())
+ item=new Item(getForcedUrl());
+ else item=new Item();
+ item.list(10, 0);
+ }catch(Throwable t) {
+ String msg=String.format("Unable to contact gCat with configuration %1$s ",desc);
+ log.error(msg,t);
+ throw new ControllerInstantiationFault(msg,t);
+ }
+ }
+
+ // Static utils from catalogue-ws
+
+ private static String getProfileName(String xmlProfile) throws WrongObjectFormatException {
+ try{
+ Document doc = builder.parse(xmlProfile);
+ return (String) expr.evaluate(doc, XPathConstants.STRING);
+ }catch(Throwable t) {
+ throw new WrongObjectFormatException("Unable to parse profile. ",t);
+ }
+ }
+
+
+ private static String getId(String publishResponse) {
+ try {
+ return mapper.readTree(publishResponse).path("result").path("id").asText();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw new RuntimeException("FAILED Parsing of "+publishResponse);
+ }
+ }
+
+ private static String getPublishedUrl(String publishResponse) {
+ try {
+ Iterator iterator=mapper.readTree(publishResponse).path("result").path("extras").elements();
+ while(iterator.hasNext()) {
+ JsonNode node=iterator.next();
+ if(node.path("key").asText().equals("Item URL"))
+ return node.path("value").asText();
+ }
+ return "N/A";
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw new RuntimeException("FAILED Parsing of "+publishResponse);
+ }
+ }
+
+ private static void handleWebException(WebApplicationException e) throws WrongObjectFormatException, PublicationException {
+ log.debug("Received Web Exception {} ",e);
+ String msg=e.getResponse().readEntity(String.class);
+ switch(e.getResponse().getStatus()) {
+ case 400 : throw new WrongObjectFormatException("BAD Request : "+msg,e);
+ case 401 : throw new CatalogueInteractionException("Unauthorized : "+msg,e);
+ case 404 : throw new CatalogueInteractionException("NOT FOUND : "+msg,e);
+ case 405 : throw new CatalogueInteractionException("Method Not Allowed : "+msg,e);
+ case 409 : throw new CatalogueInteractionException("Conflict : "+msg,e);
+ case 500 : throw new CatalogueInteractionException("Remote Error : "+msg,e);
+ default : throw new PublicationException("Unexpected error code : "+msg,e);
+ }
+ }
+
+
+
+}
diff --git a/gCat-Controller/src/main/java/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatPlugin.java b/gCat-Controller/src/main/java/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatPlugin.java
new file mode 100644
index 0000000..bafd82f
--- /dev/null
+++ b/gCat-Controller/src/main/java/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatPlugin.java
@@ -0,0 +1,22 @@
+package org.gcube.data.publishing.gCataFeeder.catalogues.gCat;
+
+import org.gcube.data.publishing.gCatFeeder.catalogues.CatalogueController;
+import org.gcube.data.publishing.gCatFeeder.catalogues.CataloguePlugin;
+import org.gcube.data.publishing.gCatFeeder.catalogues.model.CataloguePluginDescriptor;
+import org.gcube.data.publishing.gCatFeeder.catalogues.model.faults.ControllerInstantiationFault;
+import org.gcube.data.publishing.gCatFeeder.model.CatalogueInstanceDescriptor;
+
+public class GCatPlugin implements CataloguePlugin {
+
+ @Override
+ public CataloguePluginDescriptor getDescriptor() {
+ return new CataloguePluginDescriptor("GCAT");
+ }
+
+ @Override
+ public CatalogueController instantiateController(CatalogueInstanceDescriptor desc)
+ throws ControllerInstantiationFault {
+ return new GCatController(desc);
+ }
+
+}
diff --git a/gCat-Controller/src/test/java/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/Interactions.java b/gCat-Controller/src/test/java/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/Interactions.java
new file mode 100644
index 0000000..047fe55
--- /dev/null
+++ b/gCat-Controller/src/test/java/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/Interactions.java
@@ -0,0 +1,15 @@
+package org.gcube.data.publishing.gCatFeeder.catalogues.gCat;
+
+import org.gcube.data.publishing.gCatFeeder.tests.TokenSetter;
+import org.gcube.data.publishing.gCatFeeder.utils.TokenUtils;
+import org.junit.Before;
+
+public class Interactions {
+
+ @Before
+ private void setToken() {
+ TokenSetter.set("/gcube/devsec");
+ }
+
+
+}
diff --git a/gCat-Controller/target/classes/META-INF/MANIFEST.MF b/gCat-Controller/target/classes/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e2601c5
--- /dev/null
+++ b/gCat-Controller/target/classes/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Built-By: fabio
+Build-Jdk: 1.8.0_201
+Created-By: Maven Integration for Eclipse
+
diff --git a/gCat-Controller/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/gCat-Controller/pom.properties b/gCat-Controller/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/gCat-Controller/pom.properties
new file mode 100644
index 0000000..9a0b601
--- /dev/null
+++ b/gCat-Controller/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/gCat-Controller/pom.properties
@@ -0,0 +1,7 @@
+#Generated by Maven Integration for Eclipse
+#Tue Mar 19 16:05:42 CET 2019
+version=1.0.0-SNAPSHOT
+groupId=org.gcube.data-publishing.gCat-Feeder
+m2e.projectName=gCat-Controller
+m2e.projectLocation=/home/fabio/workspaces/DEV/gCat-Feeder-Suite/gCat-Controller
+artifactId=gCat-Controller
diff --git a/gCat-Controller/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/gCat-Controller/pom.xml b/gCat-Controller/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/gCat-Controller/pom.xml
new file mode 100644
index 0000000..08e4779
--- /dev/null
+++ b/gCat-Controller/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/gCat-Controller/pom.xml
@@ -0,0 +1,39 @@
+
+ 4.0.0
+
+ org.gcube.data-publishing.gCat-Feeder
+ gCat-Feeder-Suite
+ 1.0.0-SNAPSHOT
+
+ gCat-Controller
+ gCat Controller
+ Controller implementation for GCat Service
+
+
+
+
+ org.gcube.data-publishing.gCat-Feeder
+ catalogue-plugin-framework
+ [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)
+
+
+
+
+ org.gcube.data-publishing
+ gcat-client
+ [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT]
+
+
+
+
+ org.gcube.data-publishing.gCat-Feeder
+ test-commons
+ [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT]
+ test
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/gCat-Controller/target/classes/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatController.class b/gCat-Controller/target/classes/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatController.class
new file mode 100644
index 0000000..0f0bba1
Binary files /dev/null and b/gCat-Controller/target/classes/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatController.class differ
diff --git a/gCat-Controller/target/classes/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatPlugin.class b/gCat-Controller/target/classes/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatPlugin.class
new file mode 100644
index 0000000..263040c
Binary files /dev/null and b/gCat-Controller/target/classes/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatPlugin.class differ
diff --git a/gCat-Controller/target/test-classes/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/Interactions.class b/gCat-Controller/target/test-classes/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/Interactions.class
new file mode 100644
index 0000000..1f0bc3e
Binary files /dev/null and b/gCat-Controller/target/test-classes/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/Interactions.class differ
diff --git a/pom.xml b/pom.xml
index 98f47cf..dbc38e8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,6 +22,7 @@
catalogue-plugin-framework
ckan-controller-plugin
gCat-Controller
+ test-commons
diff --git a/test-commons/.classpath b/test-commons/.classpath
new file mode 100644
index 0000000..fae1a2b
--- /dev/null
+++ b/test-commons/.classpath
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test-commons/.project b/test-commons/.project
new file mode 100644
index 0000000..b954d3b
--- /dev/null
+++ b/test-commons/.project
@@ -0,0 +1,23 @@
+
+
+ test-commons
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/test-commons/.settings/org.eclipse.core.resources.prefs b/test-commons/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..29abf99
--- /dev/null
+++ b/test-commons/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,6 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding//src/main/resources=UTF-8
+encoding//src/test/java=UTF-8
+encoding//src/test/resources=UTF-8
+encoding/=UTF-8
diff --git a/test-commons/.settings/org.eclipse.jdt.core.prefs b/test-commons/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..714351a
--- /dev/null
+++ b/test-commons/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/test-commons/.settings/org.eclipse.m2e.core.prefs b/test-commons/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/test-commons/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/test-commons/pom.xml b/test-commons/pom.xml
new file mode 100644
index 0000000..f69b76e
--- /dev/null
+++ b/test-commons/pom.xml
@@ -0,0 +1,11 @@
+
+ 4.0.0
+
+ org.gcube.data-publishing.gCat-Feeder
+ gCat-Feeder-Suite
+ 1.0.0-SNAPSHOT
+
+ test-commons
+ test commons
+ Utility classes for test purposes
+
\ No newline at end of file
diff --git a/test-commons/src/main/java/org/gcube/data/publishing/gCatFeeder/tests/TokenSetter.java b/test-commons/src/main/java/org/gcube/data/publishing/gCatFeeder/tests/TokenSetter.java
new file mode 100644
index 0000000..033ebbc
--- /dev/null
+++ b/test-commons/src/main/java/org/gcube/data/publishing/gCatFeeder/tests/TokenSetter.java
@@ -0,0 +1,38 @@
+package org.gcube.data.publishing.gCatFeeder.tests;
+
+import java.util.Properties;
+
+import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
+import org.gcube.common.scope.api.ScopeProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TokenSetter {
+ private static Properties props=new Properties();
+
+ private static final Logger log= LoggerFactory.getLogger(TokenSetter.class);
+
+ static{
+ try {
+ props.load(TokenSetter.class.getResourceAsStream("/tokens.properties"));
+ } catch (Exception e) {
+ throw new RuntimeException("YOU NEED TO SET TOKEN FILE IN CONFIGURATION");
+ }
+ }
+
+
+ public static void set(String scope){
+ try{
+ if(!props.containsKey(scope)) throw new RuntimeException("No token found for scope : "+scope);
+ SecurityTokenProvider.instance.set(props.getProperty(scope));
+ }catch(Throwable e){
+ log.warn("Unable to set token for scope "+scope,e);
+ }
+ ScopeProvider.instance.set(scope);
+ }
+
+
+
+
+}
+
diff --git a/test-commons/target/classes/META-INF/MANIFEST.MF b/test-commons/target/classes/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e2601c5
--- /dev/null
+++ b/test-commons/target/classes/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Built-By: fabio
+Build-Jdk: 1.8.0_201
+Created-By: Maven Integration for Eclipse
+
diff --git a/test-commons/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/test-commons/pom.properties b/test-commons/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/test-commons/pom.properties
new file mode 100644
index 0000000..d1cfac0
--- /dev/null
+++ b/test-commons/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/test-commons/pom.properties
@@ -0,0 +1,7 @@
+#Generated by Maven Integration for Eclipse
+#Tue Mar 19 16:04:13 CET 2019
+version=1.0.0-SNAPSHOT
+groupId=org.gcube.data-publishing.gCat-Feeder
+m2e.projectName=test-commons
+m2e.projectLocation=/home/fabio/workspaces/DEV/gCat-Feeder-Suite/test-commons
+artifactId=test-commons
diff --git a/test-commons/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/test-commons/pom.xml b/test-commons/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/test-commons/pom.xml
new file mode 100644
index 0000000..f69b76e
--- /dev/null
+++ b/test-commons/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/test-commons/pom.xml
@@ -0,0 +1,11 @@
+
+ 4.0.0
+
+ org.gcube.data-publishing.gCat-Feeder
+ gCat-Feeder-Suite
+ 1.0.0-SNAPSHOT
+
+ test-commons
+ test commons
+ Utility classes for test purposes
+
\ No newline at end of file
diff --git a/test-commons/target/classes/org/gcube/data/publishing/gCatFeeder/tests/TokenSetter.class b/test-commons/target/classes/org/gcube/data/publishing/gCatFeeder/tests/TokenSetter.class
new file mode 100644
index 0000000..5803945
Binary files /dev/null and b/test-commons/target/classes/org/gcube/data/publishing/gCatFeeder/tests/TokenSetter.class differ