it.geosolutions.geoserver.rest.manager
Class GeoServerRESTStyleManager

java.lang.Object
  extended by it.geosolutions.geoserver.rest.manager.GeoServerRESTAbstractManager
      extended by it.geosolutions.geoserver.rest.manager.GeoServerRESTStyleManager

public class GeoServerRESTStyleManager
extends GeoServerRESTAbstractManager

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

Field Summary
 
Fields inherited from class it.geosolutions.geoserver.rest.manager.GeoServerRESTAbstractManager
gsBaseUrl, gspass, gsuser
 
Constructor Summary
GeoServerRESTStyleManager(URL restURL, String username, String password)
          Default constructor.
 
Method Summary
protected  String buildPostUrl(String workspace, String name)
          Creates a URL for the given stylename with the name in querystring
protected  String buildUrl(String workspace, String name, String ext)
          Creates a URL for the given stylename with the name in the REST path
protected  String buildXmlUrl(String workspace, String name)
           
 boolean existsStyle(String name)
          Check if a Style exists in the configured GeoServer instance.
 boolean existsStyle(String workspace, String name)
           
 String getSLD(String styleName)
          Get the SLD body of a Style.
 String getSLD(String workspace, String name)
          Get the SLD body of a Style.
 RESTStyle getStyle(String name)
           
 RESTStyle getStyle(String workspace, String name)
           
 RESTStyleList getStyles()
          Get summary info about all Styles.
 RESTStyleList getStyles(String workspace)
          Get summary info about Styles in a workspace.
 boolean publishStyle(File sldFile)
          Store and publish a Style.
 boolean publishStyle(File sldFile, String name)
          Store and publish a Style, assigning it a name.
 boolean publishStyle(String sldBody)
          Store and publish a Style.
 boolean publishStyle(String sldBody, String name)
          Store and publish a Style, assigning it a name.
 boolean publishStyleInWorkspace(String workspace, File sldFile)
          Store and publish a Style.
 boolean publishStyleInWorkspace(String workspace, File sldFile, String name)
          Store and publish a Style, assigning it a name.
 boolean publishStyleInWorkspace(String workspace, String sldBody)
          Store and publish a Style.
 boolean publishStyleInWorkspace(String workspace, String sldBody, String name)
          Store and publish a Style, assigning it a name.
 boolean removeStyle(String styleName)
          Remove a Style.
 boolean removeStyle(String styleName, boolean purge)
          Remove a Style.
 boolean removeStyleInWorkspace(String workspace, String styleName)
          Remove a Style.
 boolean removeStyleInWorkspace(String workspace, String styleName, boolean purge)
          Remove a Style.
 boolean updateStyle(File sldFile, String name)
          Update a Style.
 boolean updateStyle(String sldBody, String name)
          Update a Style.
 boolean updateStyleInWorkspace(String workspace, File sldFile, String name)
          Update a Style.
 boolean updateStyleInWorkspace(String workspace, String sldBody, String name)
          Update a Style.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeoServerRESTStyleManager

public GeoServerRESTStyleManager(URL restURL,
                                 String username,
                                 String password)
                          throws IllegalArgumentException
Default constructor.

Parameters:
restURL - GeoServer REST API endpoint
username - GeoServer REST API authorized username
password - GeoServer REST API password for the former username
Throws:
IllegalArgumentException
Method Detail

existsStyle

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

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

getStyles

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

Returns:
summary info about Styles as a RESTStyleList

getStyle

public RESTStyle getStyle(String name)

getSLD

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


existsStyle

public boolean existsStyle(String workspace,
                           String name)
Since:
GeoServer 2.2

getStyles

public RESTStyleList getStyles(String workspace)
Get summary info about Styles in a workspace.

Returns:
summary info about Styles as a RESTStyleList
Since:
GeoServer 2.2

getStyle

public RESTStyle getStyle(String workspace,
                          String name)
Since:
GeoServer 2.2

getSLD

public String getSLD(String workspace,
                     String name)
Get the SLD body of a Style.

Since:
GeoServer 2.2

publishStyle

public boolean publishStyle(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(String sldBody,
                            String name)
                     throws 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:
IllegalArgumentException - if the style body is null or empty.

publishStyle

public boolean publishStyle(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(File sldFile,
                            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.

updateStyle

public boolean updateStyle(String sldBody,
                           String name)
                    throws 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:
IllegalArgumentException - if the style body or name are null or empty.

updateStyle

public boolean updateStyle(File sldFile,
                           String name)
                    throws IllegalArgumentException
Update a Style.

Parameters:
sldFile - the File containing the SLD document.
name - the Style name.
Returns:
true if the operation completed successfully.
Throws:
IllegalArgumentException - if the sldFile file or name are null or name is empty.

removeStyle

public boolean removeStyle(String styleName,
                           boolean purge)
                    throws 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:
IllegalArgumentException - if styleName is null or empty.

removeStyle

public boolean removeStyle(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(String workspace,
                                       String sldBody)
Store and publish a Style.

Parameters:
sldBody - the full SLD document as a String.
Returns:
true if the operation completed successfully.
Since:
GeoServer 2.2

publishStyleInWorkspace

public boolean publishStyleInWorkspace(String workspace,
                                       String sldBody,
                                       String name)
                                throws 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:
IllegalArgumentException - if the style body is null or empty.
Since:
GeoServer 2.2

publishStyleInWorkspace

public boolean publishStyleInWorkspace(String workspace,
                                       File sldFile)
Store and publish a Style.

Parameters:
sldFile - the File containing the SLD document.
Returns:
true if the operation completed successfully.
Since:
GeoServer 2.2

publishStyleInWorkspace

public boolean publishStyleInWorkspace(String workspace,
                                       File sldFile,
                                       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.
Since:
GeoServer 2.2

updateStyleInWorkspace

public boolean updateStyleInWorkspace(String workspace,
                                      String sldBody,
                                      String name)
                               throws 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:
IllegalArgumentException - if the style body or name are null or empty.
Since:
GeoServer 2.2

updateStyleInWorkspace

public boolean updateStyleInWorkspace(String workspace,
                                      File sldFile,
                                      String name)
                               throws IllegalArgumentException
Update a Style.

Parameters:
sldFile - the File containing the SLD document.
name - the Style name.
Returns:
true if the operation completed successfully.
Throws:
IllegalArgumentException - if the sldFile file or name are null or name is empty.
Since:
GeoServer 2.2

removeStyleInWorkspace

public boolean removeStyleInWorkspace(String workspace,
                                      String styleName,
                                      boolean purge)
                               throws 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:
IllegalArgumentException - if styleName is null or empty.
Since:
GeoServer 2.2

removeStyleInWorkspace

public boolean removeStyleInWorkspace(String workspace,
                                      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.
Since:
GeoServer 2.2

buildPostUrl

protected String buildPostUrl(String workspace,
                              String name)
Creates a URL for the given stylename with the name in querystring

Parameters:
workspace - nullable workspace name
name - style name
Returns:

buildXmlUrl

protected String buildXmlUrl(String workspace,
                             String name)

buildUrl

protected String buildUrl(String workspace,
                          String name,
                          String ext)
Creates a URL for the given stylename with the name in the REST path

Parameters:
workspace - nullable workspace name
name - style name
ext - nullable output extension (e.g. ".xml" ".sld")


Copyright © 2007-2014 GeoSolutions. All Rights Reserved.