|
||||||||||
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.CoverageStoreExtension
The extension parameter specifies the type of data being uploaded. |
static class |
GeoServerRESTPublisher.DataStoreExtension
The extension parameter specifies the type of data being uploaded. |
static class |
GeoServerRESTPublisher.DataStoreType
A data store is a source of spatial data that is vector based. |
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. |
static class |
GeoServerRESTPublisher.UploadMethod
The file, url, and external endpoints are used to specify the method that is used to upload 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 |
boolean |
configureLayer(String workspace,
String resourceName,
GSLayerEncoder layer)
Allows to configure some layer attributes such and DefaultStyle |
boolean |
createCoverage(GSCoverageEncoder ce,
String wsname,
String csname)
Deprecated. use createCoverage(String, String, GSCoverageEncoder) |
boolean |
createCoverage(String wsname,
String storeName,
GSCoverageEncoder ce)
Create a new coverage in a given workspace and coverage store |
boolean |
createExternalMosaic(String workspace,
String storeName,
File mosaicDir,
GSCoverageEncoder coverageEncoder,
GSLayerEncoder layerEncoder)
Deprecated. use #publishExternalMosaic(String workspace, final String storeName, File mosaicDir, GSCoverageEncoder coverageEncoder,
GSLayerEncoder layerEncoder) |
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,
GSCoverageEncoder coverageEncoder,
GSLayerEncoder layerEncoder)
Publish a GeoTiff already in a filesystem readable by GeoServer. |
boolean |
publishExternalGeoTIFF(String workspace,
String storeName,
File geotiff,
String coverageName,
String srs,
GSResourceEncoder.ProjectionPolicy policy,
String defaultStyle)
Publish a GeoTiff already in a filesystem readable by GeoServer. |
boolean |
publishExternalMosaic(String workspace,
String storeName,
File mosaicDir,
GSCoverageEncoder coverageEncoder,
GSLayerEncoder layerEncoder)
Publish a Mosaic already in a filesystem readable by GeoServer. |
boolean |
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)
Simple wrapper for publishGeoTIFF(String, String, String, File) |
boolean |
publishGeoTIFF(String workspace,
String storeName,
String coverageName,
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. |
boolean |
updateStyle(File sldFile,
String name)
Update an SLD called 'name'. |
boolean |
updateStyle(String sldBody,
String name)
Update SLD called as 'name'. |
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 credentialMethod 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 updateStyle(String sldBody, String name) throws IllegalArgumentException
This is the equivalent call with cUrl:
curl -u admin:geoserver -XPUT \
-H 'Content-type: application/vnd.ogc.sld+xml' \
-d @$FULLSLD \
http://$GSIP:$GSPORT/$SERVLET/rest/styles/$NAME
sldBody
- the SLD document as an XML String.name
- the Style name to modify.
IllegalArgumentException
- if the style body or name are null or emptypublic boolean updateStyle(File sldFile, String name) throws IllegalArgumentException
sldFile
- the File containing the SLD document.name
- the Style name.
IllegalArgumentException
- if the sldFile file or name are null or name is emptypublic 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
publishGeoTIFF(String, String, String, File)
FileNotFoundException
public boolean publishGeoTIFF(String workspace, String storeName, String coverageName, File geotiff) throws FileNotFoundException, IllegalArgumentException
publishCoverage(String, String, CoverageStoreExtension, String, File, ParameterConfigure, NameValuePair...)
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
workspace
- Workspace to usestoreName
- Name of the coveragestore (if null the file name will be used)coverageName
- the name of the coverage (if null the file name will be used)geotiff
- file to upload
FileNotFoundException
- if file does not exists
IllegalArgumentException
- if workspace or geotiff are nullpublic boolean publishExternalGeoTIFF(String workspace, String storeName, File geotiff, String coverageName, String srs, GSResourceEncoder.ProjectionPolicy policy, String defaultStyle) throws FileNotFoundException, IllegalArgumentException
workspace
- an existing workspacestoreName
- the coverageStore to be createdgeotiff
- the geoTiff to be publishedsrs
- policy
- defaultStyle
-
FileNotFoundException
IllegalArgumentException
public RESTCoverageStore publishExternalGeoTIFF(String workspace, String storeName, File geotiff, GSCoverageEncoder coverageEncoder, GSLayerEncoder layerEncoder) throws IllegalArgumentException, FileNotFoundException
workspace
- an existing workspacestoreName
- the coverageStore to be createdgeotiff
- the geoTiff to be publishedcoverageEncoder
- layerEncoder
-
FileNotFoundException
IllegalArgumentException
- if null parameterpublic 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).FileNotFoundException
ParameterConfigure}
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 boolean 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 boolean createExternalMosaic(String workspace, String storeName, File mosaicDir, GSCoverageEncoder coverageEncoder, GSLayerEncoder layerEncoder) throws FileNotFoundException
#publishExternalMosaic(String workspace, final String storeName, File mosaicDir, GSCoverageEncoder coverageEncoder,
GSLayerEncoder layerEncoder)
workspace
- storeName
- mosaicDir
- coverageEncoder
- layerEncoder
-
FileNotFoundException
public boolean publishExternalMosaic(String workspace, String storeName, File mosaicDir, GSCoverageEncoder coverageEncoder, GSLayerEncoder layerEncoder) throws FileNotFoundException, IllegalArgumentException
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
IllegalArgumentException
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 emptypublic 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
IllegalArgumentException
public 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.
IllegalArgumentException
public boolean reload()
://docs.geoserver.org/stable/en/user/restconfig/rest-config-api.html
public boolean reset()
://docs.geoserver.org/stable/en/user/restconfig/rest-config-api.html
public boolean removeLayerGroup(String name)
public boolean removeLayer(String workspace, String layerName)
workspace
- layerName
-
public boolean configureLayer(String workspace, String resourceName, GSLayerEncoder layer) throws IllegalArgumentException
workspace
- resourceName
- the name of the resource to use (featureStore or coverageStore name)layer
- the layer encoder used to configure the layer
IllegalArgumentException
- if some arguments are null or emptypublic 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)
createCoverage(String, String, GSCoverageEncoder)
ce
- wsname
- csname
-
public boolean createCoverage(String wsname, String storeName, GSCoverageEncoder ce) throws IllegalArgumentException
wsname
- the workspace to search for existent coveragestoreName
- an existent store name to use as data sourcece
- contains the coverage name to create and the configuration to
apply
IllegalArgumentException
- if arguments are null or emptyprotected 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 |