Importer does not parse the JSON on creation if the json content type contains parameters

Description

Using REST interface of the importer the targetWorkspace configured is not used if I try to import a GeoTiff.

Steps to reproduce (note: curl requests are copied from chrome dev tools)
Create a new import with :

1 curl 'http://localhost:8080/geoserver/rest/imports' -H 'Authorization: Basic <user:pass-encoded>' -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept: application/json, text/plain, */*' --data-binary '{"import":{"targetWorkspace":{"workspace":{"name":"terrain"}}}}'

I receive the id of the new import :

1 {"import":{"id":35,"href":"http://localhost:8080/geoserver/rest/imports/35","state":"PENDING","archive":false,"tasks":[]}}

Then create a new task uploading a tiff via multipart (note: this request is incomplete because have been copied from the chrome dev tools, for a complete example in curl, use this instructions (http://docs.geoserver.org/latest/en/user/extensions/importer/rest_examples.html#uploading-and-optimizing-a-geotiff-with-ground-control-points) :

1 curl 'http://localhost:8080/geoserver/rest/imports/35/tasks' -H 'Pragma: no-cache' -H 'Authorization: Basic <user:pass-encoded>' -H 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryxd0tMCbycxWYAdmB' -H 'Accept: application/json, text/plain, */*' -H 'Cache-Control: no-cache' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.3 -H 'Connection: keep-alive' --data-binary $'------WebKitFormBoundaryxd0tMCbycxWYAdmB\r\nContent-Disposition: form-data; name="sample.tif"; filename="sample.tif"\r\nContent-Type: image/tiff\r\n\r\n\r\n------WebKitFormBoundaryxd0tMCbycxWYAdmB--\r\n'

and receive the confirmation that the task have been created:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 { "task":{ "id":0, "href":"http://localhost:8080/geoserver/rest/imports/35/tasks/0", "state":"READY", "updateMode":"CREATE", "data":{ "type":"file", "format":"GeoTIFF", "file":"sample.tif" }, "target":{ "href":"http://localhost:8080/geoserver/rest/imports/35/tasks/0/target", "coverageStore":{ "name":"sample", "type":"GeoTIFF" } }, "progress":"http://localhost:8080/geoserver/rest/imports/35/tasks/0/progress", "layer":{ "name":"sample", "href":"http://localhost:8080/geoserver/rest/imports/35/tasks/0/layer" }, "transformChain":{ "type":"raster", "transforms":[ ] } } }

But if I try to get the target details from :
http://localhost:8080/geoserver/rest/imports/35/tasks/0/target

I receive this response

1 2 3 4 5 6 7 8 9 10 11 12 13 { "href":"http://localhost:8080/geoserver/rest/imports/35/tasks/0/target", "coverageStore":{ "name":"sample", "type":"GeoTIFF", "enabled":true, "workspace":{ "name":"MY_DEFAULT_WORKSPACE" }, "_default":false, "url":"file:uploads/tmp7078593201894025318/sample.tif" } }

Where MY_DEFAULT_WORKSPACE is the default workspace set in GeoServer.

I tried the same procedure uploading a shape file.
In this case I also change the datastore to the database one

1 curl 'http://localhost:8080/geoserver/rest/imports/35/tasks/1/target' -X PUT -H 'Pragma: no-cache' -H 'Origin: http://localhost:8080' -H 'Accept-Encoding: gzip, deflate, sdch, br' -H 'Accept-Language: en-US,en;q=0.8,it-IT;q=0.6,it;q=0.4' -H 'Authorization: Basic <user:pass-encoded>' -H 'Content-Type: application/json' -H 'Accept: application/json, text/plain, */*' -H 'Cache-Control: no-cache' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36' -H 'Cookie: _ga=GA1.2.970723969.1409643516' -H 'Connection: keep-alive' -H 'Referer: http://localhost:8080/terrainExplorer/' --data-binary '{"dataStore":{"name":"terrain"}}' --compressed --insecure

And in this case works:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 { "href":"http://localhost:8080/geoserver/rest/imports/35/tasks/1/target", "dataStore":{ "name":"terrain", "type":"PostGIS (JNDI)", "enabled":true, "workspace":{ "name":"terrain" }, "connectionParameters":{ "entry":[ { "@key":"schema", "$":"public" }, { "@key":"Estimated extends", "$":"true" }, { "@key":"Batch insert size", "$":"100" }, { "@key":"preparedStatements", "$":"true" }, { "@key":"fetch size", "$":"1000" }, { "@key":"encode functions", "$":"true" }, { "@key":"jndiReferenceName", "$":"java:comp/env/jdbc/npa" }, { "@key":"Expose primary keys", "$":"false" }, { "@key":"Support on the fly geometry simplification", "$":"true" }, { "@key":"dbtype", "$":"postgis" }, { "@key":"namespace", "$":"http://localhost:8080/terrain" }, { "@key":"Loose bbox", "$":"true" } ] }, "_default":false } }

Environment

None

Status

Assignee

Andrea Aime

Reporter

Lorenzo Natali

Triage

None

Fix versions

Affects versions

2.8.5
2.10-M0

Components

Priority

Medium
Configure