Merge pull request #121 from geosolutions-it/master-coverage-band-details-wcseo
Master coverage band details wcseo
This commit is contained in:
commit
7d5d159b55
@ -1821,12 +1821,9 @@ public class GeoServerRESTPublisher {
|
|||||||
throw new IllegalArgumentException("no coverageEncoder provided for mosaic "
|
throw new IllegalArgumentException("no coverageEncoder provided for mosaic "
|
||||||
+ mosaicDir);
|
+ mosaicDir);
|
||||||
}
|
}
|
||||||
// override name to match the FIRST configured coverage
|
|
||||||
String coverageName = coverageEncoder.getName();
|
|
||||||
|
|
||||||
if (layerEncoder == null) {
|
if (layerEncoder == null) {
|
||||||
throw new IllegalArgumentException("no layerEncoder provided for " + workspace + ":"
|
throw new IllegalArgumentException("no layerEncoder provided for " + mosaicDir);
|
||||||
+ coverageName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RESTCoverageStore store = createExternaMosaicDatastore(workspace, storeName, mosaicDir,
|
RESTCoverageStore store = createExternaMosaicDatastore(workspace, storeName, mosaicDir,
|
||||||
@ -1835,6 +1832,13 @@ public class GeoServerRESTPublisher {
|
|||||||
if (store == null) {
|
if (store == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// override name to match the FIRST configured coverage
|
||||||
|
String coverageName = coverageEncoder.getName();
|
||||||
|
if (coverageName==null){
|
||||||
|
coverageName=mosaicDir.getName();
|
||||||
|
coverageEncoder.setName(coverageName);
|
||||||
|
}
|
||||||
if (!createCoverage(workspace, storeName, coverageEncoder)) {
|
if (!createCoverage(workspace, storeName, coverageEncoder)) {
|
||||||
if (LOGGER.isErrorEnabled())
|
if (LOGGER.isErrorEnabled())
|
||||||
LOGGER.error("Unable to create a coverage for the store:" + coverageName);
|
LOGGER.error("Unable to create a coverage for the store:" + coverageName);
|
||||||
@ -2129,6 +2133,8 @@ public class GeoServerRESTPublisher {
|
|||||||
*/
|
*/
|
||||||
private void deleteStylesForWorkspace(String workspace) {
|
private void deleteStylesForWorkspace(String workspace) {
|
||||||
RESTStyleList styles = styleManager.getStyles(workspace);
|
RESTStyleList styles = styleManager.getStyles(workspace);
|
||||||
|
if (styles==null)
|
||||||
|
return;
|
||||||
for (NameLinkElem nameLinkElem : styles) {
|
for (NameLinkElem nameLinkElem : styles) {
|
||||||
removeStyleInWorkspace(workspace, nameLinkElem.getName(), true);
|
removeStyleInWorkspace(workspace, nameLinkElem.getName(), true);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,13 +26,13 @@
|
|||||||
package it.geosolutions.geoserver.rest.decoder;
|
package it.geosolutions.geoserver.rest.decoder;
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.decoder.utils.JDOMBuilder;
|
import it.geosolutions.geoserver.rest.decoder.utils.JDOMBuilder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.dimensions.GSCoverageDimensionEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.feature.FeatureTypeAttribute;
|
import it.geosolutions.geoserver.rest.encoder.feature.FeatureTypeAttribute;
|
||||||
import it.geosolutions.geoserver.rest.encoder.feature.GSAttributeEncoder;
|
import it.geosolutions.geoserver.rest.encoder.feature.GSAttributeEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadatalink.GSMetadataLinkInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.metadatalink.GSMetadataLinkInfoEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadatalink.ResourceMetadataLinkInfo;
|
import it.geosolutions.geoserver.rest.encoder.metadatalink.ResourceMetadataLinkInfo;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -43,8 +43,9 @@ import org.jdom.Namespace;
|
|||||||
* Parse a resource (FeatureType or Coverage) returned as XML REST objects.
|
* Parse a resource (FeatureType or Coverage) returned as XML REST objects.
|
||||||
*
|
*
|
||||||
* @author etj
|
* @author etj
|
||||||
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com |
|
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com | emmanuel.blondel@fao.org
|
||||||
* emmanuel.blondel@fao.org
|
* @author Henry Rotzoll
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class RESTResource {
|
public class RESTResource {
|
||||||
protected final Element rootElem;
|
protected final Element rootElem;
|
||||||
@ -74,23 +75,22 @@ public class RESTResource {
|
|||||||
return rootElem.getChildText("abstract");
|
return rootElem.getChildText("abstract");
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getKeywords(){
|
public List<String> getKeywords() {
|
||||||
List<String> kwdsList = null;
|
List<String> kwdsList = null;
|
||||||
|
|
||||||
final Element keywordsRoot = rootElem.getChild("keywords");
|
final Element keywordsRoot = rootElem.getChild("keywords");
|
||||||
if(keywordsRoot != null){
|
if (keywordsRoot != null) {
|
||||||
final List<Element> keywords = keywordsRoot.getChildren();
|
final List<Element> keywords = keywordsRoot.getChildren();
|
||||||
if(keywords != null){
|
if (keywords != null) {
|
||||||
kwdsList = new ArrayList<String>(keywords.size());
|
kwdsList = new ArrayList<String>(keywords.size());
|
||||||
for(Element keyword : keywords){
|
for (Element keyword : keywords) {
|
||||||
kwdsList.add(keyword.getValue());
|
kwdsList.add(keyword.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return kwdsList;
|
return kwdsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getNameSpace() {
|
public String getNameSpace() {
|
||||||
return rootElem.getChild("namespace").getChildText("name");
|
return rootElem.getChild("namespace").getChildText("name");
|
||||||
}
|
}
|
||||||
@ -154,33 +154,77 @@ public class RESTResource {
|
|||||||
throw new UnsupportedOperationException("This method is specific for RESTFeatureType");
|
throw new UnsupportedOperationException("This method is specific for RESTFeatureType");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes the list of MetadataLinkInfo from the GeoServer Resource
|
* Decodes the list of MetadataLinkInfo from the GeoServer Resource
|
||||||
*
|
*
|
||||||
* @author Emmanuel Blondel
|
* @since gs-2.4.x
|
||||||
*
|
*
|
||||||
* @return the list of GSMetadataLinkEncoder
|
* @return the list of GSMetadataLinkEncoder
|
||||||
*/
|
*/
|
||||||
public List<GSMetadataLinkInfoEncoder> getEncodedMetadataLinkInfoList() {
|
public List<GSMetadataLinkInfoEncoder> getEncodedMetadataLinkInfoList() {
|
||||||
List<GSMetadataLinkInfoEncoder> metaLinksList = null;
|
List<GSMetadataLinkInfoEncoder> metaLinksList = null;
|
||||||
|
|
||||||
final Element metaLinksRoot = rootElem.getChild("metadataLinks");
|
final Element metaLinksRoot = rootElem.getChild("metadataLinks");
|
||||||
if(metaLinksRoot!=null){
|
if (metaLinksRoot != null) {
|
||||||
final List<Element> metaLinks = metaLinksRoot.getChildren();
|
final List<Element> metaLinks = metaLinksRoot.getChildren();
|
||||||
if (metaLinks != null) {
|
if (metaLinks != null) {
|
||||||
metaLinksList = new ArrayList<GSMetadataLinkInfoEncoder>(
|
metaLinksList = new ArrayList<GSMetadataLinkInfoEncoder>(metaLinks.size());
|
||||||
metaLinks.size());
|
for (Element metaLink : metaLinks) {
|
||||||
for (Element metaLink : metaLinks) {
|
final GSMetadataLinkInfoEncoder metaLinkEnc = new GSMetadataLinkInfoEncoder();
|
||||||
final GSMetadataLinkInfoEncoder metaLinkEnc = new GSMetadataLinkInfoEncoder();
|
metaLinkEnc
|
||||||
metaLinkEnc.setType(metaLink.getChildText(ResourceMetadataLinkInfo.type.name()));
|
.setType(metaLink.getChildText(ResourceMetadataLinkInfo.type.name()));
|
||||||
metaLinkEnc.setMetadataType(metaLink.getChildText(ResourceMetadataLinkInfo.metadataType.name()));
|
metaLinkEnc.setMetadataType(metaLink
|
||||||
metaLinkEnc.setContent(metaLink.getChildText(ResourceMetadataLinkInfo.content.name()));
|
.getChildText(ResourceMetadataLinkInfo.metadataType.name()));
|
||||||
metaLinksList.add(metaLinkEnc);
|
metaLinkEnc.setContent(metaLink.getChildText(ResourceMetadataLinkInfo.content
|
||||||
}
|
.name()));
|
||||||
|
metaLinksList.add(metaLinkEnc);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return metaLinksList;
|
return metaLinksList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes the list of GSCoverageDimensionEncoder from the GeoServer Resource
|
||||||
|
*
|
||||||
|
* @since gs-2.4.x
|
||||||
|
*
|
||||||
|
* @return the list of GSCoverageDimensionEncoder
|
||||||
|
*/
|
||||||
|
public List<GSCoverageDimensionEncoder> getEncodedDimensionsInfoList() {
|
||||||
|
List<GSCoverageDimensionEncoder> dimensionList = null;
|
||||||
|
final Element dimensionsRoot = rootElem.getChild("dimensions");
|
||||||
|
|
||||||
|
if (dimensionsRoot != null) {
|
||||||
|
final List<Element> dimensions = dimensionsRoot.getChildren();
|
||||||
|
if (dimensions != null) {
|
||||||
|
dimensionList = new ArrayList<GSCoverageDimensionEncoder>(dimensions.size());
|
||||||
|
for (Element coverageDimension : dimensions) {
|
||||||
|
final String name = coverageDimension.getChildText("name");
|
||||||
|
final String description = coverageDimension.getChildText("description");
|
||||||
|
String rangeMin = null;
|
||||||
|
String rangeMax = null;
|
||||||
|
final Element rangeElement = coverageDimension.getChild("range");
|
||||||
|
if (rangeElement != null) {
|
||||||
|
rangeMin = rangeElement.getChildText("min");
|
||||||
|
rangeMax = rangeElement.getChildText("max");
|
||||||
|
}
|
||||||
|
final String unit = coverageDimension.getChildText("unit");
|
||||||
|
String dimensionTypeName = null;
|
||||||
|
final Element dimensionTypeElement = coverageDimension
|
||||||
|
.getChild("dimensionType");
|
||||||
|
if (dimensionTypeElement != null) {
|
||||||
|
dimensionTypeName = dimensionTypeElement.getChildText("name");
|
||||||
|
}
|
||||||
|
final GSCoverageDimensionEncoder coverageDimensionEncoder = new GSCoverageDimensionEncoder(
|
||||||
|
name, description, rangeMin, rangeMax, unit, dimensionTypeName);
|
||||||
|
dimensionList.add(coverageDimensionEncoder);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dimensionList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -133,12 +133,21 @@ public class GSVersionDecoder extends XmlElement {
|
|||||||
return VERSION.getVersion(e.getTextTrim());
|
return VERSION.getVersion(e.getTextTrim());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see {@link Enum#compareTo(Enum)}
|
||||||
|
* @param v
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int compareTo(VERSION v) {
|
||||||
|
return getVersion().compareTo(v);
|
||||||
|
}
|
||||||
|
|
||||||
public static GSVersionDecoder build(String response) {
|
public static GSVersionDecoder build(String response) {
|
||||||
return new GSVersionDecoder(response);
|
return new GSVersionDecoder(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum VERSION {
|
public enum VERSION {
|
||||||
v22(22), v23(23), v24(24), v25(25), ABOVE(9999), UNRECOGNIZED(-1);
|
UNRECOGNIZED(-1), v22(22), v23(23), v24(24), v25(25), ABOVE(9999);
|
||||||
|
|
||||||
final private int version;
|
final private int version;
|
||||||
|
|
||||||
|
|||||||
@ -41,6 +41,34 @@ import org.jdom.filter.Filter;
|
|||||||
*
|
*
|
||||||
* The layer encoder is enabled by default
|
* The layer encoder is enabled by default
|
||||||
*
|
*
|
||||||
|
* {@code
|
||||||
|
* <layer>
|
||||||
|
* <name>{LAYERNAME}</name>
|
||||||
|
* <type>RASTER</type>
|
||||||
|
* <defaultStyle>
|
||||||
|
* <name>{STYLE_NAME}</name>
|
||||||
|
* <atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://{GSURL}/rest/styles/{STYLE}xml" type="application/xml"/>
|
||||||
|
* </defaultStyle>
|
||||||
|
* <resource class="coverage">
|
||||||
|
* <name>{RESOURCE_NAME}</name>
|
||||||
|
* <atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate"
|
||||||
|
* href="http://{GSURL}/rest/workspaces/{WS}/coveragestores/{STORE}/coverages/{LAYER}.xml" type="application/xml"/>
|
||||||
|
* </resource>
|
||||||
|
* <attribution>
|
||||||
|
* <title>test</title>
|
||||||
|
* <href>http://www.fao.org/fileadmin/templates/faoweb/images/FAO-logo.png</href>
|
||||||
|
* <logoURL>http://www.fao.org/fileadmin/templates/faoweb/images/FAO-logo.png</logoURL>
|
||||||
|
* <logoWidth>412</logoWidth>
|
||||||
|
* <logoHeight>77</logoHeight>
|
||||||
|
* <logoType>image/png</logoType>
|
||||||
|
* </attribution>
|
||||||
|
* ...
|
||||||
|
*
|
||||||
|
* </layer>
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @since gs-2.2.x
|
||||||
*/
|
*/
|
||||||
public class GSLayerEncoder extends PropertyXMLEncoder {
|
public class GSLayerEncoder extends PropertyXMLEncoder {
|
||||||
|
|
||||||
|
|||||||
@ -45,6 +45,8 @@ import it.geosolutions.geoserver.rest.encoder.utils.XmlElement;
|
|||||||
*
|
*
|
||||||
* The layer encoder is enabled by default
|
* The layer encoder is enabled by default
|
||||||
*
|
*
|
||||||
|
* @since gs-2.1.x
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class GSLayerEncoder21 extends GSLayerEncoder {
|
public class GSLayerEncoder21 extends GSLayerEncoder {
|
||||||
|
|
||||||
|
|||||||
@ -47,55 +47,58 @@ import org.jdom.filter.Filter;
|
|||||||
*
|
*
|
||||||
* @author ETj (etj at geo-solutions.it)
|
* @author ETj (etj at geo-solutions.it)
|
||||||
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com |
|
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com | emmanuel.blondel@fao.org
|
||||||
* emmanuel.blondel@fao.org
|
* @author Henry Rotzoll
|
||||||
*/
|
*/
|
||||||
public abstract class GSResourceEncoder
|
public abstract class GSResourceEncoder extends PropertyXMLEncoder {
|
||||||
extends PropertyXMLEncoder {
|
public final static String NAME = "name";
|
||||||
public final static String NAME = "name";
|
|
||||||
public final static String NATIVENAME = "nativeName";
|
|
||||||
public final static String METADATA="metadata";
|
|
||||||
public final static String KEYWORDS="keywords";
|
|
||||||
public final static String METADATALINKS="metadataLinks";
|
|
||||||
|
|
||||||
final private GSMetadataEncoder metadata = new GSMetadataEncoder();
|
public final static String NATIVENAME = "nativeName";
|
||||||
final private Element keywordsListEncoder = new Element(KEYWORDS);
|
|
||||||
final private Element metadataLinksListEncoder = new Element(METADATALINKS);
|
|
||||||
|
|
||||||
private class GSMetadataEncoder extends NestedElementEncoder{
|
public final static String METADATA = "metadata";
|
||||||
public GSMetadataEncoder() {
|
|
||||||
super(METADATA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public final static String KEYWORDS = "keywords";
|
||||||
* @param rootName
|
|
||||||
* Actually 'feature' or 'coverage'
|
|
||||||
* @see GSFeatureTypeEncoder
|
|
||||||
* @see GSCoverageEncoder
|
|
||||||
*/
|
|
||||||
protected GSResourceEncoder(final String rootName) {
|
|
||||||
super(rootName);
|
|
||||||
add("enabled", "true");
|
|
||||||
|
|
||||||
// Link members to the parent
|
public final static String METADATALINKS = "metadataLinks";
|
||||||
addContent(metadata.getRoot());
|
|
||||||
addContent(keywordsListEncoder);
|
|
||||||
addContent(metadataLinksListEncoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabled(boolean enabled) {
|
final private GSMetadataEncoder metadata = new GSMetadataEncoder();
|
||||||
set("enabled", (enabled) ? "true" : "false");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
final private Element keywordsListEncoder = new Element(KEYWORDS);
|
||||||
|
|
||||||
/**
|
final private Element metadataLinksListEncoder = new Element(METADATALINKS);
|
||||||
* @param key
|
|
||||||
* @param dimensionInfo
|
private class GSMetadataEncoder extends NestedElementEncoder {
|
||||||
*/
|
public GSMetadataEncoder() {
|
||||||
protected void addMetadata(String key, XmlElement dimensionInfo) {
|
super(METADATA);
|
||||||
metadata.add(key, dimensionInfo.getRoot());
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param rootName Actually 'feature' or 'coverage'
|
||||||
|
* @see GSFeatureTypeEncoder
|
||||||
|
* @see GSCoverageEncoder
|
||||||
|
*/
|
||||||
|
protected GSResourceEncoder(final String rootName) {
|
||||||
|
super(rootName);
|
||||||
|
add("enabled", "true");
|
||||||
|
|
||||||
|
// Link members to the parent
|
||||||
|
addContent(metadata.getRoot());
|
||||||
|
addContent(keywordsListEncoder);
|
||||||
|
addContent(metadataLinksListEncoder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
set("enabled", (enabled) ? "true" : "false");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param key
|
||||||
|
* @param dimensionInfo
|
||||||
|
*/
|
||||||
|
protected void addMetadata(String key, XmlElement dimensionInfo) {
|
||||||
|
metadata.add(key, dimensionInfo.getRoot());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #setMetadataDimension(String, GSDimensionInfoEncoder)} this method will be set as protected for internal use only
|
* @deprecated Use {@link #setMetadataDimension(String, GSDimensionInfoEncoder)} this method will be set as protected for internal use only
|
||||||
@ -121,16 +124,21 @@ public abstract class GSResourceEncoder
|
|||||||
* @param dimensionInfo {@link GSDimensionInfoEncoder} with additional information about the dimension
|
* @param dimensionInfo {@link GSDimensionInfoEncoder} with additional information about the dimension
|
||||||
* @param custom is the dimension custom or not?
|
* @param custom is the dimension custom or not?
|
||||||
*/
|
*/
|
||||||
protected void addMetadataDimension(String key, GSDimensionInfoEncoder dimensionInfo, boolean custom) {
|
protected void addMetadataDimension(String key, GSDimensionInfoEncoder dimensionInfo,
|
||||||
if(custom){
|
boolean custom) {
|
||||||
metadata.set("custom_dimension_"+key.toUpperCase(), dimensionInfo.getRoot());
|
if (custom) {
|
||||||
}else{
|
metadata.set("custom_dimension_" + key.toUpperCase(), dimensionInfo.getRoot());
|
||||||
|
} else {
|
||||||
metadata.add(key, dimensionInfo.getRoot());
|
metadata.add(key, dimensionInfo.getRoot());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMetadataDimension(String key, GSDimensionInfoEncoder dimensionInfo) {
|
public void setMetadataDimension(String key, GSDimensionInfoEncoder dimensionInfo) {
|
||||||
setMetadataDimension(key, dimensionInfo, false);
|
setMetadataDimension(key, dimensionInfo, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMetadataString(String key, String value) {
|
||||||
|
metadata.set(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,93 +148,140 @@ public abstract class GSResourceEncoder
|
|||||||
* @param dimensionInfo {@link GSDimensionInfoEncoder} with additional information about the dimension
|
* @param dimensionInfo {@link GSDimensionInfoEncoder} with additional information about the dimension
|
||||||
* @param custom is the dimension custom or not?
|
* @param custom is the dimension custom or not?
|
||||||
*/
|
*/
|
||||||
public void setMetadataDimension(String key, GSDimensionInfoEncoder dimensionInfo, boolean custom) {
|
public void setMetadataDimension(String key, GSDimensionInfoEncoder dimensionInfo,
|
||||||
if(custom){
|
boolean custom) {
|
||||||
metadata.set("custom_dimension_"+key.toUpperCase(), dimensionInfo.getRoot());
|
if (custom) {
|
||||||
}else{
|
metadata.set("custom_dimension_" + key.toUpperCase(), dimensionInfo.getRoot());
|
||||||
|
} else {
|
||||||
metadata.set(key, dimensionInfo.getRoot());
|
metadata.set(key, dimensionInfo.getRoot());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param key
|
|
||||||
* the name of the metadata to add (f.e.: elevation, time)
|
|
||||||
* @return true if something is removed, false otherwise
|
|
||||||
*/
|
|
||||||
public boolean delMetadata(String key) {
|
|
||||||
return metadata.remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param key the name of the metadata to add (f.e.: elevation, time)
|
||||||
|
* @return true if something is removed, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean delMetadata(String key) {
|
||||||
|
return metadata.remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
public void addKeyword(String keyword) {
|
public void addKeyword(String keyword) {
|
||||||
final Element el = new Element("string");
|
checkKeyword(keyword);
|
||||||
el.setText(keyword);
|
putKeyword(keyword);
|
||||||
keywordsListEncoder.addContent(el);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete a keyword from the list
|
* {@code
|
||||||
*
|
* <keywords>
|
||||||
* @param keyword
|
* <string>WCS</string>
|
||||||
* @return true if something is removed, false otherwise
|
* <string>ImageMosaic</string>
|
||||||
*/
|
* <string>srtm30</string> <string> KEYWORD}\@language={LANGUAGE}\;\@vocabulary={VOCABULARY}\;</string>
|
||||||
public boolean delKeyword(final String keyword) {
|
* <string>{KEYWORD_2}\@vocabulary={VOCABULARY_2}\;</string> <string>{KEYWORD_3}\@language={LANGUAGE_3}\;</string> </keywords> }
|
||||||
final Element el = new Element("string");
|
*
|
||||||
el.setText(keyword);
|
* @param keyword mandatory keyword ('\' characters are not permitted)
|
||||||
return (keywordsListEncoder.removeContent(new Filter() {
|
* @param language optional parameter
|
||||||
private static final long serialVersionUID = 1L;
|
* @param vocabulary optional parameter
|
||||||
|
*/
|
||||||
|
public void addKeyword(final String keyword, final String language, final String vocabulary) {
|
||||||
|
checkKeyword(keyword);
|
||||||
|
putKeyword(buildKeyword(keyword, language, vocabulary));
|
||||||
|
}
|
||||||
|
|
||||||
public boolean matches(Object obj) {
|
/**
|
||||||
if (((Element) obj).getText().equals(keyword)) {
|
* delete a keyword from the list
|
||||||
return true;
|
*
|
||||||
}
|
* @param keyword
|
||||||
return false;
|
* @return true if something is removed, false otherwise
|
||||||
}
|
*/
|
||||||
})).size() == 0 ? false : true;
|
public boolean delKeyword(final String keyword) {
|
||||||
}
|
return removeKeyword(keyword, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a MetadataLinkInfo to the GeoServer Resource
|
* delete a keyword from the list
|
||||||
*
|
*
|
||||||
* @param MetadataLink
|
* @param keyword
|
||||||
*
|
* @return true if something is removed, false otherwise
|
||||||
* @author Emmanuel Blondel
|
*/
|
||||||
*/
|
public boolean delKeyword(final String keyword, final String language, final String vocabulary) {
|
||||||
public void addMetadataLinkInfo(GSMetadataLinkInfoEncoder metadataLinkInfo) {
|
return removeKeyword(keyword, language, vocabulary);
|
||||||
metadataLinksListEncoder.addContent(metadataLinkInfo.getRoot());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
private boolean removeKeyword(final String keyword, final String language,
|
||||||
* Adds quickly a MetadataLinkInfo to the GeoServer Resource
|
final String vocabulary) {
|
||||||
*
|
checkKeyword(keyword);
|
||||||
* @author Emmanuel Blondel
|
final String text = buildKeyword(keyword, language, vocabulary);
|
||||||
*
|
return (keywordsListEncoder.removeContent(new Filter() {
|
||||||
* @param type
|
private static final long serialVersionUID = 1L;
|
||||||
* @param metadataType
|
|
||||||
* @param content
|
|
||||||
*/
|
|
||||||
public void addMetadataLinkInfo(String type, String metadataType,
|
|
||||||
String content) {
|
|
||||||
final GSMetadataLinkInfoEncoder mde = new GSMetadataLinkInfoEncoder(
|
|
||||||
type, metadataType, content);
|
|
||||||
metadataLinksListEncoder.addContent(mde.getRoot());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public boolean matches(Object obj) {
|
||||||
* Deletes a metadataLinkInfo from the list using the metadataURL
|
if (((Element) obj).getText().equals(text)) {
|
||||||
* (MetadataLinkInfo content)
|
return true;
|
||||||
*
|
}
|
||||||
* @author Emmanuel Blondel
|
return false;
|
||||||
*
|
}
|
||||||
* @param metadataURL
|
})).size() == 0 ? false : true;
|
||||||
* @return true if something is removed, false otherwise
|
}
|
||||||
*/
|
|
||||||
public boolean delMetadataLinkInfo(final String metadataURL) {
|
|
||||||
return (metadataLinksListEncoder
|
|
||||||
.removeContent(GSMetadataLinkInfoEncoder
|
|
||||||
.getFilterByContent(metadataURL))).size() == 0 ? false
|
|
||||||
: true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private void putKeyword(String keyword) {
|
||||||
|
final Element el = new Element("string");
|
||||||
|
el.setText(keyword);
|
||||||
|
keywordsListEncoder.addContent(el);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkKeyword(String keyword) {
|
||||||
|
if (keyword == null || keyword.isEmpty() || keyword.contains("\\")) {
|
||||||
|
throw new IllegalArgumentException("keyword may not be null, empty or contains '\'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildKeyword(final String keyword, final String language, final String vocabulary) {
|
||||||
|
StringBuilder sb = new StringBuilder(keyword);
|
||||||
|
// \@language={LANGUAGE_3}\;
|
||||||
|
if (language != null && !language.isEmpty()) {
|
||||||
|
sb.append("\\@language=").append(language).append("\\;");
|
||||||
|
}
|
||||||
|
// \@vocabulary={VOCABULARY}\;
|
||||||
|
if (vocabulary != null && !vocabulary.isEmpty()) {
|
||||||
|
sb.append("\\@vocabulary=").append(vocabulary).append("\\;");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a MetadataLinkInfo to the GeoServer Resource
|
||||||
|
*
|
||||||
|
* @param MetadataLink
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void addMetadataLinkInfo(GSMetadataLinkInfoEncoder metadataLinkInfo) {
|
||||||
|
metadataLinksListEncoder.addContent(metadataLinkInfo.getRoot());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds quickly a MetadataLinkInfo to the GeoServer Resource
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param metadataType
|
||||||
|
* @param content
|
||||||
|
*/
|
||||||
|
public void addMetadataLinkInfo(String type, String metadataType, String content) {
|
||||||
|
final GSMetadataLinkInfoEncoder mde = new GSMetadataLinkInfoEncoder(type, metadataType,
|
||||||
|
content);
|
||||||
|
metadataLinksListEncoder.addContent(mde.getRoot());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a metadataLinkInfo from the list using the metadataURL (MetadataLinkInfo content)
|
||||||
|
*
|
||||||
|
* @param metadataURL
|
||||||
|
* @return true if something is removed, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean delMetadataLinkInfo(final String metadataURL) {
|
||||||
|
return (metadataLinksListEncoder.removeContent(GSMetadataLinkInfoEncoder
|
||||||
|
.getFilterByContent(metadataURL))).size() == 0 ? false : true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reprojection policy for a published layer. One of:
|
* Reprojection policy for a published layer. One of:
|
||||||
@ -236,94 +291,89 @@ public abstract class GSResourceEncoder
|
|||||||
* <li>{@link #NONE} No reprojection (use native CRS)
|
* <li>{@link #NONE} No reprojection (use native CRS)
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public enum ProjectionPolicy {
|
public enum ProjectionPolicy {
|
||||||
/** Reproject from native to declared CRS */
|
/** Reproject from native to declared CRS */
|
||||||
REPROJECT_TO_DECLARED,
|
REPROJECT_TO_DECLARED,
|
||||||
/** Use the declared CRS (ignore native) */
|
/** Use the declared CRS (ignore native) */
|
||||||
FORCE_DECLARED,
|
FORCE_DECLARED,
|
||||||
/** Keep native */
|
/** Keep native */
|
||||||
NONE
|
NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static String PROJECTIONPOLICY = "projectionPolicy";
|
private final static String PROJECTIONPOLICY = "projectionPolicy";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NONE, REPROJECT_TO_DECLARED, FORCE_DECLARED
|
* NONE, REPROJECT_TO_DECLARED, FORCE_DECLARED
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected void addProjectionPolicy(ProjectionPolicy policy) {
|
protected void addProjectionPolicy(ProjectionPolicy policy) {
|
||||||
add(PROJECTIONPOLICY, policy.toString());
|
add(PROJECTIONPOLICY, policy.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NONE, REPROJECT_TO_DECLARED, FORCE_DECLARED
|
* NONE, REPROJECT_TO_DECLARED, FORCE_DECLARED
|
||||||
*/
|
*/
|
||||||
public void setProjectionPolicy(ProjectionPolicy policy) {
|
public void setProjectionPolicy(ProjectionPolicy policy) {
|
||||||
set(PROJECTIONPOLICY, policy.toString());
|
set(PROJECTIONPOLICY, policy.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the 'name' node with a text value from 'name'
|
* Add the 'name' node with a text value from 'name'
|
||||||
*
|
*
|
||||||
* @note REQUIRED to configure a resource
|
* @note REQUIRED to configure a resource
|
||||||
*/
|
*/
|
||||||
protected void addName(final String name) {
|
protected void addName(final String name) {
|
||||||
add(NAME, name);
|
add(NAME, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set or modify the 'name' node with a text value from 'name'
|
* Set or modify the 'name' node with a text value from 'name'
|
||||||
*
|
*
|
||||||
* @note REQUIRED to configure a resource
|
* @note REQUIRED to configure a resource
|
||||||
*/
|
*/
|
||||||
public void setName(final String name) {
|
public void setName(final String name) {
|
||||||
set(NAME, name);
|
set(NAME, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
final Element nameNode = ElementUtils.contains(getRoot(), NAME, 1);
|
final Element nameNode = ElementUtils.contains(getRoot(), NAME, 1);
|
||||||
if (nameNode != null)
|
if (nameNode != null)
|
||||||
return nameNode.getText();
|
return nameNode.getText();
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the 'nativename' node with a text value from 'name'
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected void addNativeName(final String nativename) {
|
||||||
|
add(NATIVENAME, nativename);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the 'nativename' node with a text value from 'name'
|
* Set or modify the 'nativename' node with a text value from 'name'
|
||||||
*
|
*
|
||||||
*
|
* @note if not specified, the nativeName will be set with the value of the 'name' node.
|
||||||
*/
|
*
|
||||||
protected void addNativeName(final String nativename) {
|
*/
|
||||||
add(NATIVENAME, nativename);
|
public void setNativeName(final String nativename) {
|
||||||
}
|
set(NATIVENAME, nativename);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set or modify the 'nativename' node with a text value from 'name'
|
|
||||||
*
|
|
||||||
* @note if not specified, the nativeName will be set with the value of the
|
|
||||||
* 'name' node.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void setNativeName(final String nativename) {
|
|
||||||
set(NATIVENAME, nativename);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the nativeName
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getNativeName() {
|
|
||||||
final Element nameNode = ElementUtils.contains(getRoot(), NATIVENAME, 1);
|
|
||||||
if (nameNode != null)
|
|
||||||
return nameNode.getText();
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the nativeName
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getNativeName() {
|
||||||
|
final Element nameNode = ElementUtils.contains(getRoot(), NATIVENAME, 1);
|
||||||
|
if (nameNode != null)
|
||||||
|
return nameNode.getText();
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private final static String DESCRIPTION = "description";
|
private final static String DESCRIPTION = "description";
|
||||||
|
|
||||||
@ -343,6 +393,7 @@ public abstract class GSResourceEncoder
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final static String ABSTRACT = "abstract";
|
private final static String ABSTRACT = "abstract";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the 'abstract' node with a text value from 'abstract'
|
* Add the 'abstract' node with a text value from 'abstract'
|
||||||
*
|
*
|
||||||
@ -350,6 +401,7 @@ public abstract class GSResourceEncoder
|
|||||||
protected void addAbstract(final String _abstract) {
|
protected void addAbstract(final String _abstract) {
|
||||||
add(ABSTRACT, _abstract);
|
add(ABSTRACT, _abstract);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set or modify the 'abstract' node with a text value from 'abstract'
|
* Set or modify the 'abstract' node with a text value from 'abstract'
|
||||||
*/
|
*/
|
||||||
@ -357,116 +409,124 @@ public abstract class GSResourceEncoder
|
|||||||
set(ABSTRACT, _abstract);
|
set(ABSTRACT, _abstract);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static String TITLE = "title";
|
private final static String TITLE = "title";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the 'title' node with a text value from 'title'
|
* Add the 'title' node with a text value from 'title'
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected void addTitle(final String title) {
|
protected void addTitle(final String title) {
|
||||||
add(TITLE, title);
|
add(TITLE, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set or modify the 'title' node with a text value from 'title'
|
* Set or modify the 'title' node with a text value from 'title'
|
||||||
*/
|
*/
|
||||||
public void setTitle(final String title) {
|
public void setTitle(final String title) {
|
||||||
set(TITLE, title);
|
set(TITLE, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static String SRS = "srs";
|
private final static String SRS = "srs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the 'SRS' node with a text value from 'srs'
|
* Add the 'SRS' node with a text value from 'srs'
|
||||||
*/
|
*/
|
||||||
protected void addSRS(final String srs) {
|
protected void addSRS(final String srs) {
|
||||||
add(SRS, srs);
|
add(SRS, srs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set or modify the 'SRS' node with a text value from 'srs'
|
* Set or modify the 'SRS' node with a text value from 'srs'
|
||||||
*/
|
*/
|
||||||
public void setSRS(final String srs) {
|
public void setSRS(final String srs) {
|
||||||
set(SRS, srs);
|
set(SRS, srs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static String NATIVECRS = "nativeCRS";
|
private final static String NATIVECRS = "nativeCRS";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the 'nativeCRS' node with a text value from 'nativeCRS'
|
* Add the 'nativeCRS' node with a text value from 'nativeCRS'
|
||||||
*/
|
*/
|
||||||
protected void addNativeCRS(final String nativeCRS) {
|
protected void addNativeCRS(final String nativeCRS) {
|
||||||
add(NATIVECRS, nativeCRS);
|
add(NATIVECRS, nativeCRS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set or modify the 'nativeCRS' node with a text value from 'nativeCRS'
|
* Set or modify the 'nativeCRS' node with a text value from 'nativeCRS'
|
||||||
*/
|
*/
|
||||||
public void setNativeCRS(final String nativeCRS) {
|
public void setNativeCRS(final String nativeCRS) {
|
||||||
set(NATIVECRS, nativeCRS);
|
set(NATIVECRS, nativeCRS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static String LATLONBBMINX = "latLonBoundingBox/minx";
|
private final static String LATLONBBMINX = "latLonBoundingBox/minx";
|
||||||
private final static String LATLONBBMAXX = "latLonBoundingBox/maxx";
|
|
||||||
private final static String LATLONBBMINY = "latLonBoundingBox/miny";
|
|
||||||
private final static String LATLONBBMAXY = "latLonBoundingBox/maxy";
|
|
||||||
private final static String LATLONBBCRS = "latLonBoundingBox/crs";
|
|
||||||
|
|
||||||
/**
|
private final static String LATLONBBMAXX = "latLonBoundingBox/maxx";
|
||||||
*
|
|
||||||
* @param minx
|
|
||||||
* @param maxy
|
|
||||||
* @param maxx
|
|
||||||
* @param miny
|
|
||||||
* @param crs
|
|
||||||
*/
|
|
||||||
protected void addLatLonBoundingBox(double minx, double miny, double maxx,
|
|
||||||
double maxy, final String crs) {
|
|
||||||
add(LATLONBBMINX, String.valueOf(minx));
|
|
||||||
add(LATLONBBMINY, String.valueOf(miny));
|
|
||||||
add(LATLONBBMAXY, String.valueOf(maxy));
|
|
||||||
add(LATLONBBMAXX, String.valueOf(maxx));
|
|
||||||
add(LATLONBBCRS, crs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLatLonBoundingBox(double minx, double miny, double maxx,
|
private final static String LATLONBBMINY = "latLonBoundingBox/miny";
|
||||||
double maxy, final String crs) {
|
|
||||||
set(LATLONBBMINX, String.valueOf(minx));
|
|
||||||
set(LATLONBBMAXY, String.valueOf(maxy));
|
|
||||||
set(LATLONBBMAXX, String.valueOf(maxx));
|
|
||||||
set(LATLONBBMINY, String.valueOf(miny));
|
|
||||||
set(LATLONBBCRS, crs);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static String NATIVEBBMINX = "nativeBoundingBox/minx";
|
private final static String LATLONBBMAXY = "latLonBoundingBox/maxy";
|
||||||
private final static String NATIVEBBMAXX = "nativeBoundingBox/maxx";
|
|
||||||
private final static String NATIVEBBMINY = "nativeBoundingBox/miny";
|
|
||||||
private final static String NATIVEBBMAXY = "nativeBoundingBox/maxy";
|
|
||||||
private final static String NATIVEBBCRS = "nativeBoundingBox/crs";
|
|
||||||
|
|
||||||
/**
|
private final static String LATLONBBCRS = "latLonBoundingBox/crs";
|
||||||
* @param minx
|
|
||||||
* @param maxy
|
|
||||||
* @param maxx
|
|
||||||
* @param miny
|
|
||||||
* @param crs
|
|
||||||
*/
|
|
||||||
protected void addNativeBoundingBox(double minx, double miny, double maxx,
|
|
||||||
double maxy, final String crs) {
|
|
||||||
add(NATIVEBBMINX, String.valueOf(minx));
|
|
||||||
add(NATIVEBBMAXY, String.valueOf(maxy));
|
|
||||||
add(NATIVEBBMAXX, String.valueOf(maxx));
|
|
||||||
add(NATIVEBBMINY, String.valueOf(miny));
|
|
||||||
add(NATIVEBBCRS, crs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNativeBoundingBox(double minx, double miny, double maxx,
|
/**
|
||||||
double maxy, final String crs) {
|
*
|
||||||
set(NATIVEBBMINX, String.valueOf(minx));
|
* @param minx
|
||||||
set(NATIVEBBMAXY, String.valueOf(maxy));
|
* @param maxy
|
||||||
set(NATIVEBBMAXX, String.valueOf(maxx));
|
* @param maxx
|
||||||
set(NATIVEBBMINY, String.valueOf(miny));
|
* @param miny
|
||||||
set(NATIVEBBCRS, crs);
|
* @param crs
|
||||||
}
|
*/
|
||||||
|
protected void addLatLonBoundingBox(double minx, double miny, double maxx, double maxy,
|
||||||
|
final String crs) {
|
||||||
|
add(LATLONBBMINX, String.valueOf(minx));
|
||||||
|
add(LATLONBBMINY, String.valueOf(miny));
|
||||||
|
add(LATLONBBMAXY, String.valueOf(maxy));
|
||||||
|
add(LATLONBBMAXX, String.valueOf(maxx));
|
||||||
|
add(LATLONBBCRS, crs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLatLonBoundingBox(double minx, double miny, double maxx, double maxy,
|
||||||
|
final String crs) {
|
||||||
|
set(LATLONBBMINX, String.valueOf(minx));
|
||||||
|
set(LATLONBBMAXY, String.valueOf(maxy));
|
||||||
|
set(LATLONBBMAXX, String.valueOf(maxx));
|
||||||
|
set(LATLONBBMINY, String.valueOf(miny));
|
||||||
|
set(LATLONBBCRS, crs);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static String NATIVEBBMINX = "nativeBoundingBox/minx";
|
||||||
|
|
||||||
|
private final static String NATIVEBBMAXX = "nativeBoundingBox/maxx";
|
||||||
|
|
||||||
|
private final static String NATIVEBBMINY = "nativeBoundingBox/miny";
|
||||||
|
|
||||||
|
private final static String NATIVEBBMAXY = "nativeBoundingBox/maxy";
|
||||||
|
|
||||||
|
private final static String NATIVEBBCRS = "nativeBoundingBox/crs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param minx
|
||||||
|
* @param maxy
|
||||||
|
* @param maxx
|
||||||
|
* @param miny
|
||||||
|
* @param crs
|
||||||
|
*/
|
||||||
|
protected void addNativeBoundingBox(double minx, double miny, double maxx, double maxy,
|
||||||
|
final String crs) {
|
||||||
|
add(NATIVEBBMINX, String.valueOf(minx));
|
||||||
|
add(NATIVEBBMAXY, String.valueOf(maxy));
|
||||||
|
add(NATIVEBBMAXX, String.valueOf(maxx));
|
||||||
|
add(NATIVEBBMINY, String.valueOf(miny));
|
||||||
|
add(NATIVEBBCRS, crs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNativeBoundingBox(double minx, double miny, double maxx, double maxy,
|
||||||
|
final String crs) {
|
||||||
|
set(NATIVEBBMINX, String.valueOf(minx));
|
||||||
|
set(NATIVEBBMAXY, String.valueOf(maxy));
|
||||||
|
set(NATIVEBBMAXX, String.valueOf(maxx));
|
||||||
|
set(NATIVEBBMINY, String.valueOf(miny));
|
||||||
|
set(NATIVEBBCRS, crs);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,9 +25,12 @@
|
|||||||
|
|
||||||
package it.geosolutions.geoserver.rest.encoder.coverage;
|
package it.geosolutions.geoserver.rest.encoder.coverage;
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
import org.jdom.Element;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.dimensions.GSCoverageDimensionEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an XML
|
* Creates an XML
|
||||||
@ -38,25 +41,69 @@ import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
|||||||
*/
|
*/
|
||||||
public class GSCoverageEncoder extends GSResourceEncoder {
|
public class GSCoverageEncoder extends GSResourceEncoder {
|
||||||
|
|
||||||
public GSCoverageEncoder() {
|
public final static String DIMENSIONS = "dimensions";
|
||||||
|
|
||||||
|
final private Element dimensionsEncoder = new Element(DIMENSIONS);
|
||||||
|
|
||||||
|
public GSCoverageEncoder() {
|
||||||
super("coverage");
|
super("coverage");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param key
|
* @param key
|
||||||
* @param dimensionInfo
|
* @param dimensionInfo
|
||||||
* @deprecated Use {@link GSResourceEncoder#addMetadataDimension(String, GSDimensionInfoEncoder)} this method will be removed soon
|
* @deprecated Use {@link GSResourceEncoder#addMetadataDimension(String, GSDimensionInfoEncoder)} this method will be removed soon
|
||||||
*/
|
*/
|
||||||
protected void addMetadata(String key, GSDimensionInfoEncoder dimensionInfo) {
|
protected void addMetadata(String key, GSDimensionInfoEncoder dimensionInfo) {
|
||||||
super.addMetadata(key, dimensionInfo);
|
super.addMetadata(key, dimensionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link GSResourceEncoder#setMetadataDimension(String, GSDimensionInfoEncoder)} this method will be removed soon
|
* @deprecated Use {@link GSResourceEncoder#setMetadataDimension(String, GSDimensionInfoEncoder)} this method will be removed soon
|
||||||
* @param key
|
* @param key
|
||||||
* @param dimensionInfo
|
* @param dimensionInfo
|
||||||
*/
|
*/
|
||||||
public void setMetadata(String key, GSDimensionInfoEncoder dimensionInfo) {
|
public void setMetadata(String key, GSDimensionInfoEncoder dimensionInfo) {
|
||||||
super.setMetadata(key, dimensionInfo);
|
super.setMetadata(key, dimensionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a CoverageDimensionInfo to the GeoServer Resource
|
||||||
|
*
|
||||||
|
* @param coverageDimensionInfo
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void addCoverageDimensionInfo(GSCoverageDimensionEncoder coverageDimensionInfo) {
|
||||||
|
if (ElementUtils.contains(getRoot(), DIMENSIONS) == null)
|
||||||
|
addContent(dimensionsEncoder);
|
||||||
|
dimensionsEncoder.addContent(coverageDimensionInfo.getRoot());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds quickly a CoverageDimensionInfo to the GeoServer Resource
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @param description
|
||||||
|
* @param rangeMin
|
||||||
|
* @param rangeMax
|
||||||
|
* @param unit
|
||||||
|
* @param dimensionType
|
||||||
|
*/
|
||||||
|
public void addCoverageDimensionInfo(String name, String description, String rangeMin,
|
||||||
|
String rangeMax, String unit, String dimensionType) {
|
||||||
|
final GSCoverageDimensionEncoder coverageDimensionEncoder = new GSCoverageDimensionEncoder(
|
||||||
|
name, description, rangeMin, rangeMax, unit, dimensionType);
|
||||||
|
addCoverageDimensionInfo(coverageDimensionEncoder);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a CoverageDimensionInfo from the list using the CoverageDimension Name (CoverageDimensionInfo content)
|
||||||
|
*
|
||||||
|
* @param coverageDimensionName
|
||||||
|
* @return true if something is removed, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean delCoverageDimensionInfo(final String coverageDimensionName) {
|
||||||
|
return (dimensionsEncoder.removeContent(GSCoverageDimensionEncoder
|
||||||
|
.getFilterByContent(coverageDimensionName))).size() == 0 ? false : true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,393 @@
|
|||||||
|
/*
|
||||||
|
* 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.dimensions;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.utils.XmlElement;
|
||||||
|
|
||||||
|
import org.jdom.Element;
|
||||||
|
import org.jdom.filter.Filter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GSCoverageDimension - encodes a CoverageDimension for a given GeoServer Resource (feature type /coverage), as follows:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* {@code
|
||||||
|
* final GSCoverageDimensionEncoder gsCoverageDimensionEncoder =
|
||||||
|
* new GSCoverageDimensionEncoder("GRAY_INDEX", "GridSampleDimension[-2.147483648E9,-2.147483648E9]",
|
||||||
|
* String.valueOf(Integer.MIN_VALUE), String.valueOf(Integer.MAX_VALUE), "dobson units³", "REAL_32BITS");
|
||||||
|
* coverageEncoder.addCoverageDimensionInfo(gsCoverageDimensionEncoder);
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* For this example, the XML output is:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* {@code
|
||||||
|
* <coverageDimension>
|
||||||
|
* <name>GRAY_INDEX</name>
|
||||||
|
* <description>GridSampleDimension[-2.147483648E9,2.147483648E9]</description>
|
||||||
|
* <range>
|
||||||
|
* <min>-2.147483648E9</min>
|
||||||
|
* <max>2.147483647E9</max>
|
||||||
|
* </range>
|
||||||
|
* <unit>dobson units³</unit>
|
||||||
|
* <dimensionType>
|
||||||
|
* <name>REAL_32BITS</name>
|
||||||
|
* </dimensionType>
|
||||||
|
* </coverageDimension>
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author Henry Rotzoll (henry.rotzoll@dlr.de)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GSCoverageDimensionEncoder extends XmlElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class to filter the GSCoverageDimension by content
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static class filterByContent implements Filter {
|
||||||
|
|
||||||
|
final private String key;
|
||||||
|
|
||||||
|
public filterByContent(String content) {
|
||||||
|
this.key = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public boolean matches(Object obj) {
|
||||||
|
Element el = ((Element) obj).getChild("name");
|
||||||
|
if (el != null && el.getTextTrim().equals(key)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a Filter using the GSCoverageDimensionEncoder content (GSCoverageDimensionEncoder name)
|
||||||
|
*
|
||||||
|
* @param content
|
||||||
|
* @return the filter
|
||||||
|
*/
|
||||||
|
public static Filter getFilterByContent(String content) {
|
||||||
|
return new filterByContent(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new GSCoverageDimensionEncoder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public GSCoverageDimensionEncoder() {
|
||||||
|
super("coverageDimension");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs quickly a GSCoverageDimensionEncoder info
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @param description
|
||||||
|
* @param rangeMin
|
||||||
|
* @param rangeMax
|
||||||
|
* @param unit
|
||||||
|
* @param dimensionTypeName
|
||||||
|
*/
|
||||||
|
public GSCoverageDimensionEncoder(String name, String description, String rangeMin,
|
||||||
|
String rangeMax, String unit, String dimensionTypeName) {
|
||||||
|
super("coverageDimension");
|
||||||
|
this.setup(name, description, rangeMin, rangeMax, unit, dimensionTypeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set-up quickly a GSCoverageDimensionEncoder info
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @param description
|
||||||
|
* @param rangeMin
|
||||||
|
* @param rangeMax
|
||||||
|
* @param unit
|
||||||
|
* @param dimensionTypeName
|
||||||
|
*/
|
||||||
|
protected void setup(String name, String description, String rangeMin, String rangeMax,
|
||||||
|
String unit, String dimensionTypeName) {
|
||||||
|
// name
|
||||||
|
setName(name);
|
||||||
|
|
||||||
|
// description
|
||||||
|
setDescription(description);
|
||||||
|
|
||||||
|
// range
|
||||||
|
setRange(rangeMin, rangeMax);
|
||||||
|
|
||||||
|
// unit
|
||||||
|
setUnit(unit);
|
||||||
|
|
||||||
|
// dimension Type
|
||||||
|
setDimensionType(dimensionTypeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of the GSCoverageDimensionEncoder member
|
||||||
|
*
|
||||||
|
* @param memberName
|
||||||
|
* @return the value of the GSCoverageDimensionEncoder member
|
||||||
|
*/
|
||||||
|
protected String getMember(String memberName) {
|
||||||
|
Element el = this.getRoot().getChild(memberName.toString());
|
||||||
|
if (el != null)
|
||||||
|
return el.getTextTrim();
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a GSCoverageDimensionEncoder member
|
||||||
|
*
|
||||||
|
* @param memberName
|
||||||
|
* @return true if the GSCoverageDimensionEncoder member is removed
|
||||||
|
*/
|
||||||
|
protected boolean delMemberIfExists(String memberName) {
|
||||||
|
if (ElementUtils.contains(getRoot(), memberName) != null) {
|
||||||
|
return ElementUtils.remove(this.getRoot(),
|
||||||
|
this.getRoot().getChild(memberName.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a GSCoverageDimensionEncoder member
|
||||||
|
*
|
||||||
|
* @param memberName
|
||||||
|
* @param memberValue
|
||||||
|
*/
|
||||||
|
protected void setMember(String memberName, String memberValue) {
|
||||||
|
if (memberName != null && !memberName.isEmpty() && memberValue != null
|
||||||
|
&& !memberValue.isEmpty()) {
|
||||||
|
delMemberIfExists(memberName); // delete the element if it already exists
|
||||||
|
addMember(memberName.toString(), memberValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adds a GSCoverageDimensionEncoder member
|
||||||
|
*
|
||||||
|
* @param memberName
|
||||||
|
* @param memberValue
|
||||||
|
*/
|
||||||
|
protected void addMember(String memberName, String memberValue) {
|
||||||
|
if (memberName != null && !memberName.isEmpty() && memberValue != null
|
||||||
|
&& !memberValue.isEmpty()) {
|
||||||
|
set(memberName.toString(), memberValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the name
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
setMember("name", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the name
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @return true if removed
|
||||||
|
*/
|
||||||
|
public boolean delName() {
|
||||||
|
return this.delMemberIfExists("name");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the description
|
||||||
|
*
|
||||||
|
* @return description
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return this.getMember("name");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the description
|
||||||
|
*
|
||||||
|
* @param description
|
||||||
|
*/
|
||||||
|
public void setDescription(String description) {
|
||||||
|
setMember("description", description);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the description
|
||||||
|
*
|
||||||
|
* @param description
|
||||||
|
* @return true if removed
|
||||||
|
*/
|
||||||
|
public boolean delDescription() {
|
||||||
|
return this.delMemberIfExists("description");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the description
|
||||||
|
*
|
||||||
|
* @return description
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return this.getMember("description");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the range
|
||||||
|
*
|
||||||
|
* @param range
|
||||||
|
*/
|
||||||
|
public void setRange(String rangeMin, String rangeMax) {
|
||||||
|
if (rangeMin != null && !rangeMin.isEmpty() && rangeMax != null && !rangeMax.isEmpty()) {
|
||||||
|
remove("range");
|
||||||
|
|
||||||
|
final Element rangeElement = new Element("range");
|
||||||
|
final Element rangeMinElement = new Element("min");
|
||||||
|
rangeMinElement.setText(rangeMin);
|
||||||
|
final Element rangeMaxElement = new Element("max");
|
||||||
|
rangeMaxElement.setText(rangeMax);
|
||||||
|
rangeElement.addContent(rangeMinElement);
|
||||||
|
rangeElement.addContent(rangeMaxElement);
|
||||||
|
addContent(rangeElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the range
|
||||||
|
*
|
||||||
|
* @param range
|
||||||
|
* @return true if removed
|
||||||
|
*/
|
||||||
|
public boolean delRange() {
|
||||||
|
return this.delMemberIfExists("range");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the range min
|
||||||
|
*
|
||||||
|
* @return range min
|
||||||
|
*/
|
||||||
|
public String getRangeMin() {
|
||||||
|
final Element range = this.getRoot().getChild("range");
|
||||||
|
if (range != null) {
|
||||||
|
return range.getChildText("min");
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the range max
|
||||||
|
*
|
||||||
|
* @return range max
|
||||||
|
*/
|
||||||
|
public String getRangeMax() {
|
||||||
|
final Element range = this.getRoot().getChild("range");
|
||||||
|
if (range != null) {
|
||||||
|
return range.getChildText("max");
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the unit
|
||||||
|
*
|
||||||
|
* @param unit
|
||||||
|
*/
|
||||||
|
public void setUnit(String unit) {
|
||||||
|
setMember("unit", unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the type
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @return true if removed
|
||||||
|
*/
|
||||||
|
public boolean delUnit() {
|
||||||
|
return this.delMemberIfExists("unit");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the unit
|
||||||
|
*
|
||||||
|
* @return unit
|
||||||
|
*/
|
||||||
|
public String getUnit() {
|
||||||
|
return this.getMember("unit");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the dimensionType
|
||||||
|
*
|
||||||
|
* @param dimensionType
|
||||||
|
*/
|
||||||
|
public void setDimensionType(String dimensionTypeName) {
|
||||||
|
if (dimensionTypeName != null && !dimensionTypeName.isEmpty()) {
|
||||||
|
remove("dimensionType");
|
||||||
|
|
||||||
|
final Element dimensionTypeElement = new Element("dimensionType");
|
||||||
|
final Element dimensionNameElement = new Element("name");
|
||||||
|
dimensionNameElement.setText(dimensionTypeName);
|
||||||
|
dimensionTypeElement.addContent(dimensionNameElement);
|
||||||
|
addContent(dimensionTypeElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the dimensionType
|
||||||
|
*
|
||||||
|
* @param dimensionType
|
||||||
|
* @return true if removed
|
||||||
|
*/
|
||||||
|
public boolean delDimensionType() {
|
||||||
|
return this.delMemberIfExists("dimensionType");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the dimensionType name
|
||||||
|
*
|
||||||
|
* @return dimensionType name
|
||||||
|
*/
|
||||||
|
public String getDimensionTypeName() {
|
||||||
|
final Element dimensionType = this.getRoot().getChild("dimensionType");
|
||||||
|
if (dimensionType != null) {
|
||||||
|
return dimensionType.getChildText("name");
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -316,7 +316,9 @@ public class GeoServerRESTStyleManager extends GeoServerRESTAbstractManager {
|
|||||||
if(styleName.contains(":"))
|
if(styleName.contains(":"))
|
||||||
LOGGER.warn("Style name is going to be changed ["+styleName+"]");
|
LOGGER.warn("Style name is going to be changed ["+styleName+"]");
|
||||||
styleName = styleName.replaceAll(":", "_");
|
styleName = styleName.replaceAll(":", "_");
|
||||||
styleName = URLEncoder.encode(styleName);
|
|
||||||
|
// currently REST interface does't support URLencoded URL
|
||||||
|
// styleName = URLEncoder.encode(styleName);
|
||||||
|
|
||||||
String sUrl = buildUrl(null, styleName, null);
|
String sUrl = buildUrl(null, styleName, null);
|
||||||
if (purge) {
|
if (purge) {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package it.geosolutions.geoserver.decoder;
|
package it.geosolutions.geoserver.decoder;
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTCoverage;
|
import it.geosolutions.geoserver.rest.decoder.RESTCoverage;
|
||||||
import it.geosolutions.geoserver.rest.encoder.feature.GSAttributeEncoder;
|
import it.geosolutions.geoserver.rest.encoder.dimensions.GSCoverageDimensionEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadatalink.GSMetadataLinkInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.metadatalink.GSMetadataLinkInfoEncoder;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -18,84 +18,84 @@ import org.springframework.core.io.ClassPathResource;
|
|||||||
* ResourceDecoderTest
|
* ResourceDecoderTest
|
||||||
*
|
*
|
||||||
* @author eblondel
|
* @author eblondel
|
||||||
|
* @author Henry Rotzoll (henry.rotzoll@dlr.de)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ResourceDecoderTest {
|
public class ResourceDecoderTest {
|
||||||
|
|
||||||
|
|
||||||
RESTCoverage coverage;
|
RESTCoverage coverage;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws IOException{
|
public void setup() throws IOException {
|
||||||
File coverageFile = new ClassPathResource("testdata/coverageExample.xml").getFile();
|
File coverageFile = new ClassPathResource("testdata/coverageExample.xml").getFile();
|
||||||
String coverageString = FileUtils.readFileToString(coverageFile);
|
String coverageString = FileUtils.readFileToString(coverageFile);
|
||||||
coverage = RESTCoverage.build(coverageString);
|
coverage = RESTCoverage.build(coverageString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testName(){
|
public void testName() {
|
||||||
Assert.assertEquals(coverage.getName(),"granuleTestMosaic");
|
Assert.assertEquals(coverage.getName(), "granuleTestMosaic");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNativeName(){
|
public void testNativeName() {
|
||||||
Assert.assertEquals(coverage.getNativeName(), "granuleTestMosaic");
|
Assert.assertEquals(coverage.getNativeName(), "granuleTestMosaic");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTitle(){
|
public void testTitle() {
|
||||||
Assert.assertEquals(coverage.getNativeName(), "granuleTestMosaic");
|
Assert.assertEquals(coverage.getNativeName(), "granuleTestMosaic");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAbstract(){
|
public void testAbstract() {
|
||||||
Assert.assertEquals(coverage.getAbstract(), "this is an abstract");
|
Assert.assertEquals(coverage.getAbstract(), "this is an abstract");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKeywords(){
|
public void testKeywords() {
|
||||||
List<String> keywords = coverage.getKeywords();
|
List<String> keywords = coverage.getKeywords();
|
||||||
Assert.assertEquals(keywords.get(0), "keyword1");
|
Assert.assertEquals(keywords.get(0), "keyword1");
|
||||||
Assert.assertEquals(keywords.get(1), "keyword2");
|
Assert.assertEquals(keywords.get(1), "keyword2");
|
||||||
Assert.assertEquals(keywords.get(2), "keyword3");
|
Assert.assertEquals(keywords.get(2), "keyword3");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNameSpace(){
|
public void testNameSpace() {
|
||||||
Assert.assertEquals(coverage.getNameSpace(),"topp");
|
Assert.assertEquals(coverage.getNameSpace(), "topp");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStoreName(){
|
public void testStoreName() {
|
||||||
Assert.assertEquals(coverage.getStoreName(), "granuleTestMosaic");
|
Assert.assertEquals(coverage.getStoreName(), "granuleTestMosaic");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStoreType(){
|
public void testStoreType() {
|
||||||
Assert.assertEquals(coverage.getStoreType(), "coverageStore");
|
Assert.assertEquals(coverage.getStoreType(), "coverageStore");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStoreUrl(){
|
public void testStoreUrl() {
|
||||||
Assert.assertEquals(coverage.getStoreUrl(), "http://localhost:8080/geoserver/rest/workspaces/topp/coveragestores/granuleTestMosaic.xml");
|
Assert.assertEquals(coverage.getStoreUrl(),
|
||||||
}
|
"http://localhost:8080/geoserver/rest/workspaces/topp/coveragestores/granuleTestMosaic.xml");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCRS(){
|
public void testCRS() {
|
||||||
Assert.assertEquals(coverage.getCRS(), "EPSG:4326");
|
Assert.assertEquals(coverage.getCRS(), "EPSG:4326");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBoundingBox(){
|
public void testBoundingBox() {
|
||||||
Assert.assertEquals(coverage.getMinX(), -180.0, 0);
|
Assert.assertEquals(coverage.getMinX(), -180.0, 0);
|
||||||
Assert.assertEquals(coverage.getMaxX(), 180.0, 0);
|
Assert.assertEquals(coverage.getMaxX(), 180.0, 0);
|
||||||
Assert.assertEquals(coverage.getMinY(), -90, 0);
|
Assert.assertEquals(coverage.getMinY(), -90, 0);
|
||||||
Assert.assertEquals(coverage.getMaxY(), 90, 0);
|
Assert.assertEquals(coverage.getMaxY(), 90, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testMetadataLinkInfo() throws IOException {
|
||||||
public void testMetadataLinkInfo() throws IOException{
|
|
||||||
|
|
||||||
List<GSMetadataLinkInfoEncoder> list = coverage.getEncodedMetadataLinkInfoList();
|
List<GSMetadataLinkInfoEncoder> list = coverage.getEncodedMetadataLinkInfoList();
|
||||||
|
|
||||||
@ -105,11 +105,25 @@ public class ResourceDecoderTest {
|
|||||||
Assert.assertEquals("http://www.organization.org/metadata1", metadataLinkInfo1.getContent());
|
Assert.assertEquals("http://www.organization.org/metadata1", metadataLinkInfo1.getContent());
|
||||||
|
|
||||||
GSMetadataLinkInfoEncoder metadataLinkInfo2 = list.get(1);
|
GSMetadataLinkInfoEncoder metadataLinkInfo2 = list.get(1);
|
||||||
Assert.assertEquals("text/html",metadataLinkInfo2.getType());
|
Assert.assertEquals("text/html", metadataLinkInfo2.getType());
|
||||||
Assert.assertEquals("ISO19115:2003",metadataLinkInfo2.getMetadataType());
|
Assert.assertEquals("ISO19115:2003", metadataLinkInfo2.getMetadataType());
|
||||||
Assert.assertEquals("http://www.organization.org/metadata2",metadataLinkInfo2.getContent());
|
Assert.assertEquals("http://www.organization.org/metadata2", metadataLinkInfo2.getContent());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCoverageDimension() throws IOException {
|
||||||
|
|
||||||
|
List<GSCoverageDimensionEncoder> list = coverage.getEncodedDimensionsInfoList();
|
||||||
|
|
||||||
|
GSCoverageDimensionEncoder coverageDimension1 = list.get(0);
|
||||||
|
Assert.assertEquals("GRAY_INDEX", coverageDimension1.getName());
|
||||||
|
Assert.assertEquals("GridSampleDimension[-Infinity,Infinity]",
|
||||||
|
coverageDimension1.getDescription());
|
||||||
|
Assert.assertEquals("-inf", coverageDimension1.getRangeMin());
|
||||||
|
Assert.assertEquals("inf", coverageDimension1.getRangeMax());
|
||||||
|
Assert.assertEquals("dobson units³", coverageDimension1.getUnit());
|
||||||
|
Assert.assertEquals("REAL_32BITS", coverageDimension1.getDimensionTypeName());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,10 +78,10 @@ public class VersionDecoderTest extends GeoserverRESTTest {
|
|||||||
if (!enabled())
|
if (!enabled())
|
||||||
return;
|
return;
|
||||||
GSVersionDecoder geoserver = reader.getGeoserverVersion();
|
GSVersionDecoder geoserver = reader.getGeoserverVersion();
|
||||||
if (GSVersionDecoder.VERSION.v22.equals(GSVersionDecoder.VERSION.getVersion(VERSION))) {
|
if (GSVersionDecoder.VERSION.v22.equals(GSVersionDecoder.VERSION.getVersion(GS_VERSION))) {
|
||||||
Assert.assertEquals(geoserver.getVersion(), GSVersionDecoder.VERSION.v22);
|
Assert.assertEquals(geoserver.getVersion(), GSVersionDecoder.VERSION.v22);
|
||||||
} else if (GSVersionDecoder.VERSION.UNRECOGNIZED.equals(GSVersionDecoder.VERSION
|
} else if (GSVersionDecoder.VERSION.UNRECOGNIZED.equals(GSVersionDecoder.VERSION
|
||||||
.getVersion(VERSION))) {
|
.getVersion(GS_VERSION))) {
|
||||||
Assert.assertEquals(geoserver.getVersion(), GSVersionDecoder.VERSION.UNRECOGNIZED);
|
Assert.assertEquals(geoserver.getVersion(), GSVersionDecoder.VERSION.UNRECOGNIZED);
|
||||||
}
|
}
|
||||||
// print(dec.getRoot());
|
// print(dec.getRoot());
|
||||||
|
|||||||
@ -32,6 +32,7 @@ import it.geosolutions.geoserver.rest.decoder.RESTFeatureType;
|
|||||||
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTLayerGroup;
|
import it.geosolutions.geoserver.rest.decoder.RESTLayerGroup;
|
||||||
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder.VERSION;
|
||||||
import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;
|
import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
@ -39,6 +40,8 @@ import java.net.URL;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.jdom.output.EscapeStrategy;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
@ -77,7 +80,7 @@ public abstract class GeoserverRESTTest {
|
|||||||
public static final String RESTPW;
|
public static final String RESTPW;
|
||||||
|
|
||||||
// geoserver target version
|
// geoserver target version
|
||||||
public static final String VERSION;
|
public static final String GS_VERSION;
|
||||||
|
|
||||||
public static URL URL;
|
public static URL URL;
|
||||||
|
|
||||||
@ -95,7 +98,7 @@ public abstract class GeoserverRESTTest {
|
|||||||
RESTURL = getenv("gsmgr_resturl", "http://localhost:8080/geoserver");
|
RESTURL = getenv("gsmgr_resturl", "http://localhost:8080/geoserver");
|
||||||
RESTUSER = getenv("gsmgr_restuser", "admin");
|
RESTUSER = getenv("gsmgr_restuser", "admin");
|
||||||
RESTPW = getenv("gsmgr_restpw", "geoserver");
|
RESTPW = getenv("gsmgr_restpw", "geoserver");
|
||||||
VERSION = getenv("gsmgr_version", "2.4");
|
GS_VERSION = getenv("gsmgr_version", "2.4");
|
||||||
|
|
||||||
// These tests will destroy data, so let's make sure we do want to run them
|
// These tests will destroy data, so let's make sure we do want to run them
|
||||||
enabled = getenv("gsmgr_resttest", "false").equalsIgnoreCase("true");
|
enabled = getenv("gsmgr_resttest", "false").equalsIgnoreCase("true");
|
||||||
@ -132,15 +135,15 @@ public abstract class GeoserverRESTTest {
|
|||||||
LOGGER.info("Using geoserver instance " + RESTUSER + ":" + RESTPW + " @ "
|
LOGGER.info("Using geoserver instance " + RESTUSER + ":" + RESTPW + " @ "
|
||||||
+ RESTURL);
|
+ RESTURL);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (existgs == false){
|
||||||
System.out.println("Failing tests : geoserver not found");
|
System.out.println("Failing tests : geoserver not found");
|
||||||
fail("GeoServer not found");
|
fail("GeoServer not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
GSVersionDecoder v=reader.getGeoserverVersion();
|
GSVersionDecoder v=reader.getGeoserverVersion();
|
||||||
if (!v.getVersion().equals(GSVersionDecoder.VERSION.getVersion(VERSION))){
|
if (v.compareTo(VERSION.getVersion(GS_VERSION))!=0){
|
||||||
System.out.println("Failing tests : geoserver version does not match.\nAccepted versions: "+GSVersionDecoder.VERSION.print());
|
System.out.println("Failing tests : geoserver version does not match.\nAccepted versions: "+VERSION.print());
|
||||||
fail("GeoServer version ("+v.getVersion()+") does not match the desired one (+VERSION+)");
|
fail("GeoServer version ("+v.getVersion()+") does not match the desired one ("+GS_VERSION+")");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Skipping tests ");
|
System.out.println("Skipping tests ");
|
||||||
@ -186,30 +189,32 @@ public abstract class GeoserverRESTTest {
|
|||||||
LOGGER.info("Found " + groups.size() + " layerGroups");
|
LOGGER.info("Found " + groups.size() + " layerGroups");
|
||||||
for (String groupName : groups) {
|
for (String groupName : groups) {
|
||||||
RESTLayerGroup group = reader.getLayerGroup(groupName);
|
RESTLayerGroup group = reader.getLayerGroup(groupName);
|
||||||
StringBuilder sb = new StringBuilder("Group: ").append(groupName).append(":");
|
if (groups != null) {
|
||||||
for (NameLinkElem layer : group.getLayerList()) {
|
StringBuilder sb = new StringBuilder("Group: ").append(groupName).append(":");
|
||||||
sb.append(" ").append(layer);
|
for (NameLinkElem layer : group.getLayerList()) {
|
||||||
|
sb.append(" ").append(layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean removed = publisher.removeLayerGroup(groupName);
|
||||||
|
LOGGER.info(sb.toString() + ": removed: " + removed);
|
||||||
|
assertTrue("LayerGroup not removed: " + groupName, removed);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean removed = publisher.removeLayerGroup(groupName);
|
|
||||||
LOGGER.info(sb.toString() + ": removed: " + removed);
|
|
||||||
assertTrue("LayerGroup not removed: " + groupName, removed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteAllLayers() {
|
private void deleteAllLayers() {
|
||||||
List<String> layers = reader.getLayers().getNames();
|
List<String> layers = reader.getLayers().getNames();
|
||||||
for (String layerName : layers) {
|
if (layers != null) {
|
||||||
RESTLayer layer = reader.getLayer(layerName);
|
for (String layerName : layers) {
|
||||||
if (layer.getType() == RESTLayer.Type.VECTOR)
|
RESTLayer layer = reader.getLayer(layerName);
|
||||||
deleteFeatureType(layer);
|
if (layer.getType() == RESTLayer.Type.VECTOR)
|
||||||
else if (layer.getType() == RESTLayer.Type.RASTER)
|
deleteFeatureType(layer);
|
||||||
deleteCoverage(layer);
|
else if (layer.getType() == RESTLayer.Type.RASTER)
|
||||||
else
|
deleteCoverage(layer);
|
||||||
LOGGER.error("Unknown layer type " + layer.getType());
|
else
|
||||||
|
LOGGER.error("Unknown layer type " + layer.getType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteAllCoverageStores() {
|
private void deleteAllCoverageStores() {
|
||||||
@ -269,11 +274,12 @@ public abstract class GeoserverRESTTest {
|
|||||||
|
|
||||||
protected void deleteAllStyles() {
|
protected void deleteAllStyles() {
|
||||||
List<String> styles = reader.getStyles().getNames();
|
List<String> styles = reader.getStyles().getNames();
|
||||||
for (String style : styles) {
|
if (styles != null) {
|
||||||
LOGGER.warn("Deleting Style " + style);
|
for (String style : styles) {
|
||||||
boolean removed = publisher.removeStyle(style,true);
|
LOGGER.warn("Deleting Style " + style);
|
||||||
assertTrue("Style not removed " + style, removed);
|
boolean removed = publisher.removeStyle(style, true);
|
||||||
|
assertTrue("Style not removed " + style, removed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,7 @@ public class GSArcSDEDatastoreEncoderTest extends StoreIntegrationTest {
|
|||||||
|
|
||||||
public GSArcSDEDatastoreEncoderTest() throws IllegalArgumentException, MalformedURLException {
|
public GSArcSDEDatastoreEncoderTest() throws IllegalArgumentException, MalformedURLException {
|
||||||
|
|
||||||
super(System.getProperty("Ignore", "false").equalsIgnoreCase("true"));
|
super(System.getProperty("Ignore", "true").equalsIgnoreCase("true"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -61,7 +61,7 @@ public class GSOracleNGDatastoreEncoderTest extends StoreIntegrationTest {
|
|||||||
// private final static Logger LOGGER = LoggerFactory.getLogger(GSOracleNGDatastoreEncoderTest.class);
|
// private final static Logger LOGGER = LoggerFactory.getLogger(GSOracleNGDatastoreEncoderTest.class);
|
||||||
|
|
||||||
public GSOracleNGDatastoreEncoderTest() throws IllegalArgumentException, MalformedURLException {
|
public GSOracleNGDatastoreEncoderTest() throws IllegalArgumentException, MalformedURLException {
|
||||||
super(System.getProperty("pgIgnore", "false").equalsIgnoreCase("true"));
|
super(System.getProperty("pgIgnore", "true").equalsIgnoreCase("true"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -44,10 +44,8 @@ import org.slf4j.LoggerFactory;
|
|||||||
* <P>
|
* <P>
|
||||||
* Since these tests require a running Store instance, this is more like integration tests.<br/>
|
* Since these tests require a running Store instance, this is more like integration tests.<br/>
|
||||||
*
|
*
|
||||||
* For testing that a datastore is properly configured, a layer publication has
|
* For testing that a datastore is properly configured, a layer publication has to be attempted. For this, the 'states' data (states shapefile -
|
||||||
* to be attempted. For this, the 'states' data (states shapefile - available in
|
* available in testdata/states.zip) has to be imported in the corresponding store. Note: For Oracle NG this name has to be uppercase (STATES).
|
||||||
* testdata/states.zip) has to be imported in the corresponding store.
|
|
||||||
* Note: For Oracle NG this name has to be uppercase (STATES).
|
|
||||||
*
|
*
|
||||||
* @author carlo cancellieri - GeoSolutions
|
* @author carlo cancellieri - GeoSolutions
|
||||||
* @author emmanuel blondel
|
* @author emmanuel blondel
|
||||||
@ -71,77 +69,68 @@ public abstract class StoreIntegrationTest extends GeoserverRESTTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param ignore false if this test shoudl be disabled
|
* @param ignore true if this test should be disabled
|
||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* @throws MalformedURLException
|
* @throws MalformedURLException
|
||||||
*/
|
*/
|
||||||
public StoreIntegrationTest(boolean ignore) throws IllegalArgumentException, MalformedURLException {
|
public StoreIntegrationTest(boolean ignore) throws IllegalArgumentException,
|
||||||
|
MalformedURLException {
|
||||||
super();
|
super();
|
||||||
this.storeManager = new GeoServerRESTStoreManager(URL, RESTUSER, RESTPW);
|
this.storeManager = new GeoServerRESTStoreManager(URL, RESTUSER, RESTPW);
|
||||||
this.ignore=ignore;
|
this.ignore = ignore;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract GSAbstractStoreEncoder getStoreEncoderTest();
|
public abstract GSAbstractStoreEncoder getStoreEncoderTest();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateDeleteDatastore() throws IllegalArgumentException, MalformedURLException {
|
public void testCreateDeleteDatastore() throws IllegalArgumentException, MalformedURLException {
|
||||||
if (!enabled()) {
|
if (!enabled() || ignore) {
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
deleteAll();
|
|
||||||
|
|
||||||
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
|
||||||
|
|
||||||
// creation test
|
|
||||||
GSAbstractStoreEncoder storeEncoder=getStoreEncoderTest();
|
|
||||||
|
|
||||||
String storeName = storeEncoder.getName();
|
|
||||||
// String description = storeEncoder.getDescription();
|
|
||||||
|
|
||||||
boolean created = storeManager.create(DEFAULT_WS, storeEncoder);
|
|
||||||
|
|
||||||
if( ! ignore )
|
|
||||||
assertTrue("Datastore not created", created);
|
|
||||||
else if( ! created)
|
|
||||||
LOGGER.error("*** store " + storeName + " has not been created.");
|
|
||||||
|
|
||||||
|
|
||||||
RESTDataStore datastore = reader.getDatastore(DEFAULT_WS, storeName);
|
|
||||||
assertNotNull(datastore);
|
|
||||||
LOGGER.info("The type of the created datastore is: " + datastore.getStoreType());
|
|
||||||
|
|
||||||
//check if the datastore is properly configured in GS for publishing layers
|
|
||||||
String layername = "states";
|
|
||||||
if(storeEncoder instanceof GSOracleNGDatastoreEncoder)
|
|
||||||
layername = layername.toUpperCase();
|
|
||||||
|
|
||||||
GSFeatureTypeEncoder fte = new GSFeatureTypeEncoder();
|
|
||||||
fte.setName(layername);
|
|
||||||
fte.setTitle(layername);
|
|
||||||
fte.setNativeCRS("EPSG:4326");
|
|
||||||
fte.setDescription("desc");
|
|
||||||
fte.setEnabled(true);
|
|
||||||
GSLayerEncoder layerEncoder = new GSLayerEncoder();
|
|
||||||
layerEncoder.setEnabled(true);
|
|
||||||
layerEncoder.setQueryable(true);
|
|
||||||
layerEncoder.setDefaultStyle("polygon");
|
|
||||||
|
|
||||||
boolean published = publisher.publishDBLayer(DEFAULT_WS, storeName, fte, layerEncoder);
|
|
||||||
if(!ignore){
|
|
||||||
assertTrue("Test layer not published", published);
|
|
||||||
}else if(!published){
|
|
||||||
LOGGER.error("*** Test layer "
|
|
||||||
+ layername
|
|
||||||
+ " has not been published. Problem in datastore configuration");
|
|
||||||
}
|
|
||||||
|
|
||||||
// removing test
|
|
||||||
boolean removed = storeManager.remove(DEFAULT_WS, storeEncoder, true);
|
|
||||||
if( ! ignore )
|
|
||||||
assertTrue("Datastore not removed", removed);
|
|
||||||
else if( ! removed )
|
|
||||||
LOGGER.error("*** Datastore " + storeName + " has not been removed.");
|
|
||||||
|
|
||||||
assertTrue(publisher.removeWorkspace(DEFAULT_WS, false));
|
|
||||||
}
|
}
|
||||||
|
deleteAll();
|
||||||
|
|
||||||
|
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||||
|
|
||||||
|
// creation test
|
||||||
|
GSAbstractStoreEncoder storeEncoder = getStoreEncoderTest();
|
||||||
|
|
||||||
|
String storeName = storeEncoder.getName();
|
||||||
|
// String description = storeEncoder.getDescription();
|
||||||
|
|
||||||
|
boolean created = storeManager.create(DEFAULT_WS, storeEncoder);
|
||||||
|
|
||||||
|
assertTrue("*** store " + storeName + " has not been created.", created);
|
||||||
|
|
||||||
|
RESTDataStore datastore = reader.getDatastore(DEFAULT_WS, storeName);
|
||||||
|
assertNotNull(datastore);
|
||||||
|
LOGGER.info("The type of the created datastore is: " + datastore.getStoreType());
|
||||||
|
|
||||||
|
// check if the datastore is properly configured in GS for publishing layers
|
||||||
|
String layername = "states";
|
||||||
|
|
||||||
|
if (storeEncoder instanceof GSOracleNGDatastoreEncoder)
|
||||||
|
layername = layername.toUpperCase();
|
||||||
|
|
||||||
|
GSFeatureTypeEncoder fte = new GSFeatureTypeEncoder();
|
||||||
|
fte.setName(layername);
|
||||||
|
fte.setNativeName(layername);
|
||||||
|
fte.setTitle(layername+"_TITLE");
|
||||||
|
fte.setNativeCRS("EPSG:4326");
|
||||||
|
fte.setDescription("desc");
|
||||||
|
fte.setEnabled(true);
|
||||||
|
GSLayerEncoder layerEncoder = new GSLayerEncoder();
|
||||||
|
layerEncoder.setEnabled(true);
|
||||||
|
layerEncoder.setQueryable(true);
|
||||||
|
layerEncoder.setDefaultStyle("polygon");
|
||||||
|
|
||||||
|
boolean published = publisher.publishDBLayer(DEFAULT_WS, storeName, fte, layerEncoder);
|
||||||
|
|
||||||
|
assertTrue("*** Test layer " + layername
|
||||||
|
+ " has not been published. Problem in datastore configuration", published);
|
||||||
|
|
||||||
|
// removing test
|
||||||
|
boolean removed = storeManager.remove(DEFAULT_WS, storeEncoder, true);
|
||||||
|
assertTrue("*** Datastore " + storeName + " has not been removed.", removed);
|
||||||
|
assertTrue(publisher.removeWorkspace(DEFAULT_WS, false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ package it.geosolutions.geoserver.rest.encoder.coverage;
|
|||||||
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.dimensions.GSCoverageDimensionEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
||||||
import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils;
|
import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils;
|
||||||
@ -105,6 +106,8 @@ public class GSCoverageEncoderTest extends TestCase {
|
|||||||
encoder.addKeyword("...");
|
encoder.addKeyword("...");
|
||||||
encoder.addKeyword("KEYWORD_N");
|
encoder.addKeyword("KEYWORD_N");
|
||||||
|
|
||||||
|
|
||||||
|
// setting dimensions (into metadata)
|
||||||
final GSDimensionInfoEncoder timeDimension=new GSDimensionInfoEncoder(true);
|
final GSDimensionInfoEncoder timeDimension=new GSDimensionInfoEncoder(true);
|
||||||
timeDimension.setPresentation(Presentation.CONTINUOUS_INTERVAL);
|
timeDimension.setPresentation(Presentation.CONTINUOUS_INTERVAL);
|
||||||
encoder.setMetadata("time", timeDimension);
|
encoder.setMetadata("time", timeDimension);
|
||||||
@ -120,6 +123,12 @@ public class GSCoverageEncoderTest extends TestCase {
|
|||||||
elevationDimension.setPresentation(Presentation.LIST);
|
elevationDimension.setPresentation(Presentation.LIST);
|
||||||
encoder.setMetadata("elevation", elevationDimension);
|
encoder.setMetadata("elevation", elevationDimension);
|
||||||
|
|
||||||
|
// setting dimensions (since gs-2.4.x)
|
||||||
|
GSCoverageDimensionEncoder gsCoverageDimensionEncoder = new GSCoverageDimensionEncoder(
|
||||||
|
"GRAY_INDEX", "GridSampleDimension[-Infinity,Infinity]", "-inf", "inf",
|
||||||
|
"dobson units³", "REAL_32BITS");
|
||||||
|
encoder.addCoverageDimensionInfo(gsCoverageDimensionEncoder);
|
||||||
|
|
||||||
if (LOGGER.isInfoEnabled())
|
if (LOGGER.isInfoEnabled())
|
||||||
LOGGER.info(encoder.toString());
|
LOGGER.info(encoder.toString());
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* 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.dimensions;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Henry Rotzoll (henry.rotzoll@dlr.de)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GSCoverageDimensionEncoderTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void coverageDimensionTest() {
|
||||||
|
GSCoverageDimensionEncoder encoder = new GSCoverageDimensionEncoder("GRAY_INDEX",
|
||||||
|
"GridSampleDimension[-Infinity,Infinity]", "-inf", "inf", "dobson units³",
|
||||||
|
"REAL_32BITS");
|
||||||
|
|
||||||
|
Assert.assertEquals("GRAY_INDEX", encoder.getName());
|
||||||
|
Assert.assertEquals("GridSampleDimension[-Infinity,Infinity]", encoder.getDescription());
|
||||||
|
Assert.assertEquals("-inf", encoder.getRangeMin());
|
||||||
|
Assert.assertEquals("inf", encoder.getRangeMax());
|
||||||
|
Assert.assertEquals("dobson units³", encoder.getUnit());
|
||||||
|
Assert.assertEquals("REAL_32BITS", encoder.getDimensionTypeName());
|
||||||
|
|
||||||
|
Assert.assertTrue(encoder.delName());
|
||||||
|
Assert.assertTrue(encoder.delDescription());
|
||||||
|
Assert.assertTrue(encoder.delRange());
|
||||||
|
Assert.assertTrue(encoder.delUnit());
|
||||||
|
Assert.assertTrue(encoder.delDimensionType());
|
||||||
|
|
||||||
|
Assert.assertNull(encoder.getName());
|
||||||
|
Assert.assertNull(encoder.getDescription());
|
||||||
|
Assert.assertNull(encoder.getRangeMin());
|
||||||
|
Assert.assertNull(encoder.getRangeMax());
|
||||||
|
Assert.assertNull(encoder.getUnit());
|
||||||
|
Assert.assertNull(encoder.getDimensionTypeName());
|
||||||
|
|
||||||
|
encoder.setName("GRAY_INDEX");
|
||||||
|
encoder.setDescription("GridSampleDimension[-Infinity,Infinity]");
|
||||||
|
encoder.setRange("-inf", "inf");
|
||||||
|
encoder.setUnit("dobson units³");
|
||||||
|
encoder.setDimensionType("REAL_32BITS");
|
||||||
|
|
||||||
|
Assert.assertEquals("GRAY_INDEX", encoder.getName());
|
||||||
|
Assert.assertEquals("GridSampleDimension[-Infinity,Infinity]", encoder.getDescription());
|
||||||
|
Assert.assertEquals("-inf", encoder.getRangeMin());
|
||||||
|
Assert.assertEquals("inf", encoder.getRangeMax());
|
||||||
|
Assert.assertEquals("dobson units³", encoder.getUnit());
|
||||||
|
Assert.assertEquals("REAL_32BITS", encoder.getDimensionTypeName());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -21,13 +21,16 @@ package it.geosolutions.geoserver.rest.encoder.feature;
|
|||||||
|
|
||||||
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
|
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
|
||||||
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.RESTFeatureType;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTResource;
|
import it.geosolutions.geoserver.rest.decoder.RESTResource;
|
||||||
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder.VERSION;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder21;
|
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder21;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.authorityurl.GSAuthorityURLInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.authorityurl.GSAuthorityURLInfoEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.dimensions.GSCoverageDimensionEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.identifier.GSIdentifierInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.identifier.GSIdentifierInfoEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
||||||
@ -52,14 +55,12 @@ import org.springframework.core.io.ClassPathResource;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Note on adding multiple available styles to the GSLayerEncoder: - to run the
|
* Note on adding multiple available styles to the GSLayerEncoder: - to run the testIntegration(), 2 clones of the "point" style, named "point2" and
|
||||||
* testIntegration(), 2 clones of the "point" style, named "point2" and "point3"
|
* "point3" have to be created.
|
||||||
* have to be created.
|
|
||||||
*
|
*
|
||||||
* @author ETj (etj at geo-solutions.it)
|
* @author ETj (etj at geo-solutions.it)
|
||||||
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com |
|
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com | emmanuel.blondel@fao.org
|
||||||
* emmanuel.blondel@fao.org
|
|
||||||
*/
|
*/
|
||||||
public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
||||||
protected final static Logger LOGGER = LoggerFactory.getLogger(GSFeatureEncoderTest.class);
|
protected final static Logger LOGGER = LoggerFactory.getLogger(GSFeatureEncoderTest.class);
|
||||||
@ -76,6 +77,18 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
String storeName = "resttestshp";
|
String storeName = "resttestshp";
|
||||||
String layerName = "cities";
|
String layerName = "cities";
|
||||||
|
|
||||||
|
publisher.createWorkspace(DEFAULT_WS);
|
||||||
|
|
||||||
|
File zipFile = new ClassPathResource("testdata/resttestshp.zip").getFile();
|
||||||
|
|
||||||
|
// test insert
|
||||||
|
boolean published = publisher.publishShp(DEFAULT_WS, storeName, layerName, zipFile);
|
||||||
|
assertTrue("publish() failed", published);
|
||||||
|
assertTrue(existsLayer(layerName));
|
||||||
|
|
||||||
|
publisher.publishStyle(new File(new ClassPathResource("testdata").getFile(),
|
||||||
|
"default_point.sld"));
|
||||||
|
|
||||||
GSFeatureTypeEncoder fte = new GSFeatureTypeEncoder();
|
GSFeatureTypeEncoder fte = new GSFeatureTypeEncoder();
|
||||||
fte.setNativeName(layerName);
|
fte.setNativeName(layerName);
|
||||||
fte.setName(layerName + "_NEW");
|
fte.setName(layerName + "_NEW");
|
||||||
@ -85,70 +98,52 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
fte.setDescription("desc");
|
fte.setDescription("desc");
|
||||||
fte.setEnabled(true);
|
fte.setEnabled(true);
|
||||||
|
|
||||||
//metadataLink
|
// metadataLink
|
||||||
GSMetadataLinkInfoEncoder metadatalink = new GSMetadataLinkInfoEncoder(
|
GSMetadataLinkInfoEncoder metadatalink = new GSMetadataLinkInfoEncoder("text/xml",
|
||||||
"text/xml", "ISO19115:2003",
|
"ISO19115:2003", "http://www.organization.org/metadata1");
|
||||||
"http://www.organization.org/metadata1");
|
|
||||||
fte.addMetadataLinkInfo(metadatalink);
|
fte.addMetadataLinkInfo(metadatalink);
|
||||||
|
|
||||||
GSLayerEncoder layerEncoder = null;
|
GSLayerEncoder layerEncoder = null;
|
||||||
if (!GSVersionDecoder.VERSION.getVersion(VERSION).equals(
|
if (VERSION.getVersion(GS_VERSION).compareTo(VERSION.UNRECOGNIZED) > 0) {
|
||||||
GSVersionDecoder.VERSION.UNRECOGNIZED)) {
|
layerEncoder = new GSLayerEncoder();
|
||||||
layerEncoder = new GSLayerEncoder();
|
} else if (VERSION.getVersion(GS_VERSION).compareTo(VERSION.UNRECOGNIZED) == 0) {
|
||||||
} else if (GSVersionDecoder.VERSION.getVersion(VERSION).equals(
|
layerEncoder = new GSLayerEncoder21();
|
||||||
GSVersionDecoder.VERSION.UNRECOGNIZED)) {
|
}
|
||||||
layerEncoder = new GSLayerEncoder21();
|
layerEncoder.setEnabled(true);
|
||||||
}
|
layerEncoder.setQueryable(true);
|
||||||
layerEncoder.setEnabled(true);
|
layerEncoder.setAdvertised(true);
|
||||||
layerEncoder.setQueryable(true);
|
|
||||||
layerEncoder.setAdvertised(true);
|
|
||||||
|
|
||||||
layerEncoder.setDefaultStyle("point");
|
layerEncoder.setDefaultStyle("point");
|
||||||
layerEncoder.addStyle("point2");
|
layerEncoder.addStyle("point2");
|
||||||
layerEncoder.addStyle("point3");
|
layerEncoder.addStyle("point3");
|
||||||
|
|
||||||
// authorityURL
|
// authorityURL
|
||||||
GSAuthorityURLInfoEncoder authorityURL = new GSAuthorityURLInfoEncoder(
|
GSAuthorityURLInfoEncoder authorityURL = new GSAuthorityURLInfoEncoder("authority1",
|
||||||
"authority1", "http://www.authority1.org");
|
"http://www.authority1.org");
|
||||||
layerEncoder.addAuthorityURL(authorityURL);
|
layerEncoder.addAuthorityURL(authorityURL);
|
||||||
|
|
||||||
// identifier
|
// identifier
|
||||||
GSIdentifierInfoEncoder identifier1 = new GSIdentifierInfoEncoder(
|
GSIdentifierInfoEncoder identifier1 = new GSIdentifierInfoEncoder("authority1",
|
||||||
"authority1", "identifier1");
|
"identifier1");
|
||||||
GSIdentifierInfoEncoder identifier2 = new GSIdentifierInfoEncoder(
|
GSIdentifierInfoEncoder identifier2 = new GSIdentifierInfoEncoder("authority1",
|
||||||
"authority1", "another_identifier");
|
"another_identifier");
|
||||||
layerEncoder.addIdentifier(identifier1);
|
layerEncoder.addIdentifier(identifier1);
|
||||||
layerEncoder.addIdentifier(identifier2);
|
layerEncoder.addIdentifier(identifier2);
|
||||||
|
|
||||||
publisher.createWorkspace(DEFAULT_WS);
|
|
||||||
|
|
||||||
File zipFile = new ClassPathResource("testdata/resttestshp.zip")
|
// optionally select the attributes to publish
|
||||||
.getFile();
|
RESTLayer layer = reader.getLayer(DEFAULT_WS, layerName);
|
||||||
|
RESTFeatureType resource = reader.getFeatureType(layer);
|
||||||
|
List<GSAttributeEncoder> attrs = resource.getEncodedAttributeList();
|
||||||
|
assertNotNull(attrs);
|
||||||
|
for (GSAttributeEncoder enc : attrs) {
|
||||||
|
fte.setAttribute(enc);
|
||||||
|
}
|
||||||
|
|
||||||
// test insert
|
assertTrue(publisher.publishDBLayer(DEFAULT_WS, storeName, fte, layerEncoder));
|
||||||
boolean published = publisher.publishShp(DEFAULT_WS, storeName,
|
|
||||||
layerName, zipFile);
|
|
||||||
assertTrue("publish() failed", published);
|
|
||||||
assertTrue(existsLayer(layerName));
|
|
||||||
|
|
||||||
publisher.publishStyle(new File(new ClassPathResource("testdata")
|
|
||||||
.getFile(), "default_point.sld"));
|
|
||||||
|
|
||||||
// optionally select the attributes to publish
|
|
||||||
RESTLayer layer = reader.getLayer(layerName);
|
|
||||||
RESTResource resource = reader.getResource(layer);
|
|
||||||
List<GSAttributeEncoder> attrs = resource.getEncodedAttributeList();
|
|
||||||
assertNotNull(attrs);
|
|
||||||
for (GSAttributeEncoder enc : attrs) {
|
|
||||||
fte.setAttribute(enc);
|
|
||||||
}
|
|
||||||
|
|
||||||
assertTrue(publisher.publishDBLayer(DEFAULT_WS, storeName, fte,
|
|
||||||
layerEncoder));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFeatureTypeEncoder() {
|
public void testFeatureTypeEncoder() {
|
||||||
|
|
||||||
@ -221,28 +216,34 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
if (LOGGER.isInfoEnabled())
|
if (LOGGER.isInfoEnabled())
|
||||||
LOGGER.info(encoder.toString());
|
LOGGER.info(encoder.toString());
|
||||||
|
|
||||||
assertEquals(encoder.getName(),"Layername");
|
assertEquals(encoder.getName(), "Layername");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testModifyFeature() {
|
public void testModifyFeature() {
|
||||||
GSFeatureTypeEncoder encoder = new GSFeatureTypeEncoder();
|
GSFeatureTypeEncoder encoder = new GSFeatureTypeEncoder();
|
||||||
encoder.addKeyword("KEYWORD_1");
|
encoder.addKeyword("KEYWORD_1");
|
||||||
encoder.addKeyword("KEYWORD_2");
|
encoder.addKeyword("KEYWORD_1", "LAN_1", "VOCAB_1");
|
||||||
|
assertTrue(encoder.delKeyword("KEYWORD_1", "LAN_1", "VOCAB_1"));
|
||||||
|
|
||||||
encoder.addKeyword("...");
|
encoder.addKeyword("...");
|
||||||
encoder.addKeyword("KEYWORD_N");
|
encoder.addKeyword("KEYWORD_N");
|
||||||
|
|
||||||
assertTrue(encoder.delKeyword("KEYWORD_2"));
|
|
||||||
assertFalse(encoder.delKeyword("KEYWORD_M"));
|
assertFalse(encoder.delKeyword("KEYWORD_M"));
|
||||||
|
|
||||||
//metadataLinkInfo
|
encoder.addKeyword("KEYWORD_2");
|
||||||
encoder.addMetadataLinkInfo("text/xml", "ISO19115:2003","http://www.organization.org/metadata1");
|
assertFalse(encoder.delKeyword("KEYWORD_2", "LAN_1", "VOCAB_1"));
|
||||||
encoder.addMetadataLinkInfo("text/html", "ISO19115:2003","http://www.organization.org/metadata2");
|
assertTrue(encoder.delKeyword("KEYWORD_2"));
|
||||||
|
|
||||||
|
// metadataLinkInfo
|
||||||
|
encoder.addMetadataLinkInfo("text/xml", "ISO19115:2003",
|
||||||
|
"http://www.organization.org/metadata1");
|
||||||
|
encoder.addMetadataLinkInfo("text/html", "ISO19115:2003",
|
||||||
|
"http://www.organization.org/metadata2");
|
||||||
|
|
||||||
assertTrue(encoder.delMetadataLinkInfo("http://www.organization.org/metadata2"));
|
assertTrue(encoder.delMetadataLinkInfo("http://www.organization.org/metadata2"));
|
||||||
assertFalse(encoder.delMetadataLinkInfo("http://www.organization.org/metadata3"));
|
assertFalse(encoder.delMetadataLinkInfo("http://www.organization.org/metadata3"));
|
||||||
|
|
||||||
//dimensions
|
// dimensions
|
||||||
final GSFeatureDimensionInfoEncoder elevationDimension = new GSFeatureDimensionInfoEncoder(
|
final GSFeatureDimensionInfoEncoder elevationDimension = new GSFeatureDimensionInfoEncoder(
|
||||||
"elevation_field");
|
"elevation_field");
|
||||||
|
|
||||||
@ -252,8 +253,7 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
final String metadata = "elevation";
|
final String metadata = "elevation";
|
||||||
encoder.setMetadataDimension(metadata, elevationDimension);
|
encoder.setMetadataDimension(metadata, elevationDimension);
|
||||||
|
|
||||||
elevationDimension.setPresentation(Presentation.DISCRETE_INTERVAL,
|
elevationDimension.setPresentation(Presentation.DISCRETE_INTERVAL, BigDecimal.valueOf(10));
|
||||||
BigDecimal.valueOf(10));
|
|
||||||
|
|
||||||
if (LOGGER.isInfoEnabled())
|
if (LOGGER.isInfoEnabled())
|
||||||
LOGGER.info(encoder.toString());
|
LOGGER.info(encoder.toString());
|
||||||
@ -274,26 +274,39 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for virtual table encoding / SQL view layer integration
|
* Test method for virtual table encoding / SQL view layer integration
|
||||||
*
|
*
|
||||||
* Settings information for integration tests
|
* Settings information for integration tests - test is based on the data used in
|
||||||
* - test is based on the data used in http://docs.geoserver.org/latest/en/user/data/database/sqlview.html#parameterizing-sql-views
|
* http://docs.geoserver.org/latest/en/user/data/database/sqlview.html#parameterizing-sql-views (states shapefile - available in
|
||||||
* (states shapefile - available in testdata/states.zip)
|
* testdata/states.zip) - create a postgis db - import the states shapefile (using shp2pgsql or Postgis shapefile uploader) - In Geoserver, create
|
||||||
* - create a postgis db
|
* a postgis datastore for this DB, with the name "statesdb"
|
||||||
* - import the states shapefile (using shp2pgsql or Postgis shapefile uploader)
|
*
|
||||||
* - In Geoserver, create a postgis datastore for this DB, with the name "statesdb"
|
* @throws IOException
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSQLViewIntegration(){
|
public void testSQLViewIntegration() throws IOException {
|
||||||
|
|
||||||
if (!enabled())
|
if (!enabled())
|
||||||
return;
|
return;
|
||||||
deleteAll();
|
deleteAll();
|
||||||
|
|
||||||
GeoServerRESTPublisher publisher = new GeoServerRESTPublisher(RESTURL, RESTUSER, RESTPW);
|
GeoServerRESTPublisher publisher = new GeoServerRESTPublisher(RESTURL, RESTUSER, RESTPW);
|
||||||
|
|
||||||
|
String storeName = "resttestshp";
|
||||||
|
String layerName = "cities";
|
||||||
|
|
||||||
String storeName = "statesdb"; //name of the datastore setup for tests
|
// build the store
|
||||||
String layerName = "my_sqlviewlayer";
|
publisher.createWorkspace(DEFAULT_WS);
|
||||||
String nativeName = "popstates";
|
|
||||||
|
// test insert
|
||||||
|
File zipFile = new ClassPathResource("testdata/resttestshp.zip").getFile();
|
||||||
|
boolean published = publisher.publishShp(DEFAULT_WS, storeName, layerName, zipFile);
|
||||||
|
assertTrue("publish() failed", published);
|
||||||
|
|
||||||
|
publisher.publishStyle(new File(new ClassPathResource("testdata").getFile(),
|
||||||
|
"default_point.sld"));
|
||||||
|
|
||||||
|
String nativeName = layerName;
|
||||||
|
layerName=layerName+"_NEW";
|
||||||
|
|
||||||
GSFeatureTypeEncoder fte = new GSFeatureTypeEncoder();
|
GSFeatureTypeEncoder fte = new GSFeatureTypeEncoder();
|
||||||
fte.setName(layerName);
|
fte.setName(layerName);
|
||||||
@ -306,8 +319,8 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
fte.setDescription("desc");
|
fte.setDescription("desc");
|
||||||
fte.setEnabled(true);
|
fte.setEnabled(true);
|
||||||
|
|
||||||
//virtual table
|
// virtual table
|
||||||
//-------------
|
// -------------
|
||||||
// Set-up the vtGeom
|
// Set-up the vtGeom
|
||||||
final VTGeometryEncoder vtGeom = new VTGeometryEncoder("the_geom", "Point", "4326");
|
final VTGeometryEncoder vtGeom = new VTGeometryEncoder("the_geom", "Point", "4326");
|
||||||
|
|
||||||
@ -318,16 +331,15 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
// sql
|
// sql
|
||||||
String sql = "select gid, state_name, the_geom from pgstates where persons between %low% and %high% and state_abbr = '%state%'";
|
String sql = "select gid, state_name, the_geom from pgstates where persons between %low% and %high% and state_abbr = '%state%'";
|
||||||
|
|
||||||
//set-up the virtual table
|
// set-up the virtual table
|
||||||
final GSVirtualTableEncoder vte = new GSVirtualTableEncoder();
|
final GSVirtualTableEncoder vte = new GSVirtualTableEncoder();
|
||||||
vte.setName(nativeName);
|
vte.setName(nativeName);
|
||||||
vte.setSql(sql);
|
vte.setSql(sql);
|
||||||
vte.addVirtualTableGeometry(vtGeom);
|
vte.addVirtualTableGeometry(vtGeom);
|
||||||
vte.addVirtualTableParameter(vtParam1);
|
vte.addVirtualTableParameter(vtParam1);
|
||||||
vte.addVirtualTableParameter(vtParam2);
|
vte.addVirtualTableParameter(vtParam2);
|
||||||
fte.setMetadataVirtualTable(vte); //Set the virtual table
|
|
||||||
|
|
||||||
//modif the vte
|
// modif the vte
|
||||||
vte.delVirtualTableGeometry("the_geom");
|
vte.delVirtualTableGeometry("the_geom");
|
||||||
vte.addVirtualTableGeometry("the_geom", "MultiPolygon", "4326");
|
vte.addVirtualTableGeometry("the_geom", "MultiPolygon", "4326");
|
||||||
|
|
||||||
@ -335,17 +347,19 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
vte.addVirtualTableParameter(vtParam3);
|
vte.addVirtualTableParameter(vtParam3);
|
||||||
vte.addKeyColumn("gid");
|
vte.addKeyColumn("gid");
|
||||||
|
|
||||||
//Layer encoder
|
fte.setMetadataVirtualTable(vte); // Set the virtual table
|
||||||
//-------------
|
|
||||||
|
// Layer encoder
|
||||||
|
// -------------
|
||||||
GSLayerEncoder layerEncoder = new GSLayerEncoder();
|
GSLayerEncoder layerEncoder = new GSLayerEncoder();
|
||||||
layerEncoder.setEnabled(true);
|
layerEncoder.setEnabled(true);
|
||||||
layerEncoder.setQueryable(true);
|
layerEncoder.setQueryable(true);
|
||||||
layerEncoder.setDefaultStyle("polygon");
|
layerEncoder.setDefaultStyle("polygon");
|
||||||
|
|
||||||
// test insert
|
// test insert
|
||||||
//------------
|
// ------------
|
||||||
publisher.createWorkspace(DEFAULT_WS);
|
publisher.createWorkspace(DEFAULT_WS);
|
||||||
boolean published = publisher.publishDBLayer(DEFAULT_WS, storeName, fte, layerEncoder);
|
published = publisher.publishDBLayer(DEFAULT_WS, storeName, fte, layerEncoder);
|
||||||
assertTrue("Publication unsuccessful", published);
|
assertTrue("Publication unsuccessful", published);
|
||||||
assertTrue("Layer does not exist", existsLayer(layerName));
|
assertTrue("Layer does not exist", existsLayer(layerName));
|
||||||
|
|
||||||
|
|||||||
@ -39,27 +39,28 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
if (!enabled()) {
|
if (!enabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
deleteAll();
|
||||||
|
|
||||||
|
publisher.createWorkspace(DEFAULT_WS);
|
||||||
|
|
||||||
// crea the manager
|
// crea the manager
|
||||||
GeoServerRESTStructuredGridCoverageReaderManager manager =
|
GeoServerRESTStructuredGridCoverageReaderManager manager =
|
||||||
new GeoServerRESTStructuredGridCoverageReaderManager(new URL(RESTURL), RESTUSER, RESTPW);
|
new GeoServerRESTStructuredGridCoverageReaderManager(new URL(RESTURL), RESTUSER, RESTPW);
|
||||||
|
|
||||||
// create mosaic
|
// create mosaic
|
||||||
final String workspaceName = "it.geosolutions";
|
|
||||||
final String coverageStoreName = "mosaic";
|
final String coverageStoreName = "mosaic";
|
||||||
final String coverageName = "mosaic";
|
final String coverageName = "mosaic";
|
||||||
final String format = "imagemosaic";
|
final String format = "imagemosaic";
|
||||||
|
|
||||||
// upload the mosaic
|
// upload the mosaic
|
||||||
boolean create=manager.create(workspaceName, coverageStoreName,new ClassPathResource("testdata/granules/mosaic.zip").getFile().getAbsolutePath());
|
boolean create=manager.create(DEFAULT_WS, coverageStoreName,new ClassPathResource("testdata/granules/mosaic.zip").getFile().getAbsolutePath());
|
||||||
assertTrue(create);
|
assertTrue(create);
|
||||||
|
|
||||||
// enable dimension
|
// enable dimension
|
||||||
fixDimensions(workspaceName, coverageStoreName, coverageName);
|
fixDimensions(DEFAULT_WS, coverageStoreName, coverageName);
|
||||||
|
|
||||||
// check index format
|
// check index format
|
||||||
RESTStructuredCoverageIndexSchema indexFormat = manager.getGranuleIndexSchema(workspaceName, coverageName,coverageName);
|
RESTStructuredCoverageIndexSchema indexFormat = manager.getGranuleIndexSchema(DEFAULT_WS, coverageName,coverageName);
|
||||||
assertTrue(create);
|
|
||||||
|
|
||||||
assertNotNull(indexFormat);
|
assertNotNull(indexFormat);
|
||||||
assertFalse(indexFormat.isEmpty());
|
assertFalse(indexFormat.isEmpty());
|
||||||
assertEquals(5, indexFormat.size());
|
assertEquals(5, indexFormat.size());
|
||||||
@ -95,14 +96,14 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
|
|
||||||
|
|
||||||
// get with paging
|
// get with paging
|
||||||
granulesList = manager.getGranules(workspaceName, coverageStoreName, coverageName , null, 0, 1);
|
granulesList = manager.getGranules(DEFAULT_WS, coverageStoreName, coverageName , null, 0, 1);
|
||||||
assertNotNull(granulesList);
|
assertNotNull(granulesList);
|
||||||
assertEquals(1, granulesList.size());
|
assertEquals(1, granulesList.size());
|
||||||
assertFalse(granulesList.isEmpty());
|
assertFalse(granulesList.isEmpty());
|
||||||
granule = granulesList.get(0);
|
granule = granulesList.get(0);
|
||||||
assertNotNull(granule);
|
assertNotNull(granule);
|
||||||
|
|
||||||
granulesList = manager.getGranules(workspaceName, coverageStoreName, coverageName, null, null, 2);
|
granulesList = manager.getGranules(DEFAULT_WS, coverageStoreName, coverageName, null, null, 2);
|
||||||
assertNotNull(granulesList);
|
assertNotNull(granulesList);
|
||||||
assertEquals(2, granulesList.size());
|
assertEquals(2, granulesList.size());
|
||||||
assertFalse(granulesList.isEmpty());
|
assertFalse(granulesList.isEmpty());
|
||||||
@ -110,7 +111,7 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
assertNotNull(granule);
|
assertNotNull(granule);
|
||||||
|
|
||||||
// get with no paging
|
// get with no paging
|
||||||
granulesList = manager.getGranules(workspaceName, coverageStoreName, coverageName);
|
granulesList = manager.getGranules(DEFAULT_WS, coverageStoreName, coverageName);
|
||||||
assertNotNull(granulesList);
|
assertNotNull(granulesList);
|
||||||
assertEquals(4, granulesList.size());
|
assertEquals(4, granulesList.size());
|
||||||
assertFalse(granulesList.isEmpty());
|
assertFalse(granulesList.isEmpty());
|
||||||
@ -118,21 +119,21 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
assertNotNull(granule);
|
assertNotNull(granule);
|
||||||
|
|
||||||
// examples of filtering with CQL
|
// examples of filtering with CQL
|
||||||
granulesList = manager.getGranules(workspaceName, coverageStoreName, coverageName, "depth = 100", null, null);
|
granulesList = manager.getGranules(DEFAULT_WS, coverageStoreName, coverageName, "depth = 100", null, null);
|
||||||
assertNotNull(granulesList);
|
assertNotNull(granulesList);
|
||||||
assertEquals(2, granulesList.size());
|
assertEquals(2, granulesList.size());
|
||||||
assertFalse(granulesList.isEmpty());
|
assertFalse(granulesList.isEmpty());
|
||||||
granule = granulesList.get(0);
|
granule = granulesList.get(0);
|
||||||
assertNotNull(granule);
|
assertNotNull(granule);
|
||||||
|
|
||||||
granulesList = manager.getGranules(workspaceName, coverageStoreName, coverageName, "depth = 100 AND date='20081101T0000000'", null, null);
|
granulesList = manager.getGranules(DEFAULT_WS, coverageStoreName, coverageName, "depth = 100 AND date='20081101T0000000'", null, null);
|
||||||
assertNotNull(granulesList);
|
assertNotNull(granulesList);
|
||||||
assertEquals(1, granulesList.size());
|
assertEquals(1, granulesList.size());
|
||||||
assertFalse(granulesList.isEmpty());
|
assertFalse(granulesList.isEmpty());
|
||||||
granule = granulesList.get(0);
|
granule = granulesList.get(0);
|
||||||
assertNotNull(granule);
|
assertNotNull(granule);
|
||||||
|
|
||||||
granulesList = manager.getGranules(workspaceName, coverageStoreName, coverageName, "location LIKE 'NCOM_wattemp%'", 0, 1);
|
granulesList = manager.getGranules(DEFAULT_WS, coverageStoreName, coverageName, "location LIKE 'NCOM_wattemp%'", 0, 1);
|
||||||
assertNotNull(granulesList);
|
assertNotNull(granulesList);
|
||||||
assertEquals(1, granulesList.size());
|
assertEquals(1, granulesList.size());
|
||||||
assertFalse(granulesList.isEmpty());
|
assertFalse(granulesList.isEmpty());
|
||||||
@ -141,21 +142,21 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
|
|
||||||
// remove by filter
|
// remove by filter
|
||||||
final String fileLocation = "NCOM_wattemp_100_20081101T0000000_12.tiff";
|
final String fileLocation = "NCOM_wattemp_100_20081101T0000000_12.tiff";
|
||||||
boolean result = manager.removeGranulesByCQL(workspaceName, coverageStoreName, coverageName, "location = '" + fileLocation + "'");
|
boolean result = manager.removeGranulesByCQL(DEFAULT_WS, coverageStoreName, coverageName, "location = '" + fileLocation + "'");
|
||||||
Assert.assertTrue(result);
|
Assert.assertTrue(result);
|
||||||
|
|
||||||
granulesList = manager.getGranules(workspaceName, coverageStoreName, coverageName);
|
granulesList = manager.getGranules(DEFAULT_WS, coverageStoreName, coverageName);
|
||||||
assertNotNull(granulesList);
|
assertNotNull(granulesList);
|
||||||
assertEquals(3, granulesList.size());
|
|
||||||
assertFalse(granulesList.isEmpty());
|
assertFalse(granulesList.isEmpty());
|
||||||
|
assertEquals(4, granulesList.size());
|
||||||
granule = granulesList.get(0);
|
granule = granulesList.get(0);
|
||||||
assertNotNull(granule);
|
assertNotNull(granule);
|
||||||
|
|
||||||
// Readding that granule with harvest
|
// Readding that granule with harvest
|
||||||
result = manager.harvestExternal(workspaceName, coverageStoreName, format, new ClassPathResource("testdata/granules/NCOM_wattemp_100_20081101T0000000_12.tiff").getFile().getAbsolutePath() );
|
result = manager.harvestExternal(DEFAULT_WS, coverageStoreName, format, new ClassPathResource("testdata/granules/NCOM_wattemp_100_20081101T0000000_12.tiff").getFile().getAbsolutePath() );
|
||||||
Assert.assertTrue(result);
|
Assert.assertTrue(result);
|
||||||
|
|
||||||
granulesList = manager.getGranules(workspaceName, coverageStoreName, coverageName, null, null, null);
|
granulesList = manager.getGranules(DEFAULT_WS, coverageStoreName, coverageName, null, null, null);
|
||||||
assertNotNull(granulesList);
|
assertNotNull(granulesList);
|
||||||
assertEquals(4, granulesList.size());
|
assertEquals(4, granulesList.size());
|
||||||
assertFalse(granulesList.isEmpty());
|
assertFalse(granulesList.isEmpty());
|
||||||
@ -164,7 +165,7 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
|
|
||||||
|
|
||||||
// delete
|
// delete
|
||||||
delete(workspaceName, coverageStoreName);
|
delete(DEFAULT_WS, coverageStoreName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -218,6 +219,8 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
String csname) throws NumberFormatException {
|
String csname) throws NumberFormatException {
|
||||||
// get current config for the coverage to extract the params we want to set again
|
// get current config for the coverage to extract the params we want to set again
|
||||||
final RESTCoverage coverage = reader.getCoverage(wsName, coverageStoreName, csname);
|
final RESTCoverage coverage = reader.getCoverage(wsName, coverageStoreName, csname);
|
||||||
|
if (coverage==null)
|
||||||
|
return null;
|
||||||
final Map<String, String> params = coverage.getParametersList();
|
final Map<String, String> params = coverage.getParametersList();
|
||||||
|
|
||||||
// prepare and fill the encoder
|
// prepare and fill the encoder
|
||||||
|
|||||||
@ -79,8 +79,8 @@ public class GeoserverRESTDatastoreManagerTest extends StoreIntegrationTest {
|
|||||||
private static URL LOCATION_2;
|
private static URL LOCATION_2;
|
||||||
|
|
||||||
public GeoserverRESTDatastoreManagerTest() throws Exception {
|
public GeoserverRESTDatastoreManagerTest() throws Exception {
|
||||||
super(true);
|
super(false);
|
||||||
LOCATION_1 = new URL("file:data/1");
|
LOCATION_1 = new URL("file:data/shapefiles/");
|
||||||
LOCATION_2 = new URL("file:data/2");
|
LOCATION_2 = new URL("file:data/2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -108,7 +108,7 @@ public class GeoserverRESTGeoTiffTest extends GeoserverRESTTest {
|
|||||||
assertTrue("publish() failed", pub);
|
assertTrue("publish() failed", pub);
|
||||||
|
|
||||||
double[] bbox = {-103.85, 44.38, -103.62, 44.50};
|
double[] bbox = {-103.85, 44.38, -103.62, 44.50};
|
||||||
pub = publisher.publishGeoTIFF(DEFAULT_WS, storeName+"another_complex", "layername_complex", geotiff, "EPSG:4326", ProjectionPolicy.REPROJECT_TO_DECLARED, "raster", bbox);
|
pub = publisher.publishGeoTIFF(DEFAULT_WS, storeName+"another_complex", storeName+"another_complex", geotiff, "EPSG:4326", ProjectionPolicy.REPROJECT_TO_DECLARED, "raster", bbox);
|
||||||
|
|
||||||
assertTrue("publish() failed", pub);
|
assertTrue("publish() failed", pub);
|
||||||
|
|
||||||
|
|||||||
@ -29,9 +29,11 @@ package it.geosolutions.geoserver.rest.publisher;
|
|||||||
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.ParameterConfigure;
|
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.ParameterConfigure;
|
||||||
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTCoverageStore;
|
import it.geosolutions.geoserver.rest.decoder.RESTCoverageStore;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
||||||
import it.geosolutions.geoserver.rest.encoder.coverage.GSImageMosaicEncoder;
|
import it.geosolutions.geoserver.rest.encoder.coverage.GSImageMosaicEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.dimensions.GSCoverageDimensionEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
||||||
|
|
||||||
@ -42,6 +44,7 @@ import java.io.IOException;
|
|||||||
import org.apache.commons.httpclient.NameValuePair;
|
import org.apache.commons.httpclient.NameValuePair;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
@ -91,7 +94,7 @@ public class GeoserverRESTImageMosaicTest extends GeoserverRESTTest {
|
|||||||
* or create a new one from an existing store:
|
* or create a new one from an existing store:
|
||||||
* publisher.createCoverage(ce, wsname, csname);
|
* publisher.createCoverage(ce, wsname, csname);
|
||||||
*/
|
*/
|
||||||
coverageEncoder.setName("CoverageName");
|
// coverageEncoder.setName("time_geotiff");
|
||||||
|
|
||||||
coverageEncoder.setAllowMultithreading(true);
|
coverageEncoder.setAllowMultithreading(true);
|
||||||
coverageEncoder.setBackgroundValues("");
|
coverageEncoder.setBackgroundValues("");
|
||||||
@ -105,13 +108,24 @@ public class GeoserverRESTImageMosaicTest extends GeoserverRESTTest {
|
|||||||
coverageEncoder.setSRS("EPSG:4326");
|
coverageEncoder.setSRS("EPSG:4326");
|
||||||
coverageEncoder.setSUGGESTED_TILE_SIZE("256,256");
|
coverageEncoder.setSUGGESTED_TILE_SIZE("256,256");
|
||||||
coverageEncoder.setUSE_JAI_IMAGEREAD(true);
|
coverageEncoder.setUSE_JAI_IMAGEREAD(true);
|
||||||
// activate time
|
|
||||||
final GSDimensionInfoEncoder time=new GSDimensionInfoEncoder(true);
|
GSVersionDecoder v=reader.getGeoserverVersion();
|
||||||
time.setPresentation(Presentation.LIST);
|
if (v.compareTo(GSVersionDecoder.VERSION.v24)>=0){
|
||||||
// set time metadata
|
GSCoverageDimensionEncoder gsCoverageDimensionEncoder = new GSCoverageDimensionEncoder(
|
||||||
coverageEncoder.setMetadata("time", time);
|
"GRAY_INDEX", "GridSampleDimension[-Infinity,Infinity]", "-inf", "inf",
|
||||||
// not active elevation
|
"dobson units³", "REAL_32BITS");
|
||||||
coverageEncoder.setMetadata("elevation", new GSDimensionInfoEncoder());
|
coverageEncoder.addCoverageDimensionInfo(gsCoverageDimensionEncoder);
|
||||||
|
}
|
||||||
|
|
||||||
|
// activate time
|
||||||
|
final GSDimensionInfoEncoder time=new GSDimensionInfoEncoder(true);
|
||||||
|
time.setPresentation(Presentation.LIST);
|
||||||
|
// set time metadata
|
||||||
|
coverageEncoder.setMetadata("time", time);
|
||||||
|
// not active elevation
|
||||||
|
coverageEncoder.setMetadata("elevation", new GSDimensionInfoEncoder());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
assertTrue(publisher.createWorkspace(wsName));
|
assertTrue(publisher.createWorkspace(wsName));
|
||||||
|
|
||||||
|
|||||||
@ -62,7 +62,7 @@ public class GeoserverRESTPostgisDatastoreTest extends StoreIntegrationTest {
|
|||||||
|
|
||||||
public GeoserverRESTPostgisDatastoreTest()
|
public GeoserverRESTPostgisDatastoreTest()
|
||||||
throws IllegalArgumentException, MalformedURLException {
|
throws IllegalArgumentException, MalformedURLException {
|
||||||
super(System.getProperty("pgIgnore", "false").equalsIgnoreCase("true"));
|
super(System.getProperty("pgIgnore", "true").equalsIgnoreCase("true"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
247
src/test/resources/testdata/coverageExample.xml
vendored
247
src/test/resources/testdata/coverageExample.xml
vendored
@ -1,115 +1,136 @@
|
|||||||
|
|
||||||
<coverage>
|
<coverage>
|
||||||
<name>granuleTestMosaic</name>
|
<name>granuleTestMosaic</name>
|
||||||
<nativeName>granuleTestMosaic</nativeName>
|
<nativeName>granuleTestMosaic</nativeName>
|
||||||
<abstract>this is an abstract</abstract>
|
<abstract>this is an abstract</abstract>
|
||||||
<namespace>
|
<namespace>
|
||||||
<name>topp</name>
|
<name>topp</name>
|
||||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/namespaces/topp.xml" type="application/xml"/>
|
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate"
|
||||||
</namespace>
|
href="http://localhost:8080/geoserver/rest/namespaces/topp.xml" type="application/xml" />
|
||||||
<title>granuleTestMosaic</title>
|
</namespace>
|
||||||
<keywords>
|
<title>granuleTestMosaic</title>
|
||||||
<string>keyword1</string>
|
<keywords>
|
||||||
<string>keyword2</string>
|
<string>keyword1</string>
|
||||||
<string>keyword3</string>
|
<string>keyword2</string>
|
||||||
</keywords>
|
<string>keyword3</string>
|
||||||
<metadataLinks>
|
</keywords>
|
||||||
<metadataLink>
|
<metadataLinks>
|
||||||
<type>text/xml</type>
|
<metadataLink>
|
||||||
<metadataType>ISO19115:2003</metadataType>
|
<type>text/xml</type>
|
||||||
<content>http://www.organization.org/metadata1</content>
|
<metadataType>ISO19115:2003</metadataType>
|
||||||
</metadataLink>
|
<content>http://www.organization.org/metadata1</content>
|
||||||
<metadataLink>
|
</metadataLink>
|
||||||
<type>text/html</type>
|
<metadataLink>
|
||||||
<metadataType>ISO19115:2003</metadataType>
|
<type>text/html</type>
|
||||||
<content>http://www.organization.org/metadata2</content>
|
<metadataType>ISO19115:2003</metadataType>
|
||||||
</metadataLink>
|
<content>http://www.organization.org/metadata2</content>
|
||||||
</metadataLinks>
|
</metadataLink>
|
||||||
<nativeCRS>GEOGCS["WGS 84", 
|
</metadataLinks>
|
||||||
DATUM["World Geodetic System 1984", 
|
<nativeCRS>GEOGCS["WGS 84", 
|
||||||
SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], 
|
DATUM["World Geodetic
|
||||||
AUTHORITY["EPSG","6326"]], 
|
System 1984", 
|
||||||
PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], 
|
SPHEROID["WGS 84", 6378137.0,
|
||||||
UNIT["degree", 0.017453292519943295], 
|
298.257223563,
|
||||||
AXIS["Geodetic longitude", EAST], 
|
AUTHORITY["EPSG","7030"]], 
|
||||||
AXIS["Geodetic latitude", NORTH], 
|
AUTHORITY["EPSG","6326"]], 
|
||||||
AUTHORITY["EPSG","4326"]]</nativeCRS>
|
PRIMEM["Greenwich", 0.0,
|
||||||
<srs>EPSG:4326</srs>
|
AUTHORITY["EPSG","8901"]], 
|
||||||
<nativeBoundingBox>
|
UNIT["degree", 0.017453292519943295], 
|
||||||
<minx>-180.0</minx>
|
AXIS["Geodetic longitude", EAST], 
|
||||||
<maxx>180.0</maxx>
|
AXIS["Geodetic
|
||||||
<miny>-90.0</miny>
|
latitude", NORTH], 
|
||||||
<maxy>90.0</maxy>
|
AUTHORITY["EPSG","4326"]]</nativeCRS>
|
||||||
<crs>EPSG:4326</crs>
|
<srs>EPSG:4326</srs>
|
||||||
</nativeBoundingBox>
|
<nativeBoundingBox>
|
||||||
<latLonBoundingBox>
|
<minx>-180.0</minx>
|
||||||
<minx>-180.0</minx>
|
<maxx>180.0</maxx>
|
||||||
<maxx>180.0</maxx>
|
<miny>-90.0</miny>
|
||||||
<miny>-90.0</miny>
|
<maxy>90.0</maxy>
|
||||||
<maxy>90.0</maxy>
|
<crs>EPSG:4326</crs>
|
||||||
<crs>EPSG:4326</crs>
|
</nativeBoundingBox>
|
||||||
</latLonBoundingBox>
|
<latLonBoundingBox>
|
||||||
<projectionPolicy>NONE</projectionPolicy>
|
<minx>-180.0</minx>
|
||||||
<enabled>true</enabled>
|
<maxx>180.0</maxx>
|
||||||
<advertised>true</advertised>
|
<miny>-90.0</miny>
|
||||||
<metadata>
|
<maxy>90.0</maxy>
|
||||||
<entry key="time">
|
<crs>EPSG:4326</crs>
|
||||||
<dimensionInfo>
|
</latLonBoundingBox>
|
||||||
<enabled>true</enabled>
|
<projectionPolicy>NONE</projectionPolicy>
|
||||||
<presentation>LIST</presentation>
|
<enabled>true</enabled>
|
||||||
</dimensionInfo>
|
<advertised>true</advertised>
|
||||||
</entry>
|
<metadata>
|
||||||
<entry key="elevation">
|
<entry key="time">
|
||||||
<dimensionInfo>
|
<dimensionInfo>
|
||||||
<enabled>true</enabled>
|
<enabled>true</enabled>
|
||||||
<presentation>DISCRETE_INTERVAL</presentation>
|
<presentation>LIST</presentation>
|
||||||
<resolution>2</resolution>
|
</dimensionInfo>
|
||||||
</dimensionInfo>
|
</entry>
|
||||||
</entry>
|
<entry key="elevation">
|
||||||
</metadata>
|
<dimensionInfo>
|
||||||
<store class="coverageStore">
|
<enabled>true</enabled>
|
||||||
<name>granuleTestMosaic</name>
|
<presentation>DISCRETE_INTERVAL</presentation>
|
||||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/topp/coveragestores/granuleTestMosaic.xml" type="application/xml"/>
|
<resolution>2</resolution>
|
||||||
</store>
|
</dimensionInfo>
|
||||||
<grid dimension="2">
|
</entry>
|
||||||
<range>
|
</metadata>
|
||||||
<low>0 0</low>
|
<store class="coverageStore">
|
||||||
<high>540 270</high>
|
<name>granuleTestMosaic</name>
|
||||||
</range>
|
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate"
|
||||||
<transform>
|
href="http://localhost:8080/geoserver/rest/workspaces/topp/coveragestores/granuleTestMosaic.xml"
|
||||||
<scaleX>0.6666666666666666</scaleX>
|
type="application/xml" />
|
||||||
<scaleY>-0.6666666666666666</scaleY>
|
</store>
|
||||||
<shearX>0.0</shearX>
|
<grid dimension="2">
|
||||||
<shearY>0.0</shearY>
|
<range>
|
||||||
<translateX>-179.66666666666666</translateX>
|
<low>0 0</low>
|
||||||
<translateY>89.66666666666667</translateY>
|
<high>540 270</high>
|
||||||
</transform>
|
</range>
|
||||||
<crs>EPSG:4326</crs>
|
<transform>
|
||||||
</grid>
|
<scaleX>0.6666666666666666</scaleX>
|
||||||
<parameters>
|
<scaleY>-0.6666666666666666</scaleY>
|
||||||
<entry>
|
<shearX>0.0</shearX>
|
||||||
<string>AllowMultithreading</string>
|
<shearY>0.0</shearY>
|
||||||
<string>false</string>
|
<translateX>-179.66666666666666</translateX>
|
||||||
</entry>
|
<translateY>89.66666666666667</translateY>
|
||||||
<entry>
|
</transform>
|
||||||
<string>MaxAllowedTiles</string>
|
<crs>EPSG:4326</crs>
|
||||||
<string>2147483647</string>
|
</grid>
|
||||||
</entry>
|
<dimensions>
|
||||||
<entry>
|
<coverageDimension>
|
||||||
<string>InputTransparentColor</string>
|
<name>GRAY_INDEX</name>
|
||||||
<string></string>
|
<description>GridSampleDimension[-Infinity,Infinity]</description>
|
||||||
</entry>
|
<range>
|
||||||
<entry>
|
<min>-inf</min>
|
||||||
<string>SUGGESTED_TILE_SIZE</string>
|
<max>inf</max>
|
||||||
<string>256,256</string>
|
</range>
|
||||||
</entry>
|
<unit>dobson units³</unit>
|
||||||
<entry>
|
<dimensionType>
|
||||||
<string>USE_JAI_IMAGEREAD</string>
|
<name>REAL_32BITS</name>
|
||||||
<string>false</string>
|
</dimensionType>
|
||||||
</entry>
|
</coverageDimension>
|
||||||
<entry>
|
</dimensions>
|
||||||
<string>BackgroundValues</string>
|
<parameters>
|
||||||
<string>-1.0</string>
|
<entry>
|
||||||
</entry>
|
<string>AllowMultithreading</string>
|
||||||
</parameters>
|
<string>false</string>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>MaxAllowedTiles</string>
|
||||||
|
<string>2147483647</string>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>InputTransparentColor</string>
|
||||||
|
<string></string>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>SUGGESTED_TILE_SIZE</string>
|
||||||
|
<string>256,256</string>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>USE_JAI_IMAGEREAD</string>
|
||||||
|
<string>false</string>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>BackgroundValues</string>
|
||||||
|
<string>-1.0</string>
|
||||||
|
</entry>
|
||||||
|
</parameters>
|
||||||
</coverage>
|
</coverage>
|
||||||
Loading…
Reference in New Issue
Block a user