Class GeoServerRESTPublisher


  • public class GeoServerRESTPublisher
    extends java.lang.Object
    Connect to a GeoServer instance to publish or modify its contents via REST API.

    There are no modifiable instance fields, so all the calls are thread-safe.

    Version:
    $Id: $
    Author:
    ETj (etj at geo-solutions.it), Carlo Cancellieri - carlo.cancellieri@geo-solutions.it, Lennart Karsten - lennart.k@thinking-aloud.eu
    • Field Detail

      • DEFAULT_CRS

        public static final java.lang.String DEFAULT_CRS
        Constant DEFAULT_CRS="EPSG:4326"
        See Also:
        Constant Field Values
    • Constructor Detail

      • GeoServerRESTPublisher

        public GeoServerRESTPublisher​(java.lang.String restURL,
                                      java.lang.String username,
                                      java.lang.String password)
        Creates a GeoServerRESTPublisher to connect against a GeoServer instance with the given URL and user credentials.
        Parameters:
        restURL - the base GeoServer URL (e.g.: http://localhost:8080/geoserver)
        username - auth credential
        password - auth credential
    • Method Detail

      • backup

        public java.lang.String backup​(java.lang.String backupDir)
                                throws java.lang.IllegalArgumentException
        Issues a GeoServer BACKUP.

        Won't include data, cached tiles, or logs. Use backup(String, boolean, boolean, boolean) to control these parameters.

        Parameters:
        backupDir - the target Backup Dir String.
        Returns:
        id of the backup.
        Throws:
        java.lang.IllegalArgumentException - if the backupDir is null or empty
      • backup

        public java.lang.String backup​(java.lang.String backupDir,
                                       boolean includedata,
                                       boolean includegwc,
                                       boolean includelog)
                                throws java.lang.IllegalArgumentException
        Issues a GeoServer BACKUP.
        Parameters:
        backupDir - the target Backup Dir String.
        includedata - whether or not include the data dir Boolean.
        includegwc - whether or not include the geowebcache dir Boolean.
        includelog - whether or not include the log dir Boolean.
        Returns:
        id of the backup.
        Throws:
        java.lang.IllegalArgumentException - if the backupDir is null or empty.
      • restore

        public java.lang.String restore​(java.lang.String backupDir)
                                 throws java.lang.IllegalArgumentException
        Issues a GeoServer RESTORE.
        Parameters:
        backupDir - the source backup dir.
        Returns:
        id of the backup.
        Throws:
        java.lang.IllegalArgumentException - if the backupDir is null or empty
      • createWorkspace

        public boolean createWorkspace​(java.lang.String workspace)
        Create a new Workspace.

        GeoServer will automatically create an associated Namespace with the URI being "http://{workspaceName}". To specify a custom Namespace URI, use createWorkspace(String, URI).

        Parameters:
        workspace - The name of the new workspace.
        Returns:
        true if the workspace was created.
      • createWorkspace

        public boolean createWorkspace​(java.lang.String name,
                                       java.net.URI uri)
        Create both a workspace and its associated namespace.

        Note that this method is equivalent to createNamespace(java.lang.String, java.net.URI).

        Parameters:
        name - Name for the new workspace, which will be also its associated namespace prefix.
        uri - Namespace URI. Cannot be empty.
        Returns:
        true if the Workspace and its associated namespace were successfully created.
      • createNamespace

        public boolean createNamespace​(java.lang.String prefix,
                                       java.net.URI uri)
        Create a new Namespace. GeoServer will automatically create the corresponding Workspace. Prefix and URI are mandatory and cannot be empty. If a Namespace with the given prefix already exists, it won't be created.
        Parameters:
        prefix - The name of the new Namespace.
        uri - The URI of the new Namespace.
        Returns:
        true if the Namespace was successfully created.
        See Also:
        GeoServer Documentation
      • updateNamespace

        public boolean updateNamespace​(java.lang.String prefix,
                                       java.net.URI uri)
        Update a Namespace URI. Prefix and URI are mandatory and cannot be empty. A Namespace with the given prefix should exist.
        Parameters:
        prefix - The prefix of an existing Namespace.
        uri - The new URI.
        Returns:
        true if the Namespace was successfully updated.
      • removeNamespace

        public boolean removeNamespace​(java.lang.String prefix,
                                       boolean recurse)
        Remove a given Namespace. It will remove the associated Workspace as well.
        Parameters:
        prefix - The Namespace prefix
        recurse - The recurse parameter is used to recursively delete all resources contained in the workspace associated with this Namespace. This includes data stores, coverage stores, feature types, etc... Allowable values for this parameter are true or false. The default (safer) value is false.
        Returns:
        true if the Namespace was successfully removed.
      • publishStyle

        public boolean publishStyle​(java.lang.String sldBody)
        Store and publish a Style.
        Parameters:
        sldBody - the full SLD document as a String.
        Returns:
        true if the operation completed successfully.
      • publishStyle

        public boolean publishStyle​(java.lang.String sldBody,
                                    java.lang.String name)
                             throws java.lang.IllegalArgumentException
        Store and publish a Style, assigning it a name.
        Parameters:
        sldBody - the full SLD document as a String.
        name - the Style name.
        Returns:
        true if the operation completed successfully.
        Throws:
        java.lang.IllegalArgumentException - if the style body is null or empty.
      • publishStyle

        public boolean publishStyle​(java.io.File sldFile)
        Store and publish a Style.
        Parameters:
        sldFile - the File containing the SLD document.
        Returns:
        true if the operation completed successfully.
      • publishStyle

        public boolean publishStyle​(java.io.File sldFile,
                                    java.lang.String name)
        Store and publish a Style, assigning it a name.
        Parameters:
        sldFile - the File containing the SLD document.
        name - the Style name.
        Returns:
        true if the operation completed successfully.
      • publishStyle

        public boolean publishStyle​(java.lang.String sldBody,
                                    java.lang.String name,
                                    boolean raw)
        Store and publish a Style, assigning it a name and choosing the raw format.
        Parameters:
        sldBody - the full SLD document as a String.
        name - the Style name.
        raw - the raw format
        Returns:
        true if the operation completed successfully.
      • publishStyle

        public boolean publishStyle​(java.io.File sldFile,
                                    java.lang.String name,
                                    boolean raw)
        Store and publish a Style, assigning it a name and choosing the raw format.
        Parameters:
        sldFile - the File containing the SLD document.
        name - the Style name.
        raw - the raw format
        Returns:
        true if the operation completed successfully.
      • updateStyle

        public boolean updateStyle​(java.io.File sldFile,
                                   java.lang.String name,
                                   boolean raw)
                            throws java.lang.IllegalArgumentException
        Update a Style.
        Parameters:
        sldFile - the File containing the SLD document.
        name - the Style name.
        raw - the raw format
        Returns:
        true if the operation completed successfully.
        Throws:
        java.lang.IllegalArgumentException - if the style body or name are null or empty.
      • updateStyle

        public boolean updateStyle​(java.lang.String sldBody,
                                   java.lang.String name,
                                   boolean raw)
                            throws java.lang.IllegalArgumentException
        Update a Style.
        Parameters:
        sldBody - the new SLD document as a String.
        name - the Style name.
        raw - the raw format
        Returns:
        true if the operation completed successfully.
        Throws:
        java.lang.IllegalArgumentException - if the style body or name are null or empty.
      • updateStyle

        public boolean updateStyle​(java.lang.String sldBody,
                                   java.lang.String name)
                            throws java.lang.IllegalArgumentException
        Update a Style.
        Parameters:
        sldBody - the new SLD document as a String.
        name - the Style name to update.
        Returns:
        true if the operation completed successfully.
        Throws:
        java.lang.IllegalArgumentException - if the style body or name are null or empty.
      • updateStyle

        public boolean updateStyle​(java.io.File sldFile,
                                   java.lang.String name)
                            throws java.lang.IllegalArgumentException
        Update a Style.
        Parameters:
        sldFile - the File containing the SLD document.
        name - the Style name.
        Returns:
        true if the operation completed successfully.
        Throws:
        java.lang.IllegalArgumentException - if the sldFile file or name are null or name is empty.
      • removeStyle

        public boolean removeStyle​(java.lang.String styleName,
                                   boolean purge)
                            throws java.lang.IllegalArgumentException
        Remove a Style.

        The Style will be unpublished, and (optionally) the SLD file will be removed.

        Parameters:
        styleName - the name of the Style to remove.
        purge - remove the related SLD file from disk.
        Returns:
        true if the operation completed successfully.
        Throws:
        java.lang.IllegalArgumentException - if styleName is null or empty.
      • removeStyle

        public boolean removeStyle​(java.lang.String styleName)
        Remove a Style.

        The Style will be unpublished and the related SLD file will be removed.

        Parameters:
        styleName - the name of the Style to remove.
        Returns:
        true if the operation completed successfully.
      • publishStyleInWorkspace

        public boolean publishStyleInWorkspace​(java.lang.String workspace,
                                               java.lang.String sldBody)

        publishStyleInWorkspace

        Parameters:
        workspace - a String object.
        sldBody - a String object.
        Returns:
        a boolean.
        Since:
        GeoServer 2.2
      • publishStyleInWorkspace

        public boolean publishStyleInWorkspace​(java.lang.String workspace,
                                               java.lang.String sldBody,
                                               java.lang.String name)
                                        throws java.lang.IllegalArgumentException

        publishStyleInWorkspace

        Parameters:
        workspace - a String object.
        sldBody - a String object.
        name - a String object.
        Returns:
        a boolean.
        Throws:
        java.lang.IllegalArgumentException - if any.
        Since:
        GeoServer 2.2
      • updateStyleInWorkspace

        public boolean updateStyleInWorkspace​(java.lang.String workspace,
                                              java.lang.String sldBody,
                                              java.lang.String name)
                                       throws java.lang.IllegalArgumentException

        updateStyleInWorkspace

        Parameters:
        workspace - a String object.
        sldBody - a String object.
        name - a String object.
        Returns:
        a boolean.
        Throws:
        java.lang.IllegalArgumentException - if any.
        Since:
        GeoServer 2.2
        See Also:
        GeoServerRESTStyleManager.updateStyleInWorkspace(java.lang.String, java.lang.String, java.lang.String)
      • updateStyleInWorkspace

        public boolean updateStyleInWorkspace​(java.lang.String workspace,
                                              java.io.File sldFile,
                                              java.lang.String name)
                                       throws java.lang.IllegalArgumentException

        updateStyleInWorkspace

        Parameters:
        workspace - a String object.
        sldFile - a File object.
        name - a String object.
        Returns:
        a boolean.
        Throws:
        java.lang.IllegalArgumentException - if any.
        Since:
        GeoServer 2.2
        See Also:
        GeoServerRESTStyleManager.updateStyleInWorkspace(java.lang.String, java.io.File, java.lang.String)
      • removeStyleInWorkspace

        public boolean removeStyleInWorkspace​(java.lang.String workspace,
                                              java.lang.String styleName,
                                              boolean purge)
                                       throws java.lang.IllegalArgumentException

        removeStyleInWorkspace

        Parameters:
        workspace - a String object.
        styleName - a String object.
        purge - a boolean.
        Returns:
        a boolean.
        Throws:
        java.lang.IllegalArgumentException - if any.
        Since:
        GeoServer 2.2
        See Also:
        GeoServerRESTStyleManager.removeStyleInWorkspace(java.lang.String, java.lang.String, boolean)
      • createPostGISDatastore

        public boolean createPostGISDatastore​(java.lang.String workspace,
                                              GSPostGISDatastoreEncoder datastoreEncoder)
        Deprecated.
        Will be deleted in next version 1.5.x, use GeoServerRESTStoreManager instead.
        Create a PostGIS datastore.
        Parameters:
        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).
        Returns:
        true if the PostGIS datastore has been successfully created, false otherwise
      • publishDBLayer

        public boolean publishDBLayer​(java.lang.String workspace,
                                      java.lang.String storename,
                                      java.lang.String layername,
                                      java.lang.String srs,
                                      java.lang.String defaultStyle)
        Deprecated.
        Will be removed in the next release.

        publishDBLayer

        Parameters:
        workspace - a String object.
        storename - a String object.
        layername - a String object.
        srs - a String object.
        defaultStyle - a String object.
        Returns:
        a boolean.
      • publishDBLayer

        public boolean publishDBLayer​(java.lang.String workspace,
                                      java.lang.String storename,
                                      GSFeatureTypeEncoder fte,
                                      GSLayerEncoder layerEncoder)
        Publish and configure a new layer from an existing DataStore (v. gr. a layer from a DB table).
        Parameters:
        workspace - Workspace name where DataStore is.
        storename - DataStore name.
        fte - FeatureType configuration details using a GSFeatureTypeEncoder.
        layerEncoder - a GSLayerEncoder object.
        Returns:
        true if layer is successfully created.
      • publishShp

        public boolean publishShp​(java.lang.String workspace,
                                  java.lang.String storeName,
                                  org.apache.commons.httpclient.NameValuePair[] storeParams,
                                  java.lang.String datasetName,
                                  GeoServerRESTPublisher.UploadMethod method,
                                  java.net.URI shapefile,
                                  java.lang.String srs,
                                  java.lang.String nativeCRS,
                                  GSResourceEncoder.ProjectionPolicy policy,
                                  java.lang.String defaultStyle)
                           throws java.io.FileNotFoundException,
                                  java.lang.IllegalArgumentException
        Publish a shapefile.
        Parameters:
        workspace - the name of the workspace to use
        storeName - the name of the store to create
        storeParams - parameters to append to the url (can be null).
        Accepted parameters are:
        • charset used to set the charset
        storeName - the name of the store to create
        storeName - the name of the layer to configure
        method - GeoServerRESTPublisher.UploadMethod
        shapefile - the uri of the file containing the shapefile.It should be:
        • A zip file if 'method' is file
        • A shp file if 'method' is external
        • A zip file if 'method' is uri (UNTESTED)
        srs - the SRS for this shapefile. It must be an ESPG code or GeoServer will choke.
        nativeCRS - the nativeCRS for this shapefile. It can be an EPSG code (for GSResourceEncoder.ProjectionPolicy.NONE or a WKT for GSResourceEncoder.ProjectionPolicy.REPROJECT_TO_DECLARED.
        policy - GSResourceEncoder.ProjectionPolicy
        defaultStyle - the default style to set (can be null).
        datasetName - a String object.
        Returns:
        true if success false otherwise
        Throws:
        java.io.FileNotFoundException - if file to upload is not found
        java.lang.IllegalArgumentException - if any of the mandatory arguments are null.
      • publishShp

        public boolean publishShp​(java.lang.String workspace,
                                  java.lang.String storeName,
                                  org.apache.commons.httpclient.NameValuePair[] storeParams,
                                  java.lang.String datasetName,
                                  GeoServerRESTPublisher.UploadMethod method,
                                  java.net.URI shapefile,
                                  java.lang.String srs,
                                  GSResourceEncoder.ProjectionPolicy policy,
                                  java.lang.String defaultStyle)
                           throws java.io.FileNotFoundException,
                                  java.lang.IllegalArgumentException
        Deprecated.
        use publishShp(String, String, NameValuePair[], String, UploadMethod, URI, String, String) instead as the behaviour of this method is misleading as it allows you to use wrong ProjectionPolicy values.
        Publish a shapefile.
        Parameters:
        workspace - the name of the workspace to use
        storeName - the name of the store to create
        storeParams - parameters to append to the url (can be null).
        Accepted parameters are:
        • charset used to set the charset
        method - GeoServerRESTPublisher.UploadMethod
        shapefile - the uri of the file containing the shapefile.It should be:
        • A zip file if 'method' is file
        • A shp file if 'method' is external
        • A zip file if 'method' is uri (UNTESTED)
        srs - the SRS for this shapefile. It must be an ESPG code or GeoServer will choke. Notice that we can only use GSResourceEncoder.ProjectionPolicy.FORCE_DECLARED.
        policy - GSResourceEncoder.ProjectionPolicy
        defaultStyle - the default style to set (can be null).
        datasetName - a String object.
        Returns:
        true if success false otherwise
        Throws:
        java.io.FileNotFoundException - if file to upload is not found
        java.lang.IllegalArgumentException - if any of the mandatory arguments are null.
      • publishShp

        public boolean publishShp​(java.lang.String workspace,
                                  java.lang.String storeName,
                                  org.apache.commons.httpclient.NameValuePair[] storeParams,
                                  java.lang.String datasetName,
                                  GeoServerRESTPublisher.UploadMethod method,
                                  java.net.URI shapefile,
                                  java.lang.String srs,
                                  java.lang.String defaultStyle)
                           throws java.io.FileNotFoundException,
                                  java.lang.IllegalArgumentException
        Publish a shapefile.
        Parameters:
        workspace - the name of the workspace to use
        storeName - the name of the store to create
        storeParams - parameters to append to the url (can be null).
        Accepted parameters are:
        • charset used to set the charset
        method - GeoServerRESTPublisher.UploadMethod
        shapefile - the uri of the file containing the shapefile.It should be:
        • A zip file if 'method' is file
        • A shp file if 'method' is external
        • A zip file if 'method' is uri (UNTESTED)
        srs - the SRS for this shapefile. It must be an ESPG code or GeoServer will choke.
        defaultStyle - the default style to set (can be null).
        datasetName - a String object.
        Returns:
        true if success false otherwise
        Throws:
        java.io.FileNotFoundException - if file to upload is not found
        java.lang.IllegalArgumentException - if any of the mandatory arguments are null.
      • publishShpCollection

        public boolean publishShpCollection​(java.lang.String workspace,
                                            java.lang.String storeName,
                                            java.net.URI resource)
                                     throws java.io.FileNotFoundException
        Publish a collection of shapefiles.

        Will automatically create the store and publish each shapefile as a layer.

        Parameters:
        workspace - the name of the workspace to use
        storeName - the name of the store to create
        resource - the shapefile collection. It can be:
        • A path to a directory containing shapefiles in the server.
        • A local zip file containing shapefiles that will be uploaded.
        • A URL pointing to a shapefile collection in the wild web (not tested).
        Returns:
        true if publication successful.
        Throws:
        java.io.FileNotFoundException - if the specified zip file does not exist.
      • publishArcGrid

        public boolean publishArcGrid​(java.lang.String workspace,
                                      java.lang.String storeName,
                                      java.io.File arcgrid)
                               throws java.io.FileNotFoundException
        Upload and publish a ArcGrid image.
        Parameters:
        workspace - Workspace to use
        storeName - The store name to be used or created.
        arcgrid - The ArcGrid file.
        Returns:
        true if success.
        Throws:
        java.io.FileNotFoundException - if ArcGrid file does not exist.
      • publishArcGrid

        public boolean publishArcGrid​(java.lang.String workspace,
                                      java.lang.String storeName,
                                      java.lang.String coverageName,
                                      java.io.File arcgrid)
                               throws java.io.FileNotFoundException,
                                      java.lang.IllegalArgumentException
        Upload and publish a ArcGrid image.
        Parameters:
        workspace - Workspace to use
        storeName - 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)
        arcgrid - file to upload
        Returns:
        true if the operation completed successfully.
        Throws:
        java.io.FileNotFoundException - if file does not exists
        java.lang.IllegalArgumentException - if workspace or arcgrid are null
      • publishArcGrid

        public boolean publishArcGrid​(java.lang.String workspace,
                                      java.lang.String storeName,
                                      java.lang.String coverageName,
                                      java.io.File arcgrid,
                                      java.lang.String srs,
                                      GSResourceEncoder.ProjectionPolicy policy,
                                      java.lang.String defaultStyle,
                                      double[] bbox)
                               throws java.io.FileNotFoundException,
                                      java.lang.IllegalArgumentException
        Upload and publish a ArcGrid image.
        Parameters:
        workspace - Workspace to use
        storeName - 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)
        arcgrid - file to upload
        srs - the native CRS
        policy - projection policy. See GSResourceEncoder.ProjectionPolicy.
        defaultStyle - the default style to apply.
        bbox - An array of 4 doubles indicating envelope in EPSG:4326. Order is [Xmin, Ymin, Xmax, Ymax].
        Returns:
        true if the operation completed successfully.
        Throws:
        java.io.FileNotFoundException - if file does not exists
        java.lang.IllegalArgumentException - if workspace or arcgrid are null
      • publishExternalArcGrid

        public boolean publishExternalArcGrid​(java.lang.String workspace,
                                              java.lang.String storeName,
                                              java.io.File arcgrid,
                                              java.lang.String coverageName,
                                              java.lang.String srs,
                                              GSResourceEncoder.ProjectionPolicy policy,
                                              java.lang.String defaultStyle)
                                       throws java.io.FileNotFoundException,
                                              java.lang.IllegalArgumentException
        Publish a ArcGrid already in a filesystem readable by GeoServer.
        Parameters:
        workspace - an existing workspace
        storeName - the coverageStore to be created
        arcgrid - the arcGrid to be published
        srs - the native CRS
        policy - projection policy. See GSResourceEncoder.ProjectionPolicy.
        defaultStyle - the default style to apply.
        coverageName - a String object.
        Returns:
        true if the operation completed successfully.
        Throws:
        java.io.FileNotFoundException - if file does not exists
        java.lang.IllegalArgumentException - if any of the mandatory parameters are null.
      • publishExternalArcGrid

        public RESTCoverageStore publishExternalArcGrid​(java.lang.String workspace,
                                                        java.lang.String storeName,
                                                        java.io.File arcgrid,
                                                        GSCoverageEncoder coverageEncoder,
                                                        GSLayerEncoder layerEncoder)
                                                 throws java.lang.IllegalArgumentException,
                                                        java.io.FileNotFoundException
        Publish a ArcGrid already in a filesystem readable by GeoServer.
        Parameters:
        workspace - an existing workspace
        storeName - the coverageStore to be created
        arcgrid - the arcGrid to be published
        coverageEncoder - coverage details. See GSCoverageEncoder.
        layerEncoder - layer details, See GSLayerEncoder.
        Returns:
        true if the operation completed successfully.
        Throws:
        java.io.FileNotFoundException - if file does not exists
        java.lang.IllegalArgumentException - if any of the mandatory parameters are null.
      • publishGeoTIFF

        public boolean publishGeoTIFF​(java.lang.String workspace,
                                      java.lang.String storeName,
                                      java.io.File geotiff)
                               throws java.io.FileNotFoundException
        Upload and publish a GeoTIFF image.
        Parameters:
        workspace - Workspace to use
        storeName - The store name to be used or created.
        geotiff - The GeoTIFF file.
        Returns:
        true if success.
        Throws:
        java.io.FileNotFoundException - if GeoTIFF file does not exist.
      • publishGeoTIFF

        public boolean publishGeoTIFF​(java.lang.String workspace,
                                      java.lang.String storeName,
                                      java.lang.String coverageName,
                                      java.io.File geotiff)
                               throws java.io.FileNotFoundException,
                                      java.lang.IllegalArgumentException
        Upload and publish a GeoTIFF image.
        Parameters:
        workspace - Workspace to use
        storeName - 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
        Returns:
        true if the operation completed successfully.
        Throws:
        java.io.FileNotFoundException - if file does not exists
        java.lang.IllegalArgumentException - if workspace or geotiff are null
      • publishGeoTIFF

        public boolean publishGeoTIFF​(java.lang.String workspace,
                                      java.lang.String storeName,
                                      java.lang.String coverageName,
                                      java.io.File geotiff,
                                      java.lang.String srs,
                                      GSResourceEncoder.ProjectionPolicy policy,
                                      java.lang.String defaultStyle,
                                      double[] bbox)
                               throws java.io.FileNotFoundException,
                                      java.lang.IllegalArgumentException
        Upload and publish a GeoTIFF image.
        Parameters:
        workspace - Workspace to use
        storeName - 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
        srs - the native CRS
        policy - projection policy. See GSResourceEncoder.ProjectionPolicy.
        defaultStyle - the default style to apply.
        bbox - An array of 4 doubles indicating envelope in EPSG:4326. Order is [Xmin, Ymin, Xmax, Ymax].
        Returns:
        true if the operation completed successfully.
        Throws:
        java.io.FileNotFoundException - if file does not exists
        java.lang.IllegalArgumentException - if workspace or geotiff are null
      • publishExternalGeoTIFF

        public boolean publishExternalGeoTIFF​(java.lang.String workspace,
                                              java.lang.String storeName,
                                              java.io.File geotiff,
                                              java.lang.String coverageName,
                                              java.lang.String srs,
                                              GSResourceEncoder.ProjectionPolicy policy,
                                              java.lang.String defaultStyle)
                                       throws java.io.FileNotFoundException,
                                              java.lang.IllegalArgumentException
        Publish a GeoTiff already in a filesystem readable by GeoServer.
        Parameters:
        workspace - an existing workspace
        storeName - the coverageStore to be created
        geotiff - the geoTiff to be published
        srs - the native CRS
        policy - projection policy. See GSResourceEncoder.ProjectionPolicy.
        defaultStyle - the default style to apply.
        coverageName - a String object.
        Returns:
        true if the operation completed successfully.
        Throws:
        java.io.FileNotFoundException - if file does not exists
        java.lang.IllegalArgumentException - if any of the mandatory parameters are null.
      • publishExternalGeoTIFF

        public RESTCoverageStore publishExternalGeoTIFF​(java.lang.String workspace,
                                                        java.lang.String storeName,
                                                        java.io.File geotiff,
                                                        GSCoverageEncoder coverageEncoder,
                                                        GSLayerEncoder layerEncoder)
                                                 throws java.lang.IllegalArgumentException,
                                                        java.io.FileNotFoundException
        Publish a GeoTiff already in a filesystem readable by GeoServer.
        Parameters:
        workspace - an existing workspace
        storeName - the coverageStore to be created
        geotiff - the geoTiff to be published
        coverageEncoder - coverage details. See GSCoverageEncoder.
        layerEncoder - layer details, See GSLayerEncoder.
        Returns:
        true if the operation completed successfully.
        Throws:
        java.io.FileNotFoundException - if file does not exists
        java.lang.IllegalArgumentException - if any of the mandatory parameters are null.
      • publishWorldImage

        public boolean publishWorldImage​(java.lang.String workspace,
                                         java.lang.String coveragestore,
                                         java.io.File zipFile)
                                  throws java.io.FileNotFoundException
        Publish a zipped worldimage file. It is assumed that the the zip-file contain the *.prj to set the srs.
        Parameters:
        workspace - Workspace to use
        coveragestore - Name of the coveragestore
        zipFile - zip file to upload
        Returns:
        true if the operation completed successfully.
        Throws:
        java.io.FileNotFoundException - if any.
      • publishWorldImage

        public boolean publishWorldImage​(java.lang.String workspace,
                                         java.lang.String coveragestore,
                                         java.io.File zipFile,
                                         GeoServerRESTPublisher.ParameterConfigure configure,
                                         org.apache.commons.httpclient.NameValuePair... params)
                                  throws java.io.FileNotFoundException
        Publish a zipped worldimage file. It is assumed that the the zip-file contain the *.prj to set the srs.
        Parameters:
        workspace - Workspace to use
        coveragestore - Name of the coveragestore
        zipFile - zip file to upload
        configure - Configure parameter. See GeoServerRESTPublisher.ParameterConfigure. It can be null.
        params - parameters to append to the url (can be null).
        Accepted parameters are:
        Returns:
        true if the operation completed successfully.
        Throws:
        java.io.FileNotFoundException - if any.
      • publishImageMosaic

        public boolean publishImageMosaic​(java.lang.String workspace,
                                          java.lang.String storeName,
                                          java.io.File zipFile)
                                   throws java.io.FileNotFoundException
        Publish imagemosaic as zip file.
        Parameters:
        workspace - Workspace to use
        storeName - Name of the coveragestore
        zipFile - file to upload
        Returns:
        true if the operation completed successfully.
        Throws:
        java.io.FileNotFoundException - if any.
      • publishImageMosaic

        public boolean publishImageMosaic​(java.lang.String workspace,
                                          java.lang.String storeName,
                                          java.io.File zipFile,
                                          GeoServerRESTPublisher.ParameterConfigure configure,
                                          org.apache.commons.httpclient.NameValuePair... params)
                                   throws java.io.FileNotFoundException
        Publish imagemosaic as zip file.
        Parameters:
        workspace - Workspace to use
        storeName - Name of the coveragestore
        zipFile - file to upload
        configure - Configure parameter. See GeoServerRESTPublisher.ParameterConfigure. It can be null.
        params - parameters to append to the url (can be null).
        Accepted parameters are:
        • coverageName=name coverageName parameter to append. Only works if configure is not set to ParameterConfigure.NONE.
        Returns:
        true if the operation completed successfully.
        Throws:
        java.io.FileNotFoundException - if any.
      • createExternaMosaicDatastore

        public RESTCoverageStore createExternaMosaicDatastore​(java.lang.String workspace,
                                                              java.lang.String storeName,
                                                              java.io.File mosaicDir,
                                                              GeoServerRESTPublisher.ParameterConfigure configure,
                                                              GeoServerRESTPublisher.ParameterUpdate update)
                                                       throws java.io.FileNotFoundException
        Publish a Mosaic from a filesystem currently readable by GeoServer.
        Parameters:
        workspace - an existing workspace
        storeName - the name of the coverageStore to be created
        mosaicDir - the directory where the raster images are located
        configure - a specify if a coverage should be configured
        update - a GeoServerRESTPublisher.ParameterUpdate object.
        Returns:
        true if the operation completed successfully.
        Throws:
        java.io.FileNotFoundException - if any.
      • publishExternalMosaic

        public boolean publishExternalMosaic​(java.lang.String workspace,
                                             java.lang.String storeName,
                                             java.io.File mosaicDir,
                                             java.lang.String srs,
                                             java.lang.String defaultStyle)
                                      throws java.io.FileNotFoundException
        Publish a Mosaic already in a filesystem readable by GeoServer.
        Parameters:
        workspace - an existing workspace
        storeName - the name of the coverageStore to be created
        mosaicDir - the directory where the raster images are located
        srs - the coverage declared SRS
        defaultStyle - may be null
        Returns:
        true if the operation completed successfully.
        Throws:
        java.io.FileNotFoundException - if any.
      • publishExternalMosaic

        public boolean publishExternalMosaic​(java.lang.String workspace,
                                             java.lang.String storeName,
                                             java.io.File mosaicDir,
                                             GSCoverageEncoder coverageEncoder,
                                             GSLayerEncoder layerEncoder)
                                      throws java.io.FileNotFoundException,
                                             java.lang.IllegalArgumentException
        Publish a Mosaic already in a filesystem readable by GeoServer.
        Parameters:
        workspace - an existing workspace
        storeName - the name of the coverageStore to be created
        mosaicDir - the directory where the raster images are located
        coverageEncoder - 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, ...)
        Returns:
        true if the operation completed successfully.
        Throws:
        java.io.FileNotFoundException - if any.
        java.lang.IllegalArgumentException - if any.
      • unpublishCoverage

        public boolean unpublishCoverage​(java.lang.String workspace,
                                         java.lang.String storename,
                                         java.lang.String layerName)
        Remove the Coverage configuration from GeoServer.

        First, the associated layer is removed, then the Coverage configuration itself.

        CHECKME Maybe the coveragestore has to be removed as well.

        Parameters:
        workspace - a String object.
        storename - a String object.
        layerName - a String object.
        Returns:
        true if the operation completed successfully.
      • unpublishFeatureType

        public boolean unpublishFeatureType​(java.lang.String workspace,
                                            java.lang.String storename,
                                            java.lang.String layerName)
        Removes the featuretype and the associated layer.

        You may also want to remove the datastore.

        Parameters:
        workspace - a String object.
        storename - a String object.
        layerName - a String object.
        Returns:
        true if the operation completed successfully.
      • removeDatastore

        public boolean removeDatastore​(java.lang.String workspace,
                                       java.lang.String storename)
        Deprecated.
        will be removed in next release use removeDatastore(String, String, boolean)
        Remove recursively a given Datastore in a given Workspace.
        Parameters:
        workspace - The name of the workspace
        storename - The name of the Datastore to remove.
        Returns:
        true if the datastore was successfully removed.
      • removeDatastore

        public boolean removeDatastore​(java.lang.String workspace,
                                       java.lang.String storename,
                                       boolean recurse)
                                throws java.lang.IllegalArgumentException
        Remove a given Datastore in a given Workspace.
        Parameters:
        workspace - The name of the workspace
        storename - The name of the Datastore to remove.
        recurse - if remove should be performed recursively
        Returns:
        true if the datastore was successfully removed.
        Throws:
        java.lang.IllegalArgumentException - if workspace or storename are null or empty
      • removeDatastore

        public boolean removeDatastore​(java.lang.String workspace,
                                       java.lang.String storename,
                                       boolean recurse,
                                       GeoServerRESTPublisher.Purge purge)
                                throws java.lang.IllegalArgumentException

        removeDatastore

        Parameters:
        workspace - a String object.
        storename - a String object.
        recurse - a boolean.
        purge - a GeoServerRESTPublisher.Purge object.
        Returns:
        a boolean.
        Throws:
        java.lang.IllegalArgumentException - if any.
      • removeCoverageStore

        public boolean removeCoverageStore​(java.lang.String workspace,
                                           java.lang.String storename)
        Remove recursively a given CoverageStore in a given Workspace.
        Parameters:
        workspace - The name of the workspace
        storename - The name of the CoverageStore to remove.
        Returns:
        true if the CoverageStore was successfully removed.
      • removeCoverageStore

        public boolean removeCoverageStore​(java.lang.String workspace,
                                           java.lang.String storename,
                                           boolean recurse)
                                    throws java.lang.IllegalArgumentException
        Remove a given CoverageStore in a given Workspace.
        Parameters:
        workspace - The name of the workspace
        storename - The name of the CoverageStore to remove.
        recurse - if remove should be performed recursively
        Returns:
        true if the CoverageStore was successfully removed.
        Throws:
        java.lang.IllegalArgumentException - if any.
      • removeCoverageStore

        public boolean removeCoverageStore​(java.lang.String workspace,
                                           java.lang.String storename,
                                           boolean recurse,
                                           GeoServerRESTPublisher.Purge purge)
                                    throws java.lang.IllegalArgumentException
        Remove a given CoverageStore in a given Workspace. Note that purging may not work when deleting mosaics (https://jira.codehaus.org/browse/GEOT-4613).
        Parameters:
        workspace - The name of the workspace
        storename - The name of the CoverageStore to remove.
        recurse - if remove should be performed recursively
        purge - the purge method
        Returns:
        true if the CoverageStore was successfully removed.
        Throws:
        java.lang.IllegalArgumentException - if any.
      • removeStore

        public boolean removeStore​(java.lang.String workspace,
                                   java.lang.String storename,
                                   GeoServerRESTPublisher.StoreType type,
                                   boolean recurse,
                                   GeoServerRESTPublisher.Purge purge)
                            throws java.lang.IllegalArgumentException
        Remove a given Datastore in a given Workspace.
        Parameters:
        workspace - The name of the workspace
        storename - The name of the Datastore to remove.
        type - the GeoServerRESTPublisher.StoreType type
        recurse - if remove should be performed recursively
        purge - the purge method
        Returns:
        true if the store was successfully removed.
        Throws:
        java.lang.IllegalArgumentException - if workspace or storename are null or empty
      • removeWorkspace

        public boolean removeWorkspace​(java.lang.String workspace)
        Remove the workspace given Workspace using default parameters
        Parameters:
        workspace - the workspace to remove
        Returns:
        true if success, false otherwise
        See Also:
        removeWorkspace(String, boolean)
      • removeWorkspace

        public boolean removeWorkspace​(java.lang.String workspace,
                                       boolean recurse)
                                throws java.lang.IllegalArgumentException
        Remove a given Workspace.
        Parameters:
        workspace - The name of the workspace
        recurse - 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.
        Returns:
        true if the WorkSpace was successfully removed.
        Throws:
        java.lang.IllegalArgumentException - if any.
      • removeLayerGroup

        public boolean removeLayerGroup​(java.lang.String workspace,
                                        java.lang.String name)
        Remove a layer group.
        Parameters:
        workspace - the layer group workspace.
        name - the layer group name.
        Returns:
        true if succeeded.
      • removeLayerGroup

        public boolean removeLayerGroup​(java.lang.String name)
        Remove a layer group.
        Parameters:
        name - the layer group name.
        Returns:
        true if succeeded.
      • removeLayer

        public boolean removeLayer​(java.lang.String workspace,
                                   java.lang.String layerName)
        remove a generic given layer from a given workspace
        Parameters:
        workspace - a String object.
        layerName - a String object.
        Returns:
        true if success
      • reloadStore

        public boolean reloadStore​(java.lang.String workspace,
                                   java.lang.String storeName,
                                   GeoServerRESTPublisher.StoreType storeType)
                            throws java.lang.IllegalArgumentException

        reloadStore

        Parameters:
        workspace - a String object.
        storeName - a String object.
        storeType - a GeoServerRESTPublisher.StoreType object.
        Returns:
        true if successfully reloaded
        Throws:
        java.lang.IllegalArgumentException - if any.
      • reload

        public boolean reload()
        Reload the target geoserver configuration
        Returns:
        true if success
        See Also:
        GeoServer REST Config API
      • reset

        public boolean reset()
        Reset the target geoserver configuration
        Returns:
        true if success
        See Also:
        GeoServer REST Config API
      • configureLayer

        public boolean configureLayer​(java.lang.String workspace,
                                      java.lang.String resourceName,
                                      GSLayerEncoder layer)
                               throws java.lang.IllegalArgumentException
        Allows to configure some layer attributes such as DefaultStyle
        Parameters:
        workspace - a String object.
        resourceName - the name of the resource to use (featureStore or coverageStore name)
        layer - the layer encoder used to configure the layer
        Returns:
        true if success
        Throws:
        java.lang.IllegalArgumentException - if some arguments are null or empty
      • createLayerGroup

        public boolean createLayerGroup​(java.lang.String name,
                                        GSLayerGroupEncoder group)
        Create a new LayerGroup using the specified encoder
        Parameters:
        name - name of the layer group
        group - group encoder
        Returns:
        true if operation was successful
      • createLayerGroup

        public boolean createLayerGroup​(java.lang.String workspace,
                                        java.lang.String name,
                                        GSLayerGroupEncoder group)
        Create a new LayerGroup using the specified encoder
        Parameters:
        workspace - name of the workspace
        name - name of the layer group
        group - group encoder
        Returns:
        true if operation was successful
      • configureLayerGroup

        public boolean configureLayerGroup​(java.lang.String name,
                                           GSLayerGroupEncoder group)
        Update a LayerGroup using the specified encoder
        Parameters:
        name - name of the layer group
        group - group encoder
        Returns:
        true if operation was successful
      • configureLayerGroup

        public boolean configureLayerGroup​(java.lang.String workspace,
                                           java.lang.String name,
                                           GSLayerGroupEncoder group)
        Update a LayerGroup using the specified encoder
        Parameters:
        workspace - name of the workspace
        name - name of the layer group
        group - group encoder
        Returns:
        true if operation was successful
      • configureCoverage

        public boolean configureCoverage​(GSCoverageEncoder ce,
                                         java.lang.String wsname,
                                         java.lang.String csname)
        Configure an existing coverage in a given workspace and coverage store
        Parameters:
        ce - contains the coverage name to configure and the configuration to apply
        wsname - the workspace to search for existent coverage
        csname - the coverage store to search for existent coverage
        Returns:
        true if success
      • configureCoverage

        public boolean configureCoverage​(GSCoverageEncoder ce,
                                         java.lang.String wsname,
                                         java.lang.String csname,
                                         java.lang.String coverageName)
        Configure an existing coverage in a given workspace and coverage store
        Parameters:
        ce - contains the coverage name to configure and the configuration to apply
        wsname - the workspace to search for existent coverage
        csname - the coverage store to search for existent coverage
        coverageName - the name of the coverage, useful for changing name for the coverage itself
        Returns:
        true if success
      • createCoverage

        public boolean createCoverage​(java.lang.String wsname,
                                      java.lang.String storeName,
                                      GSCoverageEncoder ce)
                               throws java.lang.IllegalArgumentException
        Create a new coverage in a given workspace and coverage store
        Parameters:
        wsname - the workspace to search for existent coverage
        storeName - an existent store name to use as data source
        ce - contains the coverage name to create and the configuration to apply
        Returns:
        true if success
        Throws:
        java.lang.IllegalArgumentException - if arguments are null or empty
      • createResource

        public boolean createResource​(java.lang.String workspace,
                                      GeoServerRESTPublisher.StoreType dsType,
                                      java.lang.String storeName,
                                      GSResourceEncoder re)
                               throws java.lang.IllegalArgumentException
        Create a new resource in a given workspace and store
        Parameters:
        workspace - the workspace to search for existent coverage
        storeName - an existent store name to use as data source
        re - contains the coverage name to create and the configuration to apply
        dsType - a GeoServerRESTPublisher.StoreType object.
        Returns:
        true if success
        Throws:
        java.lang.IllegalArgumentException - if arguments are null or empty
      • removeResource

        public boolean removeResource​(java.lang.String workspace,
                                      GeoServerRESTPublisher.StoreType dsType,
                                      java.lang.String storeName,
                                      java.lang.String resName)
                               throws java.lang.IllegalArgumentException
        Configure resource in a given workspace and store
        Parameters:
        workspace - the workspace to search for existent coverage
        storeName - an existent store name to use as data source
        resName - contains the coverage name to create and the configuration to apply
        dsType - a GeoServerRESTPublisher.StoreType object.
        Returns:
        true if success
        Throws:
        java.lang.IllegalArgumentException - if arguments are null or empty
      • configureResource

        public boolean configureResource​(java.lang.String workspace,
                                         GeoServerRESTPublisher.StoreType dsType,
                                         java.lang.String storeName,
                                         GSResourceEncoder re)
                                  throws java.lang.IllegalArgumentException
        Configure a resource
        Parameters:
        workspace - the workspace to search for existent coverage
        storeName - an existent store name to use as data source
        re - contains the configuration to apply with the resource name
        dsType - a GeoServerRESTPublisher.StoreType object.
        Returns:
        true if success
        Throws:
        java.lang.IllegalArgumentException - if arguments are null or empty
      • configureResource

        public boolean configureResource​(java.lang.String workspace,
                                         GeoServerRESTPublisher.StoreType dsType,
                                         java.lang.String storeName,
                                         java.lang.String resourceName,
                                         GSResourceEncoder re)
                                  throws java.lang.IllegalArgumentException
        Configure a resource
        Parameters:
        workspace - the workspace to search for existent coverage
        storeName - an existent store name to use as data source
        resourceName - an existent resource name
        re - contains the configuration to apply, possibly new resource name
        dsType - a GeoServerRESTPublisher.StoreType object.
        Returns:
        true if success
        Throws:
        java.lang.IllegalArgumentException - if arguments are null or empty
      • sanitize

        protected java.lang.String sanitize​(java.lang.String s)
        Appends ".DUMMY" to any string containing a dot (sic).
        Parameters:
        s - a String object.
        Returns:
        a String object.
      • harvestExternal

        public boolean harvestExternal​(java.lang.String workspace,
                                       java.lang.String coverageStore,
                                       java.lang.String format,
                                       java.lang.String path)
        Create a store or harvest the coverage from the provided external path.
        Parameters:
        workspace - the GeoServer workspace
        coverageStore - the GeoServer coverageStore
        format - the format of the file to upload
        path - the absolute path to the file to upload
        Returns:
        true if the call succeeds or false otherwise.
      • createImageMosaic

        public boolean createImageMosaic​(java.lang.String workspace,
                                         java.lang.String coverageStore,
                                         java.lang.String path)
        Create a new ImageMosaic with the provided configuration provided as a zip file.

        This call configures all the coverages contained in the ImageMosaic.

        Parameters:
        workspace - the GeoServer workspace
        coverageStore - the GeoServer coverageStore
        path - the absolute path to the file to upload
        Returns:
        true if the call succeeds or false otherwise.
        Since:
        geoserver-2.4.0, geoserver-mng-1.6.0
      • createImageMosaic

        public boolean createImageMosaic​(java.lang.String workspace,
                                         java.lang.String coverageStore,
                                         java.lang.String path,
                                         GeoServerRESTStructuredGridCoverageReaderManager.ConfigureCoveragesOption configureOpt)
        Create a new ImageMosaic with the provided configuration provided as a zip file.

        With the options configure we can decide whether or not to configure or not the coverages contained in the ImageMosaic.

        Parameters:
        workspace - the GeoServer workspace
        coverageStore - the GeoServer coverageStore
        path - the absolute path to the file to upload
        configureOpt - tells GeoServer whether to configure all coverages in this mosaic (ALL) or none of them (NONE).
        Returns:
        true if the call succeeds or false otherwise.
        Since:
        geoserver-2.4.0, geoserver-mng-1.6.0
      • removeGranuleById

        public boolean removeGranuleById​(java.lang.String workspace,
                                         java.lang.String coverageStore,
                                         java.lang.String coverage,
                                         java.lang.String granuleId)
        Remove a granule from a structured coverage by id.
        Parameters:
        workspace - the GeoServer workspace
        coverageStore - the GeoServer coverageStore
        coverage - the name of the target coverage from which we are going to remove
        granuleId - a String object.
        Returns:
        null in case the call does not succeed, or an instance of RESTStructuredCoverageGranulesList.
      • removeGranulesByCQL

        public boolean removeGranulesByCQL​(java.lang.String workspace,
                                           java.lang.String coverageStore,
                                           java.lang.String coverage,
                                           java.lang.String filter)
                                    throws java.io.UnsupportedEncodingException
        Remove granules from a structured coverage, by providing a CQL filter.
        Parameters:
        workspace - the GeoServer workspace
        coverageStore - the GeoServer coverageStore
        coverageStore - the GeoServer coverageStore
        coverage - the name of the target coverage from which we are going to remove
        filter - the absolute path to the file to upload
        Returns:
        null in case the call does not succeed, or an instance of RESTStructuredCoverageGranulesList.
        Throws:
        java.io.UnsupportedEncodingException - if any.
      • postNewImport

        public int postNewImport()
                          throws java.lang.Exception
        Refers to postNewImport method
        Returns:
        a int.
        Throws:
        java.lang.Exception - if any.
      • postNewTaskAsMultiPartForm

        public int postNewTaskAsMultiPartForm​(int i,
                                              java.lang.String data)
                                       throws java.lang.Exception
        Parameters:
        i - a int.
        data - a String object.
        Returns:
        a int.
        Throws:
        java.lang.Exception - if any.
      • getTask

        public net.sf.json.JSONObject getTask​(int i,
                                              int t)
                                       throws java.lang.Exception
        Refers to getTask method
        Parameters:
        i - a int.
        t - a int.
        Returns:
        a JSONObject object.
        Throws:
        java.lang.Exception - if any.
      • putTask

        public void putTask​(int i,
                            int t,
                            java.lang.String json)
                     throws java.lang.Exception
        Refers to putTask method
        Parameters:
        i - a int.
        t - a int.
        json - a String object.
        Throws:
        java.lang.Exception - if any.
      • putTaskLayer

        public void putTaskLayer​(int i,
                                 int t,
                                 java.lang.String json)
                          throws java.lang.Exception
        Refers to putTaskLayer method
        Parameters:
        i - a int.
        t - a int.
        json - a String object.
        Throws:
        java.lang.Exception - if any.
      • postImport

        public void postImport​(int i)
                        throws java.lang.Exception
        Refers to postImport method
        Parameters:
        i - a int.
        Throws:
        java.lang.Exception - if any.