Fix ImageMosaic Metadata pubblication and Encoder refactoring
This commit is contained in:
parent
35262dc51c
commit
99104c13cb
2
pom.xml
2
pom.xml
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
<groupId>it.geosolutions</groupId>
|
<groupId>it.geosolutions</groupId>
|
||||||
<artifactId>geoserver-manager</artifactId>
|
<artifactId>geoserver-manager</artifactId>
|
||||||
<version>1.1-SNAPSHOT</version>
|
<version>1.2-SNAPSHOT</version>
|
||||||
|
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|||||||
@ -26,11 +26,11 @@ package it.geosolutions.geoserver.rest;
|
|||||||
|
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTCoverageList;
|
import it.geosolutions.geoserver.rest.decoder.RESTCoverageList;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTCoverageStore;
|
import it.geosolutions.geoserver.rest.decoder.RESTCoverageStore;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSCoverageEncoder;
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSFeatureTypeEncoder;
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSPostGISDatastoreEncoder;
|
import it.geosolutions.geoserver.rest.encoder.GSPostGISDatastoreEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSWorkspaceEncoder;
|
import it.geosolutions.geoserver.rest.encoder.GSWorkspaceEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.coverage.GSCoverageEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -88,7 +88,7 @@ public class GeoServerRESTPublisher {
|
|||||||
public boolean createWorkspace(String workspace) {
|
public boolean createWorkspace(String workspace) {
|
||||||
String sUrl = restURL + "/rest/workspaces";
|
String sUrl = restURL + "/rest/workspaces";
|
||||||
GSWorkspaceEncoder wsenc = new GSWorkspaceEncoder(workspace);
|
GSWorkspaceEncoder wsenc = new GSWorkspaceEncoder(workspace);
|
||||||
String wsxml = wsenc.encodeXml();
|
String wsxml = wsenc.toString();
|
||||||
String result = HTTPUtils.postXml(sUrl, wsxml, gsuser, gspass);
|
String result = HTTPUtils.postXml(sUrl, wsxml, gsuser, gspass);
|
||||||
return result != null;
|
return result != null;
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ public class GeoServerRESTPublisher {
|
|||||||
*/
|
*/
|
||||||
public boolean createPostGISDatastore(String workspace, GSPostGISDatastoreEncoder datastoreEncoder) {
|
public boolean createPostGISDatastore(String workspace, GSPostGISDatastoreEncoder datastoreEncoder) {
|
||||||
String sUrl = restURL + "/rest/workspaces/" + workspace + "/datastores/";
|
String sUrl = restURL + "/rest/workspaces/" + workspace + "/datastores/";
|
||||||
String xml = datastoreEncoder.encodeXml();
|
String xml = datastoreEncoder.toString();
|
||||||
String result = HTTPUtils.postXml(sUrl, xml, gsuser, gspass);
|
String result = HTTPUtils.postXml(sUrl, xml, gsuser, gspass);
|
||||||
return result != null;
|
return result != null;
|
||||||
}
|
}
|
||||||
@ -270,7 +270,7 @@ public class GeoServerRESTPublisher {
|
|||||||
fte.setName(layername);
|
fte.setName(layername);
|
||||||
fte.setSRS(srs);
|
fte.setSRS(srs);
|
||||||
|
|
||||||
String configuredResult = HTTPUtils.putXml(postUrl.toString(), fte.encodeXml(), this.gsuser, this.gspass);
|
String configuredResult = HTTPUtils.putXml(postUrl.toString(), fte.toString(), this.gsuser, this.gspass);
|
||||||
boolean shpConfigured = configuredResult != null;
|
boolean shpConfigured = configuredResult != null;
|
||||||
|
|
||||||
if (!shpConfigured) {
|
if (!shpConfigured) {
|
||||||
@ -310,7 +310,7 @@ public class GeoServerRESTPublisher {
|
|||||||
GSFeatureTypeEncoder fte = new GSFeatureTypeEncoder();
|
GSFeatureTypeEncoder fte = new GSFeatureTypeEncoder();
|
||||||
fte.setName(layername);
|
fte.setName(layername);
|
||||||
fte.setSRS(srs); // srs=null?"EPSG:4326":srs);
|
fte.setSRS(srs); // srs=null?"EPSG:4326":srs);
|
||||||
String ftypeXml = fte.encodeXml();
|
String ftypeXml = fte.toString();
|
||||||
|
|
||||||
String configuredResult = HTTPUtils.postXml(postUrl.toString(), ftypeXml, this.gsuser, this.gspass);
|
String configuredResult = HTTPUtils.postXml(postUrl.toString(), ftypeXml, this.gsuser, this.gspass);
|
||||||
boolean published = configuredResult != null;
|
boolean published = configuredResult != null;
|
||||||
@ -498,14 +498,14 @@ public class GeoServerRESTPublisher {
|
|||||||
try {
|
try {
|
||||||
// // retrieve coverage name
|
// // retrieve coverage name
|
||||||
GeoServerRESTReader reader = new GeoServerRESTReader(restURL, gsuser, gspass);
|
GeoServerRESTReader reader = new GeoServerRESTReader(restURL, gsuser, gspass);
|
||||||
RESTCoverageList covList = reader.getCoverages(workspace, storeName);
|
RESTCoverageList covList = reader.getCoverages(store.getWorkspaceName(), storeName);
|
||||||
if (covList.isEmpty()) {
|
if (covList.isEmpty()) {
|
||||||
LOGGER.error("No coverages found in new coveragestore " + storeName);
|
LOGGER.error("No coverages found in new coveragestore " + storeName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String coverageName = covList.get(0).getName();
|
String coverageName = covList.get(0).getName();
|
||||||
|
|
||||||
configureCoverage(coverageEncoder, workspace, storeName, coverageName);
|
configureCoverage(coverageEncoder, store.getWorkspaceName(), storeName, coverageName);
|
||||||
configureLayer(layerEncoder, storeName);
|
configureLayer(layerEncoder, storeName);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -709,7 +709,7 @@ public class GeoServerRESTPublisher {
|
|||||||
|
|
||||||
final String url = restURL + "/rest/layers/" + layerName;
|
final String url = restURL + "/rest/layers/" + layerName;
|
||||||
|
|
||||||
String layerXml = layer.encodeXml();
|
String layerXml = layer.toString();
|
||||||
String sendResult = HTTPUtils.putXml(url, layerXml, gsuser, gspass);
|
String sendResult = HTTPUtils.putXml(url, layerXml, gsuser, gspass);
|
||||||
if (sendResult != null) {
|
if (sendResult != null) {
|
||||||
if (LOGGER.isInfoEnabled()) {
|
if (LOGGER.isInfoEnabled()) {
|
||||||
@ -730,7 +730,7 @@ public class GeoServerRESTPublisher {
|
|||||||
|
|
||||||
final String url = restURL + "/rest/workspaces/" + wsname + "/coveragestores/" + csname + "/coverages/" + cname + ".xml";
|
final String url = restURL + "/rest/workspaces/" + wsname + "/coveragestores/" + csname + "/coverages/" + cname + ".xml";
|
||||||
|
|
||||||
String xmlBody = ce.encodeXml();
|
String xmlBody = ce.toString();
|
||||||
String sendResult = HTTPUtils.putXml(url, xmlBody, gsuser, gspass);
|
String sendResult = HTTPUtils.putXml(url, xmlBody, gsuser, gspass);
|
||||||
if (sendResult != null) {
|
if (sendResult != null) {
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
|||||||
@ -35,15 +35,16 @@ public class GSLayerEncoder extends PropertyXMLEncoder {
|
|||||||
|
|
||||||
public GSLayerEncoder() {
|
public GSLayerEncoder() {
|
||||||
super("layer");
|
super("layer");
|
||||||
set("enabled", "true");
|
// enable layer
|
||||||
|
add("enabled","true");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWmsPath(String wmspath) {
|
// public void setWmsPath(String wmspath) {
|
||||||
setOrRemove("wmspath", wmspath);
|
// add("wmspath", wmspath);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public void setDefaultStyle(String defaultStyle) {
|
public void setDefaultStyle(String defaultStyle) {
|
||||||
setOrRemove("defaultStyle", defaultStyle);
|
add("defaultStyle", defaultStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,6 @@ package it.geosolutions.geoserver.rest.encoder;
|
|||||||
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.utils.EntryKeyListEncoder;
|
import it.geosolutions.geoserver.rest.encoder.utils.EntryKeyListEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.utils.PropertyXMLEncoder;
|
import it.geosolutions.geoserver.rest.encoder.utils.PropertyXMLEncoder;
|
||||||
import org.jdom.Element;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Geoserver datastore XML encoder.
|
* Geoserver datastore XML encoder.
|
||||||
@ -37,7 +36,7 @@ import org.jdom.Element;
|
|||||||
*/
|
*/
|
||||||
public class GSPostGISDatastoreEncoder extends PropertyXMLEncoder {
|
public class GSPostGISDatastoreEncoder extends PropertyXMLEncoder {
|
||||||
|
|
||||||
private EntryKeyListEncoder connectionParameters = new EntryKeyListEncoder("connectionParameters");
|
private EntryKeyListEncoder<String> connectionParameters = new EntryKeyListEncoder<String>("connectionParameters");
|
||||||
|
|
||||||
|
|
||||||
public GSPostGISDatastoreEncoder() {
|
public GSPostGISDatastoreEncoder() {
|
||||||
@ -70,19 +69,19 @@ public class GSPostGISDatastoreEncoder extends PropertyXMLEncoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
setOrRemove("name", name);
|
add("name", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
setOrRemove("description", description);
|
add("description", description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setType(String type) {
|
||||||
setOrRemove("type", type);
|
add("type", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabled(boolean enabled) {
|
public void setEnabled(boolean enabled) {
|
||||||
setOrRemove("enabled", Boolean.toString(enabled));
|
add("enabled", Boolean.toString(enabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNamespace(String namespace) {
|
public void setNamespace(String namespace) {
|
||||||
@ -161,10 +160,4 @@ public class GSPostGISDatastoreEncoder extends PropertyXMLEncoder {
|
|||||||
connectionParameters.add("Max open prepared statements", Integer.toString(maxOpenPreparedStatements));
|
connectionParameters.add("Max open prepared statements", Integer.toString(maxOpenPreparedStatements));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addNodesBeforeOutput(Element e) {
|
|
||||||
super.addNodesBeforeOutput(e);
|
|
||||||
connectionParameters.attachList(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -25,27 +25,83 @@
|
|||||||
|
|
||||||
package it.geosolutions.geoserver.rest.encoder;
|
package it.geosolutions.geoserver.rest.encoder;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSMetadataEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.utils.PropertyXMLEncoder;
|
import it.geosolutions.geoserver.rest.encoder.utils.PropertyXMLEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.utils.TextNodeListEncoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author ETj (etj at geo-solutions.it)
|
* @author ETj (etj at geo-solutions.it)
|
||||||
|
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
*/
|
*/
|
||||||
public abstract class GSResourceEncoder extends PropertyXMLEncoder {
|
public abstract class GSResourceEncoder<T extends GSDimensionInfoEncoder> extends PropertyXMLEncoder {
|
||||||
|
|
||||||
protected GSResourceEncoder(String rootName) {
|
final private GSMetadataEncoder<T> metadata=new GSMetadataEncoder<T>();
|
||||||
super(rootName);
|
|
||||||
|
|
||||||
|
public void addMetadata(String key, T dimensionInfo) {
|
||||||
|
metadata.add(key, dimensionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private TextNodeListEncoder keywordsListEncoder = new TextNodeListEncoder("keywords");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NONE, REPROJECT_TO_DECLARED, FORCE_DECLARED
|
||||||
|
*/
|
||||||
|
public enum ProjectionPolicy {
|
||||||
|
REPROJECT_TO_DECLARED, FORCE_DECLARED, NONE
|
||||||
|
}
|
||||||
|
|
||||||
|
protected GSResourceEncoder(final String rootName) {
|
||||||
|
super(rootName);
|
||||||
|
add("enabled", "true");
|
||||||
|
|
||||||
|
// Link members to the parent
|
||||||
|
addContent(metadata.getElement());
|
||||||
|
addContent(keywordsListEncoder.getElement());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(final String name) {
|
||||||
|
add("name", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSRS(String srs) {
|
public void setTitle(final String title) {
|
||||||
setOrRemove("srs", srs);
|
add("title", title);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLatLonBoundingBox(double minx, double maxy, double maxx, double miny, String crs) {
|
public void setSRS(final String srs) {
|
||||||
setOrRemove("latLonBoundingBox/minx", String.valueOf(minx));
|
add("srs", srs);
|
||||||
setOrRemove("latLonBoundingBox/maxy", String.valueOf(maxy));
|
}
|
||||||
setOrRemove("latLonBoundingBox/maxx", String.valueOf(maxx));
|
|
||||||
setOrRemove("latLonBoundingBox/miny", String.valueOf(miny));
|
public void setLatLonBoundingBox(double minx, double maxy, double maxx,
|
||||||
setOrRemove("latLonBoundingBox/crs", crs);
|
double miny, final String crs) {
|
||||||
}
|
add("latLonBoundingBox/minx", String.valueOf(minx));
|
||||||
|
add("latLonBoundingBox/maxy", String.valueOf(maxy));
|
||||||
|
add("latLonBoundingBox/maxx", String.valueOf(maxx));
|
||||||
|
add("latLonBoundingBox/miny", String.valueOf(miny));
|
||||||
|
add("latLonBoundingBox/crs", crs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNativeBoundingBox(double minx, double maxy, double maxx,
|
||||||
|
double miny, final String crs) {
|
||||||
|
add("nativeBoundingBox/minx", String.valueOf(minx));
|
||||||
|
add("nativeBoundingBox/maxy", String.valueOf(maxy));
|
||||||
|
add("nativeBoundingBox/maxx", String.valueOf(maxx));
|
||||||
|
add("nativeBoundingBox/miny", String.valueOf(miny));
|
||||||
|
add("nativeBoundingBox/crs", crs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NONE, REPROJECT_TO_DECLARED, FORCE_DECLARED
|
||||||
|
*/
|
||||||
|
public void setProjectionPolicy(ProjectionPolicy policy) {
|
||||||
|
add("projectionPolicy", policy.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void addKeyword(String keyword) {
|
||||||
|
keywordsListEncoder.add("string", keyword);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,11 +25,14 @@
|
|||||||
|
|
||||||
package it.geosolutions.geoserver.rest.encoder;
|
package it.geosolutions.geoserver.rest.encoder;
|
||||||
|
|
||||||
|
import org.jdom.Element;
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.utils.PropertyXMLEncoder;
|
import it.geosolutions.geoserver.rest.encoder.utils.PropertyXMLEncoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author ETj (etj at geo-solutions.it)
|
* @author ETj (etj at geo-solutions.it)
|
||||||
|
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
*/
|
*/
|
||||||
public class GSWorkspaceEncoder extends PropertyXMLEncoder {
|
public class GSWorkspaceEncoder extends PropertyXMLEncoder {
|
||||||
|
|
||||||
@ -43,7 +46,15 @@ public class GSWorkspaceEncoder extends PropertyXMLEncoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
setOrRemove("name", name);
|
add("name", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName(){
|
||||||
|
final Element el=get("name");
|
||||||
|
if (el!=null)
|
||||||
|
return el.getName();
|
||||||
|
else
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package it.geosolutions.geoserver.rest.encoder.coverage;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||||
|
|
||||||
|
import org.jdom.Element;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an XML
|
||||||
|
*
|
||||||
|
* @author ETj (etj at geo-solutions.it)
|
||||||
|
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GSCoverageEncoder extends GSResourceEncoder<GSDimensionInfoEncoder> {
|
||||||
|
|
||||||
|
|
||||||
|
final private Element parameters=new Element("parameters");
|
||||||
|
|
||||||
|
public GSCoverageEncoder() {
|
||||||
|
super("coverage");
|
||||||
|
// Link members to the parent
|
||||||
|
addContent(parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param val
|
||||||
|
*/
|
||||||
|
public void setAllowMultithreading(final boolean val){
|
||||||
|
final Element param=new Element("entry");
|
||||||
|
param.addContent(new Element("string").setText("AllowMultithreading"));
|
||||||
|
param.addContent(new Element("string").setText((val)?"true":"false"));
|
||||||
|
parameters.addContent(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilter(final String val){
|
||||||
|
final Element param=new Element("entry");
|
||||||
|
param.addContent(new Element("string").setText("Filter"));
|
||||||
|
param.addContent(new Element("string").setText(val));
|
||||||
|
parameters.addContent(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxAllowedTiles(final int val){
|
||||||
|
final Element param=new Element("entry");
|
||||||
|
param.addContent(new Element("string").setText("MaxAllowedTiles"));
|
||||||
|
param.addContent(new Element("string").setText(String.valueOf(val)));
|
||||||
|
parameters.addContent(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInputTransparentColor(final String val){
|
||||||
|
final Element param=new Element("entry");
|
||||||
|
param.addContent(new Element("string").setText("InputTransparentColor"));
|
||||||
|
param.addContent(new Element("string").setText(val));
|
||||||
|
parameters.addContent(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOutputTransparentColor(final String val){
|
||||||
|
final Element param=new Element("entry");
|
||||||
|
param.addContent(new Element("string").setText("OutputTransparentColor"));
|
||||||
|
param.addContent(new Element("string").setText(val));
|
||||||
|
parameters.addContent(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSUGGESTED_TILE_SIZE(final String val){
|
||||||
|
final Element param=new Element("entry");
|
||||||
|
param.addContent(new Element("string").setText("SUGGESTED_TILE_SIZE"));
|
||||||
|
param.addContent(new Element("string").setText(val));
|
||||||
|
parameters.addContent(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUSE_JAI_IMAGEREAD(final boolean val){
|
||||||
|
final Element param=new Element("entry");
|
||||||
|
param.addContent(new Element("string").setText("USE_JAI_IMAGEREAD"));
|
||||||
|
param.addContent(new Element("string").setText((val)?"true":"false"));
|
||||||
|
parameters.addContent(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBackgroundValues(final String val){
|
||||||
|
final Element param=new Element("entry");
|
||||||
|
param.addContent(new Element("string").setText("BackgroundValues"));
|
||||||
|
param.addContent(new Element("string").setText(val));
|
||||||
|
parameters.addContent(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package it.geosolutions.geoserver.rest.encoder.feature;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||||
|
|
||||||
|
public class GSFeatureDimensionInfoEncoder extends GSDimensionInfoEncoder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* if this dimension is enabled this constructor should be called.
|
||||||
|
* @param attribute the attribute to use as dimension
|
||||||
|
*/
|
||||||
|
public GSFeatureDimensionInfoEncoder(final String attribute){
|
||||||
|
super(true);
|
||||||
|
add("attribute", attribute);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package it.geosolutions.geoserver.rest.encoder.feature;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author ETj (etj at geo-solutions.it)
|
||||||
|
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
|
*/
|
||||||
|
public class GSFeatureTypeEncoder extends GSResourceEncoder<GSFeatureDimensionInfoEncoder> {
|
||||||
|
|
||||||
|
public GSFeatureTypeEncoder() {
|
||||||
|
super("featureType");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
package it.geosolutions.geoserver.rest.encoder.metadata;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.utils.TextNodeListEncoder;
|
||||||
|
|
||||||
|
public class GSDimensionInfoEncoder extends TextNodeListEncoder {
|
||||||
|
final boolean enabled;
|
||||||
|
|
||||||
|
public enum Presentation{
|
||||||
|
LIST,
|
||||||
|
CONTINUOUS_INTERVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DiscretePresentation{
|
||||||
|
DISCRETE_INTERVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
public GSDimensionInfoEncoder(final boolean enabled) {
|
||||||
|
super("dimensionInfo");
|
||||||
|
add("enabled", (enabled)?"true":"false");
|
||||||
|
this.enabled=enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GSDimensionInfoEncoder() {
|
||||||
|
super("dimensionInfo");
|
||||||
|
add("enabled", "false");
|
||||||
|
this.enabled=Boolean.FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPresentation(final Presentation pres){
|
||||||
|
if (enabled){
|
||||||
|
add("presentation",pres.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPresentation(final DiscretePresentation pres, final BigDecimal interval){
|
||||||
|
if (enabled){
|
||||||
|
add("presentation",pres.toString());
|
||||||
|
add("resolution",String.valueOf(interval));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package it.geosolutions.geoserver.rest.encoder.metadata;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.utils.EntryKeyListEncoder;
|
||||||
|
|
||||||
|
public class GSMetadataEncoder <T extends GSDimensionInfoEncoder> extends EntryKeyListEncoder<T>{
|
||||||
|
|
||||||
|
public GSMetadataEncoder() {
|
||||||
|
super("metadata");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMetadata(final String key, final T value) {
|
||||||
|
this.add(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -25,13 +25,14 @@
|
|||||||
|
|
||||||
package it.geosolutions.geoserver.rest.encoder.utils;
|
package it.geosolutions.geoserver.rest.encoder.utils;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||||
import java.util.Map;
|
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes lists of entries with key attribute.
|
* Encodes lists of entries with key attribute. <br/>
|
||||||
* <br/>e.g.:
|
* e.g.:
|
||||||
|
*
|
||||||
* <PRE>
|
* <PRE>
|
||||||
* {@code
|
* {@code
|
||||||
* <listName>
|
* <listName>
|
||||||
@ -39,34 +40,71 @@ import org.jdom.Element;
|
|||||||
* <entry key="k2">val2</entry>
|
* <entry key="k2">val2</entry>
|
||||||
* <entry key="k3">val3</entry>
|
* <entry key="k3">val3</entry>
|
||||||
* </listName>}
|
* </listName>}
|
||||||
|
*
|
||||||
|
* <PRE>
|
||||||
|
*
|
||||||
|
* This can be also used in compounded to the PropertyXMLEncoder
|
||||||
|
* or other objects overriding the toString() method
|
||||||
|
* <br/>
|
||||||
|
* e.g.:
|
||||||
|
*
|
||||||
|
* <PRE>
|
||||||
|
* {@code
|
||||||
|
* <listName>
|
||||||
|
* <entry key="time">
|
||||||
|
* <dimensionInfo>
|
||||||
|
* <enabled>false</enabled>
|
||||||
|
* </dimensionInfo>
|
||||||
|
* </entry>
|
||||||
|
* <entry key="elevation">
|
||||||
|
* <dimensionInfo>
|
||||||
|
* <enabled>true</enabled>
|
||||||
|
* <attribute>ele</attribute>
|
||||||
|
* <presentation>LIST</presentation>
|
||||||
|
* </dimensionInfo>
|
||||||
|
* </entry>
|
||||||
|
* </listName>}
|
||||||
|
*
|
||||||
* <PRE>
|
* <PRE>
|
||||||
*
|
*
|
||||||
* @author ETj (etj at geo-solutions.it)
|
* @author ETj (etj at geo-solutions.it)
|
||||||
|
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class EntryKeyListEncoder {
|
public class EntryKeyListEncoder <T> extends XMLSerializer{
|
||||||
|
|
||||||
private Map<String, String> metadata = new LinkedHashMap<String, String>();
|
private final Element root;
|
||||||
private final String listName;
|
|
||||||
|
|
||||||
public EntryKeyListEncoder(String listName) {
|
public EntryKeyListEncoder(String listName) {
|
||||||
this.listName = listName;
|
root=new Element(listName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(String key, String value) {
|
public void add(String key, T value) {
|
||||||
metadata.put(key, value);
|
final Element entryElem = new Element("entry");
|
||||||
}
|
entryElem.setAttribute("key", key);
|
||||||
|
if (value instanceof String)
|
||||||
|
entryElem.setText((String)value);
|
||||||
|
else if (value instanceof Element)
|
||||||
|
entryElem.addContent((Element)value);
|
||||||
|
else if (value instanceof GSDimensionInfoEncoder)
|
||||||
|
entryElem.addContent(((GSDimensionInfoEncoder)value).getElement());
|
||||||
|
else
|
||||||
|
throw new IllegalArgumentException("Unable to add entry: unrecognized object");
|
||||||
|
|
||||||
public void attachList(Element e) {
|
root.addContent(entryElem);
|
||||||
|
}
|
||||||
|
|
||||||
if( ! metadata.isEmpty() ) {
|
|
||||||
Element md = new Element(listName);
|
/**
|
||||||
for (Map.Entry<String, String> entry : metadata.entrySet()) {
|
* add a node to the root
|
||||||
Element entryeElem = new Element("entry")
|
*
|
||||||
.setAttribute("key", entry.getKey())
|
* @param el the node to add
|
||||||
.setText(entry.getValue());
|
*/
|
||||||
md.addContent(entryeElem);
|
public void addContent(final Element el){
|
||||||
}
|
root.addContent(el);
|
||||||
e.addContent(md);
|
}
|
||||||
}
|
|
||||||
}
|
public Element getElement() {
|
||||||
|
return root;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,11 +25,7 @@
|
|||||||
|
|
||||||
package it.geosolutions.geoserver.rest.encoder.utils;
|
package it.geosolutions.geoserver.rest.encoder.utils;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
import org.jdom.output.Format;
|
|
||||||
import org.jdom.output.XMLOutputter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an XML document by mapping properties to XML nodes.<br/>
|
* Creates an XML document by mapping properties to XML nodes.<br/>
|
||||||
@ -44,56 +40,67 @@ import org.jdom.output.XMLOutputter;
|
|||||||
* <PRE> {@code <k1><k2><k3>value</k3></k2></k1> }</pre>
|
* <PRE> {@code <k1><k2><k3>value</k3></k2></k1> }</pre>
|
||||||
*
|
*
|
||||||
* @author ETj (etj at geo-solutions.it)
|
* @author ETj (etj at geo-solutions.it)
|
||||||
|
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
*/
|
*/
|
||||||
public class PropertyXMLEncoder {
|
public class PropertyXMLEncoder extends XMLSerializer{
|
||||||
|
|
||||||
private final static XMLOutputter OUTPUTTER = new XMLOutputter(Format.getCompactFormat());
|
// private final Map<String, String> configElements = new HashMap<String, String>();
|
||||||
private final Map<String, String> configElements = new HashMap<String, String>();
|
private final Element root;
|
||||||
private final String rootName;
|
|
||||||
|
|
||||||
public PropertyXMLEncoder(String rootName) {
|
public PropertyXMLEncoder(final String rootName) {
|
||||||
this.rootName = rootName;
|
root=new Element(rootName);
|
||||||
}
|
|
||||||
|
|
||||||
protected void setOrRemove(String key, String value) {
|
|
||||||
if (value != null) {
|
|
||||||
configElements.put(key, value);
|
|
||||||
} else {
|
|
||||||
configElements.remove(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void set(String key, String value) {
|
|
||||||
setOrRemove(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return configElements.isEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return an xml document representing the stored properties.
|
* add a node (as child) to the root node
|
||||||
|
*
|
||||||
|
* @param el the node to add
|
||||||
*/
|
*/
|
||||||
public String encodeXml() {
|
@Override
|
||||||
|
public void addContent(final Element el){
|
||||||
|
root.addContent(el);
|
||||||
|
}
|
||||||
|
|
||||||
Element root = new Element(rootName);
|
/**
|
||||||
for (String key : configElements.keySet()) {
|
* @Deprecated use add()
|
||||||
final String value = configElements.get(key);
|
*/
|
||||||
|
@Deprecated
|
||||||
|
protected void setOrRemove(String key, String value) {
|
||||||
|
final Element e=root.getChild(key);
|
||||||
|
if (value != null && e==null) {
|
||||||
|
add(root, key, value);
|
||||||
|
} else {
|
||||||
|
root.removeChild(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void add(String key, String value) {
|
||||||
|
final Element e=root.getChild(key);
|
||||||
|
if (value != null && e==null) {
|
||||||
add(root, key, value);
|
add(root, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
addNodesBeforeOutput(root);
|
|
||||||
return OUTPUTTER.outputString(root);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
// return configElements.isEmpty();
|
||||||
|
return root.getChildren().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Element get(final String key){
|
||||||
|
return root.getChild(key);
|
||||||
|
// return configElements.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclasses may need to override this method if some more info in the XML
|
* Subclasses may need to override this method if some more info in the XML
|
||||||
* string are needed when calling {@link #encodeXml() encodeXml()}.
|
* string are needed when calling {@link #encodeXml() encodeXml()}.
|
||||||
*
|
*
|
||||||
* @param root the root element that will be converted into String by encodeXml
|
* @param root the root element that will be converted into String by encodeXml
|
||||||
*/
|
*/
|
||||||
protected void addNodesBeforeOutput(Element root) {
|
@Override
|
||||||
// nothing to do, just override when needed.
|
public Element getElement(){
|
||||||
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add(Element e, String key, String value) {
|
private void add(Element e, String key, String value) {
|
||||||
@ -114,4 +121,6 @@ public class PropertyXMLEncoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
package it.geosolutions.geoserver.rest.encoder.utils;
|
package it.geosolutions.geoserver.rest.encoder.utils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,39 +40,27 @@ import org.jdom.Element;
|
|||||||
* <PRE>
|
* <PRE>
|
||||||
*
|
*
|
||||||
* @author ETj (etj at geo-solutions.it)
|
* @author ETj (etj at geo-solutions.it)
|
||||||
|
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
*/
|
*/
|
||||||
public class TextNodeListEncoder {
|
public class TextNodeListEncoder extends XMLSerializer{
|
||||||
|
|
||||||
private List<Pair> list = new ArrayList<Pair>();
|
|
||||||
private final String listName;
|
|
||||||
|
|
||||||
|
private final Element root;
|
||||||
public TextNodeListEncoder(String listName) {
|
public TextNodeListEncoder(String listName) {
|
||||||
this.listName = listName;
|
root=new Element(listName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(String nodename, String nodetext) {
|
public void add(String nodename, String nodetext) {
|
||||||
list.add(new Pair(nodename, nodetext));
|
final Element el=new Element(nodename);
|
||||||
|
el.setText(nodetext);
|
||||||
|
root.addContent(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachList(Element e) {
|
public Element getElement() {
|
||||||
|
return root;
|
||||||
if( ! list.isEmpty() ) {
|
|
||||||
Element elist = new Element(listName);
|
|
||||||
for (Pair pair : list) {
|
|
||||||
Element entry = new Element(pair.v1).setText(pair.v2);
|
|
||||||
elist.addContent(entry);
|
|
||||||
}
|
|
||||||
e.addContent(elist);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Pair {
|
public void addContent(final Element el){
|
||||||
String v1;
|
root.addContent(el);
|
||||||
String v2;
|
}
|
||||||
|
|
||||||
public Pair(String v1, String v2) {
|
|
||||||
this.v1 = v1;
|
|
||||||
this.v2 = v2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package it.geosolutions.geoserver.rest.encoder.utils;
|
||||||
|
|
||||||
|
import org.jdom.Element;
|
||||||
|
import org.jdom.output.Format;
|
||||||
|
import org.jdom.output.XMLOutputter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class XMLSerializer {
|
||||||
|
private final static XMLOutputter OUTPUTTER = new XMLOutputter(Format.getCompactFormat());
|
||||||
|
|
||||||
|
public XMLSerializer(){}
|
||||||
|
|
||||||
|
public abstract Element getElement();
|
||||||
|
|
||||||
|
public abstract void addContent(final Element el);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return an xml String
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
final Element root= getElement();
|
||||||
|
if (root!=null)
|
||||||
|
return OUTPUTTER.outputString(root);
|
||||||
|
else
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -42,7 +42,7 @@ public class EntryKeyListEncoderTest extends TestCase {
|
|||||||
ekle.add("k3", "v3");
|
ekle.add("k3", "v3");
|
||||||
|
|
||||||
Element root = new Element("root");
|
Element root = new Element("root");
|
||||||
ekle.attachList(root);
|
root.addContent(ekle.getElement());
|
||||||
|
|
||||||
assertEquals(1, root.getChildren().size());
|
assertEquals(1, root.getChildren().size());
|
||||||
assertNotNull(root.getChild("EKL"));
|
assertNotNull(root.getChild("EKL"));
|
||||||
|
|||||||
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007 - 2011 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* GPLv3 + Classpath exception
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package it.geosolutions.geoserver.rest.encoder.utils;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.coverage.GSCoverageEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author ETj (etj at geo-solutions.it)
|
||||||
|
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
|
*/
|
||||||
|
public class GSCoverageEncoderTest extends TestCase {
|
||||||
|
|
||||||
|
public GSCoverageEncoderTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default logger
|
||||||
|
*/
|
||||||
|
protected final static Logger LOGGER = Logger.getLogger(GSCoverageEncoderTest.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAll() {
|
||||||
|
GSCoverageEncoder encoder=new GSCoverageEncoder();
|
||||||
|
encoder.addKeyword("KEYWORD_1");
|
||||||
|
encoder.addKeyword("KEYWORD_2");
|
||||||
|
encoder.addKeyword("...");
|
||||||
|
encoder.addKeyword("KEYWORD_N");
|
||||||
|
GSDimensionInfoEncoder dim=new GSDimensionInfoEncoder(true);
|
||||||
|
dim.setPresentation(Presentation.CONTINUOUS_INTERVAL);
|
||||||
|
encoder.addMetadata("time", dim);
|
||||||
|
GSDimensionInfoEncoder dim2=new GSDimensionInfoEncoder(true);
|
||||||
|
dim2.setPresentation(Presentation.LIST);
|
||||||
|
encoder.addMetadata("elev", dim2);
|
||||||
|
encoder.setAllowMultithreading(true);
|
||||||
|
|
||||||
|
LOGGER.info(encoder.toString());
|
||||||
|
// TODO TESTS
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007 - 2011 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* GPLv3 + Classpath exception
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package it.geosolutions.geoserver.rest.encoder.utils;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureDimensionInfoEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.DiscretePresentation;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author ETj (etj at geo-solutions.it)
|
||||||
|
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
|
*/
|
||||||
|
public class GSFeatureEncoderTest extends TestCase {
|
||||||
|
|
||||||
|
public GSFeatureEncoderTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAll() {
|
||||||
|
GSFeatureTypeEncoder feature = new GSFeatureTypeEncoder();
|
||||||
|
feature.addKeyword("KEYWORD_1");
|
||||||
|
feature.addKeyword("KEYWORD_2");
|
||||||
|
feature.addKeyword("...");
|
||||||
|
feature.addKeyword("KEYWORD_N");
|
||||||
|
GSFeatureDimensionInfoEncoder dim2 = new GSFeatureDimensionInfoEncoder(
|
||||||
|
"ELE");
|
||||||
|
dim2.setPresentation(DiscretePresentation.DISCRETE_INTERVAL,
|
||||||
|
BigDecimal.valueOf(10));
|
||||||
|
feature.addMetadata("elevation", dim2);
|
||||||
|
|
||||||
|
// TODO TESTS
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user