Improve on appending the raw parameter on existing query string for publish and update SLDs

This commit is contained in:
andypower 2015-04-03 11:54:02 +02:00
parent 213ed8326d
commit 3e810bb869

View File

@ -295,14 +295,14 @@ public class GeoServerRESTStyleManager extends GeoServerRESTAbstractManager {
throw new IllegalArgumentException("The style body may not be null or empty"); throw new IllegalArgumentException("The style body may not be null or empty");
} }
String sUrl = buildPostUrl(null, name); StringBuilder sUrl = new StringBuilder(buildPostUrl(null, name));
sUrl += "&raw=" + raw; Util.appendParameter(sUrl, "raw", ""+raw);
LOGGER.debug("POSTing new style " + name + " to " + sUrl);
String contentType = GeoServerRESTPublisher.Format.SLD.getContentType(); String contentType = GeoServerRESTPublisher.Format.SLD.getContentType();
if(!this.checkSLD10Version(sldBody)){ if(!this.checkSLD10Version(sldBody)){
contentType = GeoServerRESTPublisher.Format.SLD_1_1_0.getContentType(); contentType = GeoServerRESTPublisher.Format.SLD_1_1_0.getContentType();
} }
String result = HTTPUtils.post(sUrl, sldBody, contentType, gsuser, gspass); LOGGER.debug("POSTing new style " + name + " to " + sUrl + " using version: " + contentType);
String result = HTTPUtils.post(sUrl.toString(), sldBody, contentType, gsuser, gspass);
return result != null; return result != null;
} }
@ -323,14 +323,14 @@ public class GeoServerRESTStyleManager extends GeoServerRESTAbstractManager {
* {@code curl -u admin:geoserver -XPOST \ -H 'Content-type: application/vnd.ogc.sld+xml' \ -d @$FULLSLD \ * {@code curl -u admin:geoserver -XPOST \ -H 'Content-type: application/vnd.ogc.sld+xml' \ -d @$FULLSLD \
* http://$GSIP:$GSPORT/$SERVLET/rest/styles?name=$name&raw=$raw} * http://$GSIP:$GSPORT/$SERVLET/rest/styles?name=$name&raw=$raw}
*/ */
String sUrl = buildPostUrl(null, name); StringBuilder sUrl = new StringBuilder(buildPostUrl(null, name));
sUrl += "&raw=" + raw; Util.appendParameter(sUrl, "raw", ""+raw);
LOGGER.debug("POSTing new style " + name + " to " + sUrl);
String contentType = GeoServerRESTPublisher.Format.SLD.getContentType(); String contentType = GeoServerRESTPublisher.Format.SLD.getContentType();
if(!this.checkSLD10Version(sldFile)){ if(!this.checkSLD10Version(sldFile)){
contentType = GeoServerRESTPublisher.Format.SLD_1_1_0.getContentType(); contentType = GeoServerRESTPublisher.Format.SLD_1_1_0.getContentType();
} }
String result = HTTPUtils.post(sUrl, sldFile, contentType, gsuser, gspass); LOGGER.debug("POSTing new style " + name + " to " + sUrl + " using version: " + contentType);
String result = HTTPUtils.post(sUrl.toString(), sldFile, contentType, gsuser, gspass);
return result != null; return result != null;
} }
@ -358,14 +358,14 @@ public class GeoServerRESTStyleManager extends GeoServerRESTAbstractManager {
throw new IllegalArgumentException("The style name may not be null or empty"); throw new IllegalArgumentException("The style name may not be null or empty");
} }
String sUrl = buildUrl(null, name, null); StringBuilder sUrl = new StringBuilder(buildUrl(null, name, null));
sUrl += "?raw=" + raw; Util.appendParameter(sUrl, "raw", ""+raw);
LOGGER.debug("POSTing style " + name + " to " + sUrl);
String contentType = GeoServerRESTPublisher.Format.SLD.getContentType(); String contentType = GeoServerRESTPublisher.Format.SLD.getContentType();
if(!this.checkSLD10Version(sldFile)){ if(!this.checkSLD10Version(sldFile)){
contentType = GeoServerRESTPublisher.Format.SLD_1_1_0.getContentType(); contentType = GeoServerRESTPublisher.Format.SLD_1_1_0.getContentType();
} }
String result = HTTPUtils.put(sUrl, sldFile, contentType, gsuser, gspass); LOGGER.debug("PUTting style " + name + " to " + sUrl + " using version: " + contentType);
String result = HTTPUtils.put(sUrl.toString(), sldFile, contentType, gsuser, gspass);
return result != null; return result != null;
} }
@ -393,14 +393,14 @@ public class GeoServerRESTStyleManager extends GeoServerRESTAbstractManager {
throw new IllegalArgumentException("The style name may not be null or empty"); throw new IllegalArgumentException("The style name may not be null or empty");
} }
String sUrl = buildUrl(null, name, null); StringBuilder sUrl = new StringBuilder(buildUrl(null, name, null));
sUrl += "&raw=" + raw; Util.appendParameter(sUrl, "raw", ""+raw);
LOGGER.debug("POSTing style " + name + " to " + sUrl);
String contentType = GeoServerRESTPublisher.Format.SLD.getContentType(); String contentType = GeoServerRESTPublisher.Format.SLD.getContentType();
if(!this.checkSLD10Version(sldBody)){ if(!this.checkSLD10Version(sldBody)){
contentType = GeoServerRESTPublisher.Format.SLD_1_1_0.getContentType(); contentType = GeoServerRESTPublisher.Format.SLD_1_1_0.getContentType();
} }
String result = HTTPUtils.put(sUrl, sldBody, contentType, gsuser, gspass); LOGGER.debug("PUTting style " + name + " to " + sUrl + " using version: " + contentType);
String result = HTTPUtils.put(sUrl.toString(), sldBody, contentType, gsuser, gspass);
return result != null; return result != null;
} }