From 9be8b0dbb2587c7c188ad2e8c6ad6aefb8bda0aa Mon Sep 17 00:00:00 2001 From: "fabio.sinibaldi" Date: Tue, 19 Mar 2019 17:02:08 +0000 Subject: [PATCH] git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-publishing/gCat-Feeder-Suite@178631 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../catalogues/CatalogueController.java | 7 +- .../faults/CatalogueInteractionException.java | 30 ++ ckan-controller-plugin/pom.xml | 6 +- .../target/classes/META-INF/MANIFEST.MF | 5 + .../ckan-controller-plugin/pom.properties | 7 + .../ckan-controller-plugin/pom.xml | 26 ++ .../catalogues/ckan/CKANController.class | Bin 0 -> 9026 bytes .../catalogues/ckan/CkanPlugin.class | Bin 0 -> 1553 bytes .../collectors/CollectorPlugin.java | 3 + .../model/ControllerConfiguration.java | 16 + gCat-Controller/pom.xml | 8 + .../org/gcube/data/pu/GCatController.java | 52 --- .../catalogues/gCat/GCatController.java | 371 ++++++++++++++++++ .../catalogues/gCat/GCatPlugin.java | 22 ++ .../catalogues/gCat/Interactions.java | 15 + .../target/classes/META-INF/MANIFEST.MF | 5 + .../gCat-Controller/pom.properties | 7 + .../gCat-Controller/pom.xml | 39 ++ .../catalogues/gCat/GCatController.class | Bin 0 -> 12961 bytes .../catalogues/gCat/GCatPlugin.class | Bin 0 -> 1338 bytes .../catalogues/gCat/Interactions.class | Bin 0 -> 624 bytes pom.xml | 1 + test-commons/.classpath | 36 ++ test-commons/.project | 23 ++ .../org.eclipse.core.resources.prefs | 6 + .../.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.eclipse.m2e.core.prefs | 4 + test-commons/pom.xml | 11 + .../gCatFeeder/tests/TokenSetter.java | 38 ++ .../target/classes/META-INF/MANIFEST.MF | 5 + .../test-commons/pom.properties | 7 + .../test-commons/pom.xml | 11 + .../gCatFeeder/tests/TokenSetter.class | Bin 0 -> 2040 bytes 33 files changed, 707 insertions(+), 59 deletions(-) create mode 100644 catalogue-plugin-framework/src/main/java/org/gcube/data/publishing/gCatFeeder/catalogues/model/faults/CatalogueInteractionException.java create mode 100644 ckan-controller-plugin/target/classes/META-INF/MANIFEST.MF create mode 100644 ckan-controller-plugin/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/ckan-controller-plugin/pom.properties create mode 100644 ckan-controller-plugin/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/ckan-controller-plugin/pom.xml create mode 100644 ckan-controller-plugin/target/classes/org/gcube/data/publishing/gCatFeeder/catalogues/ckan/CKANController.class create mode 100644 ckan-controller-plugin/target/classes/org/gcube/data/publishing/gCatFeeder/catalogues/ckan/CkanPlugin.class create mode 100644 commons/src/main/java/org/gcube/data/publishing/gCatFeeder/model/ControllerConfiguration.java delete mode 100644 gCat-Controller/src/main/java/org/gcube/data/pu/GCatController.java create mode 100644 gCat-Controller/src/main/java/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatController.java create mode 100644 gCat-Controller/src/main/java/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatPlugin.java create mode 100644 gCat-Controller/src/test/java/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/Interactions.java create mode 100644 gCat-Controller/target/classes/META-INF/MANIFEST.MF create mode 100644 gCat-Controller/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/gCat-Controller/pom.properties create mode 100644 gCat-Controller/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/gCat-Controller/pom.xml create mode 100644 gCat-Controller/target/classes/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatController.class create mode 100644 gCat-Controller/target/classes/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatPlugin.class create mode 100644 gCat-Controller/target/test-classes/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/Interactions.class create mode 100644 test-commons/.classpath create mode 100644 test-commons/.project create mode 100644 test-commons/.settings/org.eclipse.core.resources.prefs create mode 100644 test-commons/.settings/org.eclipse.jdt.core.prefs create mode 100644 test-commons/.settings/org.eclipse.m2e.core.prefs create mode 100644 test-commons/pom.xml create mode 100644 test-commons/src/main/java/org/gcube/data/publishing/gCatFeeder/tests/TokenSetter.java create mode 100644 test-commons/target/classes/META-INF/MANIFEST.MF create mode 100644 test-commons/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/test-commons/pom.properties create mode 100644 test-commons/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/test-commons/pom.xml create mode 100644 test-commons/target/classes/org/gcube/data/publishing/gCatFeeder/tests/TokenSetter.class 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 0000000000000000000000000000000000000000..d9229fb071c17f399159eba74eb562005809a4e1 GIT binary patch literal 9026 zcmbVS33y!9b^ebun)ft%mTd{_jKR(rZ<1`!u$UzyW3Xi#$(Dp;Nj5SG@HBdo#-5Ft zH{RI6X~I&PwF$H&fsiO|Q(_=!K>?Grg*0two9<2bEiT<@n})Ku|GjTE$-`%XKYQMr zyPSK@f7W}(-+$-%7XfUN`wY|wI?~zE$Y?A-T>*~CD?~cCf2ljUCFwrDfTYW2Or1ROBg0`^T z982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~z1zNRDDw@GL#-mR5U)O7;4 z+dC#KT-OP_!BDrmdFgs8qO!Mirt30@6%Ul;O1NR5qR{sRh5OO|yJ%;ed6UvSF%{(e zY0EAi1&}*L1u zbO9bPY+qbL^#d8w)ns^mQAPT{1wVTsc~x2_7#>$~6St`Jy)cP9(UJP$*YcM1L|{ public DataTransformer 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 0000000000000000000000000000000000000000..0f0bba127202ec80970e231d18338fb98ff488ba GIT binary patch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Ni%LO6XsALz5pimEw&~wzmH0BSP-K`t;$OI*c_hvJ z)L7JqGG=(!%|Fn^!L}HxzR+7D_98jdVZ_jDu3vyXALlWJp`58`Gib}g0>f_pVJ}Uc zLxU9DZol2LQO8ZA;4Owmvzz6vrz1*y%ShdjL9BV8CD)=I2099r5)|&Y=D$Td72?N~ z=81_QFE87fVA+8vA@=*Po)~Hw2C;?v4E_Jp?SLmr$4-VGAK3^%=#Keo;Q_-|K0fab zWo#SESTPxR#PI3r6g4F>pu5TN;i|Gk`u4&k@XgtbmG>zFB%xOiyJ= zZJA~c^^E%2jS=i0G$^1#Z7DUDQKfNZ?11a2(TtuE+@RJh-b`VDeS&(wzBt0tcd||r zsuKkJjBp!w$m=fo7KwB(WxXU;fh^?{Ecc&{@NgQnkfN5xPNyhx$0{BZgkde+`pI7x CvV*e# literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..1f0bc3e1eb74341604e9b41d4d45ababfb0d39ef GIT binary patch literal 624 zcmbtSyG{c!5FF>t5l9GcsOW$KH;5((DMX5d6oEvd^uEgy94(oT?`!W5wHU!YM^wpmMH__7?)h!=sTvscXj+popb9%BTo5 z`r6QSItwWosxT&jR^LV{9;rlU>-n(c@3j-?_Wy0PEl_jhhxUPt!0v5oyq?iWJI$wc zjImzj7s`!rD$|tx%S*bm3AJlz39S4iMNf{R02|nR^SH(3jD>%a;@@8au?jo$1kWo z=WxI^gTaJluJvyM_mv!9Wwe0CoYl;E*`M+)RB5ffVtt_$Fc+*-=KTw`%3O^D&NcVG E00kG92><{9 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..580394587003ac36b326396ab351568809a643b9 GIT binary patch literal 2040 zcmbtVT~ixX7=BJDY!a42LxBRNUBR{l3ac&F+JH)Ff{`?-Bt)s7C!0f9SavhJC#`tr z-|!Fgy3_$HGkWija(vGQlN4}9$BR9?=l%Y8-gp1_^Vi=1EMQkdgyEj&*UXyLs0g#l zB{%Dhiem@cwoB9%E;B+@g>Om`$iOUlyTUCBDTS}$0>i)#f5uIRlWd`~BP_|#UH83u zz%ZN(c@1eh<`W_bU)mx_F?2azjUka!ZUbj)VaLpQwVLpW6)Ow5Q`OOfn3T z({&Me4c`*WK~egG?=d7h-4l_TK>kAuwr6JDdP6ovQ!4ehb=<&Bs*>aJD#Mi%prMTh)DzVd%V&$)!m-wq3S-Q9*LHEAoxKittOk;)oCn7I(_rx7GcG z$cQo2(TtV_!bx9Ia%=Z7uZOa6bfKTBAh&J8-Tkm#{~gZ?nSqe1t`Bsiu*lGBd9LKP z8?1@_Q;9awo=QH|KwuqdC)#YviE$Gw04LYezZW@Iz==!m5r>kfkA#UXw{fGkpS{5YA0%Duy*Y){tXJ zw8$9>F2@j1h_4Oan-x?xbKTTS`9 z9lhAZml~eZT06ZkbbN)c31ZK=?=sAs0+q80@D8eP9Pns+fuy4z$$WgkV? PWI;o9l