|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectit.geosolutions.geoserver.rest.GeoServerRESTPublisher
public class GeoServerRESTPublisher
Connect to a GeoServer instance to publish or modify data.
There are no modifiable instance fields, so all the calls are thread-safe.
| Nested Class Summary | |
|---|---|
static class |
GeoServerRESTPublisher.ParameterConfigure
The configure parameter is used to control how the data store is configured upon file upload. |
static class |
GeoServerRESTPublisher.ParameterUpdate
The update parameter is used to control how existing data is handled when the file is PUT into a datastore that (a) already exists and (b) already contains a schema that matches the content of the file. |
| Constructor Summary | |
|---|---|
GeoServerRESTPublisher(String restURL,
String username,
String password)
Creates a GeoServerRESTPublisher for a given GeoServer instance with the given auth credentials. |
|
| Method Summary | |
|---|---|
boolean |
configureCoverage(GSCoverageEncoder ce,
String wsname,
String csname)
Configure an existent coverage in a given workspace and coverage store |
protected boolean |
configureCoverage(GSCoverageEncoder ce,
String wsname,
String csname,
String cname)
Deprecated. use configureCoverage(GSCoverageEncoder, String, String) |
RESTCoverageStore |
configureExternaMosaicDatastore(String workspace,
String storeName,
File mosaicDir)
Deprecated. provided for backward compatibility use createExternaMosaicDatastore(String workspace, String
storeName, File mosaicDir, CoverageConfigure configure) |
boolean |
configureLayer(GSLayerEncoder layer,
String layerName)
Deprecated. please use configureLayer(String workspace, String
layerName, GSLayerEncoder layer) |
boolean |
configureLayer(String workspace,
String layerName,
GSLayerEncoder layer)
Allows to configure some layer attributes such and DefaultStyle |
boolean |
createCoverage(GSCoverageEncoder ce,
String wsname,
String csname)
Create a new coverage in a given workspace and coverage store |
boolean |
createExternalMosaic(String workspace,
String storeName,
File mosaicDir,
GSCoverageEncoder coverageEncoder,
GSLayerEncoder layerEncoder)
Publish a Mosaic already in a filesystem readable by GeoServer. |
RESTCoverageStore |
createExternaMosaicDatastore(String workspace,
String storeName,
File mosaicDir,
GeoServerRESTPublisher.ParameterConfigure configure,
GeoServerRESTPublisher.ParameterUpdate update)
Publish a Mosaic from a filesystem currently readable by GeoServer. |
boolean |
createPostGISDatastore(String workspace,
GSPostGISDatastoreEncoder datastoreEncoder)
Create a PostGIS datastore. |
boolean |
createWorkspace(String workspace)
Create a new Workspace |
protected String |
encode(String s)
|
boolean |
publishDBLayer(String workspace,
String storename,
GSFeatureTypeEncoder fte,
GSLayerEncoder layerEncoder)
Publish a table in a PostGis store as a new layer. |
boolean |
publishDBLayer(String workspace,
String storename,
String layername,
String srs,
String defaultStyle)
|
RESTCoverageStore |
publishExternalGeoTIFF(String workspace,
String storeName,
File geotiff,
String srs,
String defaultStyle)
Publish a GeoTiff already in a filesystem readable by GeoServer. |
RESTCoverageStore |
publishExternalMosaic(String workspace,
String storeName,
File mosaicDir,
GSCoverageEncoder coverageEncoder,
GSLayerEncoder layerEncoder)
Deprecated. this is keep only for backward compatibility use createExternalMosaic and getCoverageStore separately |
RESTCoverageStore |
publishExternalMosaic(String workspace,
String storeName,
File mosaicDir,
String srs,
String defaultStyle)
Publish a Mosaic already in a filesystem readable by GeoServer. |
boolean |
publishGeoTIFF(String workspace,
String storeName,
File geotiff)
Publish a GeoTiff. |
boolean |
publishImageMosaic(String workspace,
String storeName,
File zipFile)
Publish imagemosaic as zip file |
boolean |
publishImageMosaic(String workspace,
String storeName,
File zipFile,
GeoServerRESTPublisher.ParameterConfigure configure,
org.apache.commons.httpclient.NameValuePair... params)
Publish imagemosaic as zip file |
boolean |
publishShp(String workspace,
String storename,
String layername,
File zipFile)
Publish a zipped shapefile. |
boolean |
publishShp(String workspace,
String storename,
String layername,
File zipFile,
String srs)
Publish a zipped shapefile. |
boolean |
publishShp(String workspace,
String storename,
String layername,
File zipFile,
String srs,
org.apache.commons.httpclient.NameValuePair... params)
Publish a zipped shapefile. http://docs.geoserver.org/stable/en/user /restconfig/rest-config-examples/rest- config-examples-curl.html#uploading-a-shapefile |
boolean |
publishShp(String workspace,
String storename,
String layerName,
File zipFile,
String nativeCrs,
String defaultStyle)
Publish a zipped shapefile. |
boolean |
publishStyle(File sldFile)
Store and publish an SLD. |
boolean |
publishStyle(File sldFile,
String name)
Store and publish an SLD, assigning it a name. |
boolean |
publishStyle(String sldBody)
Store and publish an SLD. |
boolean |
publishStyle(String sldBody,
String name)
Store and publish an SLD. |
boolean |
publishWorldImage(String workspace,
String coveragestore,
File zipFile)
publishWorldImage(String, String, File, ParameterConfigure, NameValuePair...) |
boolean |
publishWorldImage(String workspace,
String coveragestore,
File zipFile,
GeoServerRESTPublisher.ParameterConfigure configure,
org.apache.commons.httpclient.NameValuePair... params)
Publish a zipped worldimage file. |
boolean |
reload()
reload the target geoserver configuration |
boolean |
removeCoverageStore(String workspace,
String storename)
Deprecated. use removeCoverageStore(String, String, boolean) |
boolean |
removeCoverageStore(String workspace,
String storename,
boolean recurse)
Remove a given CoverageStore in a given Workspace. |
boolean |
removeDatastore(String workspace,
String storename)
Deprecated. will be removed in next release use removeDatastore(String, String, boolean) |
boolean |
removeDatastore(String workspace,
String storename,
boolean recurse)
Remove a given Datastore in a given Workspace. |
boolean |
removeLayer(String workspace,
String layerName)
remove a generic given layer from a given workspace |
boolean |
removeLayerGroup(String name)
|
boolean |
removeStyle(String styleName)
Remove a Style. |
boolean |
removeStyle(String styleName,
boolean purge)
Remove a Style. The Style will be unpublished and the related SLD file will be removed (if purge==true). |
boolean |
removeWorkspace(String workspace)
Deprecated. removeWorkspace(String, boolean) |
boolean |
removeWorkspace(String workspace,
boolean recurse)
Remove a given Workspace. |
boolean |
reset()
reset the target geoserver configuration |
protected String |
sanitize(String s)
|
boolean |
unpublishCoverage(String workspace,
String storename,
String layerName)
Remove the Coverage configuration from GeoServer. |
boolean |
unpublishFeatureType(String workspace,
String storename,
String layerName)
Removes the featuretype and the associated layer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GeoServerRESTPublisher(String restURL,
String username,
String password)
restURL - the base GeoServer URL (e.g.:
http://localhost:8080/geoserver)username - username auth credentialpassword - password auth credential| Method Detail |
|---|
public boolean createWorkspace(String workspace)
workspace - The name of the new workspace.
This is the equivalent call with cUrl:
curl -u admin:geoserver -XPOST \
-H 'Content-type: text/xml' \
-d "<workspace><name>$WORKSPACE</name></workspace>" \
http://$GSIP:$GSPORT/$SERVLET/rest/workspaces
public boolean publishStyle(String sldBody)
This is the equivalent call with cUrl:
curl -u admin:geoserver -XPOST \
-H 'Content-type: application/vnd.ogc.sld+xml' \
-d @$FULLSLD \
http://$GSIP:$GSPORT/$SERVLET/rest/styles
sldBody - the SLD document as an XML String.
public boolean publishStyle(String sldBody,
String name)
throws IllegalArgumentException
This is the equivalent call with cUrl:
curl -u admin:geoserver -XPOST \
-H 'Content-type: application/vnd.ogc.sld+xml' \
-d @$FULLSLD \
http://$GSIP:$GSPORT/$SERVLET/rest/styles?name=name
sldBody - the SLD document as an XML String.name - the Style name (can be null).
IllegalArgumentException - if the style body is null or emptypublic boolean publishStyle(File sldFile)
sldFile - the File containing the SLD document.
public boolean publishStyle(File sldFile,
String name)
sldFile - the File containing the SLD document.name - the Style name.
public boolean removeStyle(String styleName,
boolean purge)
throws IllegalArgumentException
styleName - the name of the Style to remove.purge - and the related SLD file will be removed.
IllegalArgumentException - if styleName is null or emptypublic boolean removeStyle(String styleName)
The Style will be unpublished and the related SLD file will be removed.
styleName - the name of the Style to remove.
public boolean createPostGISDatastore(String workspace,
GSPostGISDatastoreEncoder datastoreEncoder)
workspace - Name of the workspace to contain the database. This will also
be the prefix of any layer names created from tables in the
database.datastoreEncoder - the set of parameters to be set to the datastore (including
connection params)
public boolean publishShp(String workspace,
String storename,
String layername,
File zipFile)
throws FileNotFoundException
workspace - storename - layername - zipFile -
FileNotFoundException
public boolean publishShp(String workspace,
String storename,
String layerName,
File zipFile,
String nativeCrs,
String defaultStyle)
throws FileNotFoundException
workspace - storename - layerName - nativeCrs - defaultStyle - may be null
FileNotFoundException
public boolean publishShp(String workspace,
String storename,
String layername,
File zipFile,
String srs)
throws FileNotFoundException
These are the equivalent calls with cUrl:
curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' \
--data-binary @$ZIPFILE \
http://$GSIP:$GSPORT/$SERVLET/rest/workspaces/$WORKSPACE/datastores/$STORENAME/file.shp
curl -u admin:geoserver -XPOST -H 'Content-type: text/xml' \
-d "<featureType><name>$BARE</name><nativeCRS>EPSG:4326</nativeCRS><enabled>true</enabled></featureType>" \
http://$GSIP:$GSPORT/$SERVLET/rest/workspaces/$WORKSPACE/datastores/$STORENAME/featuretypes/$LAYERNAME
publishShp(String, String, String, File, String, NameValuePair...)
FileNotFoundException
public boolean publishShp(String workspace,
String storename,
String layername,
File zipFile,
String srs,
org.apache.commons.httpclient.NameValuePair... params)
throws FileNotFoundException
workspace - the name of the workspace to usestorename - the name of the store to createlayername - the name of the layer to configurezipFile - the zip file containing the shapefilesrs - the native CRSparams - parameters to append to the url (can be null).FileNotFoundException
public boolean publishDBLayer(String workspace,
String storename,
String layername,
String srs,
String defaultStyle)
workspace - storename - layername - srs - defaultStyle -
public boolean publishDBLayer(String workspace,
String storename,
GSFeatureTypeEncoder fte,
GSLayerEncoder layerEncoder)
This is the equivalent call with cUrl:
curl -u admin:geoserver -XPOST -H 'Content-type: text/xml' \
-d "<featureType><name>easia_gaul_1_aggr</name><nativeCRS>EPSG:4326</nativeCRS><enabled>true</enabled></featureType>" \
http://localhost:8080/geoserver/rest/workspaces/it.geosolutions/datastores/pg_kids/featuretypes
and a PUT to
workspace - storename - fte - GSFeatureTypeEncoder encoding creating FeatureType
public boolean publishGeoTIFF(String workspace,
String storeName,
File geotiff)
throws FileNotFoundException
This is the equivalent call with cUrl:
curl -u admin:geoserver -XPUT -H 'Content-type: text' -d "file:$FULLPATH" \
http://$GSIP:$GSPORT/$SERVLET/rest/workspaces/$WORKSPACE/coveragestores/$STORENAME/external.geotiff
FileNotFoundException
public RESTCoverageStore publishExternalGeoTIFF(String workspace,
String storeName,
File geotiff,
String srs,
String defaultStyle)
throws FileNotFoundException
workspace - an existing workspacestoreName - the coverageStore to be createdgeotiff - the geoTiff to be published
FileNotFoundException
public boolean publishWorldImage(String workspace,
String coveragestore,
File zipFile)
throws FileNotFoundException
publishWorldImage(String, String, File, ParameterConfigure, NameValuePair...)
FileNotFoundException
public boolean publishWorldImage(String workspace,
String coveragestore,
File zipFile,
GeoServerRESTPublisher.ParameterConfigure configure,
org.apache.commons.httpclient.NameValuePair... params)
throws FileNotFoundException
This is equivalent call with cUrl:
{@code
curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' \
--data-binary @$ZIPFILE \
http://$GSIP:$GSPORT/$SERVLET/rest/workspaces/$WORKSPACE/coveragestores/$COVERAGESTORE/file.worldimage
workspace - Workspace to usecoveragestore - Name of the coveragestorezipFile - zip file to uploadconfigure - Configure parameter. It may be null.params - parameters to append to the url (can be null).FileNotFoundExceptionParameterConfigure}
public boolean publishImageMosaic(String workspace,
String storeName,
File zipFile)
throws FileNotFoundException
FileNotFoundException#publishWorldImage(String, String, File)}
public boolean publishImageMosaic(String workspace,
String storeName,
File zipFile,
GeoServerRESTPublisher.ParameterConfigure configure,
org.apache.commons.httpclient.NameValuePair... params)
throws FileNotFoundException
FileNotFoundException#publishWorldImage(String, String, File, ParameterConfigure, NameValuePair...)}
public RESTCoverageStore createExternaMosaicDatastore(String workspace,
String storeName,
File mosaicDir,
GeoServerRESTPublisher.ParameterConfigure configure,
GeoServerRESTPublisher.ParameterUpdate update)
throws FileNotFoundException
Sample cUrl usage:
<>
curl -u admin:geoserver -XPUT -H 'Content-type: text' -d "file:$ABSPORTDIR"
http://$GSIP:$GSPORT/$SERVLET/rest/workspaces/$WORKSPACE/coveragestores/$BAREDIR/external.imagemosaic
workspace - an existing workspacestoreName - the name of the coverageStore to be createdmosaicDir - the directory where the raster images are locatedconfigure - a specify if a coverage should be configured
FileNotFoundException
public RESTCoverageStore configureExternaMosaicDatastore(String workspace,
String storeName,
File mosaicDir)
throws FileNotFoundException
createExternaMosaicDatastore(String workspace, String
storeName, File mosaicDir, CoverageConfigure configure)
workspace - storeName - mosaicDir -
FileNotFoundException
public RESTCoverageStore publishExternalMosaic(String workspace,
String storeName,
File mosaicDir,
String srs,
String defaultStyle)
throws FileNotFoundException
Sample cUrl usage:
curl -u admin:geoserver -XPUT -H 'Content-type: text' -d "file:$ABSPORTDIR"
http://$GSIP:$GSPORT/$SERVLET/rest/workspaces/$WORKSPACE/coveragestores/$BAREDIR/external.imagemosaic
workspace - an existing workspacestoreName - the name of the coverageStore to be createdmosaicDir - the directory where the raster images are locatedsrs - the coverage declared SRSdefaultStyle - may be null
FileNotFoundException
public RESTCoverageStore publishExternalMosaic(String workspace,
String storeName,
File mosaicDir,
GSCoverageEncoder coverageEncoder,
GSLayerEncoder layerEncoder)
throws FileNotFoundException
Sample cUrl usage:
curl -u admin:geoserver -XPUT -H 'Content-type: text' -d "file:$ABSPORTDIR"
http://$GSIP:$GSPORT/$SERVLET/rest/workspaces/$WORKSPACE/coveragestores/$BAREDIR/external.imagemosaic
workspace - an existing workspacestoreName - the name of the coverageStore to be createdmosaicDir - the directory where the raster images are locatedcoverageEncoder - the set of parameters to be set to the coverage (bbox, srs,
...)layerEncoder - the set of parameters to be set to the layer (defaultstyle,
wmspath, ...)
FileNotFoundException
public boolean createExternalMosaic(String workspace,
String storeName,
File mosaicDir,
GSCoverageEncoder coverageEncoder,
GSLayerEncoder layerEncoder)
throws FileNotFoundException
Sample cUrl usage:
curl -u admin:geoserver -XPUT -H 'Content-type: text' -d "file:$ABSPORTDIR"
http://$GSIP:$GSPORT/$SERVLET/rest/workspaces/$WORKSPACE/coveragestores/$BAREDIR/external.imagemosaic
workspace - an existing workspacestoreName - the name of the coverageStore to be createdmosaicDir - the directory where the raster images are locatedcoverageEncoder - the set of parameters to be set to the coverage (bbox, srs,
...)layerEncoder - the set of parameters to be set to the layer (defaultstyle,
wmspath, ...)
FileNotFoundException
public boolean unpublishCoverage(String workspace,
String storename,
String layerName)
CHECKME Maybe the coveragestore has to be removed as well.
REST URL: http://localhost:8080/geoserver/rest/workspaces/it.geosolutions/coveragestores/gbRESTtestStore/coverages/resttestdem.xml
public boolean unpublishFeatureType(String workspace,
String storename,
String layerName)
remove the
datastore.
public boolean removeDatastore(String workspace,
String storename)
removeDatastore(String, String, boolean)
workspace - The name of the workspacestorename - The name of the Datastore to remove.
public boolean removeDatastore(String workspace,
String storename,
boolean recurse)
throws IllegalArgumentException
workspace - The name of the workspacestorename - The name of the Datastore to remove.recurse - if remove should be performed recursively
IllegalArgumentException - if workspace or storename are null or empty
public boolean removeCoverageStore(String workspace,
String storename)
removeCoverageStore(String, String, boolean)
workspace - The name of the workspacestorename - The name of the CoverageStore to remove.
public boolean removeCoverageStore(String workspace,
String storename,
boolean recurse)
throws IllegalArgumentException
workspace - The name of the workspacestorename - The name of the CoverageStore to remove.recurse - if remove should be performed recursively
IllegalArgumentExceptionpublic boolean removeWorkspace(String workspace)
removeWorkspace(String, boolean)
workspace - the workspace to remove
GeoServerRESTPublisher#removeWorkspace(String, boolean)}
public boolean removeWorkspace(String workspace,
boolean recurse)
throws IllegalArgumentException
workspace - The name of the workspacerecurse - The recurse parameter is used to recursively delete all
resources contained by the specified workspace. This includes
data stores, coverage stores, feature types, etc... Allowable
values for this parameter are true or false. The
default value is false.
IllegalArgumentExceptionpublic boolean reload()
://docs.geoserver.org/stable/en/user/restconfig/rest-config-api.htmlpublic boolean reset()
://docs.geoserver.org/stable/en/user/restconfig/rest-config-api.htmlpublic boolean removeLayerGroup(String name)
public boolean configureLayer(GSLayerEncoder layer,
String layerName)
configureLayer(String workspace, String
layerName, GSLayerEncoder layer)
public boolean removeLayer(String workspace,
String layerName)
workspace - layerName -
public boolean configureLayer(String workspace,
String layerName,
GSLayerEncoder layer)
public boolean configureCoverage(GSCoverageEncoder ce,
String wsname,
String csname)
ce - contains the coverage name to configure and the configuration
to applywsname - the workspace to search for existent coveragecsname - the coverage store to search for existent coverage
public boolean createCoverage(GSCoverageEncoder ce,
String wsname,
String csname)
ce - contains the coverage name to create and the configuration to
applywsname - the workspace to search for existent coveragecsname - the coverage store to search for existent coverage
protected boolean configureCoverage(GSCoverageEncoder ce,
String wsname,
String csname,
String cname)
configureCoverage(GSCoverageEncoder, String, String)
ce - Coverage encoderwsname - workspace namecsname - coveragestore namecname - coverage name (if != null will override the CoverageEncoder
name)
protected String sanitize(String s)
protected String encode(String s)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||