@@ -376,28 +376,67 @@ class PortalController {
376
376
377
377
def url = grailsApplication. config. lists. url
378
378
379
- def header = [:]
380
- if (Holders . config. security. oidc. enabled) {
381
- header. put(" userId" , userId)
382
- header. put(" X-ALA-userId" , userId)
383
- header. put(" apiKey" , grailsApplication. config. api_key)
384
- // header.put('Cookie', 'ALA-Auth=' + URLEncoder.encode(authService.email, 'UTF-8'))
379
+ def r = webService. post(" ${ url} /ws/speciesList/" , json)
380
+
381
+ if (r == null ) {
382
+ def status = response. setStatus(HttpURLConnection . HTTP_INTERNAL_ERROR )
383
+ r = [status : status, error : ' Unknown error when creating list' ]
384
+ }
385
+
386
+ def status = r. statusCode
387
+ if (r. statusCode < 200 || r. statusCode > 300 ) {
388
+ r = [error : r. resp ]
385
389
}
386
390
387
- def r = hubWebService. urlResponse(HttpPost . METHOD_NAME , " ${ url} /ws/speciesList/" , null , header,
388
- new StringRequestEntity ((json as JSON ). toString()), true )
391
+ render status : status, r. resp as JSON
392
+ }
393
+ }
394
+
395
+ def speciesListItems () {
396
+ def userId = getValidUserId(params)
397
+
398
+ if (! userId) {
399
+ notAuthorised()
400
+ } else {
401
+ def url = grailsApplication. config. lists. url
402
+
403
+ def r = webService. get(" ${ url} /ws/speciesListItems/" + params. id, [:], org.apache.http.entity.ContentType . APPLICATION_JSON , false , true , [:])
389
404
390
405
if (r == null ) {
391
406
def status = response. setStatus(HttpURLConnection . HTTP_INTERNAL_ERROR )
392
- r = [status : status, error : ' Unknown error when creating list' ]
407
+ r = [status : status, error : ' Unknown error when fetching list' ]
408
+ }
409
+
410
+ def status = r. statusCode
411
+ if (r. statusCode < 200 || r. statusCode > 300 ) {
412
+ r = [error : r. resp ]
413
+ }
414
+
415
+ render status : status, r. resp as JSON
416
+ }
417
+ }
418
+
419
+ def speciesList () {
420
+ def userId = getValidUserId(params)
421
+
422
+ if (! userId) {
423
+ notAuthorised()
424
+ } else {
425
+ def url = grailsApplication. config. lists. url
426
+
427
+ def r = webService. get(" ${ url} /ws/speciesList" , [user : params. user ? userId : null , max: params. max], org.apache.http.entity.ContentType . APPLICATION_JSON , false , true , [:])
428
+
429
+ if (r == null ) {
430
+ def status = response. setStatus(HttpURLConnection . HTTP_INTERNAL_ERROR )
431
+ r = [status : status, error : ' Unknown error when fetching list' ]
393
432
}
394
433
395
434
def status = r. statusCode
396
435
if (r. statusCode < 200 || r. statusCode > 300 ) {
397
- r = [error : r. text ]
436
+ r = [error : r. resp ]
398
437
}
399
438
400
- render status : status, r as JSON
439
+ render status : status, r. resp as JSON
401
440
}
402
441
}
403
442
@@ -421,7 +460,6 @@ class PortalController {
421
460
json. fq[0 ] = json. q
422
461
json. q = tmp
423
462
} else if (json?. wkt || json?. qc) {
424
- log. error(getWkt(json?. wkt))
425
463
json. fq = [json. q]
426
464
json. q = ' *:*'
427
465
} else {
0 commit comments