Force 19139:2007
This commit is contained in:
parent
94064f17f7
commit
252e273556
|
@ -2,7 +2,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||||
|
|
||||||
# Changelog for org.gcube.data.transfer.sis-geotk-plugin
|
# Changelog for org.gcube.data.transfer.sis-geotk-plugin
|
||||||
|
|
||||||
## [v1.2.0] 2020-09-07
|
## [v1.2.0-SNAPSHOT] 2020-09-07
|
||||||
Upgrade to apache-sis 1.0
|
Upgrade to apache-sis 1.0
|
||||||
|
|
||||||
## [v1.1.3] 2020-09-07
|
## [v1.1.3] 2020-09-07
|
||||||
|
|
16
pom.xml
16
pom.xml
|
@ -9,7 +9,7 @@
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.gcube.data.transfer</groupId>
|
<groupId>org.gcube.data.transfer</groupId>
|
||||||
<artifactId>sis-geotk-plugin</artifactId>
|
<artifactId>sis-geotk-plugin</artifactId>
|
||||||
<version>1.2.0</version>
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
<name>Sis/GeoToolkit plugin</name>
|
<name>Sis/GeoToolkit plugin</name>
|
||||||
<description>Apache Sis/Geotk plugin for data-transfer-service</description>
|
<description>Apache Sis/Geotk plugin for data-transfer-service</description>
|
||||||
|
|
||||||
|
@ -132,6 +132,20 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- OVERRIDE NAMESPACE PREFIX -->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-impl</artifactId>
|
||||||
|
<version>2.2.11</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-core</artifactId>
|
||||||
|
<version>2.2.11</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- TEST -->
|
<!-- TEST -->
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
package org.gcube.data.transfer.plugins.thredds;
|
||||||
|
|
||||||
|
import static java.util.Collections.singletonMap;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.xml.bind.JAXBException;
|
||||||
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
|
import org.apache.sis.xml.MarshallerPool;
|
||||||
|
import org.apache.sis.xml.XML;
|
||||||
|
import org.opengis.metadata.Metadata;
|
||||||
|
|
||||||
|
import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
|
||||||
|
|
||||||
|
import lombok.Synchronized;
|
||||||
|
|
||||||
|
public class ISOMetadataMarshalling {
|
||||||
|
|
||||||
|
private static MarshallerPool pool=null;
|
||||||
|
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
private static MarshallerPool getPool() throws JAXBException {
|
||||||
|
if(pool==null)
|
||||||
|
pool=new MarshallerPool(
|
||||||
|
singletonMap(XML.METADATA_VERSION,"2007"));
|
||||||
|
|
||||||
|
return pool;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final File asXML(Metadata meta) throws JAXBException, IOException {
|
||||||
|
File tmp=File.createTempFile("tmp_meta_", ".xml");
|
||||||
|
try (FileWriter fw=new FileWriter(tmp)){
|
||||||
|
|
||||||
|
getPool().acquireMarshaller().marshal(meta,new StreamResult(fw));
|
||||||
|
|
||||||
|
// XML.marshal(meta, new StreamResult(fw), singletonMap(XML.METADATA_VERSION,"2007"));
|
||||||
|
}
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class Mapper extends NamespacePrefixMapper {
|
||||||
|
|
||||||
|
private Map<String, String> namespaceMap = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create mappings.
|
||||||
|
*/
|
||||||
|
public Mapper() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespaceMap.put("http://www.w3.org/2001/XMLSchema-instance", "xsi");
|
||||||
|
namespaceMap.put("https://www.intertech.com/software-consulting-services/", "consult");
|
||||||
|
namespaceMap.put("http://www.w3.org/2003/05/soap-envelope/", "soap");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* Returning null when not found based on spec.
|
||||||
|
* @see com.sun.xml.bind.marshaller.NamespacePrefixMapper#getPreferredPrefix(java.lang.String, java.lang.String, boolean)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) {
|
||||||
|
return namespaceMap.getOrDefault(namespaceUri, suggestion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,6 +16,7 @@ import org.gcube.data.transfer.model.plugins.thredds.ThreddsCatalog;
|
||||||
import org.gcube.data.transfer.plugin.AbstractPlugin;
|
import org.gcube.data.transfer.plugin.AbstractPlugin;
|
||||||
import org.gcube.data.transfer.plugin.fails.PluginCleanupException;
|
import org.gcube.data.transfer.plugin.fails.PluginCleanupException;
|
||||||
import org.gcube.data.transfer.plugin.fails.PluginExecutionException;
|
import org.gcube.data.transfer.plugin.fails.PluginExecutionException;
|
||||||
|
import org.gcube.data.transfer.plugins.thredds.ISOMetadataMarshalling;
|
||||||
import org.gcube.data.transfer.plugins.thredds.ThreddsInstanceManager;
|
import org.gcube.data.transfer.plugins.thredds.ThreddsInstanceManager;
|
||||||
import org.gcube.spatial.data.sdi.model.metadata.MetadataPublishOptions;
|
import org.gcube.spatial.data.sdi.model.metadata.MetadataPublishOptions;
|
||||||
import org.gcube.spatial.data.sdi.model.metadata.MetadataReport;
|
import org.gcube.spatial.data.sdi.model.metadata.MetadataReport;
|
||||||
|
@ -69,9 +70,7 @@ public class SisPlugin extends AbstractPlugin {
|
||||||
log.debug("Extracting meta from {} ",dataStore.getAbsolutePath());
|
log.debug("Extracting meta from {} ",dataStore.getAbsolutePath());
|
||||||
Metadata meta=getMetaFromFile(dataStore);
|
Metadata meta=getMetaFromFile(dataStore);
|
||||||
|
|
||||||
tmp=File.createTempFile("tmp_meta_", ".xml");
|
tmp=ISOMetadataMarshalling.asXML(meta);
|
||||||
|
|
||||||
XML.marshal(meta,tmp);
|
|
||||||
|
|
||||||
org.gcube.spatial.data.sdi.interfaces.Metadata metadataInterface=SDIAbstractPlugin.metadata().build();
|
org.gcube.spatial.data.sdi.interfaces.Metadata metadataInterface=SDIAbstractPlugin.metadata().build();
|
||||||
|
|
||||||
|
|
|
@ -12,24 +12,29 @@ import java.nio.file.StandardCopyOption;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
|
import javax.xml.bind.JAXBException;
|
||||||
|
|
||||||
import org.apache.sis.storage.DataStoreException;
|
import org.apache.sis.storage.DataStoreException;
|
||||||
import org.apache.sis.storage.UnsupportedStorageException;
|
import org.apache.sis.storage.UnsupportedStorageException;
|
||||||
|
import org.apache.sis.xml.XML;
|
||||||
|
import org.gcube.data.transfer.plugins.thredds.ISOMetadataMarshalling;
|
||||||
import org.gcube.data.transfer.plugins.thredds.sis.SisPlugin;
|
import org.gcube.data.transfer.plugins.thredds.sis.SisPlugin;
|
||||||
|
import org.opengis.metadata.Metadata;
|
||||||
|
|
||||||
public class TestGetMetadata {
|
public class TestGetMetadata {
|
||||||
|
|
||||||
public static void main(String[] args) throws UnsupportedStorageException, DataStoreException, IOException, NoSuchAlgorithmException {
|
public static void main(String[] args) throws UnsupportedStorageException, DataStoreException, IOException, NoSuchAlgorithmException, JAXBException {
|
||||||
String[] toCheckFiles=new String[] {
|
String[] toCheckFiles=new String[] {
|
||||||
|
|
||||||
|
|
||||||
// ********** HDF - NETCDF 4
|
// ********** HDF - NETCDF 4
|
||||||
"/Users/FabioISTI/Downloads/NASA_Precipitations_1950_2100_rcp45.nc",
|
"/Users/FabioISTI/Downloads/NASA_Surface_Air_Temperature_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_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_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_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/NASA_Surface_Air_Temperature_1950_2100_rcp85.nc",
|
||||||
"https://thredds.d4science.org/thredds/fileServer/public/netcdf/ClimateChange/hcaf_v6_1950_2100.nc",
|
// "https://thredds.d4science.org/thredds/fileServer/public/netcdf/ClimateChange/hcaf_v6_1950_2100.nc",
|
||||||
|
|
||||||
|
|
||||||
// *********** NETCDF 3
|
// *********** NETCDF 3
|
||||||
|
@ -68,7 +73,7 @@ public class TestGetMetadata {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
private static void check(boolean checkCopy,String src) throws UnsupportedStorageException, DataStoreException, IOException, NoSuchAlgorithmException {
|
private static void check(boolean checkCopy,String src) throws UnsupportedStorageException, DataStoreException, IOException, NoSuchAlgorithmException, JAXBException {
|
||||||
|
|
||||||
File original=new File(src);
|
File original=new File(src);
|
||||||
|
|
||||||
|
@ -94,14 +99,18 @@ public class TestGetMetadata {
|
||||||
|
|
||||||
|
|
||||||
if(dataset.exists())
|
if(dataset.exists())
|
||||||
System.out.println(SisPlugin.getMetaFromFile(dataset));
|
System.out.println(
|
||||||
|
ISOMetadataMarshalling.asXML(SisPlugin.getMetaFromFile(dataset)).getAbsolutePath());
|
||||||
else {
|
else {
|
||||||
System.out.println(SisPlugin.getMetaFromFile(new URL(src)));
|
System.out.println(
|
||||||
|
ISOMetadataMarshalling.asXML(SisPlugin.getMetaFromFile(new URL(src))).getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static String getChecksum(File datafile) throws NoSuchAlgorithmException, IOException {
|
private static String getChecksum(File datafile) throws NoSuchAlgorithmException, IOException {
|
||||||
MessageDigest md = MessageDigest.getInstance("SHA1");
|
MessageDigest md = MessageDigest.getInstance("SHA1");
|
||||||
|
|
Loading…
Reference in New Issue