it.geosolutions.geoserver.rest
Class GeoServerRESTReader

java.lang.Object
  extended by it.geosolutions.geoserver.rest.GeoServerRESTReader

public class GeoServerRESTReader
extends Object

Connect to a GeoServer instance to read its data.
Info are returned as Strings or, for complex data, as XML elements wrapped in proper parsers (e.g.: RESTLayer, RESTCoverageStore, ...).

Author:
ETj (etj at geo-solutions.it)

Constructor Summary
GeoServerRESTReader(String restUrl)
          Creates a GeoServerRESTReader for a given GeoServer instance and no auth credentials.
GeoServerRESTReader(String restUrl, String username, String password)
          Creates a GeoServerRESTReader for a given GeoServer instance with the given auth credentials.
GeoServerRESTReader(URL restUrl)
          Creates a GeoServerRESTReader for a given GeoServer instance and no auth credentials.
GeoServerRESTReader(URL restUrl, String username, String password)
          Creates a GeoServerRESTReader for a given GeoServer instance with the given auth credentials.
 
Method Summary
 boolean existGeoserver()
          Check if a GeoServer instance is running at the given URL.
 boolean existsStyle(String styleName)
          Check if a Style exists in the configured GeoServer instance.
 RESTCoverage getCoverage(RESTLayer layer)
          Get detailed info about a Coverage given the Layer where it's published with.
 RESTCoverage getCoverage(String workspace, String store, String name)
          Get detailed info about a given Coverage.
 RESTCoverageList getCoverages(String workspace, String csName)
          Get list of coverages (usually only one).
 RESTCoverageStore getCoverageStore(RESTCoverage coverage)
          Get detailed info about a Coverage's Datastore.
 RESTCoverageStore getCoverageStore(String workspace, String csName)
          Get detailed info about a given CoverageStore in a given Workspace.
 RESTCoverageStoreList getCoverageStores(String workspace)
          Get summary info about all CoverageStores in a WorkSpace.
 RESTDataStore getDatastore(RESTFeatureType featureType)
          Get detailed info about a FeatureType's Datastore.
 RESTDataStore getDatastore(String workspace, String dsName)
          Get detailed info about a given Datastore in a given Workspace.
 RESTDataStoreList getDatastores(String workspace)
          Get summary info about all DataStores in a WorkSpace.
 RESTFeatureType getFeatureType(RESTLayer layer)
          Get detailed info about a FeatureType given the Layer where it's published with.
 RESTLayer getLayer(String name)
          Get detailed info about a given Layer.
 RESTLayerGroup getLayerGroup(String name)
          Get detailed info about a given LayerGroup.
 RESTLayerGroup getLayerGroup(String workspace, String name)
          Get detailed info about a given LayerGroup.
 RESTLayerGroupList getLayerGroups()
          Get summary info about all LayerGroups.
 RESTLayerGroupList getLayerGroups(String workspace)
          Get summary info about all LayerGroups in the given workspace.
 RESTLayerList getLayers()
          Get summary info about all Layers.
 RESTNamespace getNamespace(String prefix)
          Get a namespace.
 List<String> getNamespaceNames()
          Get the names of all the Namespaces.
 RESTNamespaceList getNamespaces()
          Get summary info about all Namespaces.
 RESTResource getResource(RESTLayer layer)
          Get detailed info about a Resource given the Layer where it's published with.
 String getSLD(String styleName)
          Get the SLD body of a Style.
 RESTStyleList getStyles()
          Get summary info about all Styles.
 List<String> getWorkspaceNames()
          Get the names of all the Workspaces.
 RESTWorkspaceList getWorkspaces()
          Get summary info about all Workspaces.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeoServerRESTReader

public GeoServerRESTReader(URL restUrl)
Creates a GeoServerRESTReader for a given GeoServer instance and no auth credentials.

Note that GeoServer 2.0 REST interface requires username/password credentials by default, if not otherwise configured. .

Parameters:
restUrl - the base GeoServer URL(e.g.: http://localhost:8080/geoserver)

GeoServerRESTReader

public GeoServerRESTReader(String restUrl)
                    throws MalformedURLException
Creates a GeoServerRESTReader for a given GeoServer instance and no auth credentials.

Note that GeoServer 2.0 REST interface requires username/password credentials by default, if not otherwise configured. .

Parameters:
restUrl - the base GeoServer URL (e.g.: http://localhost:8080/geoserver)
Throws:
MalformedURLException

GeoServerRESTReader

public GeoServerRESTReader(String restUrl,
                           String username,
                           String password)
                    throws MalformedURLException
Creates a GeoServerRESTReader for a given GeoServer instance with the given auth credentials.

Parameters:
restUrl - the base GeoServer URL (e.g.: http://localhost:8080/geoserver)
username - username auth credential
password - password auth credential
Throws:
MalformedURLException

GeoServerRESTReader

public GeoServerRESTReader(URL restUrl,
                           String username,
                           String password)
Creates a GeoServerRESTReader for a given GeoServer instance with the given auth credentials.

Parameters:
restUrl - the base GeoServer URL (e.g.: http://localhost:8080/geoserver)
username - username auth credential
password - password auth credential
Method Detail

existGeoserver

public boolean existGeoserver()
Check if a GeoServer instance is running at the given URL.
Return true if the configured GeoServer is up and replies to REST requests.
Send a HTTP GET request to the configured URL.
Return true if a HTTP 200 code (OK) is read from the HTTP response; any other response code, or connection error, will return a false boolean.

Returns:
true if a GeoServer instance was found at the configured URL.

existsStyle

public boolean existsStyle(String styleName)
                    throws RuntimeException
Check if a Style exists in the configured GeoServer instance.

Parameters:
styleName - the name of the style to check for.
Returns:
true on HTTP 200, false on HTTP 404
Throws:
RuntimeException - if any other HTTP code than 200 or 404 was retrieved.

getStyles

public RESTStyleList getStyles()
Get summary info about all Styles.

Returns:
summary info about Styles as a RESTStyleList

getSLD

public String getSLD(String styleName)
Get the SLD body of a Style.


getDatastores

public RESTDataStoreList getDatastores(String workspace)
Get summary info about all DataStores in a WorkSpace.

Parameters:
workspace - The name of the workspace
Returns:
summary info about Datastores as a RESTDataStoreList

getDatastore

public RESTDataStore getDatastore(String workspace,
                                  String dsName)
Get detailed info about a given Datastore in a given Workspace.

Parameters:
workspace - The name of the workspace
dsName - The name of the Datastore
Returns:
DataStore details as a RESTDataStore

getDatastore

public RESTDataStore getDatastore(RESTFeatureType featureType)
Get detailed info about a FeatureType's Datastore.

Parameters:
featureType - the RESTFeatureType
Returns:
DataStore details as a RESTDataStore

getFeatureType

public RESTFeatureType getFeatureType(RESTLayer layer)
Get detailed info about a FeatureType given the Layer where it's published with.

Parameters:
layer - A layer publishing the FeatureType
Returns:
FeatureType details as a RESTCoverage

getCoverageStores

public RESTCoverageStoreList getCoverageStores(String workspace)
Get summary info about all CoverageStores in a WorkSpace.

Parameters:
workspace - The name of the workspace
Returns:
summary info about CoverageStores as a RESTDataStoreList

getCoverageStore

public RESTCoverageStore getCoverageStore(String workspace,
                                          String csName)
Get detailed info about a given CoverageStore in a given Workspace.

Parameters:
workspace - The name of the workspace
csName - The name of the CoverageStore
Returns:
CoverageStore details as a RESTCoverageStore

getCoverageStore

public RESTCoverageStore getCoverageStore(RESTCoverage coverage)
Get detailed info about a Coverage's Datastore.

Parameters:
coverage - the RESTFeatureType
Returns:
CoverageStore details as a RESTCoverageStore

getCoverages

public RESTCoverageList getCoverages(String workspace,
                                     String csName)
Get list of coverages (usually only one).

Parameters:
workspace - The name of the workspace
csName - The name of the CoverageStore
Returns:
Coverages list as a RESTCoverageList

getCoverage

public RESTCoverage getCoverage(String workspace,
                                String store,
                                String name)
Get detailed info about a given Coverage.

Parameters:
workspace - The name of the workspace
store - The name of the CoverageStore
name - The name of the Coverage
Returns:
Coverage details as a RESTCoverage

getCoverage

public RESTCoverage getCoverage(RESTLayer layer)
Get detailed info about a Coverage given the Layer where it's published with.

Parameters:
layer - A layer publishing the CoverageStore
Returns:
Coverage details as a RESTCoverage

getResource

public RESTResource getResource(RESTLayer layer)
Get detailed info about a Resource given the Layer where it's published with. The Resource can then be converted to RESTCoverage or RESTFeatureType

Returns:
Resource details as a RESTResource

getLayerGroups

public RESTLayerGroupList getLayerGroups(String workspace)
Get summary info about all LayerGroups in the given workspace.

Parameters:
workspace - name of the workspace
Returns:
summary info about LayerGroups as a RESTLayerGroupList

getLayerGroup

public RESTLayerGroup getLayerGroup(String workspace,
                                    String name)
Get detailed info about a given LayerGroup.

Parameters:
workspace - name of the workspace
name - the name of the LayerGroup
Returns:
LayerGroup details as a RESTLayerGroup

getLayerGroups

public RESTLayerGroupList getLayerGroups()
Get summary info about all LayerGroups.

Returns:
summary info about LayerGroups as a RESTLayerGroupList

getLayerGroup

public RESTLayerGroup getLayerGroup(String name)
Get detailed info about a given LayerGroup.

Parameters:
name - The name of the LayerGroup
Returns:
LayerGroup details as a RESTLayerGroup

getLayers

public RESTLayerList getLayers()
Get summary info about all Layers.

Returns:
summary info about Layers as a RESTLayerList

getLayer

public RESTLayer getLayer(String name)
Get detailed info about a given Layer.

Parameters:
name - The name of the Layer
Returns:
Layer details as a RESTLayer

getNamespace

public RESTNamespace getNamespace(String prefix)
Get a namespace.

Parameters:
prefix - namespace prefix.
Returns:
a RESTNamespace, or null if couldn't be created.

getNamespaces

public RESTNamespaceList getNamespaces()
Get summary info about all Namespaces.

Returns:
summary info about Namespaces as a RESTNamespaceList

getNamespaceNames

public List<String> getNamespaceNames()
Get the names of all the Namespaces.
This is a shortcut call: These info could be retrieved using getNamespaces

Returns:
the list of the names of all Namespaces.

getWorkspaces

public RESTWorkspaceList getWorkspaces()
Get summary info about all Workspaces.

Returns:
summary info about Workspaces as a RESTWorkspaceList

getWorkspaceNames

public List<String> getWorkspaceNames()
Get the names of all the Workspaces.
This is a shortcut call: These info could be retrieved using getWorkspaces

Returns:
the list of the names of all Workspaces or an empty list.


Copyright © 2007-2013 GeoSolutions. All Rights Reserved.