commit
8073671631
@ -32,6 +32,7 @@ import it.geosolutions.geoserver.rest.decoder.RESTCoverageStoreList;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTDataStoreList;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTFeatureType;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTFeatureTypeList;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTLayerGroup;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTLayerGroupList;
|
||||
@ -524,6 +525,19 @@ public class GeoServerRESTReader {
|
||||
}
|
||||
return RESTLayerList.build(load(url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get summary info about all FeatureTypes of a workspace.
|
||||
*
|
||||
* @return summary info about Layers as a {@link RESTLayerList}
|
||||
*/
|
||||
public RESTFeatureTypeList getFeatureTypes(String workspace) {
|
||||
String url = "/rest/workspaces/" + workspace + "/featuretypes.xml";
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("### Retrieving featuretypes from " + url);
|
||||
}
|
||||
return RESTFeatureTypeList.build(load(url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get detailed info about a given Layer.
|
||||
|
||||
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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 FeatureTypes.
|
||||
*
|
||||
*
|
||||
* FeatureType summary info.
|
||||
* <BR>This is an XML fragment:
|
||||
* <PRE>
|
||||
*{@code
|
||||
<featureType>
|
||||
<name>states</name>
|
||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate"
|
||||
href="http://localhost:8080/geoserver/rest/workspaces/topp/featuretypes/states.xml"
|
||||
type="application/xml"/>
|
||||
</featureType>
|
||||
* }
|
||||
* </PRE>
|
||||
*
|
||||
* @author wumpz
|
||||
*/
|
||||
public class RESTFeatureTypeList extends RESTAbstractList<NameLinkElem> {
|
||||
|
||||
public static RESTFeatureTypeList build(String response) {
|
||||
Element elem = JDOMBuilder.buildElement(response);
|
||||
return elem == null? null : new RESTFeatureTypeList(elem);
|
||||
}
|
||||
|
||||
protected RESTFeatureTypeList(Element list) {
|
||||
super(list);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
package it.geosolutions.geoserver.rest.decoder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author toben
|
||||
*/
|
||||
public class RESTFeatureTypeListTest {
|
||||
|
||||
public RESTFeatureTypeListTest() {
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuild() throws IOException {
|
||||
InputStream is = RESTFeatureTypeListTest.class.getResourceAsStream("/testdata/featureTypeListExample.xml");
|
||||
String response = IOUtils.toString(is);
|
||||
is.close();
|
||||
RESTFeatureTypeList result = RESTFeatureTypeList.build(response);
|
||||
List<String> list = result.getNames();
|
||||
|
||||
assertArrayEquals(new String[]{"states", "tasmania_cities", "tasmania_roads", "tasmania_state_boundaries", "tasmania_water_bodies"}
|
||||
, list.toArray());
|
||||
}
|
||||
}
|
||||
22
src/test/resources/testdata/featureTypeListExample.xml
vendored
Normal file
22
src/test/resources/testdata/featureTypeListExample.xml
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
<featureTypes>
|
||||
<featureType>
|
||||
<name>states</name>
|
||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/topp/featuretypes/states.xml" type="application/xml"/>
|
||||
</featureType>
|
||||
<featureType>
|
||||
<name>tasmania_cities</name>
|
||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/topp/featuretypes/tasmania_cities.xml" type="application/xml"/>
|
||||
</featureType>
|
||||
<featureType>
|
||||
<name>tasmania_roads</name>
|
||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/topp/featuretypes/tasmania_roads.xml" type="application/xml"/>
|
||||
</featureType>
|
||||
<featureType>
|
||||
<name>tasmania_state_boundaries</name>
|
||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/topp/featuretypes/tasmania_state_boundaries.xml" type="application/xml"/>
|
||||
</featureType>
|
||||
<featureType>
|
||||
<name>tasmania_water_bodies</name>
|
||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/topp/featuretypes/tasmania_water_bodies.xml" type="application/xml"/>
|
||||
</featureType>
|
||||
</featureTypes>
|
||||
Loading…
Reference in New Issue
Block a user