[Geoserver-devel] [JIRA] (GEOS-9280) Uploading of SLD from GeoNode fails

Robert Ward created an issue

GeoServer / BugGEOS-9280

Uploading of SLD from GeoNode fails

Issue Type:

BugBug

Affects Versions:

2.15.2

Assignee:

Unassigned

Components:

REST

Created:

08/Jul/19 3:16 PM

Environment:

Ubuntu 18.04 GeoServer 2.15.2

Priority:

HighHigh

Reporter:

Robert Ward

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.

Add Comment

Add Comment

Get Jira notifications on your phone! Download the Jira Cloud app for Android or iOS


This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100105-sha1:45b16e0)

Atlassian logo