| When using GeoNode 2.10rc5 to upload a layer to GeoServer 2.15.2 it results in GeoServer reporting the error
No such style handler: format = application/xml
In GeoNode the python package used to upload the data to GeoServer is called gsconfig. Tested with GeoServer 2.15.1 and the same error is returned. Testing with an older nightly build of GeoServer 2.15.1 from a couple of weeks ago works fine. No code has changed in GeoServer in this area and also in gsconfig. As per the (GeoServer API documentation) the POST /styles REST endpoint it passes the following:
<style>
<name>roads_style</name>
<filename>roads.sld</filename>
</style>
gsconfig when passing making this call passes the following data in the header:
Content-Type : application/xml
Accept : application/xml
The problem is the Accept header item, if it is omitted the correct method is called :
org.geoserver.rest.catalog.StyleController stylePost()
If the Accept header is present then it calls
org.geoserver.rest.catalog.StyleController styleSLDPost()
The reason this happens is because the `produces` list is not expecting application/xml. I assume an underlying xml library has updated.
@PostMapping(
value = {"/styles", "/layers/{layerName}/styles", "/workspaces/{workspaceName}/styles"},
consumes = {
MediaType.TEXT_XML_VALUE,
MediaType.APPLICATION_XML_VALUE,
MediaType.APPLICATION_JSON_VALUE,
MediaTypeExtensions.TEXT_JSON_VALUE
},
produces = MediaType.TEXT_PLAIN_VALUE
)
and should be:
@PostMapping(
value = {"/styles", "/layers/{layerName}/styles", "/workspaces/{workspaceName}/styles"},
consumes = {
MediaType.TEXT_XML_VALUE,
MediaType.APPLICATION_XML_VALUE,
MediaType.APPLICATION_JSON_VALUE,
MediaTypeExtensions.TEXT_JSON_VALUE
},
produces = {MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE}
)
This fix ensures that it is backwards compatible. |