@@ -198,12 +198,10 @@ class PortalController {
198
198
* null when not logged in
199
199
*/
200
200
private def getValidUserId (params ) {
201
- // apiKey + userId (non-numeric) OR authenticated user
201
+ // find the authenticated user, or the default user
202
202
def userId
203
203
if (! Holders . config. security. oidc. enabled) {
204
204
userId = portalService. DEFAULT_USER_ID
205
- } else if (portalService. isValidApiKey(params. apiKey) && ! StringUtils . isNumeric(params. userId)) {
206
- userId = params. userId
207
205
} else {
208
206
userId = authService. userId
209
207
}
@@ -290,26 +288,29 @@ class PortalController {
290
288
notAuthorised()
291
289
} else {
292
290
def type = id
291
+
292
+ // write the file to disk
293
293
MultipartFile mFile = ((MultipartHttpServletRequest ) request). getFile(' shapeFile' )
294
- def settings = [apiKey : grailsApplication. config. api_key]
295
294
296
295
String ce = grailsApplication. config. character. encoding
297
296
298
- def r = hubWebService . postUrl( " ${ grailsApplication.config.layersService.url} /shape/upload/${ type} ?" +
297
+ String url = " ${ grailsApplication.config.layersService.url} /shape/upload/${ type} ?" +
299
298
" name=${ URLEncoder.encode((String) params.name, ce)} &" +
300
- " description=${ URLEncoder.encode((String) params.description, ce)} &" +
301
- " api_key=${ grailsApplication.config.api_key} " , null , settings, mFile);
299
+ " description=${ URLEncoder.encode((String) params.description, ce)} "
300
+
301
+ List files = [mFile]
302
+ def r = webService. post(url, null , null , files, ContentType . MULTIPART_FORM_DATA , false , true )
302
303
303
304
if (! r) {
304
305
render [:] as JSON
305
306
} else if (r. error || r. statusCode > 299 ) {
306
307
log. error(" failed ${ type} upload: ${ r} " )
307
- def msg = JSON . parse( new String (r ?. text ?: " {} " ))
308
+ def msg = r . resp
308
309
Map error = [error : msg. error]
309
310
response. status = r. statusCode
310
311
render error as JSON
311
312
} else {
312
- def json = JSON . parse( new String (r ?. text ?: " {} " ))
313
+ def json = r . resp
313
314
def shapeFileId = json. id
314
315
def area = json. collect { key , value ->
315
316
if (key == ' shp_id' ) {
@@ -352,14 +353,8 @@ class PortalController {
352
353
} else {
353
354
def json = request. JSON as Map
354
355
355
- Map params = [sessionId : params. sessionId]
356
- for (def key : json. keySet()) {
357
- if (key != ' sessionId' ) {
358
- params. put(key, String . valueOf(json[key]))
359
- }
360
- }
361
-
362
- def r = webService. post(" ${ grailsApplication.config.layersService.url} /tasks/create" , null , params, ContentType . APPLICATION_JSON , false , true )
356
+ String url = " ${ grailsApplication.config.layersService.url} /tasks/create?userId=${ userId} &sessionId=${ params.sessionId} "
357
+ def r = webService. post(url, json, null , ContentType . APPLICATION_JSON , false , true )
363
358
364
359
if (r == null ) {
365
360
render [:] as JSON
0 commit comments