GS Styles
This commit is contained in:
parent
065b0bd29a
commit
830f57ac1a
|
@ -1,26 +1,12 @@
|
|||
package org.gcube.spatial.data.clients.geoserver;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.spatial.data.clients.GenericLoginClient;
|
||||
//import org.apache.commons.httpclient.NameValuePair;
|
||||
//import org.gcube.application.geoportal.service.engine.RESTFeatureType;
|
||||
//import org.gcube.application.geoportal.service.engine.RESTLayer;
|
||||
import org.gcube.spatial.data.sdi.model.faults.RemoteException;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
//import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.UploadMethod;
|
||||
//import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
||||
|
||||
public interface GSRESTClient extends GenericLoginClient{
|
||||
|
||||
|
||||
// Management
|
||||
public boolean exist();
|
||||
|
||||
|
||||
|
||||
|
||||
// ********** READ OPS
|
||||
|
||||
|
@ -61,9 +47,8 @@ public interface GSRESTClient extends GenericLoginClient{
|
|||
|
||||
// *********** CREATE OPS
|
||||
public void createWorkspace(String ws)throws RemoteException,Exception;
|
||||
//
|
||||
// public void createStyle(String name,String content)throws RemoteException,Exception;
|
||||
// public void createStyle(String name,InputStream content)throws RemoteException,Exception;
|
||||
|
||||
public void createStyle(String name,String content)throws RemoteException,Exception;
|
||||
//
|
||||
// publish DB layer
|
||||
// publish local files
|
||||
|
|
|
@ -213,7 +213,7 @@ public class GSRESTClientImpl extends AbstractGenericRESTClient implements GSRES
|
|||
public void createWorkspace(String ws) throws RemoteException, Exception {
|
||||
JSONObject obj=new JSONObject();
|
||||
obj.put("name", ws);
|
||||
post(WS_BASE_PATH,Entity.entity(new JSONObject(Collections.singletonMap("workspace", obj)),MediaType.APPLICATION_JSON));
|
||||
post(WS_BASE_PATH,new JSONObject(Collections.singletonMap("workspace", obj)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -222,23 +222,10 @@ public class GSRESTClientImpl extends AbstractGenericRESTClient implements GSRES
|
|||
post(WS_BASE_PATH+"/"+ws+"/"+DATASTORE_BASE_PATH, Entity.entity(parameters, MediaType.APPLICATION_JSON_TYPE));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//************************* BASIC
|
||||
@Override
|
||||
public boolean exist() {
|
||||
try {
|
||||
GXWebTargetAdapterRequest request =GXWebTargetAdapterRequest.newHTTPSRequest(getConn().getEndpoint());
|
||||
check(request.get(),null);
|
||||
return true;
|
||||
}catch(Exception e) {
|
||||
return false;
|
||||
}
|
||||
public void createStyle(String name, String content) throws RemoteException, Exception {
|
||||
put(STYLES_BASE_PATH+"/"+name, Entity.entity(content, "application/vnd.ogc.sld+xml"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package org.gcube.spatial.data.clients.geoserver;
|
||||
|
||||
import org.gcube.spatial.data.clients.AbstractGenericClient;
|
||||
import org.gcube.spatial.data.clients.SDIGenericClient;
|
||||
import org.gcube.spatial.data.clients.SDIGenericPlugin;
|
||||
import org.gcube.spatial.data.clients.model.ClientInfo;
|
||||
import org.gcube.spatial.data.clients.model.engine.Engine;
|
||||
import org.gcube.spatial.data.clients.model.engine.Range;
|
||||
|
||||
public class GeoServerClient extends AbstractGenericClient implements SDIGenericClient{
|
||||
public class GeoServerClient extends AbstractGenericClient implements SDIGenericPlugin{
|
||||
|
||||
|
||||
public GeoServerClient() {
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.UUID;
|
|||
import javax.sound.midi.SysexMessage;
|
||||
|
||||
import org.gcube.sdi.test.GCubeSDITest;
|
||||
import org.gcube.spatial.data.clients.SDIGenericClient;
|
||||
import org.gcube.spatial.data.clients.SDIGenericPlugin;
|
||||
import org.gcube.spatial.data.clients.model.engine.Engine;
|
||||
import org.gcube.spatial.data.sdi.model.faults.RemoteException;
|
||||
import org.json.simple.JSONObject;
|
||||
|
@ -20,7 +20,7 @@ public class GSTests extends GCubeSDITest{
|
|||
|
||||
|
||||
protected GSRESTClient getClient() throws RemoteException, Exception {
|
||||
SDIGenericClient obj=manager().getClientByEngineId(Engine.GS_ENGINE);
|
||||
SDIGenericPlugin obj=manager().getClientByEngineId(Engine.GS_ENGINE);
|
||||
assertTrue(obj.getClass().isAssignableFrom(GeoServerClient.class));
|
||||
return (GSRESTClient) obj.getRESTClient();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<StyledLayerDescriptor version="1.0.0"
|
||||
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
|
||||
xmlns="http://www.opengis.net/sld"
|
||||
xmlns:ogc="http://www.opengis.net/ogc"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<!-- a Named Layer is the basic building block of an SLD document -->
|
||||
<NamedLayer>
|
||||
<Name>default_line</Name>
|
||||
<UserStyle>
|
||||
<!-- Styles can have names, titles and abstracts -->
|
||||
<Title>Default Line</Title>
|
||||
<Abstract>A sample style that draws a line</Abstract>
|
||||
<!-- FeatureTypeStyles describe how to render different features -->
|
||||
<!-- A FeatureTypeStyle for rendering lines -->
|
||||
<FeatureTypeStyle>
|
||||
<Rule>
|
||||
<Name>rule1</Name>
|
||||
<Title>Blue Line</Title>
|
||||
<Abstract>A solid blue line with a 1 pixel width</Abstract>
|
||||
<LineSymbolizer>
|
||||
<Stroke>
|
||||
<CssParameter name="stroke">#0000FF</CssParameter>
|
||||
</Stroke>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
</FeatureTypeStyle>
|
||||
</UserStyle>
|
||||
</NamedLayer>
|
||||
</StyledLayerDescriptor>
|
|
@ -5,7 +5,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||
import org.gcube.spatial.data.clients.model.ClientInfo;
|
||||
import org.gcube.spatial.data.clients.model.ConnectionDescriptor;
|
||||
|
||||
public abstract class AbstractGenericClient implements SDIGenericClient {
|
||||
public abstract class AbstractGenericClient implements SDIGenericPlugin {
|
||||
|
||||
private ConnectionDescriptor conn;
|
||||
private Class<?> restClientClass;
|
||||
|
@ -26,7 +26,7 @@ public abstract class AbstractGenericClient implements SDIGenericClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SDIGenericClient at(ConnectionDescriptor conn) {
|
||||
public SDIGenericPlugin at(ConnectionDescriptor conn) {
|
||||
this.conn=conn;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.spatial.data.clients;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -49,6 +50,30 @@ public abstract class AbstractGenericRESTClient implements GenericLoginClient{
|
|||
}
|
||||
|
||||
|
||||
protected String getExistsPath() {
|
||||
return conn.getEndpoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exist() {
|
||||
try {
|
||||
get(getExistsPath());
|
||||
return true;
|
||||
}catch(IOException e) {
|
||||
log.warn("Unable to check instance "+conn,e);
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
log.warn("Unable to check instance "+conn,e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ConnectionDescriptor getInstance() {
|
||||
return conn;
|
||||
}
|
||||
|
||||
public void authenticate(AccessType type) {
|
||||
log.info("Setting access type {} ",type);
|
||||
conn.getCredentials().forEach((Credentials c)->{
|
||||
|
@ -114,8 +139,8 @@ public abstract class AbstractGenericRESTClient implements GenericLoginClient{
|
|||
}
|
||||
|
||||
|
||||
protected void post(String path,Object obj) {
|
||||
|
||||
protected void post(String path,Object obj) throws Exception {
|
||||
post(path,Entity.entity(obj, MediaType.APPLICATION_JSON_TYPE));
|
||||
}
|
||||
|
||||
protected <T> T post(String path,Entity<?> entity,Class<T> returnClazz) throws Exception {
|
||||
|
@ -128,6 +153,26 @@ public abstract class AbstractGenericRESTClient implements GenericLoginClient{
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
protected void put(String path,Entity<?> entity)throws Exception{
|
||||
post(path,entity,null);
|
||||
}
|
||||
|
||||
|
||||
protected void put(String path,Object obj) throws Exception {
|
||||
post(path,Entity.entity(obj, MediaType.APPLICATION_JSON_TYPE));
|
||||
}
|
||||
|
||||
protected <T> T put(String path,Entity<?> entity,Class<T> returnClazz) throws Exception {
|
||||
return makeCall(new Call<GXWebTargetAdapterRequest, T>() {
|
||||
|
||||
public T call(GXWebTargetAdapterRequest endpoint) throws Exception {
|
||||
return check(endpoint.path(path).post(entity),returnClazz);
|
||||
};
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
protected String get(String path) throws Exception {
|
||||
return get(path,String.class);
|
||||
}
|
||||
|
|
|
@ -2,11 +2,12 @@ package org.gcube.spatial.data.clients;
|
|||
|
||||
import org.gcube.spatial.data.sdi.model.credentials.AccessType;
|
||||
|
||||
public interface GenericLoginClient {
|
||||
public interface GenericLoginClient extends SDIRESTClient{
|
||||
|
||||
|
||||
public void authenticate();
|
||||
|
||||
public void authenticate(AccessType type);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -15,12 +15,12 @@ import lombok.extern.slf4j.Slf4j;
|
|||
@Slf4j
|
||||
public class SDIClientManager {
|
||||
|
||||
private List<SDIGenericClient> clients=new ArrayList<SDIGenericClient>();
|
||||
private List<SDIGenericPlugin> clients=new ArrayList<SDIGenericPlugin>();
|
||||
|
||||
public SDIClientManager() {
|
||||
ServiceLoader.load(SDIGenericClient.class).forEach((SDIGenericClient c)->{clients.add(c);});
|
||||
ServiceLoader.load(SDIGenericPlugin.class).forEach((SDIGenericPlugin c)->{clients.add(c);});
|
||||
log.info("Loaded {} clients ",clients.size());
|
||||
clients.forEach((SDIGenericClient c)->{
|
||||
clients.forEach((SDIGenericPlugin c)->{
|
||||
log.debug("Loaded "+c.getInfo());
|
||||
});
|
||||
}
|
||||
|
@ -33,9 +33,9 @@ public class SDIClientManager {
|
|||
* @param version
|
||||
* @return
|
||||
*/
|
||||
public SDIGenericClient get(String engine,String version) {
|
||||
public SDIGenericPlugin get(String engine,String version) {
|
||||
log.info("Looking for clients [target : {} {} ] ",engine,version);
|
||||
for(SDIGenericClient c:clients) {
|
||||
for(SDIGenericPlugin c:clients) {
|
||||
if(c.getInfo().getSupportedEngine().getEngineUniqueString().equals(engine)
|
||||
&& c.getInfo().getSupportedEngine().getRange().supports(version))
|
||||
return c;
|
||||
|
@ -52,8 +52,8 @@ public class SDIClientManager {
|
|||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public SDIGenericClient get(ConnectionDescriptor conn) throws Exception {
|
||||
SDIGenericClient toReturn=get(conn.getEngineUniqueID(),conn.getVersion());
|
||||
public SDIGenericPlugin get(ConnectionDescriptor conn) throws Exception {
|
||||
SDIGenericPlugin toReturn=get(conn.getEngineUniqueID(),conn.getVersion());
|
||||
if(toReturn==null) throw new Exception("Unable to get client for "+conn.getEngineUniqueID()+" "+conn.getVersion());
|
||||
return toReturn.at(conn);
|
||||
}
|
||||
|
@ -67,20 +67,20 @@ public class SDIClientManager {
|
|||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public SDIGenericClient get(GeoServiceDescriptor service) throws Exception {
|
||||
public SDIGenericPlugin get(GeoServiceDescriptor service) throws Exception {
|
||||
return get(service.getConnection());
|
||||
}
|
||||
|
||||
|
||||
public List<ClientInfo> list(){
|
||||
List<ClientInfo> toReturn=new ArrayList<ClientInfo>();
|
||||
clients.forEach((SDIGenericClient c)->{toReturn.add(c.getInfo());});
|
||||
clients.forEach((SDIGenericPlugin c)->{toReturn.add(c.getInfo());});
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public List<ClientInfo> list(String engineId){
|
||||
List<ClientInfo> toReturn=new ArrayList<ClientInfo>();
|
||||
clients.forEach((SDIGenericClient c)->{
|
||||
clients.forEach((SDIGenericPlugin c)->{
|
||||
if(c.getInfo().getSupportedEngine().getEngineUniqueString().equals(engineId))
|
||||
toReturn.add(c.getInfo());});
|
||||
return toReturn;
|
||||
|
|
|
@ -3,13 +3,13 @@ package org.gcube.spatial.data.clients;
|
|||
import org.gcube.spatial.data.clients.model.ClientInfo;
|
||||
import org.gcube.spatial.data.clients.model.ConnectionDescriptor;
|
||||
|
||||
public interface SDIGenericClient {
|
||||
public interface SDIGenericPlugin {
|
||||
|
||||
|
||||
public ClientInfo getInfo();
|
||||
|
||||
public Object getRESTClient();
|
||||
|
||||
public SDIGenericClient at(ConnectionDescriptor conn);
|
||||
public SDIGenericPlugin at(ConnectionDescriptor conn);
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package org.gcube.spatial.data.clients;
|
||||
|
||||
import org.gcube.spatial.data.clients.model.ConnectionDescriptor;
|
||||
|
||||
public interface SDIRESTClient {
|
||||
|
||||
|
||||
// Management
|
||||
public boolean exist();
|
||||
|
||||
public ConnectionDescriptor getInstance();
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package org.gcube.spatial.data.sdi.interfaces;
|
||||
|
||||
import org.gcube.spatia.data.model.profiles.ApplicationProfile;
|
||||
import org.gcube.spatial.data.clients.SDIGenericClient;
|
||||
import org.gcube.spatial.data.clients.SDIGenericPlugin;
|
||||
import org.gcube.spatial.data.clients.model.ConnectionDescriptor;
|
||||
import org.gcube.spatial.data.sdi.model.ScopeConfiguration;
|
||||
import org.gcube.spatial.data.sdi.model.faults.RemoteException;
|
||||
|
@ -15,6 +15,6 @@ public interface SDIManagement {
|
|||
|
||||
|
||||
|
||||
public SDIGenericClient getClientByEngineId(String engineId) throws Exception;
|
||||
public SDIGenericPlugin getClientByEngineId(String engineId) throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package org.gcube.spatial.data.sdi;
|
||||
|
||||
import org.gcube.spatial.data.clients.SDIGenericClient;
|
||||
import org.gcube.spatial.data.clients.SDIGenericPlugin;
|
||||
import org.gcube.spatial.data.clients.model.ClientInfo;
|
||||
import org.gcube.spatial.data.clients.model.ConnectionDescriptor;
|
||||
import org.gcube.spatial.data.clients.model.engine.Engine;
|
||||
import org.gcube.spatial.data.clients.model.engine.Range;
|
||||
|
||||
public class DumbGNClient implements SDIGenericClient{
|
||||
public class DumbGNClient implements SDIGenericPlugin{
|
||||
|
||||
|
||||
ClientInfo gnClient=new ClientInfo("dumb-gn","GeoNetwork 2","Client to communicate with GN 2","org.gcube.sdi.some.clients.Client",
|
||||
|
@ -23,7 +23,7 @@ public class DumbGNClient implements SDIGenericClient{
|
|||
return null;
|
||||
}
|
||||
@Override
|
||||
public SDIGenericClient at(ConnectionDescriptor conn) {
|
||||
public SDIGenericPlugin at(ConnectionDescriptor conn) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.gcube.common.clients.delegates.ProxyDelegate;
|
|||
import org.gcube.common.gxrest.request.GXWebTargetAdapterRequest;
|
||||
import org.gcube.spatia.data.model.profiles.ApplicationProfile;
|
||||
import org.gcube.spatial.data.clients.SDIClientManager;
|
||||
import org.gcube.spatial.data.clients.SDIGenericClient;
|
||||
import org.gcube.spatial.data.clients.SDIGenericPlugin;
|
||||
import org.gcube.spatial.data.clients.model.ClientInfo;
|
||||
import org.gcube.spatial.data.sdi.interfaces.SDIManagement;
|
||||
import org.gcube.spatial.data.sdi.model.ScopeConfiguration;
|
||||
|
@ -87,13 +87,13 @@ public class DefaultSDIManagement implements SDIManagement{
|
|||
}
|
||||
|
||||
@Override
|
||||
public SDIGenericClient getClientByEngineId(String engineId) throws Exception {
|
||||
public SDIGenericPlugin getClientByEngineId(String engineId) throws Exception {
|
||||
List<? extends GeoServiceDescriptor> desc=getConfiguration().getByEngine(engineId);
|
||||
|
||||
if(desc==null|| desc.isEmpty()) throw new Exception("No "+engineId+" available in current context. Check ScopeConfiguration object.");
|
||||
|
||||
for(GeoServiceDescriptor d:desc) {
|
||||
SDIGenericClient c=clientManager.get(d);
|
||||
SDIGenericPlugin c=clientManager.get(d);
|
||||
if(c!=null) return c;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.gcube.common.gxrest.request.GXWebTargetAdapterRequest;
|
|||
import org.gcube.common.gxrest.response.inbound.GXInboundResponse;
|
||||
import org.gcube.spatia.data.model.profiles.ApplicationProfile;
|
||||
import org.gcube.spatial.data.clients.SDIClientManager;
|
||||
import org.gcube.spatial.data.clients.SDIGenericClient;
|
||||
import org.gcube.spatial.data.clients.SDIGenericPlugin;
|
||||
import org.gcube.spatial.data.clients.model.ConnectionDescriptor;
|
||||
import org.gcube.spatial.data.sdi.interfaces.SDIManagement;
|
||||
import org.gcube.spatial.data.sdi.model.ScopeConfiguration;
|
||||
|
@ -108,13 +108,13 @@ public class SimpleSDIManagerClient implements SDIManagement{
|
|||
}
|
||||
|
||||
@Override
|
||||
public SDIGenericClient getClientByEngineId(String engineId) throws Exception {
|
||||
public SDIGenericPlugin getClientByEngineId(String engineId) throws Exception {
|
||||
List<? extends GeoServiceDescriptor> desc=getConfiguration().getByEngine(engineId);
|
||||
|
||||
if(desc==null|| desc.isEmpty()) throw new Exception("No "+engineId+" available in current context. Check ScopeConfiguration object.");
|
||||
|
||||
for(GeoServiceDescriptor d:desc) {
|
||||
SDIGenericClient c=clientManager.get(d);
|
||||
SDIGenericPlugin c=clientManager.get(d);
|
||||
if(c!=null) return c;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue