Added classes for WMS backends
This commit is contained in:
parent
213ed8326d
commit
4241e4d83d
@ -45,6 +45,10 @@ import it.geosolutions.geoserver.rest.decoder.RESTStructuredCoverageGranulesList
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTStructuredCoverageIndexSchema;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTStyle;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTStyleList;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTWms;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTWmsList;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTWmsStore;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTWmsStoreList;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTWorkspaceList;
|
||||
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
||||
import it.geosolutions.geoserver.rest.manager.GeoServerRESTStructuredGridCoverageReaderManager;
|
||||
@ -544,6 +548,153 @@ public class GeoServerRESTReader {
|
||||
return RESTCoverage.build(response);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//=== WMSSTORES
|
||||
//==========================================================================
|
||||
|
||||
/**
|
||||
* Get summary info about all WmsStore in a WorkSpace.
|
||||
*
|
||||
* @param workspace The name of the workspace
|
||||
*
|
||||
* @return summary info about CoverageStores as a {@link RESTWmsStoreList}
|
||||
*/
|
||||
public RESTWmsStoreList getWmsStores(String workspace) {
|
||||
String url = "/rest/workspaces/" + workspace + "/wmsstores.xml";
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("### Retrieving CS list from " + url);
|
||||
}
|
||||
return RESTWmsStoreList.build(load(url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get detailed info about a given WmsStore in a given Workspace.
|
||||
*
|
||||
* @param workspace The name of the workspace
|
||||
* @param wsName The name of the WmsStore
|
||||
* @return WmsStore details as a {@link RESTWmsStore}
|
||||
*/
|
||||
public RESTWmsStore getWmsStore(String workspace, String wsName) {
|
||||
String url = "/rest/workspaces/" + workspace + "/wmsstores/" + wsName + ".xml";
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("### Retrieving CS from " + url);
|
||||
}
|
||||
return RESTWmsStore.build(load(url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get detailed info about a Wms's Datastore.
|
||||
*
|
||||
* @param wms the RESTWms
|
||||
* @return wmsStore details as a {@link RESTWmsStore}
|
||||
*/
|
||||
public RESTWmsStore getWmsStore(RESTWms wms) {
|
||||
String url = wms.getStoreUrl();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("### Retrieving CS from fullurl " + url);
|
||||
}
|
||||
String response = loadFullURL(url);
|
||||
return RESTWmsStore.build(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the selected Wms store is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||
*
|
||||
* @param workspace workspace of the wmsstore
|
||||
* @param wsName name of the wmsstore
|
||||
* @param quietOnNotFound if true, no exception is logged
|
||||
* @return boolean indicating if the wmsstore exists
|
||||
*/
|
||||
public boolean existsWmsstore(String workspace, String wsName, boolean quietOnNotFound){
|
||||
String url = baseurl + "/rest/workspaces/" + workspace + "/wmsstores/" + wsName + ".xml";
|
||||
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||
return HTTPUtils.exists(composed, username, password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the selected wms store is present.
|
||||
*
|
||||
* @param workspace workspace of the wmsstore
|
||||
* @param wsName name of the wmsstore
|
||||
* @return boolean indicating if the wmsstore exists
|
||||
*/
|
||||
public boolean existsWmsstore(String workspace, String wsName){
|
||||
return existsCoveragestore(workspace, wsName, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//=== WMSS
|
||||
//==========================================================================
|
||||
|
||||
/**
|
||||
* Get list of wmss (usually only one).
|
||||
*
|
||||
* @param workspace The name of the workspace
|
||||
* @param wsName The name of the WmsStore
|
||||
* @return wms list as a {@link RESTWmsList}
|
||||
*/
|
||||
public RESTWmsList getWms(String workspace, String wsName) {
|
||||
String url = "/rest/workspaces/" + workspace + "/wmsstores/" + wsName + "/wmslayers.xml";
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("### Retrieving Wmss from " + url);
|
||||
}
|
||||
return RESTWmsList.build(load(url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get detailed info about a given Wms.
|
||||
*
|
||||
* @param workspace The name of the workspace
|
||||
* @param store The name of the WmsStore
|
||||
* @param name The name of the Wms
|
||||
* @return wms details as a {@link RESTwms}
|
||||
*/
|
||||
public RESTWms getWms(String workspace, String store, String name) {
|
||||
String url = "/rest/workspaces/" + workspace + "/wmsstores/" + store + "/wmslayers/"+name+".xml";
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("### Retrieving Wmss from " + url);
|
||||
}
|
||||
return RESTWms.build(load(url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the selected Wms is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||
*
|
||||
* @param workspace workspace of the wmsstore
|
||||
* @param wsName name of the wmsstore
|
||||
* @param name name of the wms
|
||||
* @param quietOnNotFound if true, no exception is logged
|
||||
* @return boolean indicating if the coverage exists
|
||||
*/
|
||||
public boolean existsWms(String workspace, String store, String name, boolean quietOnNotFound){
|
||||
String url = baseurl + "/rest/workspaces/" + workspace + "/wmsstores/" + store + "/wmslayers/"+name+".xml";
|
||||
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||
return HTTPUtils.exists(composed, username, password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the selected wms is present.
|
||||
*
|
||||
* @param workspace workspace of the wmsstore
|
||||
* @param store name of the wmsstore
|
||||
* @param name name of the wms
|
||||
* @return boolean indicating if the coverage exists
|
||||
*/
|
||||
public boolean existsWms(String workspace, String store, String name){
|
||||
return existsWms(workspace, store, name, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get detailed info about a Wms given the Layer where it's published with.
|
||||
*
|
||||
* @param layer A layer publishing the wmsStore
|
||||
* @return Wms details as a {@link RESTWms}
|
||||
*/
|
||||
public RESTWms getWms(RESTLayer layer) {
|
||||
String response = loadFullURL(layer.getResourceUrl());
|
||||
return RESTWms.build(response);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//==========================================================================
|
||||
|
||||
|
||||
@ -0,0 +1,306 @@
|
||||
/*
|
||||
* 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.decoder;
|
||||
|
||||
import it.geosolutions.geoserver.rest.decoder.utils.JDOMBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
/**
|
||||
* Parse <TT>WMS</TT>s returned as XML REST objects.
|
||||
*
|
||||
* <P>This is the XML REST representation:
|
||||
* <PRE>
|
||||
*{@code
|
||||
<wmsLayer>
|
||||
<name>comunilazio</name>
|
||||
<nativeName>lait:comunilazio</nativeName>
|
||||
<namespace>
|
||||
<name>arit</name>
|
||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://172.27.30.25:8080/geoserver/rest/namespaces/arit.xml" type="application/xml"/>
|
||||
</namespace>
|
||||
<title>comunilazio</title>
|
||||
<description/>
|
||||
<keywords>
|
||||
<string>features</string>
|
||||
<string>comunilazio</string>
|
||||
</keywords>
|
||||
<nativeCRS>
|
||||
GEOGCS["WGS 84", DATUM["World Geodetic System 1984", SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4326"]]
|
||||
</nativeCRS>
|
||||
<srs>EPSG:4326</srs>
|
||||
<nativeBoundingBox>
|
||||
<minx>11.4482128</minx>
|
||||
<maxx>14.0288013</maxx>
|
||||
<miny>40.7848334</miny>
|
||||
<maxy>42.8396541</maxy>
|
||||
<crs>EPSG:4326</crs>
|
||||
</nativeBoundingBox>
|
||||
<latLonBoundingBox>
|
||||
<minx>11.4482128</minx>
|
||||
<maxx>14.0288013</maxx>
|
||||
<miny>40.7848334</miny>
|
||||
<maxy>42.8396541</maxy>
|
||||
<crs>
|
||||
GEOGCS["WGS84(DD)", DATUM["WGS84", SPHEROID["WGS84", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]]
|
||||
</crs>
|
||||
</latLonBoundingBox>
|
||||
<projectionPolicy>FORCE_DECLARED</projectionPolicy>
|
||||
<enabled>true</enabled>
|
||||
<metadata>
|
||||
<entry key="cachingEnabled">false</entry>
|
||||
</metadata>
|
||||
<store class="wmsStore">
|
||||
<name>regione</name>
|
||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://172.27.30.25:8080/geoserver/rest/workspaces/arit/wmsstores/regione.xml" type="application/xml"/>
|
||||
</store>
|
||||
</wmsLayer>
|
||||
* }</PRE>
|
||||
*
|
||||
* @author cip
|
||||
*/
|
||||
public class RESTWms extends RESTResource {
|
||||
|
||||
|
||||
public static RESTWms build(String response) {
|
||||
Element elem = JDOMBuilder.buildElement(response);
|
||||
return elem == null? null : new RESTWms(elem);
|
||||
}
|
||||
|
||||
public RESTWms(Element resource) {
|
||||
super(resource);
|
||||
}
|
||||
|
||||
public RESTWms(RESTResource resource) {
|
||||
super(resource.rootElem);
|
||||
}
|
||||
|
||||
// public String getName() {
|
||||
// return rootElem.getChildText("name");
|
||||
// }
|
||||
|
||||
// public String getNativeName() {
|
||||
// return rootElem.getChildText("nativeName");
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// public String getNameSpace() {
|
||||
// return rootElem.getChild("namespace").getChildText("name");
|
||||
// }
|
||||
//
|
||||
// public String getTitle() {
|
||||
// return rootElem.getChildText("title");
|
||||
// }
|
||||
|
||||
public String getNativeCRS() {
|
||||
return rootElem.getChildText("nativeCRS");
|
||||
}
|
||||
|
||||
public String getSRS() {
|
||||
return rootElem.getChildText("srs");
|
||||
}
|
||||
|
||||
public RESTMetadataList getMetadataList() {
|
||||
return new RESTMetadataList(rootElem.getChild("metadata"));
|
||||
}
|
||||
|
||||
public List<RESTDimensionInfo> getDimensionInfo() {
|
||||
List<RESTDimensionInfo> listDim = new ArrayList<RESTDimensionInfo>();
|
||||
for (RESTMetadataList.RESTMetadataElement el : getMetadataList()){
|
||||
if(el.getKey().equals(RESTDimensionInfo.TIME) || el.getKey().equals(RESTDimensionInfo.ELEVATION)){
|
||||
listDim.add(new RESTDimensionInfo(el.getMetadataElem()));
|
||||
}
|
||||
}
|
||||
return listDim;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the list of parameters for this wms.
|
||||
*
|
||||
* @return a {@link Map} where the key is the name for the parameter and the value is the value for the parameter.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, String> getParametersList() {
|
||||
Map<String, String> paramsList = new HashMap<String, String>();
|
||||
|
||||
final Element paramsRoot = rootElem.getChild("parameters");
|
||||
if (paramsRoot != null) {
|
||||
final List<Element> params = paramsRoot.getChildren();
|
||||
if (params != null) {
|
||||
for (Element param : params) {
|
||||
final List<Element> values = param.getChildren();
|
||||
assert values.size()==2;
|
||||
paramsList.put(values.get(0).getValue(), values.get(1).getValue()); // save key and value
|
||||
}
|
||||
}
|
||||
}
|
||||
return paramsList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("RESTWms [");
|
||||
if (getNativeCRS() != null) {
|
||||
builder.append("getNativeCRS()=");
|
||||
builder.append(getNativeCRS());
|
||||
builder.append(", ");
|
||||
}
|
||||
if (getSRS() != null) {
|
||||
builder.append("getSRS()=");
|
||||
builder.append(getSRS());
|
||||
builder.append(", ");
|
||||
}
|
||||
if (getMetadataList() != null) {
|
||||
builder.append("getMetadataList()=");
|
||||
builder.append(getMetadataList());
|
||||
builder.append(", ");
|
||||
}
|
||||
if (getDimensionInfo() != null) {
|
||||
builder.append("getDimensionInfo()=");
|
||||
builder.append(getDimensionInfo());
|
||||
builder.append(", ");
|
||||
}
|
||||
if (getParametersList() != null) {
|
||||
builder.append("getParametersList()=");
|
||||
builder.append(getParametersList());
|
||||
builder.append(", ");
|
||||
}
|
||||
if (getName() != null) {
|
||||
builder.append("getName()=");
|
||||
builder.append(getName());
|
||||
builder.append(", ");
|
||||
}
|
||||
if (getTitle() != null) {
|
||||
builder.append("getTitle()=");
|
||||
builder.append(getTitle());
|
||||
builder.append(", ");
|
||||
}
|
||||
if (getNativeName() != null) {
|
||||
builder.append("getNativeName()=");
|
||||
builder.append(getNativeName());
|
||||
builder.append(", ");
|
||||
}
|
||||
if (getAbstract() != null) {
|
||||
builder.append("getAbstract()=");
|
||||
builder.append(getAbstract());
|
||||
builder.append(", ");
|
||||
}
|
||||
if (getNameSpace() != null) {
|
||||
builder.append("getNameSpace()=");
|
||||
builder.append(getNameSpace());
|
||||
builder.append(", ");
|
||||
}
|
||||
if (getStoreName() != null) {
|
||||
builder.append("getStoreName()=");
|
||||
builder.append(getStoreName());
|
||||
builder.append(", ");
|
||||
}
|
||||
if (getStoreType() != null) {
|
||||
builder.append("getStoreType()=");
|
||||
builder.append(getStoreType());
|
||||
builder.append(", ");
|
||||
}
|
||||
if (getStoreUrl() != null) {
|
||||
builder.append("getStoreUrl()=");
|
||||
builder.append(getStoreUrl());
|
||||
builder.append(", ");
|
||||
}
|
||||
if (getCRS() != null) {
|
||||
builder.append("getCRS()=");
|
||||
builder.append(getCRS());
|
||||
builder.append(", ");
|
||||
}
|
||||
builder.append("getMinX()=");
|
||||
builder.append(getMinX());
|
||||
builder.append(", getMaxX()=");
|
||||
builder.append(getMaxX());
|
||||
builder.append(", getMinY()=");
|
||||
builder.append(getMinY());
|
||||
builder.append(", getMaxY()=");
|
||||
builder.append(getMaxY());
|
||||
builder.append(", ");
|
||||
if (getAttributeList() != null) {
|
||||
builder.append("getAttributeList()=");
|
||||
builder.append(getAttributeList());
|
||||
builder.append(", ");
|
||||
}
|
||||
if (getEncodedAttributeList() != null) {
|
||||
builder.append("getEncodedAttributeList()=");
|
||||
builder.append(getEncodedAttributeList());
|
||||
builder.append(", ");
|
||||
}
|
||||
if (getEncodedMetadataLinkInfoList() != null) {
|
||||
builder.append("getEncodedMetadataLinkInfoList()=");
|
||||
builder.append(getEncodedMetadataLinkInfoList());
|
||||
}
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
// public String getStoreName() {
|
||||
// return rootElem.getChild("store").getChildText("name");
|
||||
// }
|
||||
//
|
||||
// public String getStoreType() {
|
||||
// return rootElem.getChild("store").getAttributeValue("class");
|
||||
// }
|
||||
|
||||
|
||||
// public String getStoreUrl() {
|
||||
// Element store = rootElem.getChild("store");
|
||||
// Element atom = store.getChild("link", Namespace.getNamespace("atom", "http://www.w3.org/2005/Atom"));
|
||||
// return atom.getAttributeValue("href");
|
||||
// }
|
||||
|
||||
// public String getBBCRS() {
|
||||
// Element elBBox = rootElem.getChild("latLonBoundingBox");
|
||||
// return elBBox.getChildText("crs");
|
||||
// }
|
||||
//
|
||||
// protected double getLatLonEdge(String edge) {
|
||||
// Element elBBox = rootElem.getChild("latLonBoundingBox");
|
||||
// return Double.parseDouble(elBBox.getChildText(edge));
|
||||
// }
|
||||
//
|
||||
// public double getMinX() {
|
||||
// return getLatLonEdge("minx");
|
||||
// }
|
||||
// public double getMaxX() {
|
||||
// return getLatLonEdge("maxx");
|
||||
// }
|
||||
// public double getMinY() {
|
||||
// return getLatLonEdge("miny");
|
||||
// }
|
||||
// public double getMaxY() {
|
||||
// return getLatLonEdge("maxy");
|
||||
// }
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.decoder;
|
||||
|
||||
import it.geosolutions.geoserver.rest.decoder.utils.JDOMBuilder;
|
||||
import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
/**
|
||||
* Parses list of summary data about Wms.
|
||||
*
|
||||
* <P>This is the XML REST representation:
|
||||
* <PRE>{@code <wmsLayers>
|
||||
<wmsLayer>
|
||||
<name>comunilazio</name>
|
||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://172.27.30.25:8080/geoserver/rest/workspaces/arit/wmsstores/regione/wmslayers/comunilazio.xml" type="application/xml"/>
|
||||
</wmsLayer>
|
||||
</wmsLayers>
|
||||
*
|
||||
}</PRE>
|
||||
*
|
||||
* @author cip
|
||||
*/
|
||||
public class RESTWmsList extends RESTAbstractList<NameLinkElem> {
|
||||
|
||||
public static RESTWmsList build(String response) {
|
||||
Element elem = JDOMBuilder.buildElement(response);
|
||||
return elem == null? null : new RESTWmsList(elem);
|
||||
}
|
||||
|
||||
protected RESTWmsList(Element list) {
|
||||
super(list);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* 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.decoder;
|
||||
|
||||
import it.geosolutions.geoserver.rest.decoder.utils.JDOMBuilder;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
/**
|
||||
* Parse <TT>WmsStore</TT>s returned as XML REST objects.
|
||||
* <P>
|
||||
* This is the XML document returned by GeoServer when requesting a WmsStore:
|
||||
* <PRE>
|
||||
* {@code
|
||||
<wmsStore>
|
||||
<name>regione</name>
|
||||
<type>WMS</type>
|
||||
<enabled>true</enabled>
|
||||
<workspace>
|
||||
<name>arit</name>
|
||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://172.27.30.25:8080/geoserver/rest/workspaces/arit.xml" type="application/xml"/>
|
||||
</workspace>
|
||||
<metadata>
|
||||
<entry key="useConnectionPooling">true</entry>
|
||||
</metadata>
|
||||
<__default>false</__default>
|
||||
<capabilitiesURL>http://www.regione.lazio.it/geoserver/wms</capabilitiesURL>
|
||||
<maxConnections>6</maxConnections>
|
||||
<readTimeout>60</readTimeout>
|
||||
<connectTimeout>30</connectTimeout>
|
||||
<wmsLayers>
|
||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://172.27.30.25:8080/geoserver/rest/workspaces/arit/wmsstores/regione/wmslayers.xml" type="application/xml"/>
|
||||
</wmsLayers>
|
||||
</wmsStore>
|
||||
* }
|
||||
* </PRE>
|
||||
*
|
||||
* <I>Note: the whole XML fragment is stored in memory. At the moment, there are
|
||||
* methods to retrieve only the more useful data.
|
||||
*
|
||||
* @author etj
|
||||
*/
|
||||
public class RESTWmsStore {
|
||||
private final Element cs;
|
||||
|
||||
|
||||
public RESTWmsStore(Element cs) {
|
||||
this.cs = cs;
|
||||
}
|
||||
|
||||
public static RESTWmsStore build(String response) {
|
||||
if(response == null)
|
||||
return null;
|
||||
if(response.isEmpty())
|
||||
return new RESTWmsStore(new Element("wmsStore")); // TODO check how to response
|
||||
|
||||
Element pb = JDOMBuilder.buildElement(response);
|
||||
if(pb != null)
|
||||
return new RESTWmsStore(pb);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return cs.getChildText("name");
|
||||
}
|
||||
|
||||
public String getWorkspaceName() {
|
||||
return cs.getChild("workspace").getChildText("name");
|
||||
}
|
||||
|
||||
public String getCapabilitiesURL() {
|
||||
return cs.getChildText("capabilitiesURL");
|
||||
}
|
||||
|
||||
public String getMaxConnections() {
|
||||
return cs.getChildText("maxConnections");
|
||||
}
|
||||
|
||||
public String getReadTimeout() {
|
||||
return cs.getChildText("readTimeout");
|
||||
}
|
||||
|
||||
public String getConnectTimeout() {
|
||||
return cs.getChildText("connectTimeout");
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return cs.getChildText("type");
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(getClass().getSimpleName())
|
||||
.append('[');
|
||||
if(cs == null)
|
||||
sb.append("null");
|
||||
else
|
||||
sb.append("name:").append(getName())
|
||||
.append(" wsname:").append(getWorkspaceName());
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.decoder;
|
||||
|
||||
import it.geosolutions.geoserver.rest.decoder.utils.JDOMBuilder;
|
||||
import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
/**
|
||||
* Parses list of summary data about WmsStores.
|
||||
*
|
||||
* <P>This is the XML REST representation:
|
||||
* <PRE>{@code
|
||||
<wmsStores>
|
||||
<wmsStore>
|
||||
<name>regione</name>
|
||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://172.27.30.25:8080/geoserver/rest/workspaces/arit/wmsstores/regione.xml" type="application/xml"/>
|
||||
</wmsStore>
|
||||
</wmsStores>
|
||||
*
|
||||
}</PRE>
|
||||
*
|
||||
* @author cip
|
||||
*/
|
||||
public class RESTWmsStoreList extends RESTAbstractList<NameLinkElem> {
|
||||
|
||||
public static RESTWmsStoreList build(String response) {
|
||||
Element elem = JDOMBuilder.buildElement(response);
|
||||
return elem == null? null : new RESTWmsStoreList(elem);
|
||||
}
|
||||
|
||||
protected RESTWmsStoreList(Element list) {
|
||||
super(list);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user