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 :
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 :
{"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) :
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:
{
"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
{
"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
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:
{
"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
}
}
|