diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..fae1a2b
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..0e1021a
--- /dev/null
+++ b/.project
@@ -0,0 +1,23 @@
+
+
+ sis-geotk-plugin
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..29abf99
--- /dev/null
+++ b/.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/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..714351a
--- /dev/null
+++ b/.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/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..ff7698f
--- /dev/null
+++ b/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=false
+version=1
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..849d64f
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,78 @@
+
+ 4.0.0
+
+ org.gcube.tools
+ maven-parent
+ LATEST
+
+ org.gcube.data.transfer
+ sis-geotk-plugin
+ 0.0.1-SNAPSHOT
+ Sis/GeoToolkit plugin
+ Apache Sis/Geotk plugin for data-transfer-service
+
+
+ ${project.basedir}/distro
+ http://svn.research-infrastructures.eu/d4science/gcube/trunk/data-transfer/${project.artifactId}
+ 0.7
+ ${sis.version}
+
+
+
+
+ scm:svn:${svnBaseUrl}/${project.artifactId}
+ scm:svn:${svnBaseUrl}/${project.artifactId}
+ ${svnBaseUrl}/${project.artifactId}
+
+
+
+
+
+ org.gcube.data.transfer
+ data-transfer-plugin-framework
+ [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)
+
+
+
+ org.gcube.spatial.data
+ geonetwork
+ [3.0.0-SNAPSHOT,4.0.0-SNAPSHOT)
+
+
+
+
+ org.apache.sis.core
+ sis-referencing
+ ${sis.version}
+
+
+
+ org.apache.sis.storage
+ sis-storage
+ ${sis.utils.modules}
+
+
+ org.apache.sis.storage
+ sis-netcdf
+ ${sis.utils.modules}
+
+
+
+
+ org.slf4j
+ slf4j-log4j12
+ 1.6.4
+ test
+
+
+ junit
+ junit
+ 4.11
+ test
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/org/gcube/data/transfer/plugins/sis/SISPluginFactory.java b/src/main/java/org/gcube/data/transfer/plugins/sis/SISPluginFactory.java
new file mode 100644
index 0000000..5cbb808
--- /dev/null
+++ b/src/main/java/org/gcube/data/transfer/plugins/sis/SISPluginFactory.java
@@ -0,0 +1,69 @@
+package org.gcube.data.transfer.plugins.sis;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.gcube.data.transfer.model.PluginInvocation;
+import org.gcube.data.transfer.plugin.AbstractPluginFactory;
+import org.gcube.data.transfer.plugin.fails.ParameterException;
+import org.gcube.data.transfer.plugin.fails.PluginInitializationException;
+import org.gcube.data.transfer.plugin.fails.PluginShutDownException;
+
+public class SISPluginFactory extends AbstractPluginFactory {
+
+ static final String PLUGIN_ID="SIS/GEOTK";
+
+ public static final String SOURCE_PARAMETER="SOURCE_FILE";
+ public static final String GEONETWORK_CATEGORY="GEONETWORK_CATEGORY";
+ public static final String GEONETWORK_STYLESHEET="GEONETWORK_STYLESHEET";
+
+ static final Map PARAMETERS_DESCRIPTION= new HashMap();
+
+ static{
+ PARAMETERS_DESCRIPTION.put(SOURCE_PARAMETER, "[String value] Absolute path of source archive file.");
+ PARAMETERS_DESCRIPTION.put(GEONETWORK_CATEGORY, "[String value] GeoNetwork category for publiehd metadata. Default is 'Dataset'.");
+ PARAMETERS_DESCRIPTION.put(GEONETWORK_STYLESHEET, "[String value] GeoNetwork stylesheet for publiehd metadata. Default is '_none_'.");
+ }
+
+
+ public SISPluginFactory() {
+
+ }
+
+ @Override
+ public void checkInvocation(PluginInvocation arg0) throws ParameterException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public SisPlugin createWorker(PluginInvocation arg0) {
+ return new SisPlugin(arg0);
+ }
+
+ @Override
+ public String getDescription() {
+ return String.format("Extracts ISO metadata file from <%s> and publishes to GeoNetwork.", SOURCE_PARAMETER);
+ }
+
+ @Override
+ public String getID() {
+ return PLUGIN_ID;
+ }
+
+ @Override
+ public Map getParameters() {
+ return PARAMETERS_DESCRIPTION;
+ }
+
+ @Override
+ public boolean init() throws PluginInitializationException {
+ return true;
+ }
+
+ @Override
+ public boolean shutDown() throws PluginShutDownException {
+ return true;
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/transfer/plugins/sis/SisPlugin.java b/src/main/java/org/gcube/data/transfer/plugins/sis/SisPlugin.java
new file mode 100644
index 0000000..0445fa7
--- /dev/null
+++ b/src/main/java/org/gcube/data/transfer/plugins/sis/SisPlugin.java
@@ -0,0 +1,73 @@
+package org.gcube.data.transfer.plugins.sis;
+
+import java.io.File;
+import java.util.Map;
+
+import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.storage.DataStores;
+import org.apache.sis.storage.UnsupportedStorageException;
+import org.gcube.data.transfer.model.PluginInvocation;
+import org.gcube.data.transfer.plugin.AbstractPlugin;
+import org.gcube.data.transfer.plugin.ExecutionReport;
+import org.gcube.data.transfer.plugin.ExecutionReport.ExecutionReportFlag;
+import org.gcube.data.transfer.plugin.fails.PluginCleanupException;
+import org.gcube.data.transfer.plugin.fails.PluginExecutionException;
+import org.gcube.spatial.data.geonetwork.GeoNetwork;
+import org.gcube.spatial.data.geonetwork.GeoNetworkPublisher;
+import org.gcube.spatial.data.geonetwork.LoginLevel;
+import org.opengis.metadata.Metadata;
+
+import it.geosolutions.geonetwork.util.GNInsertConfiguration;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class SisPlugin extends AbstractPlugin {
+
+ public SisPlugin(PluginInvocation invocation) {
+ super(invocation);
+ }
+
+ @Override
+ public void cleanup() throws PluginCleanupException {
+
+ }
+
+ @Override
+ public ExecutionReport run() throws PluginExecutionException {
+ try{
+ log.debug("Checking parameters for {} ",invocation);
+ Map params=invocation.getParameters();
+ String dataStorePath=params.get(SISPluginFactory.SOURCE_PARAMETER);
+ String category=params.containsKey(SISPluginFactory.GEONETWORK_CATEGORY)?params.get(SISPluginFactory.GEONETWORK_CATEGORY):"Dataset";
+ String stylesheet=params.containsKey(SISPluginFactory.GEONETWORK_STYLESHEET)?params.get(SISPluginFactory.GEONETWORK_STYLESHEET):"_none_";
+ File dataStore=new File(dataStorePath);
+ log.debug("Extracting meta from {} ",dataStore.getAbsolutePath());
+ Metadata meta=getMetaFromFile(dataStore);
+ // TODO Links from current thredds
+ // TODO Info from infrastructure
+ long id=publishMetadata(meta, category, stylesheet);
+ return new ExecutionReport(invocation, "Published meta with id : "+id, ExecutionReportFlag.SUCCESS);
+
+ }catch(DataStoreException e){
+ log.error("Unable to parse source ",e);
+ throw new PluginExecutionException("Unable to extract metadata.", e);
+ }catch(Throwable t){
+ log.error("Unexpected error while generating metadata.",t);
+ throw new PluginExecutionException("Unexpected error while generating meta.",t);
+ }
+ }
+
+
+ public static final Metadata getMetaFromFile(Object dataStore) throws UnsupportedStorageException, DataStoreException{
+ return DataStores.open(dataStore).getMetadata();
+ }
+
+
+ public static final long publishMetadata(Metadata meta,String category, String stylesheet) throws Exception{
+ GeoNetworkPublisher publisher=GeoNetwork.get();
+ publisher.login(LoginLevel.DEFAULT);
+ GNInsertConfiguration config=publisher.getCurrentUserConfiguration(category, stylesheet);
+ config.setValidate(false);
+ return publisher.insertMetadata(config, meta);
+ }
+}
diff --git a/src/test/java/org/gcube/data/transfer/plugins/sis/TestGetMetadata.java b/src/test/java/org/gcube/data/transfer/plugins/sis/TestGetMetadata.java
new file mode 100644
index 0000000..6064902
--- /dev/null
+++ b/src/test/java/org/gcube/data/transfer/plugins/sis/TestGetMetadata.java
@@ -0,0 +1,16 @@
+package org.gcube.data.transfer.plugins.sis;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.storage.UnsupportedStorageException;
+
+public class TestGetMetadata {
+
+ public static void main(String[] args) throws UnsupportedStorageException, MalformedURLException, DataStoreException {
+ System.out.println(SisPlugin.getMetaFromFile(new URL("https://github.com/opengeospatial/geoapi/raw/master/geoapi-netcdf/src/test/resources/org/opengis/wrapper/netcdf/NCEP-SST.nc")));
+
+ }
+
+}