1.2.0 #1
36
.classpath
36
.classpath
|
@ -1,36 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
|
@ -0,0 +1 @@
|
|||
/org.eclipse.jdt.core.prefs
|
|
@ -1,5 +0,0 @@
|
|||
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
|
|
@ -2,6 +2,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
|
||||
# Changelog for org.gcube.data.transfer.sis-geotk-plugin
|
||||
|
||||
## [v1.2.0] 2020-09-07
|
||||
Upgrade to apache-sis 1.0
|
||||
|
||||
## [v1.1.3] 2020-09-07
|
||||
|
||||
### Fixes
|
||||
|
|
82
pom.xml
82
pom.xml
|
@ -1,4 +1,5 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
|
@ -8,14 +9,15 @@
|
|||
</parent>
|
||||
<groupId>org.gcube.data.transfer</groupId>
|
||||
<artifactId>sis-geotk-plugin</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.2.0</version>
|
||||
<name>Sis/GeoToolkit plugin</name>
|
||||
<description>Apache Sis/Geotk plugin for data-transfer-service</description>
|
||||
|
||||
<properties>
|
||||
<sis.version>0.7</sis.version>
|
||||
<sis.version>1.0</sis.version>
|
||||
<sis.utils.modules>${sis.version}</sis.utils.modules>
|
||||
<gitBaseUrl>https://code-repo.d4science.org/gCubeSystem</gitBaseUrl>
|
||||
<netcdfJavaVersion>5.3.3</netcdfJavaVersion>
|
||||
</properties>
|
||||
|
||||
<scm>
|
||||
|
@ -30,14 +32,22 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-smartgears-bom</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.1.0</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-bom</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.sis/storage -->
|
||||
<dependency>
|
||||
<groupId>org.apache.sis</groupId>
|
||||
<artifactId>storage</artifactId>
|
||||
<version>1.0</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@ -48,7 +58,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.data.transfer</groupId>
|
||||
<artifactId>data-transfer-plugin-framework</artifactId>
|
||||
<version>[1.0.2,2.0.0-SNAPSHOT)</version>
|
||||
<version>[1.0.2,2.0.0)</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -69,7 +79,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.spatial.data</groupId>
|
||||
<artifactId>sdi-library</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<version>[1.0.0,2.0.0)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- SMARTGEARS -->
|
||||
|
@ -96,6 +106,43 @@
|
|||
<artifactId>sis-netcdf</artifactId>
|
||||
<version>${sis.utils.modules}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.sis.storage</groupId>
|
||||
<artifactId>sis-earth-observation</artifactId>
|
||||
<version>${sis.utils.modules}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.sis.storage</groupId>
|
||||
<artifactId>sis-geotiff</artifactId>
|
||||
<version>${sis.utils.modules}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- SIS EXTERNALS -->
|
||||
<!-- https://mvnrepository.com/artifact/com.esri.geometry/esri-geometry-api -->
|
||||
<dependency>
|
||||
<groupId>com.esri.geometry</groupId>
|
||||
<artifactId>esri-geometry-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/edu.ucar/cdm -->
|
||||
<dependency>
|
||||
<groupId>edu.ucar</groupId>
|
||||
<artifactId>cdm</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- EPSG Dataset. NB Check Performances -->
|
||||
<dependency>
|
||||
<groupId>org.apache.sis.non-free</groupId>
|
||||
<artifactId>sis-embedded-data</artifactId>
|
||||
<version>${sis.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- TEST -->
|
||||
<dependency>
|
||||
|
@ -107,7 +154,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -117,11 +163,29 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.opengis</groupId>
|
||||
<artifactId>geoapi-conformance</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>unidata-all</id>
|
||||
<name>Unidata All</name>
|
||||
|
||||
<url>https://nexus.d4science.org/nexus/content/repositories/unidata/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
|
|
|
@ -2,12 +2,11 @@ package org.gcube.data.transfer.plugins.sis;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.security.MessageDigest;
|
||||
|
@ -15,54 +14,117 @@ import java.security.NoSuchAlgorithmException;
|
|||
|
||||
import org.apache.sis.storage.DataStoreException;
|
||||
import org.apache.sis.storage.UnsupportedStorageException;
|
||||
import org.gcube.data.transfer.model.TransferTicket.Status;
|
||||
import org.gcube.data.transfer.plugins.thredds.sis.SisPlugin;
|
||||
|
||||
public class TestGetMetadata {
|
||||
|
||||
public static void main(String[] args) throws UnsupportedStorageException, DataStoreException, IOException, NoSuchAlgorithmException {
|
||||
String[] toCheckFiles=new String[] {
|
||||
|
||||
|
||||
// ********** HDF - NETCDF 4
|
||||
"/Users/FabioISTI/Downloads/NASA_Precipitations_1950_2100_rcp45.nc",
|
||||
|
||||
"https://thredds.d4science.org/thredds/fileServer/public/netcdf/ClimateChange/NASA_Precipitations_1950_2100_rcp45.nc",
|
||||
"https://thredds.d4science.org/thredds/fileServer/public/netcdf/ClimateChange/NASA_Precipitations_1950_2100_rcp85.nc",
|
||||
"https://thredds.d4science.org/thredds/fileServer/public/netcdf/ClimateChange/NASA_Surface_Air_Temperature_1950_2100_rcp45.nc",
|
||||
"https://thredds.d4science.org/thredds/fileServer/public/netcdf/ClimateChange/NASA_Surface_Air_Temperature_1950_2100_rcp85.nc",
|
||||
"https://thredds.d4science.org/thredds/fileServer/public/netcdf/ClimateChange/hcaf_v6_1950_2100.nc",
|
||||
|
||||
|
||||
// *********** NETCDF 3
|
||||
|
||||
"/Users/FabioISTI/Downloads/Aaptos_aaptos.nc"
|
||||
};
|
||||
|
||||
File temp=File.createTempFile("temp", ".temp");
|
||||
File original=new File("/home/fabio/Downloads/oscar_vel2011_180.nc");
|
||||
File copied=File.createTempFile("copied", ".nc");
|
||||
transferStream(new FileInputStream(original),new FileOutputStream(temp));
|
||||
System.out.println("copied. Moving..");
|
||||
for(String f:toCheckFiles) {
|
||||
System.out.println("checking "+f);
|
||||
try{
|
||||
check(false,f);
|
||||
}catch(UnsupportedStorageException e) {
|
||||
System.err.println(e.getMessage());
|
||||
// System.out.println("Trying opening "+f+" manually");
|
||||
// open(f);
|
||||
}
|
||||
}
|
||||
System.out.println("Done");
|
||||
}
|
||||
|
||||
|
||||
// private static void open(String path) throws IOException, UnsupportedStorageException, DataStoreException {
|
||||
// System.out.println("Opening "+path);
|
||||
// NetcdfFile f=NetcdfFiles.open(path);
|
||||
// System.out.println(f.getFileTypeDescription()+"\t"+f.getFileTypeId());
|
||||
//
|
||||
//
|
||||
// NetcdfDataset ncDs=NetcdfDatasets.openDataset(path);
|
||||
//// NcMLReaderNew.
|
||||
////
|
||||
// System.out.println(ncDs.getFileTypeDescription()+"\t"+ncDs.getFileTypeId());
|
||||
//
|
||||
//// NetcdfDatasets.openFile(path,null);
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
private static void check(boolean checkCopy,String src) throws UnsupportedStorageException, DataStoreException, IOException, NoSuchAlgorithmException {
|
||||
|
||||
File original=new File(src);
|
||||
|
||||
System.out.println("Checksum original : "+getChecksum(original));
|
||||
System.out.println("Checksum temp : "+getChecksum(temp));
|
||||
File dataset=original;
|
||||
|
||||
if(checkCopy) {
|
||||
File temp=File.createTempFile("temp", ".temp");
|
||||
File copied=File.createTempFile("copied", ".nc");
|
||||
transferStream(new FileInputStream(original),new FileOutputStream(temp));
|
||||
System.out.println("copied. Moving..");
|
||||
|
||||
System.out.println("Checksum original : "+getChecksum(original));
|
||||
System.out.println("Checksum temp : "+getChecksum(temp));
|
||||
|
||||
|
||||
|
||||
Files.move(temp.toPath(), copied.toPath(),StandardCopyOption.ATOMIC_MOVE,StandardCopyOption.REPLACE_EXISTING);
|
||||
if(copied.length()<original.length()) throw new RuntimeException("Different size after moving");
|
||||
|
||||
dataset=copied;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(dataset.exists())
|
||||
System.out.println(SisPlugin.getMetaFromFile(dataset));
|
||||
else {
|
||||
System.out.println(SisPlugin.getMetaFromFile(new URL(src)));
|
||||
}
|
||||
|
||||
|
||||
Files.move(temp.toPath(), copied.toPath(),StandardCopyOption.ATOMIC_MOVE,StandardCopyOption.REPLACE_EXISTING);
|
||||
if(copied.length()<original.length()) throw new RuntimeException("Different size after moving");
|
||||
System.out.println(SisPlugin.getMetaFromFile(copied));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static String getChecksum(File datafile) throws NoSuchAlgorithmException, IOException {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA1");
|
||||
FileInputStream fis = new FileInputStream(datafile);
|
||||
byte[] dataBytes = new byte[1024];
|
||||
FileInputStream fis = new FileInputStream(datafile);
|
||||
byte[] dataBytes = new byte[1024];
|
||||
|
||||
int nread = 0;
|
||||
int nread = 0;
|
||||
|
||||
while ((nread = fis.read(dataBytes)) != -1) {
|
||||
md.update(dataBytes, 0, nread);
|
||||
};
|
||||
while ((nread = fis.read(dataBytes)) != -1) {
|
||||
md.update(dataBytes, 0, nread);
|
||||
};
|
||||
|
||||
byte[] mdbytes = md.digest();
|
||||
byte[] mdbytes = md.digest();
|
||||
|
||||
//convert the byte to hex format
|
||||
StringBuffer sb = new StringBuffer("");
|
||||
for (int i = 0; i < mdbytes.length; i++) {
|
||||
sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
|
||||
}
|
||||
//convert the byte to hex format
|
||||
StringBuffer sb = new StringBuffer("");
|
||||
for (int i = 0; i < mdbytes.length; i++) {
|
||||
sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void transferStream(InputStream in, OutputStream out){
|
||||
|
||||
|
@ -74,12 +136,12 @@ public class TestGetMetadata {
|
|||
while ((received=in.read(internalBuf))!=-1){
|
||||
out.write(internalBuf,0,received);
|
||||
receivedTotal+=received;
|
||||
|
||||
|
||||
}
|
||||
out.flush();
|
||||
}catch(IOException e){
|
||||
throw new RuntimeException("Unable to read from source.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue