diff --git a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java index 3a9f47a..b823604 100644 --- a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java +++ b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java @@ -208,6 +208,36 @@ public class GeoServerRESTPublisher { "application/vnd.ogc.sld+xml", gsuser, gspass); return result != null; } + + /** + * Replace an existing SLD. + *
+ * This is the equivalent call with cUrl: + * + *
+ * {@code curl -u admin:geoserver -XPUT \
+ * -H 'Content-type: application/vnd.ogc.sld+xml' \
+ * -d @$FULLSLD \
+ * http://$GSIP:$GSPORT/$SERVLET/rest/styles/$FULLSLD}
+ *
+ *
+ * @param sldBody, String sldName
+ * the SLD document as an XML String.
+ *
+ * @return true if the operation completed successfully.
+ */
+ public boolean putStyle(final String sldBody, final String sldName) throws IllegalArgumentException {
+ if (sldBody == null || sldBody.isEmpty()){
+ throw new IllegalArgumentException("The style body may not be null or empty");
+ } else if (sldName != null && !sldName.isEmpty()){
+ throw new IllegalArgumentException("The style name may not be null or empty");
+ }
+ StringBuilder sUrl = new StringBuilder(restURL);
+ sUrl.append("/rest/styles/").append(sldName);
+ final String result = HTTPUtils.put(sUrl.toString(), sldBody,
+ "application/vnd.ogc.sld+xml", gsuser, gspass);
+ return result != null;
+ }
/**
* Remove a Style.