From cae76f1adc3df108e7b3c580d559edaa55abbbc9 Mon Sep 17 00:00:00 2001 From: Fabio Sinibaldi Date: Fri, 12 Feb 2021 16:39:58 +0100 Subject: [PATCH] imported common interface module --- pom.xml | 5 +- sdi-interface/.DS_Store | Bin 0 -> 6148 bytes sdi-interface/CHANGELOG.md | 13 + sdi-interface/FUNDING.md | 26 ++ sdi-interface/LICENSE.md | 312 ++++++++++++++++++ sdi-interface/README.md | 51 +++ sdi-interface/pom.xml | 93 ++++++ .../model/profiles/ApplicationProfile.java | 114 +++++++ .../data/plugins/GISServicePlugin.java | 5 + .../data/sdi/interfaces/GeoNetwork.java | 43 +++ .../spatial/data/sdi/interfaces/Metadata.java | 14 + .../spatial/data/sdi/model/MapAdapter.java | 50 +++ .../spatial/data/sdi/model/ParameterType.java | 31 ++ .../data/sdi/model/ScopeConfiguration.java | 41 +++ .../data/sdi/model/ServiceConstants.java | 45 +++ .../spatial/data/sdi/model/StringEntry.java | 20 ++ .../sdi/model/credentials/AccessType.java | 10 + .../sdi/model/credentials/Credentials.java | 34 ++ .../model/faults/ConfigurationException.java | 35 ++ .../data/sdi/model/faults/ErrorMessage.java | 36 ++ .../sdi/model/faults/InternalException.java | 39 +++ .../sdi/model/faults/RemoteException.java | 34 ++ .../spatial/data/sdi/model/gn/Account.java | 28 ++ .../spatial/data/sdi/model/gn/Group.java | 50 +++ .../spatial/data/sdi/model/gn/LoginLevel.java | 9 + .../gcube/spatial/data/sdi/model/gn/User.java | 74 +++++ .../sdi/model/gn/query/GNSearchRequest.java | 5 + .../sdi/model/gn/query/GNSearchResponse.java | 9 + .../data/sdi/model/metadata/MetadataInfo.java | 9 + .../metadata/MetadataPublishOptions.java | 35 ++ .../sdi/model/metadata/MetadataReport.java | 36 ++ .../metadata/TemplateApplicationRequest.java | 71 ++++ .../model/metadata/TemplateCollection.java | 65 ++++ .../model/metadata/TemplateDescriptor.java | 113 +++++++ .../model/metadata/TemplateInvocation.java | 81 +++++ .../metadata/TemplateInvocationBuilder.java | 36 ++ .../data/sdi/model/services/ACCESS_TYPE.java | 5 + .../sdi/model/services/CatalogDefinition.java | 30 ++ .../services/GeoNetworkServiceDefinition.java | 35 ++ .../model/services/GeoServerDefinition.java | 79 +++++ .../sdi/model/services/SdiStatusReport.java | 10 + .../sdi/model/services/ServiceDefinition.java | 168 ++++++++++ .../sdi/model/services/ThreddsDefinition.java | 74 +++++ .../model/services/WorkspaceDefinition.java | 30 ++ .../spatial/data/sdi/utils/ScopeUtils.java | 113 +++++++ .../spatial/data/sdi/utils/StringUtils.java | 27 ++ .../data/sdi/MarshallUnmarshallTest.java | 209 ++++++++++++ 47 files changed, 2450 insertions(+), 2 deletions(-) create mode 100644 sdi-interface/.DS_Store create mode 100644 sdi-interface/CHANGELOG.md create mode 100644 sdi-interface/FUNDING.md create mode 100644 sdi-interface/LICENSE.md create mode 100644 sdi-interface/README.md create mode 100644 sdi-interface/pom.xml create mode 100644 sdi-interface/src/main/java/org/gcube/spatia/data/model/profiles/ApplicationProfile.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/plugins/GISServicePlugin.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/interfaces/GeoNetwork.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/interfaces/Metadata.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/MapAdapter.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/ParameterType.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/ScopeConfiguration.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/ServiceConstants.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/StringEntry.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/credentials/AccessType.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/credentials/Credentials.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/faults/ConfigurationException.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/faults/ErrorMessage.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/faults/InternalException.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/faults/RemoteException.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/Account.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/Group.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/LoginLevel.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/User.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/query/GNSearchRequest.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/query/GNSearchResponse.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/MetadataInfo.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/MetadataPublishOptions.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/MetadataReport.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateApplicationRequest.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateCollection.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateDescriptor.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateInvocation.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateInvocationBuilder.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/ACCESS_TYPE.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/CatalogDefinition.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/GeoNetworkServiceDefinition.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/GeoServerDefinition.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/SdiStatusReport.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/ServiceDefinition.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/ThreddsDefinition.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/WorkspaceDefinition.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/utils/ScopeUtils.java create mode 100644 sdi-interface/src/main/java/org/gcube/spatial/data/sdi/utils/StringUtils.java create mode 100644 sdi-interface/src/test/java/org/gcube/spatial/data/sdi/MarshallUnmarshallTest.java diff --git a/pom.xml b/pom.xml index 2b38320..94f0ec8 100644 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,7 @@ UTF-8 8.0-M4 + 3.0.1 distro https://code-repo.d4science.org/gCubeSystem @@ -34,9 +35,9 @@ - + - + sdi-interface diff --git a/sdi-interface/.DS_Store b/sdi-interface/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..9a874b5768f336915163bb88cd434575b859f936 GIT binary patch literal 6148 zcmeH~Jr2S!425ml0g0s}V-^m;4I%_5-~tF3k&vj^b9A16778<}(6eNJu~Vz<8=6`~ zboab&MFtUB!i}=AFfm2m$tVxGT*u4pe81nUlA49C} z?O@64YO)2RT{MRe%{!}2F))pG(Sih~)xkgosK7*lF7m<7{{#Hn{6A@7N(HFEpDCdI z{ + 4.0.0 + + org.gcube.tools + maven-parent + 1.1.0 + + org.gcube.spatial.data + sdi-interface + 1.3.0-SNAPSHOT + SDI Interface + SDI Service interface and model + + + ${project.basedir}/distro + https://code-repo.d4science.org/gCubeSystem/ + 3.0.1 + + + + + scm:git:${gitBaseUrl}/${project.artifactId}.git + scm:git:${gitBaseUrl}/${project.artifactId}.git + ${gitBaseUrl}/${project.artifactId}.git + + + + + + + + org.gcube.distribution + gcube-bom + 2.0.0 + pom + import + + + + + + + + + + org.gcube.common + authorization-client + + + + junit + junit + 4.10 + test + + + + org.glassfish.jersey.media + jersey-media-json-jackson + test + + + + commons-collections + commons-collections + 3.0 + test + + + + + org.opengis + geoapi + ${geoAPI-version} + + + + + + org.projectlombok + lombok + 1.14.8 + + + org.slf4j + slf4j-api + + + + + \ No newline at end of file diff --git a/sdi-interface/src/main/java/org/gcube/spatia/data/model/profiles/ApplicationProfile.java b/sdi-interface/src/main/java/org/gcube/spatia/data/model/profiles/ApplicationProfile.java new file mode 100644 index 0000000..bc8dd19 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatia/data/model/profiles/ApplicationProfile.java @@ -0,0 +1,114 @@ +package org.gcube.spatia.data.model.profiles; + +import java.util.Collections; +import java.util.Map; +import java.util.Map.Entry; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +@RequiredArgsConstructor +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +public class ApplicationProfile { + + public static interface Properties{ + public static final String GEOSERVER_STORAGE="geoserver.storage"; + public static final String GEOSERVER_WORKSPACE="geoserver.workspace"; + + public static final String GEONETWORK_CATEGORY="geonetwork.category"; + public static final String GEONETWORK_STYLE="geonetwork.style"; + + public static final String THREDDS_CATALOG="thredds.catalog"; + } + + + @NonNull + private String serviceClass; + @NonNull + private String serviceName; + @NonNull + private Map properties; + + + public String getProperty(String propertyName) { + return properties==null?null:properties.get(propertyName); + } + + + @Override + public String toString() { + return "ApplicationProfile [serviceClass=" + serviceClass + ", serviceName=" + serviceName + ", properties=" + + properties + "]"; + } + + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + + + if(properties!=null && !properties.isEmpty()) + for(Entry prop:properties.entrySet()) { + result = prime * result + ((prop.getKey() == null) ? 0 : prop.getKey().hashCode()); + result = prime * result + ((prop.getValue() == null) ? 0 : prop.getValue().hashCode()); + } + + result = prime * result + ((properties == null) ? 0 : properties.hashCode()); + result = prime * result + ((serviceClass == null) ? 0 : serviceClass.hashCode()); + result = prime * result + ((serviceName == null) ? 0 : serviceName.hashCode()); + return result; + } + + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ApplicationProfile other = (ApplicationProfile) obj; + + + + if (properties == null) { + if (other.properties != null) + return false; + } else { + if(properties.size()!= other.properties.size()) return false; + for(Entry prop:properties.entrySet()) { + if(!other.properties.containsKey(prop.getKey())) return false; + if(!prop.getValue().equals(other.properties.get(prop.getKey()))) return false; + } + } + + + if (serviceClass == null) { + if (other.serviceClass != null) + return false; + } else if (!serviceClass.equals(other.serviceClass)) + return false; + if (serviceName == null) { + if (other.serviceName != null) + return false; + } else if (!serviceName.equals(other.serviceName)) + return false; + return true; + } + + + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/plugins/GISServicePlugin.java b/sdi-interface/src/main/java/org/gcube/spatial/data/plugins/GISServicePlugin.java new file mode 100644 index 0000000..8a5c693 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/plugins/GISServicePlugin.java @@ -0,0 +1,5 @@ +package org.gcube.spatial.data.plugins; + +public interface GISServicePlugin { + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/interfaces/GeoNetwork.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/interfaces/GeoNetwork.java new file mode 100644 index 0000000..a67a6ea --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/interfaces/GeoNetwork.java @@ -0,0 +1,43 @@ +package org.gcube.spatial.data.sdi.interfaces; + +import org.gcube.spatial.data.sdi.model.faults.ConfigurationException; +import org.gcube.spatial.data.sdi.model.faults.InternalException; +import org.gcube.spatial.data.sdi.model.faults.RemoteException; +import org.gcube.spatial.data.sdi.model.gn.LoginLevel; +import org.gcube.spatial.data.sdi.model.gn.query.GNSearchRequest; +import org.gcube.spatial.data.sdi.model.gn.query.GNSearchResponse; +import org.gcube.spatial.data.sdi.model.metadata.MetadataInfo; + + + +public interface GeoNetwork { + + // MANAGEMENT + +// public Credentials getCredentials(String host); + + + + public GNSearchResponse query(GNSearchRequest request) + throws InternalException,RemoteException,ConfigurationException; + + + public Metadata getById(long id) throws InternalException,RemoteException,ConfigurationException; + + public Metadata getById(String UUID) throws InternalException,RemoteException,ConfigurationException; + + public String getByIdAsRawString(String UUID) throws InternalException,RemoteException,ConfigurationException; + + + public void login()throws InternalException,RemoteException,ConfigurationException; + + public void login(LoginLevel level)throws InternalException,RemoteException,ConfigurationException; + + public void logout() throws InternalException,RemoteException,ConfigurationException; + + public MetadataInfo getInfo(Long id) throws InternalException,RemoteException,ConfigurationException; + + public MetadataInfo getInfo(String uuid) throws InternalException,RemoteException,ConfigurationException; + + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/interfaces/Metadata.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/interfaces/Metadata.java new file mode 100644 index 0000000..45f976b --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/interfaces/Metadata.java @@ -0,0 +1,14 @@ +package org.gcube.spatial.data.sdi.interfaces; + +import java.io.File; + +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.TemplateCollection; + +public interface Metadata { + + public TemplateCollection getAvailableTemplates(); + public MetadataReport pushMetadata(File toPublish); + public MetadataReport pushMetadata(File toPublish,MetadataPublishOptions options); +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/MapAdapter.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/MapAdapter.java new file mode 100644 index 0000000..068e148 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/MapAdapter.java @@ -0,0 +1,50 @@ +package org.gcube.spatial.data.sdi.model; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import javax.xml.bind.annotation.adapters.XmlAdapter; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +public class MapAdapter extends XmlAdapter> { + + private DocumentBuilder documentBuilder; + + public MapAdapter() throws Exception { + documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + } + + @Override + public Element marshal(Map map) throws Exception { + Document document = documentBuilder.newDocument(); + Element rootElement = document.createElement("data"); + document.appendChild(rootElement); + for(Entry entry : map.entrySet()) { + Element childElement = document.createElement(entry.getKey()); + childElement.setTextContent(entry.getValue()); + rootElement.appendChild(childElement); + } + return rootElement; + } + + @Override + public Map unmarshal(Element rootElement) throws Exception { + NodeList nodeList = rootElement.getChildNodes(); + Map map = new HashMap(nodeList.getLength()); + for(int x=0; x geonetworkConfiguration; + @NonNull + private List geoserverClusterConfiguration; + @NonNull + private List threddsConfiguration; + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/ServiceConstants.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/ServiceConstants.java new file mode 100644 index 0000000..c05f3e8 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/ServiceConstants.java @@ -0,0 +1,45 @@ +package org.gcube.spatial.data.sdi.model; + +public class ServiceConstants { + + public static final String APPLICATION="SDI-Service"; + public static final String INTERFACE="SDI"; + + public static final String SERVICE_CLASS="SDI"; + public static final String SERVICE_NAME="sdi-service"; + public static final String NAMESPACE="http://gcube-system.org/namespaces/data/sdi-service"; + + + public static final class Metadata{ + public static final String INTERFACE="Metadata"; + public static final String LIST_METHOD="list"; + public static final String PUBLISH_METHOD="publish"; + public static final String VALIDATE_PARAMETER="validate"; + public static final String PUBLIC_PARAMETER="public"; + public static final String STYLESHEET_PARAMETER="stylesheet"; + public static final String UPLOADED_FILE_PARAMETER="theMeta"; + public static final String METADATA_ENRICHMENTS_PARAMETER="metadataEnrichments"; + // Defaults + + public static final Boolean DEFAULT_VALIDATE=true; + public static final Boolean DEFAULT_PUBLIC=false; + public static final String DEFAULT_CATEGORY="Dataset"; + public static final String DEFAULT_STYLESHEET="_none_"; + + } + + + public static final class GeoNetwork{ + public static final String INTERFACE="GeoNetwork"; + public static final String CONFIGURATION_PATH="configuration"; + public static final String GROUPS_PATH="groups"; + + } + + public static final class GeoServer{ + public static final String INTERFACE="GeoServer"; + public static final String HOST_PARAM="host"; + } + + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/StringEntry.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/StringEntry.java new file mode 100644 index 0000000..9871972 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/StringEntry.java @@ -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; + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/credentials/AccessType.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/credentials/AccessType.java new file mode 100644 index 0000000..68a8088 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/credentials/AccessType.java @@ -0,0 +1,10 @@ +package org.gcube.spatial.data.sdi.model.credentials; + +public enum AccessType { + + ADMIN, + CONTEXT_MANAGER, + CONTEXT_USER, + CKAN; + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/credentials/Credentials.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/credentials/Credentials.java new file mode 100644 index 0000000..f3ee67a --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/credentials/Credentials.java @@ -0,0 +1,34 @@ +package org.gcube.spatial.data.sdi.model.credentials; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +@RequiredArgsConstructor +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +public class Credentials { + + @NonNull + private String username; + @NonNull + private String password; + @NonNull + private AccessType accessType; + @Override + public String toString() { + return "Credentials [username=" + username + ", password=****, accessType=" + accessType + "]"; + } + + + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/faults/ConfigurationException.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/faults/ConfigurationException.java new file mode 100644 index 0000000..6d17701 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/faults/ConfigurationException.java @@ -0,0 +1,35 @@ +package org.gcube.spatial.data.sdi.model.faults; + +public class ConfigurationException extends Exception { + + /** + * + */ + private static final long serialVersionUID = -8621547149713561540L; + + public ConfigurationException() { + // TODO Auto-generated constructor stub + } + + public ConfigurationException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + public ConfigurationException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + + public ConfigurationException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + + public ConfigurationException(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + // TODO Auto-generated constructor stub + } + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/faults/ErrorMessage.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/faults/ErrorMessage.java new file mode 100644 index 0000000..a39533d --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/faults/ErrorMessage.java @@ -0,0 +1,36 @@ +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; + +import lombok.Data; + +@XmlRootElement +@Data +@XmlAccessorType(XmlAccessType.NONE) +public class ErrorMessage { + + /** contains the same HTTP Status code returned by the server */ + @XmlElement(name = "status") + int status; + + /** application specific error code */ + @XmlElement(name = "code") + int code; + + /** message describing the error*/ + @XmlElement(name = "message") + String message; + + /** link point to page where the error message is documented */ + @XmlElement(name = "link") + String link; + + /** extra information that might useful for developers */ + @XmlElement(name = "developerMessage") + String developerMessage; + + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/faults/InternalException.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/faults/InternalException.java new file mode 100644 index 0000000..7a609f7 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/faults/InternalException.java @@ -0,0 +1,39 @@ +package org.gcube.spatial.data.sdi.model.faults; + +public class InternalException extends Exception { + + + + /** + * + */ + private static final long serialVersionUID = 7957607092593029526L; + + public InternalException() { + super(); + // TODO Auto-generated constructor stub + } + + public InternalException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + // TODO Auto-generated constructor stub + } + + public InternalException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + + public InternalException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + public InternalException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + + + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/faults/RemoteException.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/faults/RemoteException.java new file mode 100644 index 0000000..412210e --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/faults/RemoteException.java @@ -0,0 +1,34 @@ +package org.gcube.spatial.data.sdi.model.faults; + +public class RemoteException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 3758504937629040958L; + + public RemoteException() { + // TODO Auto-generated constructor stub + } + + public RemoteException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + public RemoteException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + + public RemoteException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + + public RemoteException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + // TODO Auto-generated constructor stub + } + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/Account.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/Account.java new file mode 100644 index 0000000..9c7392e --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/Account.java @@ -0,0 +1,28 @@ +package org.gcube.spatial.data.sdi.model.gn; + +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@EqualsAndHashCode +@AllArgsConstructor +public class Account { + + public static enum Type{ + CKAN,SCOPE + } + + private String user; + private String password; + private Type type; + @Override + public String toString() { + return "Account [user=" + user + ", password=" + "***" + ", type=" + + type + "]"; + } + + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/Group.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/Group.java new file mode 100644 index 0000000..eeafd4e --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/Group.java @@ -0,0 +1,50 @@ +package org.gcube.spatial.data.sdi.model.gn; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@AllArgsConstructor +@ToString +public class Group { + + private String name; + private String description; + private String mail; + private Integer id; + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Group other = (Group) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + + + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/LoginLevel.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/LoginLevel.java new file mode 100644 index 0000000..2b500c0 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/LoginLevel.java @@ -0,0 +1,9 @@ +package org.gcube.spatial.data.sdi.model.gn; + +public class LoginLevel { + + public LoginLevel() { + // TODO Auto-generated constructor stub + } + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/User.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/User.java new file mode 100644 index 0000000..fa38551 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/User.java @@ -0,0 +1,74 @@ +package org.gcube.spatial.data.sdi.model.gn; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +public class User { + + public static enum Profile{ + Editor, // R+W rights + RegisteredUser, // R rights + Administrator, + UserAdmin, + Reviewer, + Guest, + Monitor + } + + + private Integer id; + private String username; + private String password; + private Profile profile; + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((username == null) ? 0 : username.hashCode()); + return result; + } + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + User other = (User) obj; + if (username == null) { + if (other.username != null) + return false; + } else if (!username.equals(other.username)) + return false; + return true; + } + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("User [id="); + builder.append(id); + builder.append(", username="); + builder.append(username); + builder.append(", password="); + builder.append("*******"); + builder.append(", profile="); + builder.append(profile); + builder.append("]"); + return builder.toString(); + } +} \ No newline at end of file diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/query/GNSearchRequest.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/query/GNSearchRequest.java new file mode 100644 index 0000000..ee47ed5 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/query/GNSearchRequest.java @@ -0,0 +1,5 @@ +package org.gcube.spatial.data.sdi.model.gn.query; + +public class GNSearchRequest { + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/query/GNSearchResponse.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/query/GNSearchResponse.java new file mode 100644 index 0000000..908d683 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/gn/query/GNSearchResponse.java @@ -0,0 +1,9 @@ +package org.gcube.spatial.data.sdi.model.gn.query; + +public class GNSearchResponse { + + public GNSearchResponse() { + // TODO Auto-generated constructor stub + } + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/MetadataInfo.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/MetadataInfo.java new file mode 100644 index 0000000..38cbb86 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/MetadataInfo.java @@ -0,0 +1,9 @@ +package org.gcube.spatial.data.sdi.model.metadata; + +public class MetadataInfo { + + public MetadataInfo() { + // TODO Auto-generated constructor stub + } + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/MetadataPublishOptions.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/MetadataPublishOptions.java new file mode 100644 index 0000000..56e5bfd --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/MetadataPublishOptions.java @@ -0,0 +1,35 @@ +package org.gcube.spatial.data.sdi.model.metadata; + +import java.util.HashSet; +import java.util.Set; + +import org.gcube.spatial.data.sdi.model.ServiceConstants; +import org.gcube.spatial.data.sdi.model.ServiceConstants.Metadata; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@ToString +public class MetadataPublishOptions { + + private boolean validate=ServiceConstants.Metadata.DEFAULT_VALIDATE; + private boolean makePublic=ServiceConstants.Metadata.DEFAULT_PUBLIC; + + private String geonetworkCategory=ServiceConstants.Metadata.DEFAULT_CATEGORY; + private String geonetworkStyleSheet=ServiceConstants.Metadata.DEFAULT_STYLESHEET; + private Set templateInvocations=new HashSet<>(); + + public MetadataPublishOptions(Set invocations){ + setTemplateInvocations(invocations); + + + } + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/MetadataReport.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/MetadataReport.java new file mode 100644 index 0000000..9ef9aa8 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/MetadataReport.java @@ -0,0 +1,36 @@ +package org.gcube.spatial.data.sdi.model.metadata; + +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; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@ToString +@EqualsAndHashCode +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) +public class MetadataReport { + + @XmlElement(name="publishedUUID") + private String publishedUUID; + + @XmlElement(name="publishedID") + private Long publishedID; + + @XmlElement(name="appliedTemplates") + private Set appliedTemplates; + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateApplicationRequest.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateApplicationRequest.java new file mode 100644 index 0000000..4006b8c --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateApplicationRequest.java @@ -0,0 +1,71 @@ +package org.gcube.spatial.data.sdi.model.metadata; + +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; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@ToString +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) +public class TemplateApplicationRequest { + + @XmlElement(name="invocationSet") + private HashSet invocationSet; + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + if(invocationSet!=null && !invocationSet.isEmpty()) + for(TemplateInvocation inv:invocationSet) + result=prime*result+inv.hashCode(); + + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TemplateApplicationRequest other = (TemplateApplicationRequest) obj; + + + if (invocationSet == null ) { + if (other.invocationSet != null) + return false; + } else if (invocationSet.size()!=other.invocationSet.size()) + return false; + else for(TemplateInvocation inv:invocationSet) { + boolean ok=false; + for(TemplateInvocation inv2:other.invocationSet) + if(inv.equals(inv2)) { + ok=true; + break; + } + if(!ok)return false; + } + + + return true; + } + + + + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateCollection.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateCollection.java new file mode 100644 index 0000000..954327f --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateCollection.java @@ -0,0 +1,65 @@ +package org.gcube.spatial.data.sdi.model.metadata; + +import java.util.HashSet; +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; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@ToString +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) +public class TemplateCollection { + + @XmlElement(name="availableTemplates") + private Set availableTemplates=new HashSet(); + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + if(availableTemplates!=null && !availableTemplates.isEmpty()) + for(TemplateDescriptor inv:availableTemplates) + result=prime*result+inv.hashCode(); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TemplateCollection other = (TemplateCollection) obj; + + + if (availableTemplates == null ) { + if (other.availableTemplates != null) + return false; + } else if (availableTemplates.size()!=other.availableTemplates.size()) + return false; + else for(TemplateDescriptor inv:availableTemplates) + if(!other.availableTemplates.contains(inv))return false; + + + + return true; + } + + + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateDescriptor.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateDescriptor.java new file mode 100644 index 0000000..c2fef40 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateDescriptor.java @@ -0,0 +1,113 @@ +package org.gcube.spatial.data.sdi.model.metadata; + +import java.util.ArrayList; + +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 org.gcube.spatial.data.sdi.model.ParameterType; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@ToString +@XmlRootElement +@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) + + @XmlElement(name="parameters") + private ArrayList expectedParameters; + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + + if(!(expectedParameters == null || expectedParameters.isEmpty())) + for(ParameterType param:expectedParameters) + result=prime*result+param.hashCode(); + + + + + result = prime * result + ((description == null) ? 0 : description.hashCode()); + + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((sourceURL == null) ? 0 : sourceURL.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TemplateDescriptor other = (TemplateDescriptor) obj; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + + + + if (expectedParameters == null || expectedParameters.isEmpty()) { + if (!(other.expectedParameters == null || other.expectedParameters.isEmpty())) + return false; + } else if (expectedParameters.size()!=other.expectedParameters.size()) + return false; + else + if(!other.expectedParameters.containsAll(this.expectedParameters)) return false; + + + + + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (sourceURL == null) { + if (other.sourceURL != null) + return false; + } else if (!sourceURL.equals(other.sourceURL)) + return false; + return true; + } + + public void addParameter(String name,String value) { + if(expectedParameters==null) expectedParameters=new ArrayList<>(); + expectedParameters.add(new ParameterType(name,value)); + } + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateInvocation.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateInvocation.java new file mode 100644 index 0000000..673c119 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateInvocation.java @@ -0,0 +1,81 @@ +package org.gcube.spatial.data.sdi.model.metadata; + +import java.util.ArrayList; +import java.util.Map.Entry; + +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 org.gcube.spatial.data.sdi.model.ParameterType; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@ToString +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) +public class TemplateInvocation { + + @XmlElement(name="templateID") + private String toInvokeTemplateID; + +// @XmlAnyElement +// @XmlJavaTypeAdapter(MapAdapter.class) + @XmlElement(name="parameters") + private ArrayList templateParameters; + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + if(!(templateParameters == null || templateParameters.isEmpty())) + for(ParameterType param:templateParameters) + result=prime*result+param.hashCode(); + + + result = prime * result + ((toInvokeTemplateID == null) ? 0 : toInvokeTemplateID.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TemplateInvocation other = (TemplateInvocation) obj; + + if (templateParameters == null || templateParameters.isEmpty()) { + if (!(other.templateParameters == null || other.templateParameters.isEmpty())) + return false; + } else if (templateParameters.size()!=other.templateParameters.size()) + return false; + else + if(!other.templateParameters.containsAll(this.templateParameters)) return false; + + + + if (toInvokeTemplateID == null) { + if (other.toInvokeTemplateID != null) + return false; + } else if (!toInvokeTemplateID.equals(other.toInvokeTemplateID)) + return false; + return true; + } + + public void addParameter(String name,String value) { + if(templateParameters==null) templateParameters=new ArrayList<>(); + templateParameters.add(new ParameterType(name,value)); + } +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateInvocationBuilder.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateInvocationBuilder.java new file mode 100644 index 0000000..248b3f1 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/metadata/TemplateInvocationBuilder.java @@ -0,0 +1,36 @@ +package org.gcube.spatial.data.sdi.model.metadata; + +import java.util.HashSet; + +public class TemplateInvocationBuilder { + + // Constants + public static final class THREDDS_ONLINE{ + public static final String ID="THREDDS_ONLINE_RESOURCES"; + public static final String HOSTNAME="hostname"; + public static final String FILENAME="filename"; + public static final String CATALOG="catalog"; + } + + + + + private HashSet invocations=new HashSet(); + + + public TemplateInvocationBuilder threddsOnlineResources(String hostname, String filename, String catalog){ + TemplateInvocation toAdd=new TemplateInvocation(); + toAdd.setToInvokeTemplateID(THREDDS_ONLINE.ID); + + toAdd.addParameter(THREDDS_ONLINE.HOSTNAME, hostname); + toAdd.addParameter(THREDDS_ONLINE.FILENAME, filename); + toAdd.addParameter(THREDDS_ONLINE.CATALOG, catalog); + invocations.add(toAdd); + return this; + } + + public HashSet get(){ + return invocations; + } +} + diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/ACCESS_TYPE.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/ACCESS_TYPE.java new file mode 100644 index 0000000..b82394a --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/ACCESS_TYPE.java @@ -0,0 +1,5 @@ +package org.gcube.spatial.data.sdi.model.services; + +public enum ACCESS_TYPE{ + CONFIDENTIAL,SHARED,PUBLIC +} \ No newline at end of file diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/CatalogDefinition.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/CatalogDefinition.java new file mode 100644 index 0000000..e4ebb4a --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/CatalogDefinition.java @@ -0,0 +1,30 @@ +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 CatalogDefinition { + + @XmlElement + private String name; + + @XmlElement + private ACCESS_TYPE access; +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/GeoNetworkServiceDefinition.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/GeoNetworkServiceDefinition.java new file mode 100644 index 0000000..2671b9a --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/GeoNetworkServiceDefinition.java @@ -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; + } + + + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/GeoServerDefinition.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/GeoServerDefinition.java new file mode 100644 index 0000000..aa31b07 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/GeoServerDefinition.java @@ -0,0 +1,79 @@ +package org.gcube.spatial.data.sdi.model.services; + +import java.util.ArrayList; + +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.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@ToString +public class GeoServerDefinition extends ServiceDefinition { + + @Override + public Type getType() { + return Type.GEOSERVER; + } + + @XmlElement + private ArrayList workspaces; + + + public void addWorkspace(WorkspaceDefinition def) { + if(workspaces==null) workspaces=new ArrayList<>(); + workspaces.add(def); + } + + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + + if(!(workspaces == null || workspaces.isEmpty())) + for(WorkspaceDefinition workspace:workspaces) + result=prime*result+workspace.hashCode(); + + + return result; + } + + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + GeoServerDefinition other = (GeoServerDefinition) obj; + + if (workspaces == null || workspaces.isEmpty()) { + if (!(other.workspaces == null || other.workspaces.isEmpty())) + return false; + } else if (workspaces.size()!=other.workspaces.size()) + return false; + else + if(!other.workspaces.containsAll(this.workspaces)) return false; + + + return true; + } + + + + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/SdiStatusReport.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/SdiStatusReport.java new file mode 100644 index 0000000..2e251ac --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/SdiStatusReport.java @@ -0,0 +1,10 @@ +package org.gcube.spatial.data.sdi.model.services; + +public class SdiStatusReport { + + + + + + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/ServiceDefinition.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/ServiceDefinition.java new file mode 100644 index 0000000..3721e64 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/ServiceDefinition.java @@ -0,0 +1,168 @@ +package org.gcube.spatial.data.sdi.model.services; + +import java.util.ArrayList; + +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 org.gcube.spatial.data.sdi.model.ParameterType; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.Setter; + +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) +@Getter +@Setter +@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 ArrayList 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 + "]"; + } + + + + public void addProperty(String name,String value) { + if(properties==null) properties=new ArrayList<>(); + properties.add(new ParameterType(name,value)); + } + + + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((adminPassword == null) ? 0 : adminPassword.hashCode()); + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((hostname == null) ? 0 : hostname.hashCode()); + result = prime * result + ((majorVersion == null) ? 0 : majorVersion.hashCode()); + result = prime * result + ((minorVersion == null) ? 0 : minorVersion.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + + if(!(properties == null || properties.isEmpty())) + for(ParameterType param:properties) + result=prime*result+param.hashCode(); + + + result = prime * result + ((releaseVersion == null) ? 0 : releaseVersion.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ServiceDefinition other = (ServiceDefinition) obj; + if (adminPassword == null) { + if (other.adminPassword != null) + return false; + } else if (!adminPassword.equals(other.adminPassword)) + return false; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (hostname == null) { + if (other.hostname != null) + return false; + } else if (!hostname.equals(other.hostname)) + return false; + if (majorVersion == null) { + if (other.majorVersion != null) + return false; + } else if (!majorVersion.equals(other.majorVersion)) + return false; + if (minorVersion == null) { + if (other.minorVersion != null) + return false; + } else if (!minorVersion.equals(other.minorVersion)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + + + if (properties == null || properties.isEmpty()) { + if (!(other.properties == null || other.properties.isEmpty())) + return false; + } else if (properties.size()!=other.properties.size()) + return false; + else + if(!other.properties.containsAll(this.properties)) return false; + + + + if (releaseVersion == null) { + if (other.releaseVersion != null) + return false; + } else if (!releaseVersion.equals(other.releaseVersion)) + return false; + if (type != other.type) + return false; + return true; + } + + + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/ThreddsDefinition.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/ThreddsDefinition.java new file mode 100644 index 0000000..a2b741e --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/ThreddsDefinition.java @@ -0,0 +1,74 @@ +package org.gcube.spatial.data.sdi.model.services; + +import java.util.ArrayList; +import java.util.List; + +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.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@ToString +public class ThreddsDefinition extends ServiceDefinition { + + @Override + public Type getType() { + return Type.THREDDS; + } + + @XmlElement + private List catalogs; + + + public void addCatalog(CatalogDefinition catalog) { + if(catalogs==null) catalogs=new ArrayList<>(); + catalogs.add(catalog); + } + + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + if(!(catalogs == null || catalogs.isEmpty())) + for(CatalogDefinition catalog:catalogs) + result=prime*result+catalog.hashCode(); + return result; + } + + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + ThreddsDefinition other = (ThreddsDefinition) obj; + + if (catalogs == null || catalogs.isEmpty()) { + if (!(other.catalogs == null || other.catalogs.isEmpty())) + return false; + } else if (catalogs.size()!=other.catalogs.size()) + return false; + else + if(!other.catalogs.containsAll(this.catalogs)) return false; + + return true; + } + + +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/WorkspaceDefinition.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/WorkspaceDefinition.java new file mode 100644 index 0000000..3023586 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/model/services/WorkspaceDefinition.java @@ -0,0 +1,30 @@ +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 WorkspaceDefinition { + + @XmlElement + private String name; + + @XmlElement + private ACCESS_TYPE access; +} diff --git a/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/utils/ScopeUtils.java b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/utils/ScopeUtils.java new file mode 100644 index 0000000..9802fb6 --- /dev/null +++ b/sdi-interface/src/main/java/org/gcube/spatial/data/sdi/utils/ScopeUtils.java @@ -0,0 +1,113 @@ +package org.gcube.spatial.data.sdi.utils; + +import static org.gcube.common.authorization.client.Constants.authorizationService; + +import java.util.ArrayList; + +import org.gcube.common.authorization.library.AuthorizationEntry; +import org.gcube.common.authorization.library.provider.SecurityTokenProvider; +import org.gcube.common.scope.api.ScopeProvider; + +import lombok.extern.slf4j.Slf4j; + + + +@Slf4j +public class ScopeUtils { + + public static String getCurrentCaller(){ + try{ + String token=SecurityTokenProvider.instance.get(); + log.debug("Token is : "+token); + if(token==null) throw new Exception("Security Token is null"); + AuthorizationEntry entry = authorizationService().get(token); + return entry.getClientInfo().getId(); + }catch(Exception e ){ + log.debug("Unable to resolve token, checking scope provider..",e); + return "Unidentified data-transfer user"; + } + } + + + public static String getCurrentScope(){ + // try{ + // String token=SecurityTokenProvider.instance.get(); + // log.debug("Token is : "+token); + // if(token==null) throw new Exception("Security Token is null"); + // AuthorizationEntry entry = authorizationService().get(token); + // return entry.getContext(); + // }catch(Exception e ){ + // log.debug("Unable to resolve token, checking scope provider..",e); + // return ScopeProvider.instance.get(); + // } + + String scope=ScopeProvider.instance.get(); + if(scope!=null) { + log.debug("Found scope provider {}, skipping token",scope); + return scope; + }else{ + try{ + log.debug("Scope provider not set, reverting to token"); + String token=SecurityTokenProvider.instance.get(); + log.debug("Token is : "+token); + if(token==null) throw new Exception("Security Token is null"); + AuthorizationEntry entry = authorizationService().get(token); + return entry.getContext(); + }catch(Exception e){ + throw new RuntimeException("Unable to evaluate scope ",e); + } + } + } + + + + // Commented version doesn't check ScopeProvider + // public static String getCurrentScope(){ + // try{ + // String token=SecurityTokenProvider.instance.get(); + // log.debug("Token is : "+token); + // if(token==null) throw new Exception("Security Token is null"); + // AuthorizationEntry entry = authorizationService().get(token); + // return entry.getContext(); + // }catch(Exception e ){ + // log.debug("Unable to resolve token, checking scope provider..",e); + // return ScopeProvider.instance.get(); + // } + // } + + + public static String getCurrentScopeName(){ + return getScopeName(getCurrentScope()); + } + + public static String getScopeName(String scope) { + return scope.substring(scope.lastIndexOf('/')+1); + } + + + public static ArrayList getParentScopes(){ + String currentScope=getCurrentScope(); + String[] splitted=currentScope.substring(1).split("/"); + ArrayList toReturn=new ArrayList(); + for(int i=0;i getParentScopes(String scope){ + String[] splitted=scope.substring(1).split("/"); + ArrayList toReturn=new ArrayList(); + for(int i=0;i existing,int length){ + String toReturn=generateRandomString(length); + while(existing.contains(toReturn)) + toReturn=generateRandomString(length); + return toReturn; + } +} diff --git a/sdi-interface/src/test/java/org/gcube/spatial/data/sdi/MarshallUnmarshallTest.java b/sdi-interface/src/test/java/org/gcube/spatial/data/sdi/MarshallUnmarshallTest.java new file mode 100644 index 0000000..0b560ed --- /dev/null +++ b/sdi-interface/src/test/java/org/gcube/spatial/data/sdi/MarshallUnmarshallTest.java @@ -0,0 +1,209 @@ +package org.gcube.spatial.data.sdi; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; + +import javax.xml.bind.JAXBException; + +import org.apache.commons.collections.CollectionUtils; +import org.gcube.spatia.data.model.profiles.ApplicationProfile; +import org.gcube.spatial.data.sdi.model.ParameterType; +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.services.ACCESS_TYPE; +import org.gcube.spatial.data.sdi.model.services.GeoNetworkServiceDefinition; +import org.gcube.spatial.data.sdi.model.services.GeoServerDefinition; +import org.gcube.spatial.data.sdi.model.services.WorkspaceDefinition; +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 ObjectMapper mapper=null; + + static ArrayList modelInstance=new ArrayList<>(); + + + @BeforeClass + public static void init() throws JAXBException{ + + mapper=new ObjectMapper(); + AnnotationIntrospector introspector=new JaxbAnnotationIntrospector(mapper.getTypeFactory()); + mapper.setAnnotationIntrospector(introspector); + mapper.enable(SerializationFeature.INDENT_OUTPUT); + + modelInstance.add(getTemplateInvocations()); + modelInstance.add(getDescriptors()); + modelInstance.add(getError()); + modelInstance.add(getReport()); + modelInstance.add(getGSDefinition()); + modelInstance.add(getGNDefinition()); + modelInstance.add(getBasicProfile()); + } + + public static boolean roundTrip(Object obj) throws JsonParseException, JsonMappingException, JsonProcessingException, IOException{ + Object roundTripResult=mapper.readValue(marshal(obj), obj.getClass()); + + if(obj instanceof Collection) { + return CollectionUtils.isEqualCollection((Collection)obj, (Collection)roundTripResult); + } + return obj.equals(roundTripResult); + + } + + @Test + public void testHashAndEquals() throws IOException { + for(Object obj:modelInstance) { + assertTrue(obj.equals(copy(obj))); + assertTrue(obj.hashCode()==copy(obj).hashCode()); + } + } + + + @Test + public void Marshall() throws IOException{ + for(Object obj:modelInstance) + print(obj); + } + @Test + public void unMarshall() throws JsonParseException, JsonMappingException, JsonProcessingException, IOException{ + for(Object obj:modelInstance) + assertTrue(roundTrip(obj)); + } + + @Test + public void toStringTest() throws IOException{ + for(Object obj:modelInstance) + System.out.println(obj); + } + + + public static String marshal(Object toSerialize) throws JsonProcessingException { + return mapper.writeValueAsString(toSerialize); + } + + public static void print(Object obj) throws JsonProcessingException { + System.out.println(marshal(obj)); + } + +// public static T unmarshal(Class resourceClass, String toRead) throws JsonParseException, JsonMappingException, IOException { +// return mapper.readValue(toRead, resourceClass); +// } + + + + private static TemplateApplicationRequest getTemplateInvocations(){ + return new TemplateApplicationRequest(new TemplateInvocationBuilder().threddsOnlineResources("localhost", "myDataset.nc", "my Catalog").get()); + } + + private static TemplateCollection getDescriptors(){ + HashSet 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 ArrayList())); + descriptors.add(new TemplateDescriptor(TemplateInvocationBuilder.THREDDS_ONLINE.ID,"Thredds Online Resources","Online reousrce template for thredds resources","http://some.place.org/theTemplate", new ArrayList())); + return new TemplateCollection(descriptors); + } + + private static MetadataReport getReport(){ + return new MetadataReport("theUUID", 12335l, Collections.singleton(TemplateInvocationBuilder.THREDDS_ONLINE.ID)); + } + + private static GeoServerDefinition getGSDefinition() { + GeoServerDefinition toReturn=new GeoServerDefinition(); + toReturn.setAdminPassword("*****"); + toReturn.setDescription("Dummy geoserver"); + toReturn.setHostname("some.place.org"); + toReturn.setMajorVersion((short)2); + toReturn.setMinorVersion((short)10); + toReturn.setReleaseVersion((short)3); + toReturn.setName("My GeoServer"); + toReturn.addWorkspace(new WorkspaceDefinition("myWS", ACCESS_TYPE.PUBLIC)); + toReturn.addProperty("my own application property", "some value"); + return toReturn; + + } + + private static ApplicationProfile getBasicProfile() { + HashMap props=new HashMap(); + props.put(ApplicationProfile.Properties.GEONETWORK_CATEGORY,"blah"); + props.put(ApplicationProfile.Properties.GEOSERVER_STORAGE,"blahBlah"); + + return new ApplicationProfile("Fake Class", "Fake Name", props); + } + + + private static GeoNetworkServiceDefinition getGNDefinition() { + GeoNetworkServiceDefinition def=new GeoNetworkServiceDefinition(); + def.setAdminPassword("admin"); + def.setDescription("Connector for GN 3.0.4 development instance"); + def.setHostname("geonetwork-sdi.dev.d4science.org"); + def.setMajorVersion((short)3); + def.setMinorVersion((short)0); + def.setReleaseVersion((short)4); + def.setName("GN 3.0.4 connector"); + def.setPriority(100); + ParameterType[] params=new ParameterType[] { + new ParameterType("suffixes","1,2"), + //devNext Manually configured + new ParameterType("scope1","devNext"), + new ParameterType("scopeUser1","devNext_context"), + new ParameterType("scopePwd1","123456"), + new ParameterType("ckanUser1","devNext_ckan"), + new ParameterType("scopePwd1","987456"), + new ParameterType("mngUser1","devNext_manager"), + new ParameterType("mngPwd1","741852"), + new ParameterType("default1","1"), + new ParameterType("public1","1"), + new ParameterType("confidential1","1"), + new ParameterType("private1","1"), + //NextNext + new ParameterType("scope2","NextNext"), + new ParameterType("scopeUser2","nextNext_context"), + new ParameterType("scopePwd2","456789"), + new ParameterType("ckanUser2","nextNext_ckan"), + new ParameterType("scopePwd2","123789"), + new ParameterType("mngUser2","nextNext_manager"), + new ParameterType("mngPwd2","963852"), + new ParameterType("default2","1"), + new ParameterType("public2","1"), + new ParameterType("confidential2","1"), + new ParameterType("private2","1"), + }; + def.setProperties(new ArrayList(Arrays.asList(params))); + return def; + } + private static 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 copy(T obj) throws IOException { + return (T) mapper.readValue(marshal(obj), obj.getClass()); + } + +}