git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/spatial-data/sdi-interface@152447 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Fabio Sinibaldi 2017-08-03 10:42:27 +00:00
parent 75f5e0340a
commit 73b9975e1c
22 changed files with 447 additions and 197 deletions

View File

@ -1,4 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
resolveWorkspaceProjects=false
version=1

56
pom.xml
View File

@ -1,17 +1,18 @@
<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>
<groupId>org.gcube.tools</groupId>
<artifactId>maven-parent</artifactId>
<version>LATEST</version>
</parent>
<groupId>org.gcube.spatial.data</groupId>
<artifactId>sdi-interface</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>SDI Interface</name>
<description>SDI Service interface and model</description>
<dependencyManagement>
<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>
<groupId>org.gcube.tools</groupId>
<artifactId>maven-parent</artifactId>
<version>LATEST</version>
</parent>
<groupId>org.gcube.spatial.data</groupId>
<artifactId>sdi-interface</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>SDI Interface</name>
<description>SDI Service interface and model</description>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
@ -22,10 +23,10 @@
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@ -34,15 +35,20 @@
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>2.6.0</version>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>
<!-- lombok -->
<dependency>
@ -56,5 +62,5 @@
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,20 @@
package org.gcube.spatial.data.sdi.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import lombok.Data;
@XmlRootElement
@Data
@XmlAccessorType(XmlAccessType.NONE)
public class StringEntry {
@XmlElement(name = "name")
private String name;
@XmlElement(name = "value")
private String value;
}

View File

@ -1,5 +1,7 @@
package org.gcube.spatial.data.sdi.model.faults;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@ -7,6 +9,7 @@ import lombok.Data;
@XmlRootElement
@Data
@XmlAccessorType(XmlAccessType.NONE)
public class ErrorMessage {
/** contains the same HTTP Status code returned by the server */

View File

@ -21,14 +21,16 @@ import lombok.ToString;
@ToString
@EqualsAndHashCode
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlAccessorType(XmlAccessType.NONE)
public class MetadataReport {
@XmlElement(name="publishedUUID")
private String publishedUUID;
@XmlElement(name="publishedID")
private Long publishedID;
@XmlElement(name="appliedTemplates")
private Set<String> appliedTemplates;
}

View File

@ -4,6 +4,7 @@ import java.util.HashSet;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import lombok.AllArgsConstructor;
@ -18,9 +19,10 @@ import lombok.ToString;
@AllArgsConstructor
@ToString
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlAccessorType(XmlAccessType.NONE)
public class TemplateApplicationRequest {
@XmlElement(name="invocationSet")
private HashSet<TemplateInvocation> invocationSet;
@Override

View File

@ -5,6 +5,7 @@ import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import lombok.AllArgsConstructor;
@ -19,9 +20,10 @@ import lombok.ToString;
@AllArgsConstructor
@ToString
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlAccessorType(XmlAccessType.NONE)
public class TemplateCollection {
@XmlElement(name="availableTemplates")
private Set<TemplateDescriptor> availableTemplates=new HashSet<TemplateDescriptor>();
@Override

View File

@ -6,6 +6,7 @@ import java.util.Map.Entry;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@ -23,16 +24,22 @@ import lombok.ToString;
@AllArgsConstructor
@ToString
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlAccessorType(XmlAccessType.NONE)
public class TemplateDescriptor {
@XmlElement(name="templateID")
private String id;
@XmlElement(name="name")
private String name;
@XmlElement(name="description")
private String description;
@XmlElement(name="sourceURL")
private String sourceURL;
@XmlAnyElement
@XmlJavaTypeAdapter(MapAdapter.class)
// @XmlAnyElement
// @XmlJavaTypeAdapter(MapAdapter.class)
@XmlElement(name="parameters")
private HashMap<String,String> expectedParameters;
@Override

View File

@ -5,11 +5,8 @@ import java.util.Map.Entry;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.gcube.spatial.data.sdi.model.MapAdapter;
import lombok.AllArgsConstructor;
import lombok.Getter;
@ -23,13 +20,15 @@ import lombok.ToString;
@AllArgsConstructor
@ToString
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlAccessorType(XmlAccessType.NONE)
public class TemplateInvocation {
@XmlElement(name="templateID")
private String toInvokeTemplateID;
@XmlAnyElement
@XmlJavaTypeAdapter(MapAdapter.class)
// @XmlAnyElement
// @XmlJavaTypeAdapter(MapAdapter.class)
@XmlElement(name="parameters")
private HashMap<String,String> templateParameters;
@Override

View File

@ -0,0 +1,26 @@
package org.gcube.spatial.data.sdi.model.services;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@Getter
@Setter
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class CatalogDefinition {
private String name;
}

View File

@ -0,0 +1,35 @@
package org.gcube.spatial.data.sdi.model.services;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@Getter
@Setter
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class GeoNetworkServiceDefinition extends ServiceDefinition {
@XmlElement(name = "priority")
private int priority;
@Override
public Type getType() {
return Type.GEONETWORK;
}
}

View File

@ -0,0 +1,33 @@
package org.gcube.spatial.data.sdi.model.services;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@Getter
@Setter
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class GeoServerDefinition extends ServiceDefinition {
@Override
public Type getType() {
return Type.GEOSERVER;
}
private List<WorkspaceDefinition> workspaces;
}

View File

@ -0,0 +1,10 @@
package org.gcube.spatial.data.sdi.model.services;
public class SdiStatusReport {
}

View File

@ -0,0 +1,78 @@
package org.gcube.spatial.data.sdi.model.services;
import java.util.HashMap;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@Getter
@Setter
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@RequiredArgsConstructor
public abstract class ServiceDefinition {
public static enum Type{
THREDDS,GEOSERVER,GEONETWORK
}
@XmlElement(name ="hostname")
@NonNull
private String hostname;
@XmlElement(name ="majorVersion")
@NonNull
private Short majorVersion;
@XmlElement(name ="minorVersion")
@NonNull
private Short minorVersion;
@XmlElement(name ="releaseVersion")
private Short releaseVersion;
@XmlElement(name ="type")
@NonNull
private Type type;
@XmlElement(name ="adminPassword")
@NonNull
private String adminPassword;
@XmlElement(name ="properties")
private HashMap<String,String> properties;
@XmlElement(name ="description")
private String description;
@XmlElement(name ="name")
@NonNull
private String name;
@Override
public String toString() {
return "ServiceDefinition [hostname=" + hostname + ", majorVersion=" + majorVersion + ", minorVersion="
+ minorVersion + ", releaseVersion=" + releaseVersion + ", type=" + type + ", properties=" + properties
+ ", description=" + description + ", name=" + name + "]";
}
}

View File

@ -0,0 +1,34 @@
package org.gcube.spatial.data.sdi.model.services;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@Getter
@Setter
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class ThreddsDefinition extends ServiceDefinition {
@Override
public Type getType() {
return Type.THREDDS;
}
private List<CatalogDefinition> catalogs;
}

View File

@ -0,0 +1,28 @@
package org.gcube.spatial.data.sdi.model.services;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@Getter
@Setter
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class WorkspaceDefinition {
private String name;
}

View File

@ -1 +0,0 @@
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory

View File

@ -2,204 +2,139 @@ package org.gcube.spatial.data.sdi;
import static org.junit.Assert.assertTrue;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collection;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.apache.commons.collections.CollectionUtils;
import org.gcube.spatial.data.sdi.model.faults.ErrorMessage;
import org.gcube.spatial.data.sdi.model.metadata.MetadataReport;
import org.gcube.spatial.data.sdi.model.metadata.TemplateApplicationRequest;
import org.gcube.spatial.data.sdi.model.metadata.TemplateCollection;
import org.gcube.spatial.data.sdi.model.metadata.TemplateDescriptor;
import org.gcube.spatial.data.sdi.model.metadata.TemplateInvocationBuilder;
import org.gcube.spatial.data.sdi.model.metadata.TemplateInvocation;
import org.junit.BeforeClass;
import org.junit.Test;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.AnnotationIntrospector;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
public class MarshallUnmarshallTest {
static JAXBContext ctx =null;
static ObjectMapper mapper=null;
@BeforeClass
public static void init() throws JAXBException{
ctx = JAXBContext.newInstance(
MetadataReport.class,
TemplateApplicationRequest.class,
TemplateCollection.class,
ErrorMessage.class);
mapper=new ObjectMapper();
AnnotationIntrospector introspector=new JaxbAnnotationIntrospector(mapper.getTypeFactory());
mapper.setAnnotationIntrospector(introspector);
mapper.enable(SerializationFeature.INDENT_OUTPUT);
}
public static boolean roundTrip(Object obj){
public static boolean roundTrip(Object obj) throws JsonParseException, JsonMappingException, JsonProcessingException, IOException{
Object roundTripResult=mapper.readValue(marshal(obj), obj.getClass());
Object roundTripResult=unmarshal(obj.getClass(), new StringReader(marshal(obj,new StringWriter()).toString()));
if(obj instanceof Collection) {
return CollectionUtils.isEqualCollection((Collection)obj, (Collection)roundTripResult);
}
return obj.equals(roundTripResult);
}
@Test
public void testHashAndEquals() {
assertTrue(getTemplateInvocations().equals(getTemplateInvocations()));
assertTrue(getTemplateInvocations().hashCode()==getTemplateInvocations().hashCode());
assertTrue(getDescriptors().equals(getDescriptors()));
assertTrue(getDescriptors().hashCode()==getDescriptors().hashCode());
assertTrue(getReport().equals(getReport()));
assertTrue(getReport().hashCode()==getReport().hashCode());
assertTrue(getError().equals(getError()));
assertTrue(getError().hashCode()==getError().hashCode());
public void testHashAndEquals() throws IOException {
assertTrue(loadObject(TemplateInvocation.class).equals(loadObject(TemplateInvocation.class)));
assertTrue(loadObject(TemplateInvocation.class).hashCode()==loadObject(TemplateInvocation.class).hashCode());
assertTrue(loadObject(TemplateDescriptor.class).equals(loadObject(TemplateDescriptor.class)));
assertTrue(loadObject(TemplateDescriptor.class).hashCode()==loadObject(TemplateDescriptor.class).hashCode());
assertTrue(loadObject(MetadataReport.class).equals(loadObject(MetadataReport.class)));
assertTrue(loadObject(MetadataReport.class).hashCode()==loadObject(MetadataReport.class).hashCode());
assertTrue(loadObject(ErrorMessage.class).equals(loadObject(ErrorMessage.class)));
assertTrue(loadObject(ErrorMessage.class).hashCode()==loadObject(ErrorMessage.class).hashCode());
}
@Test
public void Marshall(){
print(getTemplateInvocations());
print(getDescriptors());
print(getReport());
print(getError());
public void Marshall() throws IOException{
print(loadObject(TemplateInvocation.class));
print(loadObject(TemplateDescriptor.class));
print(loadObject(MetadataReport.class));
print(loadObject(ErrorMessage.class));
}
@Test
public void unMarshall(){
assertTrue(roundTrip(getTemplateInvocations()));
assertTrue(roundTrip(getDescriptors()));
assertTrue(roundTrip(getReport()));
assertTrue(roundTrip(getError()));
public void unMarshall() throws JsonParseException, JsonMappingException, JsonProcessingException, IOException{
assertTrue(roundTrip(loadObject(TemplateInvocation.class)));
assertTrue(roundTrip(loadObject(TemplateDescriptor.class)));
assertTrue(roundTrip(loadObject(MetadataReport.class)));
assertTrue(roundTrip(loadObject(ErrorMessage.class)));
}
@Test
public void toStringTest(){
System.out.println(getTemplateInvocations());
System.out.println(getDescriptors());
System.out.println(getReport());
System.out.println(getError());
}
/**
* Write the serialisation of a given resource to a {@link Result}.
* @param resource the resource
* @param stream the result
* @return the result in input
*/
public static <T extends Result> T marshal(Object resource,T result) {
try {
// OLD XML MARSHALLING
// JAXBContext context = ctx;
// Marshaller m = context.createMarshaller();
// m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
//
// m.marshal(resource,result);
//
// return result;
JAXBContext jaxbContext = ctx;
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty("eclipselink.media-type", "application/json");
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.marshal(resource, result);
return result;
}
catch(Exception e) {
throw new RuntimeException("serialisation error",e);
}
public void toStringTest() throws IOException{
System.out.println(loadObject(TemplateInvocation.class));
System.out.println(loadObject(TemplateDescriptor.class));
System.out.println(loadObject(MetadataReport.class));
System.out.println(loadObject(ErrorMessage.class));
}
public static void print(Object resource) {
marshal(resource,new OutputStreamWriter(System.out));
public static String marshal(Object toSerialize) throws JsonProcessingException {
return mapper.writeValueAsString(toSerialize);
}
/**
* Write the serialisation of a given resource to a given character stream.
* @param resource the resource
* @param stream the stream in input
*/
public static <T extends Writer> T marshal(Object resource,T stream) {
marshal(resource,new StreamResult(stream));
return stream;
public static void print(Object obj) throws JsonProcessingException {
System.out.println(marshal(obj));
}
// public static <T> T unmarshal(Class<T> resourceClass, String toRead) throws JsonParseException, JsonMappingException, IOException {
// return mapper.readValue(toRead, resourceClass);
// }
/**
* Creates a resource of given class from its serialisation in a given {@link Reader}.
* @param resourceClass the class of the resource
* @param reader the reader
* @return the resource
*/
public static <T> T unmarshal(Class<T> resourceClass, Reader reader) {
return unmarshal(resourceClass,new StreamSource(reader));
}
/**
* Creates a resource of given class from its serialisation in a given {@link InputStream}.
* @param resourceClass the class of the resource
* @param stream the stream
* @return the resource
*/
public static <T> T unmarshal(Class<T> resourceClass, InputStream stream) {
return unmarshal(resourceClass,new StreamSource(stream));
}
/**
* Creates a resource of given class from its serialisation in a given {@link Source}.
* @param resourceClass the class of the resource
* @param source the source
* @return the resource
*/
public static <T> T unmarshal(Class<T> resourceClass,Source source) {
try {
Unmarshaller um = ctx.createUnmarshaller();
um.setProperty("eclipselink.media-type", "application/json");
return resourceClass.cast(um.unmarshal(source));
}
catch(Exception e) {
throw new RuntimeException("deserialisation error",e);
}
}
private TemplateApplicationRequest getTemplateInvocations(){
return new TemplateApplicationRequest(new TemplateInvocationBuilder().threddsOnlineResources("localhost", "myDataset.nc", "my Catalog").get());
}
private TemplateCollection getDescriptors(){
HashSet<TemplateDescriptor> descriptors=new HashSet<>();
descriptors.add(new TemplateDescriptor(TemplateInvocationBuilder.THREDDS_ONLINE.ID,"Thredds Online Resources","Online reousrce template for thredds resources","http://some.place.org/theTemplate", new HashMap<String,String>()));
descriptors.add(new TemplateDescriptor(TemplateInvocationBuilder.THREDDS_ONLINE.ID,"Thredds Online Resources","Online reousrce template for thredds resources","http://some.place.org/theTemplate", new HashMap<String,String>()));
return new TemplateCollection(descriptors);
}
private MetadataReport getReport(){
return new MetadataReport("theUUID", 12335l, Collections.singleton(TemplateInvocationBuilder.THREDDS_ONLINE.ID));
}
//
//
// private TemplateApplicationRequest getTemplateInvocations(){
// return new TemplateApplicationRequest(new TemplateInvocationBuilder().threddsOnlineResources("localhost", "myDataset.nc", "my Catalog").get());
// }
//
// private TemplateCollection getDescriptors(){
// HashSet<TemplateDescriptor> descriptors=new HashSet<>();
// descriptors.add(new TemplateDescriptor(TemplateInvocationBuilder.THREDDS_ONLINE.ID,"Thredds Online Resources","Online reousrce template for thredds resources","http://some.place.org/theTemplate", new HashMap<String,String>()));
// descriptors.add(new TemplateDescriptor(TemplateInvocationBuilder.THREDDS_ONLINE.ID,"Thredds Online Resources","Online reousrce template for thredds resources","http://some.place.org/theTemplate", new HashMap<String,String>()));
// return new TemplateCollection(descriptors);
// }
//
// private MetadataReport getReport(){
// return new MetadataReport("theUUID", 12335l, Collections.singleton(TemplateInvocationBuilder.THREDDS_ONLINE.ID));
// }
//
//
// private ErrorMessage getError(){
// ErrorMessage error=new ErrorMessage();
// error.setCode(500);
// error.setDeveloperMessage("Develop it better!");
// error.setMessage("You didn't see anything");
// error.setLink("www.sto.ca.z.z.o.org");
// return error;
// }
private ErrorMessage getError(){
ErrorMessage error=new ErrorMessage();
error.setCode(500);
error.setDeveloperMessage("Develop it better!");
error.setMessage("You didn't see anything");
error.setLink("www.sto.ca.z.z.o.org");
return error;
private <T> T loadObject(Class<T> objectClass) throws IOException {
byte[] encoded = Files.readAllBytes(Paths.get("src/test/resources/json/"+objectClass.getSimpleName()+".json"));
return mapper.readValue(encoded, objectClass);
}
}

View File

@ -0,0 +1,7 @@
{
"status" : 0,
"code" : 500,
"message" : "You didn't see anything",
"link" : "www.sto.ca.z.z.o.org",
"developerMessage" : "Develop it better!"
}

View File

@ -0,0 +1,5 @@
{
"publishedUUID" : "theUUID",
"publishedID" : 12335,
"appliedTemplates" : [ "THREDDS_ONLINE_RESOURCES" ]
}

View File

@ -0,0 +1,11 @@
{
"templateID": "THREDDS_ONLINE_RESOURCES",
"name": "Thredds Online Resources",
"description": "Template for online resources exposed by thredds.",
"sourceURL": "http://sdi-d4s.d4science.org",
"parameters": {
"hostname" : "Thredds hostname",
"filename" : "The dataset's file name",
"catalog" : "The thredds catalog name"
}
}

View File

@ -0,0 +1,8 @@
{
"templateID" : "THREDDS_ONLINE_RESOURCES",
"parameters" : {
"hostname" : "localhost",
"filename" : "myDataset.nc",
"catalog" : "my Catalog"
}
}