Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
Fabio Sinibaldi | a35230e8c4 |
|
@ -3,6 +3,7 @@ package org.gcube.spatial.data.clients.geoserver;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.spatial.data.clients.GenericLoginClient;
|
||||
import org.gcube.spatial.data.clients.geoserver.model.DataStoreRegistrationRequest;
|
||||
import org.gcube.spatial.data.clients.geoserver.model.FeatureTypeInfo;
|
||||
import org.gcube.spatial.data.sdi.model.faults.RemoteException;
|
||||
import org.json.simple.JSONObject;
|
||||
|
@ -61,11 +62,30 @@ public interface GSRESTClient extends GenericLoginClient{
|
|||
/**
|
||||
* Publish a DS described in @param parameters. Parameters vary depending on DS type. See https://docs.geoserver.org/latest/en/api/#1.0.0/datastores.yaml for more details.
|
||||
*
|
||||
* e.g.
|
||||
* {
|
||||
* "dataStore": {
|
||||
* "name": "nyc",
|
||||
* "connectionParameters": {
|
||||
* "entry": [
|
||||
* {"@key":"host","$":"localhost"},
|
||||
* {"@key":"port","$":"5432"},
|
||||
* {"@key":"database","$":"nyc"},
|
||||
* {"@key":"user","$":"bob"},
|
||||
* {"@key":"passwd","$":"postgres"},
|
||||
* {"@key":"dbtype","$":"postgis"}
|
||||
* ]
|
||||
*}
|
||||
*}
|
||||
*}
|
||||
*
|
||||
*
|
||||
* @param ws
|
||||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
public void publishDataStore(String ws, JSONObject parameters)throws RemoteException,Exception;
|
||||
public void publishDataStore(String ws, DataStoreRegistrationRequest request)throws RemoteException,Exception;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -8,12 +8,17 @@ import java.util.Map;
|
|||
import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.gcube.com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import org.gcube.spatial.data.clients.AbstractGenericRESTClient;
|
||||
import org.gcube.spatial.data.clients.geoserver.model.DataStoreRegistrationRequest;
|
||||
import org.gcube.spatial.data.clients.geoserver.model.FeatureTypeInfo;
|
||||
import org.gcube.spatial.data.clients.model.ConnectionDescriptor;
|
||||
import org.gcube.spatial.data.sdi.model.faults.RemoteException;
|
||||
import org.json.simple.JSONAware;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.opengis.feature.type.FeatureType;
|
||||
|
||||
import com.jayway.jsonpath.Configuration;
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
|
@ -34,20 +39,37 @@ public class GSRESTClientImpl extends AbstractGenericRESTClient implements GSRES
|
|||
private static final String FEATURES_BASE_PATH="featuretypes";
|
||||
|
||||
|
||||
static Configuration JSON_PATH_ALWAYS_LIST_CONFIG=
|
||||
Configuration.builder().options(Option.ALWAYS_RETURN_LIST,Option.SUPPRESS_EXCEPTIONS,Option.DEFAULT_PATH_LEAF_TO_NULL).build();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public GSRESTClientImpl(ConnectionDescriptor conn) {
|
||||
super(conn);
|
||||
|
||||
setBasePath(API_BASE_PATH);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String asJSON(Object obj) throws JsonProcessingException {
|
||||
return SerializationUtils.toJSONString(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> T deserialize(String contentType,String content, Class<T> clazz) throws Exception {
|
||||
if(contentType.equals(MediaType.APPLICATION_JSON) && clazz.getPackage().equals(FeatureTypeInfo.class.getPackage())) {
|
||||
|
||||
//Custom deserialization
|
||||
|
||||
|
||||
|
||||
|
||||
return mapper.readValue(content, clazz);
|
||||
}else return super.deserialize(contentType,content, clazz);
|
||||
}
|
||||
|
||||
//************************** READ OPS
|
||||
|
||||
|
||||
|
@ -130,7 +152,10 @@ public class GSRESTClientImpl extends AbstractGenericRESTClient implements GSRES
|
|||
|
||||
@Override
|
||||
public FeatureTypeInfo getFeatureType(String workspace, String featureName) throws RemoteException, Exception {
|
||||
return get(WS_BASE_PATH+"/"+workspace+"/"+FEATURES_BASE_PATH+"/"+featureName,FeatureTypeInfo.class);
|
||||
|
||||
return get(WS_BASE_PATH+"/"+workspace+"/"+FEATURES_BASE_PATH+"/"+featureName,FeatureTypeInfo.class,MediaType.APPLICATION_XML_TYPE);
|
||||
// String jsonString=(new JSONObject((Map<String,Object>)reply.get("featureType"))).toJSONString();
|
||||
// return JsonUtils.fromJson(jsonString, FeatureTypeInfo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -218,10 +243,14 @@ public class GSRESTClientImpl extends AbstractGenericRESTClient implements GSRES
|
|||
post(WS_BASE_PATH,new JSONObject(Collections.singletonMap("workspace", obj)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishDataStore(String ws, DataStoreRegistrationRequest request) throws Exception {
|
||||
post(WS_BASE_PATH+"/"+ws+"/"+DATASTORE_BASE_PATH, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishDataStore(String ws, JSONObject parameters) throws Exception {
|
||||
post(WS_BASE_PATH+"/"+ws+"/"+DATASTORE_BASE_PATH, Entity.entity(parameters, MediaType.APPLICATION_JSON_TYPE));
|
||||
post(WS_BASE_PATH+"/"+ws+"/"+DATASTORE_BASE_PATH, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -233,8 +262,8 @@ public class GSRESTClientImpl extends AbstractGenericRESTClient implements GSRES
|
|||
@Override
|
||||
public void createLayerAsFeatureType(String ws, String dataStoreName, FeatureTypeInfo ft)
|
||||
throws RemoteException, Exception {
|
||||
post(WS_BASE_PATH+"/"+ws+"/"+DATASTORE_BASE_PATH+"/"+dataStoreName+"/"+FEATURES_BASE_PATH, Entity.entity(
|
||||
new JSONObject(Collections.singletonMap("featureType",ft)), MediaType.APPLICATION_JSON_TYPE));
|
||||
post(WS_BASE_PATH+"/"+ws+"/"+DATASTORE_BASE_PATH+"/"+dataStoreName+"/"+FEATURES_BASE_PATH,
|
||||
ft);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class GeoServerPlugin extends AbstractGenericClient implements SDIGeneric
|
|||
@Override
|
||||
public ClientInfo getInfo() {
|
||||
return new ClientInfo("gs-rest", "GeoServer REST", "GeoServer REST client", GSRESTClientImpl.class.getCanonicalName(),
|
||||
new Engine(Engine.GS_ENGINE, "Default GeoServerVersion", new Range("2.0.0", null)));
|
||||
new Engine(Engine.GS_ENGINE, "Default GeoServerVersion", new Range("2.0.0", "2.15.0")));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package org.gcube.spatial.data.clients.geoserver;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.gcube.com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import org.gcube.spatial.data.clients.geoserver.model.FeatureTypeInfo;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import com.jayway.jsonpath.Configuration;
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import com.jayway.jsonpath.Option;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class SerializationUtils {
|
||||
|
||||
static ObjectMapper mapper=new ObjectMapper();
|
||||
|
||||
static Configuration JSON_PATH_ALWAYS_LIST_CONFIG=
|
||||
Configuration.builder().options(Option.ALWAYS_RETURN_LIST,Option.SUPPRESS_EXCEPTIONS,Option.DEFAULT_PATH_LEAF_TO_NULL).build();
|
||||
|
||||
|
||||
static{
|
||||
mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
|
||||
mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
|
||||
}
|
||||
|
||||
|
||||
public static final <T> T fromJSONString(String json,Class<T> clazz) throws IOException{
|
||||
|
||||
try {
|
||||
return mapper.readValue(json, clazz);
|
||||
} catch (IOException e) {
|
||||
if(clazz.getPackage().equals(FeatureTypeInfo.class.getPackage())) {
|
||||
log.debug("Unable to read normally, trying adjusting object. JSON IS {}",json,e);
|
||||
if(clazz.isAssignableFrom(FeatureTypeInfo.class)) {
|
||||
DocumentContext ctx=
|
||||
|
||||
JSONObject obj=mapper.readValue(json,JSONObject.class);
|
||||
obj.get("attributes")
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
else throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static final String toJSONString(Object obj) throws JsonProcessingException {
|
||||
return mapper.writeValueAsString(obj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static DocumentContext parseContext(String json) {
|
||||
return JsonPath.using(JSON_PATH_ALWAYS_LIST_CONFIG).parse(json);
|
||||
}
|
||||
}
|
|
@ -1,40 +1,46 @@
|
|||
package org.gcube.spatial.data.clients.geoserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonRootName;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Synchronized;
|
||||
|
||||
@Data
|
||||
@XmlRootElement(name = "datastore")
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
@JsonRootName(value = "dataStore")
|
||||
public class DataStoreRegistrationRequest {
|
||||
|
||||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
private static class Parameter{
|
||||
@XmlElement(name="@key")
|
||||
private String key;
|
||||
@XmlElement(name="$")
|
||||
@XmlElement(name="$")
|
||||
private String value;
|
||||
}
|
||||
|
||||
private JSONObject datastore=new JSONObject();
|
||||
|
||||
private ArrayList<Parameter> paramList=new ArrayList<Parameter>();
|
||||
|
||||
|
||||
public DataStoreRegistrationRequest() {
|
||||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
private static class ConnectionParameters{
|
||||
private List<Parameter> entry;
|
||||
}
|
||||
|
||||
public DataStoreRegistrationRequest(String name) {
|
||||
setName(name);
|
||||
}
|
||||
|
||||
private String name;
|
||||
private ConnectionParameters connectionParameters;
|
||||
|
||||
|
||||
/**
|
||||
* See @method setParameters
|
||||
|
@ -48,7 +54,7 @@ public class DataStoreRegistrationRequest {
|
|||
}
|
||||
|
||||
public DataStoreRegistrationRequest setName(String name) {
|
||||
datastore.put("name",name);
|
||||
this.name=name;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -60,11 +66,7 @@ public class DataStoreRegistrationRequest {
|
|||
* @return
|
||||
*/
|
||||
public DataStoreRegistrationRequest setParameters(Map<String,String> params) {
|
||||
|
||||
params.forEach((String k,String v)->{paramList.add(new Parameter(k,v));});
|
||||
|
||||
datastore.put("connectionParameters", new JSONObject(Collections.singletonMap("entry", paramList)));
|
||||
|
||||
params.forEach((String k,String v)->{param(k,v);});
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -75,12 +77,17 @@ public class DataStoreRegistrationRequest {
|
|||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@Synchronized
|
||||
public DataStoreRegistrationRequest param(String key,String value) {
|
||||
|
||||
paramList.add(new Parameter(key,value));
|
||||
|
||||
datastore.put("connectionParameters", new JSONObject(Collections.singletonMap("entry", paramList)));
|
||||
|
||||
if(connectionParameters==null)
|
||||
connectionParameters=new ConnectionParameters(new ArrayList<DataStoreRegistrationRequest.Parameter>());
|
||||
|
||||
connectionParameters.entry.add(new Parameter(key,value));
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataStoreRegistrationRequest(String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,22 +2,31 @@ package org.gcube.spatial.data.clients.geoserver.model;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonRootName;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonRootName(value = "featureType")
|
||||
@NoArgsConstructor
|
||||
public class FeatureTypeInfo {
|
||||
|
||||
public static enum ProjectionPolicy{
|
||||
FORCE_DECLARED
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Namespace{
|
||||
private String name;
|
||||
private String href;
|
||||
|
@ -26,12 +35,14 @@ public class FeatureTypeInfo {
|
|||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
public static class Keyword{
|
||||
@NoArgsConstructor
|
||||
public static class KeywordSet{
|
||||
private List<String> string;
|
||||
}
|
||||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class MetadataLink{
|
||||
private String type;
|
||||
private String metadataType;
|
||||
|
@ -40,6 +51,7 @@ public class FeatureTypeInfo {
|
|||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class BoundingBox{
|
||||
private Number minx;
|
||||
private Number maxx;
|
||||
|
@ -50,6 +62,7 @@ public class FeatureTypeInfo {
|
|||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Entry{
|
||||
private String key;
|
||||
private String value;
|
||||
|
@ -58,7 +71,9 @@ public class FeatureTypeInfo {
|
|||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Store{
|
||||
@JsonProperty("@class")
|
||||
private String clazz;
|
||||
private String name;
|
||||
private String href;
|
||||
|
@ -68,6 +83,7 @@ public class FeatureTypeInfo {
|
|||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class AttributeList{
|
||||
public List<Attribute> attribute;
|
||||
}
|
||||
|
@ -76,6 +92,7 @@ public class FeatureTypeInfo {
|
|||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Attribute{
|
||||
|
||||
private String name;
|
||||
|
@ -92,17 +109,19 @@ public class FeatureTypeInfo {
|
|||
private String title;
|
||||
|
||||
|
||||
@XmlElement(name="abstract")
|
||||
@JsonProperty("abstract")
|
||||
private String abstractField;
|
||||
private List<Keyword> keywords;
|
||||
private KeywordSet keywords;
|
||||
|
||||
|
||||
|
||||
private List<MetadataLink> metadataLinks;
|
||||
private List<MetadataLink> dataLinks;
|
||||
|
||||
|
||||
private String nativeCRS;
|
||||
private String srs;
|
||||
private BoundingBox nativeVoundingBox;
|
||||
private BoundingBox nativeBoundingBox;
|
||||
private BoundingBox latLonBoundingBox;
|
||||
|
||||
|
||||
|
@ -121,4 +140,9 @@ public class FeatureTypeInfo {
|
|||
|
||||
private AttributeList attributes;
|
||||
|
||||
|
||||
private Boolean enabled;
|
||||
|
||||
|
||||
private ProjectionPolicy projectionPolicy;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
package org.gcube.spatial.data.clients.geoserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonRootName;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonRootName(value = "layer")
|
||||
@NoArgsConstructor
|
||||
public class Layer {
|
||||
|
||||
|
||||
public static enum LayerType{
|
||||
VECTOR,RASTER,REMOTE,WMS,GROUP
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
public static class Style{
|
||||
private String name;
|
||||
private String link;
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
public static class Styles{
|
||||
@XmlElement(name="@class")
|
||||
private String clazz="linked-hash-set";
|
||||
|
||||
@XmlElement(name="style")
|
||||
private List<Style> list;
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
public static class Resource{
|
||||
@XmlElement(name="@class")
|
||||
private String clazz="featureType";
|
||||
private String name;
|
||||
private String link;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
public static class MetadataEntry{
|
||||
|
||||
public static enum Keys{buffer}
|
||||
@XmlElement(name="@key")
|
||||
private String key;
|
||||
@XmlElement(name="$")
|
||||
private String value;
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
public static class Attribution{
|
||||
private String title;
|
||||
private String href;
|
||||
private String logoURL;
|
||||
private String logoWodth;
|
||||
private String logoHeight;
|
||||
private String logoType;
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
public static class AuthorityUrl{
|
||||
private String name;
|
||||
private String href;
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@AllArgsConstructor
|
||||
public static class Identifier{
|
||||
private String authority;
|
||||
private String identifier;
|
||||
}
|
||||
|
||||
private String name;
|
||||
private String path;
|
||||
private LayerType type;
|
||||
private Style defaultStyle;
|
||||
private Styles styles;
|
||||
private Resource resource;
|
||||
private Boolean opaque;
|
||||
private List<MetadataEntry> metadata;
|
||||
private Attribution attribution;
|
||||
private List<AuthorityUrl> authorityURL;
|
||||
private List<Identifier> identifiers;
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package org.gcube.spatial.data.clients.geoserver.model;
|
||||
|
||||
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonRootName;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonRootName(value = "workspaces")
|
||||
@NoArgsConstructor
|
||||
public class WorkspaceList {
|
||||
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@ package org.gcube.spatial.data.clients.geoserver;
|
|||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assume.assumeNotNull;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -10,14 +11,20 @@ import java.nio.charset.Charset;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.sdi.test.GCubeSDITest;
|
||||
import org.gcube.spatial.data.clients.SDIGenericPlugin;
|
||||
import org.gcube.spatial.data.clients.geoserver.model.DataStoreRegistrationRequest;
|
||||
import org.gcube.spatial.data.clients.geoserver.model.FeatureTypeInfo;
|
||||
import org.gcube.spatial.data.clients.geoserver.model.FeatureTypeInfo.AttributeList;
|
||||
import org.gcube.spatial.data.clients.model.engine.Engine;
|
||||
import org.gcube.spatial.data.sdi.model.faults.RemoteException;
|
||||
import org.gcube.spatial.data.sdi.utils.Files;
|
||||
import org.gcube.spatial.data.sdi.utils.ISUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
public class GSTests extends GCubeSDITest{
|
||||
|
@ -51,44 +58,61 @@ public class GSTests extends GCubeSDITest{
|
|||
if(ws!=null) {
|
||||
System.out.println("************************************ WS ***************************");
|
||||
System.out.println(client.getWorkspace(ws));
|
||||
for(String sld:client.getStylesNamesinWorkspace(ws))
|
||||
|
||||
|
||||
List<String> sldList=client.getStylesNamesinWorkspace(ws);
|
||||
System.out.println("*************** "+ws+" :SD "+sldList);
|
||||
|
||||
for(String sld:sldList)
|
||||
if(sld!=null)try {
|
||||
System.out.println(client.getSLD(sld));
|
||||
}catch(RemoteException e ) {System.err.println("Unable to read SLD "+sld+" from "+ws+". Cause "+e.getResponseHTTPCode()+": "+e.getMessage());}
|
||||
}catch(RemoteException e ) {
|
||||
System.err.println("Unable to read SLD "+sld+" from "+ws+". Cause "+e.getResponseHTTPCode()+": "+e.getMessage());}
|
||||
|
||||
|
||||
System.out.println("WS "+ws+" ->"+client.getDataStoresInWorkspace(ws));
|
||||
|
||||
// for(String ds:client.getDataStoresNamesInWorkspace(ws))
|
||||
// if(ds!=null) {
|
||||
// try{ System.out.println(client.getDataStore(ws, ds));
|
||||
// }catch(RemoteException e ) {System.err.println("Unable to read DS "+ds+" from "+ws+". Cause "+e.getResponseHTTPCode()+": "+e.getMessage());}
|
||||
// }
|
||||
List<String> dsList=client.getDataStoresNamesInWorkspace(ws);
|
||||
System.out.println("*************** "+ws+" : DS "+dsList);
|
||||
|
||||
for(String ds:dsList)
|
||||
if(ds!=null) {
|
||||
try{ System.out.println(client.getDataStore(ws, ds));
|
||||
}catch(RemoteException e ) {
|
||||
System.err.println("Unable to read DS "+ds+" from "+ws+". Cause "+e.getResponseHTTPCode()+": "+e.getMessage());}
|
||||
}
|
||||
|
||||
for(String ft : client.getFeatureTypesInWorkspace(ws))
|
||||
List<String> ftList=client.getFeatureTypesInWorkspace(ws);
|
||||
System.out.println("*************** "+ws+" : FT "+ftList);
|
||||
for(String ft : ftList)
|
||||
if(ft!=null)try {
|
||||
assertTrue(client.getFeatureType(ws, ft).getNativeName()!=null);
|
||||
System.out.println(client.getFeatureType(ws, ft));
|
||||
}catch(RemoteException e ) {System.err.println("Unable to read FT "+ft+" from "+ws+". Cause "+e.getResponseHTTPCode()+": "+e.getMessage());}
|
||||
FeatureTypeInfo ftInfo=client.getFeatureType(ws, ft);
|
||||
assertTrue(ftInfo.getNativeName()!=null);
|
||||
System.out.println(ftInfo);
|
||||
}catch(RemoteException e ) {
|
||||
System.err.println("Unable to read FT "+ft+" from "+ws+". Cause "+e.getResponseHTTPCode()+": "+e.getMessage());}
|
||||
|
||||
|
||||
for(String l : client.getLayers(ws))
|
||||
|
||||
List<String> layerList=client.getLayers(ws);
|
||||
System.out.println("*************** "+ws+" : LAYERS "+layerList);
|
||||
for(String l : layerList)
|
||||
if(l!=null)try {
|
||||
System.out.println(client.getLayerInWorkspace(ws, l));
|
||||
System.out.println(client.getLayer(l));
|
||||
}catch(RemoteException e ) {System.err.println("Unable to read LA "+l+" from "+ws+". Cause "+e.getResponseHTTPCode()+": "+e.getMessage());}
|
||||
// System.out.println(client.getLayer(l));
|
||||
}catch(RemoteException e ) {
|
||||
System.err.println("Unable to read LA "+l+" from "+ws+". Cause "+e.getResponseHTTPCode()+": "+e.getMessage());}
|
||||
|
||||
}
|
||||
}catch(Exception e) {
|
||||
System.err.println("Unable to check "+ws+" : "+e);
|
||||
throw new RuntimeException("Unable to check "+ws+" : ",e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
System.out.println("Listing layers without ws");
|
||||
// System.out.println("Listing layers without ws");
|
||||
// client.getLayers().forEach((String l)->{
|
||||
// try{System.out.println(client.getLayer(l));
|
||||
// }catch(RemoteException e ) {System.err.println("Unable to read LA "+l+". Cause "+e.getResponseHTTPCode()+": "+e.getMessage());}
|
||||
|
@ -104,6 +128,7 @@ public class GSTests extends GCubeSDITest{
|
|||
|
||||
client.authenticate();
|
||||
String ws=UUID.randomUUID().toString().replace("-", "_");
|
||||
System.out.println("WS name is :"+ ws);
|
||||
client.createWorkspace(ws);
|
||||
client.getWorkspace(ws);
|
||||
|
||||
|
@ -118,19 +143,16 @@ public class GSTests extends GCubeSDITest{
|
|||
assertFalse("SLD Removed",client.getStylesNames().contains(myStyle));
|
||||
|
||||
// DS
|
||||
// String myDS=UUID.randomUUID().toString().replace("-", "_");
|
||||
//
|
||||
// HashMap<String,String> parameters=new HashMap<String, String>();
|
||||
//
|
||||
//// parameters.put("dbtype","gpkg");
|
||||
// parameters.put("url","gpkg");
|
||||
//
|
||||
// client.publishDataStore(ws,
|
||||
// new DataStoreRegistrationRequest(myDS,parameters).getDatastore());
|
||||
//
|
||||
// client.deleteWorkspace(ws,true);
|
||||
//
|
||||
//
|
||||
|
||||
DataStoreRegistrationRequest dsReq=getDB();
|
||||
System.out.println("Registering dsReq "+dsReq);
|
||||
assumeNotNull(dsReq);
|
||||
|
||||
client.publishDataStore(ws,dsReq);
|
||||
|
||||
|
||||
|
||||
|
||||
//FT
|
||||
|
||||
|
||||
|
@ -143,13 +165,52 @@ public class GSTests extends GCubeSDITest{
|
|||
|
||||
ft.setAttributes(new AttributeList(atts));
|
||||
System.out.println("Writing "+ft);
|
||||
client.createLayerAsFeatureType("aquamaps", "timeseriesws", ft);
|
||||
client.createLayerAsFeatureType(ws, dsReq.getName(), ft);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void specifics() throws RemoteException, Exception {
|
||||
assumeTrue(isTestInfrastructureEnabled());
|
||||
GSRESTClient client=getClient();
|
||||
client.authenticate();
|
||||
System.out.println(client.getFeatureType("gna_conc_65", "uuss15-19"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
private DataStoreRegistrationRequest getDB() {
|
||||
List<ServiceEndpoint> eps=ISUtils.queryForServiceEndpoints("Database", "postgis");
|
||||
System.out.println("EPS Size "+eps.size());
|
||||
for (ServiceEndpoint se:eps) {
|
||||
for(AccessPoint ap : se.profile().accessPoints().asCollection()) {
|
||||
if(ap.propertyMap().containsKey("gs-tests")) {
|
||||
if(Boolean.parseBoolean(ap.propertyMap().get("gs-tests").value())) {
|
||||
System.out.println(new StringBuilder("Using AP ").
|
||||
append(ap.name()).append(" from SE ").append(se.id()));
|
||||
|
||||
|
||||
return new DataStoreRegistrationRequest(ap.name()).
|
||||
param("host", se.profile().runtime().hostedOn()).
|
||||
param("port", "5432").
|
||||
param("database",ap.address().substring(ap.address().lastIndexOf('/'),ap.address().length()-1)).
|
||||
param("user",ap.username()).
|
||||
param("passwd",ISUtils.decryptString(ap.password())).
|
||||
param("dbtype","postgis");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static final String read(String toRead) throws IOException {
|
||||
File f= Files.getFileFromResources(toRead);
|
||||
return Files.readFileAsString(f.getAbsolutePath(), Charset.defaultCharset());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,10 +12,16 @@ import java.util.Set;
|
|||
|
||||
import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.bind.util.JAXBSource;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.common.clients.Call;
|
||||
import org.gcube.common.gxrest.request.GXWebTargetAdapterRequest;
|
||||
import org.gcube.common.gxrest.response.inbound.GXInboundResponse;
|
||||
import org.gcube.common.gxrest.response.inbound.JsonUtils;
|
||||
import org.gcube.spatial.data.clients.model.ConnectionDescriptor;
|
||||
import org.gcube.spatial.data.sdi.model.credentials.AccessType;
|
||||
import org.gcube.spatial.data.sdi.model.credentials.Credentials;
|
||||
|
@ -227,7 +233,7 @@ public abstract class AbstractGenericRESTClient implements GenericLoginClient{
|
|||
|
||||
|
||||
|
||||
protected static <T> T check(GXInboundResponse resp, Class<T> clazz) throws RemoteException{
|
||||
protected <T> T check(GXInboundResponse resp, Class<T> clazz) throws RemoteException{
|
||||
try {
|
||||
log.debug("Checking Response [Status : {}, Msg : {}]",resp.getHTTPCode(),resp.getMessage());
|
||||
if(!resp.isSuccessResponse()) {
|
||||
|
@ -238,10 +244,17 @@ public abstract class AbstractGenericRESTClient implements GenericLoginClient{
|
|||
throw e;
|
||||
}else {
|
||||
if(clazz==null) return null;
|
||||
|
||||
if(clazz==String.class) return (T) resp.getStreamedContentAsString();
|
||||
|
||||
return resp.tryConvertStreamedContentFromJson(clazz);
|
||||
String content=resp.getStreamedContentAsString();
|
||||
if(clazz==String.class) return (T) content;
|
||||
|
||||
String contentType=MediaType.APPLICATION_JSON;
|
||||
try {
|
||||
contentType=resp.getHeaderFields().get("Content-Type").get(0);
|
||||
log.debug("Deseiralizing contentType {} as {}",contentType,clazz);
|
||||
}catch(Throwable t) {
|
||||
log.warn("Unable to get content type from response ",t);
|
||||
}
|
||||
return deserialize(contentType, content, clazz);
|
||||
}
|
||||
}catch(RemoteException e) {
|
||||
throw e;
|
||||
|
@ -259,6 +272,21 @@ public abstract class AbstractGenericRESTClient implements GenericLoginClient{
|
|||
}
|
||||
}
|
||||
|
||||
protected <T> T defaultDeserialize(String content,Class<T> clazz)throws Exception{
|
||||
return JsonUtils.fromJson(content.getBytes(), clazz);
|
||||
}
|
||||
|
||||
protected <T> T deserialize(String contentType, String content,Class<T> clazz) throws Exception {
|
||||
if(contentType.equalsIgnoreCase(MediaType.APPLICATION_XML)) {
|
||||
JAXBContext context=JAXBContext.newInstance(clazz);
|
||||
Unmarshaller unmarshaller = context.createUnmarshaller();
|
||||
JAXBSource source=new JAXBSource(context, content);
|
||||
return (T) unmarshaller.unmarshal(source, clazz);
|
||||
}
|
||||
else return defaultDeserialize(content, clazz);
|
||||
}
|
||||
|
||||
protected String asJSON(Object obj) throws JsonProcessingException{
|
||||
return new ObjectMapper().writeValueAsString(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,21 +27,35 @@
|
|||
|
||||
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-bom</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<!-- <dependencyManagement> -->
|
||||
<!-- <dependencies> -->
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.gcube.distribution</groupId> -->
|
||||
<!-- <artifactId>gcube-bom</artifactId> -->
|
||||
<!-- <version>2.0.0</version> -->
|
||||
<!-- <type>pom</type> -->
|
||||
<!-- <scope>import</scope> -->
|
||||
<!-- </dependency> -->
|
||||
<!-- </dependencies> -->
|
||||
<!-- </dependencyManagement> -->
|
||||
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
<artifactId>ic-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
<artifactId>discovery-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-encryption</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
|
@ -55,11 +69,11 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-json-jackson</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependency> -->
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
|
|
|
@ -0,0 +1,124 @@
|
|||
package org.gcube.spatial.data.sdi.utils;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.client;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.gcube.common.encryption.encrypter.StringEncrypter;
|
||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class ISUtils {
|
||||
|
||||
public static List<ServiceEndpoint> queryForServiceEndpoints(String category, String platformName){
|
||||
log.debug("Querying for Service Endpoints [category : {} , platformName : {}, currentScope : {} ]",category,platformName,ScopeUtils.getCurrentScope());
|
||||
|
||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||
|
||||
query.addCondition("$resource/Profile/Category/text() eq '"+category+"'")
|
||||
.addCondition("$resource/Profile/Platform/Name/text() eq '"+platformName+"'");
|
||||
// .setResult("$resource/Profile/AccessPoint");
|
||||
|
||||
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||||
|
||||
return client.submit(query);
|
||||
}
|
||||
|
||||
public static List<GCoreEndpoint> queryForGCoreEndpoint(String serviceClass,String serviceName){
|
||||
log.debug("Querying for GCore Endpoints [ServiceClass : {} , ServiceName : {}, currentScope : {} ]",serviceClass,serviceName,ScopeUtils.getCurrentScope());
|
||||
|
||||
|
||||
SimpleQuery query =queryFor(GCoreEndpoint.class);
|
||||
query.addCondition("$resource/Profile/ServiceClass/text() eq '"+serviceClass+"'")
|
||||
.addCondition("$resource/Profile/ServiceName/text() eq '"+serviceName+"'");
|
||||
// .setResult("$resource/Profile/AccessPoint");
|
||||
|
||||
DiscoveryClient<GCoreEndpoint> client = clientFor(GCoreEndpoint.class);
|
||||
|
||||
return client.submit(query);
|
||||
}
|
||||
|
||||
|
||||
public static <T extends Resource> T getByHostnameInCollection(String hostname, Collection<T> toCheckList) throws UnknownHostException {
|
||||
for(T gc:toCheckList) {
|
||||
String currentHostToCheck=getHost(gc);
|
||||
if(NetUtils.isSameHost(currentHostToCheck, hostname)) return gc;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static String getHost(Resource res) {
|
||||
if(res instanceof GCoreEndpoint)
|
||||
return (((GCoreEndpoint)res).profile().endpoints().iterator().next().uri().getHost());
|
||||
else return (((ServiceEndpoint)res).profile().runtime().hostedOn());
|
||||
}
|
||||
|
||||
public static List<ServiceEndpoint> querySEByHostname(String category,String platformName,String hostname){
|
||||
log.debug("Querying Service Endpoints by hostname [category : {} , platformName : {}, currentScope : {}, hostname {} ]",category,platformName,ScopeUtils.getCurrentScope(),hostname);
|
||||
|
||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||
|
||||
query.addCondition("$resource/Profile/Category/text() eq '"+category+"'")
|
||||
.addCondition("$resource/Profile/Platform/Name/text() eq '"+platformName+"'")
|
||||
.addCondition("$resource/Profile/Runtime/HostedOn/text() eq '"+hostname+"'");
|
||||
// .setResult("$resource/Profile/AccessPoint");
|
||||
|
||||
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||||
|
||||
return client.submit(query);
|
||||
}
|
||||
|
||||
|
||||
public static List<String> queryById(String id) {
|
||||
DiscoveryClient<String> client = client();
|
||||
String queryString ="declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry'; "+
|
||||
"for $profiles in collection('/db/Profiles')//Document/Data/ic:Profile/Resource "+
|
||||
"where $profiles/ID/text() eq '"+id+"'"+
|
||||
" return $profiles";
|
||||
return client.submit(new QueryBox(queryString));
|
||||
}
|
||||
|
||||
|
||||
public static ServiceEndpoint querySEById(String id) {
|
||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||
|
||||
query.addCondition("$resource/ID/text() eq '"+id+"'");
|
||||
|
||||
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||||
|
||||
return client.submit(query).get(0);
|
||||
}
|
||||
|
||||
|
||||
public static String decryptString(String toDecrypt){
|
||||
try{
|
||||
return StringEncrypter.getEncrypter().decrypt(toDecrypt);
|
||||
}catch(Exception e) {
|
||||
throw new RuntimeException("Unable to decrypt : "+toDecrypt,e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String encryptString(String toEncrypt){
|
||||
try{
|
||||
return StringEncrypter.getEncrypter().encrypt(toEncrypt);
|
||||
}catch(Exception e) {
|
||||
throw new RuntimeException("Unable to encrypt : "+toEncrypt,e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.spatial.data.sdi;
|
||||
package org.gcube.spatial.data.sdi.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
|
@ -7,8 +7,8 @@ import java.util.Comparator;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.spatial.data.sdi.utils.NetUtils;
|
||||
import org.gcube.spatial.data.sdi.utils.ScopeUtils;
|
||||
import org.gcube.spatial.data.sdi.NetUtils;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.faults.ConfigurationNotFoundException;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.faults.InvalidServiceEndpointException;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.is.CachedObject;
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.gcube.data.transfer.model.TransferTicket;
|
|||
import org.gcube.data.transfer.model.plugins.thredds.ThreddsCatalog;
|
||||
import org.gcube.data.transfer.model.plugins.thredds.ThreddsInfo;
|
||||
import org.gcube.spatial.data.sdi.LocalConfiguration;
|
||||
import org.gcube.spatial.data.sdi.NetUtils;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.faults.InvalidServiceEndpointException;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.faults.OutdatedServiceEndpointException;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.faults.ThreddsOperationFault;
|
||||
|
@ -35,6 +34,7 @@ import org.gcube.spatial.data.sdi.engine.impl.is.ISUtils;
|
|||
import org.gcube.spatial.data.sdi.engine.impl.metadata.GenericTemplates;
|
||||
import org.gcube.spatial.data.sdi.model.CatalogDescriptor;
|
||||
import org.gcube.spatial.data.sdi.model.service.ThreddsDescriptor;
|
||||
import org.gcube.spatial.data.sdi.utils.NetUtils;
|
||||
import org.glassfish.jersey.client.ClientConfig;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
|||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
|
||||
import org.gcube.spatial.data.sdi.LocalConfiguration;
|
||||
import org.gcube.spatial.data.sdi.NetUtils;
|
||||
import org.gcube.spatial.data.sdi.utils.NetUtils;
|
||||
import org.gcube.spatial.data.sdi.utils.ScopeUtils;
|
||||
import org.gcube.vremanagement.resourcemanager.client.RMBinderLibrary;
|
||||
import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidScopeException;
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.gcube.common.resources.gcore.ServiceEndpoint;
|
|||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.common.resources.gcore.common.Platform;
|
||||
import org.gcube.spatial.data.sdi.LocalConfiguration;
|
||||
import org.gcube.spatial.data.sdi.NetUtils;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.faults.InvalidServiceDefinitionException;
|
||||
import org.gcube.spatial.data.sdi.model.credentials.AccessType;
|
||||
import org.gcube.spatial.data.sdi.model.credentials.Credentials;
|
||||
|
@ -19,6 +18,7 @@ import org.gcube.spatial.data.sdi.model.service.ThreddsDescriptor;
|
|||
import org.gcube.spatial.data.sdi.model.service.Version;
|
||||
import org.gcube.spatial.data.sdi.model.services.ServiceDefinition;
|
||||
import org.gcube.spatial.data.sdi.model.services.ServiceDefinition.Type;
|
||||
import org.gcube.spatial.data.sdi.utils.NetUtils;
|
||||
import org.gcube.spatial.data.sdi.model.services.ThreddsDefinition;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
|
@ -12,7 +12,6 @@ import javax.ws.rs.WebApplicationException;
|
|||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.gcube.smartgears.annotations.ManagedBy;
|
||||
import org.gcube.spatial.data.sdi.NetUtils;
|
||||
import org.gcube.spatial.data.sdi.SDIServiceManager;
|
||||
import org.gcube.spatial.data.sdi.engine.RoleManager;
|
||||
import org.gcube.spatial.data.sdi.engine.SDIManager;
|
||||
|
@ -21,6 +20,7 @@ import org.gcube.spatial.data.sdi.model.credentials.Credentials;
|
|||
import org.gcube.spatial.data.sdi.model.service.GeoNetworkDescriptor;
|
||||
import org.gcube.spatial.data.sdi.model.services.GeoNetworkServiceDefinition;
|
||||
import org.gcube.spatial.data.sdi.model.services.ServiceDefinition.Type;
|
||||
import org.gcube.spatial.data.sdi.utils.NetUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.jaxrs.annotation.JacksonFeatures;
|
||||
|
|
|
@ -12,7 +12,6 @@ import javax.ws.rs.WebApplicationException;
|
|||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.gcube.smartgears.annotations.ManagedBy;
|
||||
import org.gcube.spatial.data.sdi.NetUtils;
|
||||
import org.gcube.spatial.data.sdi.SDIServiceManager;
|
||||
import org.gcube.spatial.data.sdi.engine.SDIManager;
|
||||
import org.gcube.spatial.data.sdi.model.ServiceConstants;
|
||||
|
@ -20,6 +19,7 @@ import org.gcube.spatial.data.sdi.model.credentials.Credentials;
|
|||
import org.gcube.spatial.data.sdi.model.service.GeoServerDescriptor;
|
||||
import org.gcube.spatial.data.sdi.model.services.GeoServerDefinition;
|
||||
import org.gcube.spatial.data.sdi.model.services.ServiceDefinition.Type;
|
||||
import org.gcube.spatial.data.sdi.utils.NetUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.jaxrs.annotation.JacksonFeatures;
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.spatial.data.sdi.test;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.gcube.spatial.data.sdi.NetUtils;
|
||||
import org.gcube.spatial.data.sdi.utils.NetUtils;
|
||||
|
||||
public class NetTests {
|
||||
|
||||
|
|
|
@ -114,8 +114,12 @@ public class SimpleSDIManagerClient implements SDIManagement{
|
|||
if(desc==null|| desc.isEmpty()) throw new Exception("No "+engineId+" available in current context. Check ScopeConfiguration object.");
|
||||
|
||||
for(GeoServiceDescriptor d:desc) {
|
||||
SDIGenericPlugin c=clientManager.get(d);
|
||||
if(c!=null) return c;
|
||||
try{
|
||||
SDIGenericPlugin c=clientManager.get(d);
|
||||
return c;
|
||||
}catch(Exception e) {
|
||||
// continue looking for right implementation
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException("No implementation available for "+engineId);
|
||||
|
|
Loading…
Reference in New Issue