@@ -111,7 +111,8 @@ class PortalController {
111
111
userDetails : authService. userDetails(),
112
112
sessionId : sessionService. newId(userId),
113
113
messagesAge : messageService. messagesAge,
114
- hub : hub])
114
+ hub : hub,
115
+ custom_facets : toMapOfLists(config. biocacheService. custom_facets)])
115
116
} else if (! authDisabled && userId == null ) {
116
117
login()
117
118
} else {
@@ -378,6 +379,7 @@ class PortalController {
378
379
def header = [:]
379
380
if (Holders . config. security. oidc. enabled) {
380
381
header. put(" userId" , userId)
382
+ header. put(" X-ALA-userId" , userId)
381
383
header. put(" apiKey" , grailsApplication. config. api_key)
382
384
// header.put('Cookie', 'ALA-Auth=' + URLEncoder.encode(authService.email, 'UTF-8'))
383
385
}
@@ -631,4 +633,78 @@ class PortalController {
631
633
def embedExample () {
632
634
render(view : ' embedExample' )
633
635
}
636
+
637
+ private def toList (Object o ) {
638
+ if (o == null || org.apache.commons.lang3.StringUtils . isEmpty(o. toString())) {
639
+ return []
640
+ } else if (o instanceof List ) {
641
+ return o
642
+ } else if (o. toString(). startsWith(" [" )) {
643
+ // JSON list
644
+ return JSON . parse(o. toString())
645
+ } else {
646
+ // comma delimited
647
+ return Arrays . asList(o. toString(). split(" ," ))
648
+ }
649
+ }
650
+
651
+ private def toListOfMaps (Object o ) {
652
+ if (o == null || o. toString(). isEmpty()) {
653
+ return new ArrayList ()
654
+ }
655
+
656
+ def listOfMaps = toList(o)
657
+
658
+ for (def i = 0 ; i < listOfMaps. size(); i++ ) {
659
+ listOfMaps. set(i, toMap(listOfMaps. get(i)))
660
+ }
661
+
662
+ return listOfMaps
663
+ }
664
+
665
+ private def toMap (Object o ) {
666
+ if (o == null || o. toString(). isEmpty()) {
667
+ return new HashMap ()
668
+ }
669
+
670
+ def map = o
671
+
672
+ if (! (map instanceof Map )) {
673
+ map = JSON . parse(map. toString())
674
+ }
675
+
676
+ return map
677
+ }
678
+
679
+ private def toMapOfMaps (Object o ) {
680
+ if (o == null || o. toString(). isEmpty()) {
681
+ return new HashMap ()
682
+ }
683
+
684
+ def mapOfMaps = toMap(o)
685
+
686
+ for (def key : mapOfMaps. keySet) {
687
+ mapOfMaps[key] = toMap(mapOfMaps[key])
688
+ }
689
+
690
+ return mapOfMaps
691
+ }
692
+
693
+ private def toMapOfLists (Object o ) {
694
+ if (o == null || o. toString(). isEmpty()) {
695
+ return new HashMap ()
696
+ }
697
+
698
+ def mapOfLists = toMap(o)
699
+
700
+ def result = [:]
701
+ mapOfLists. each { k , v ->
702
+ if (! k. contains(' [' )) { // exclude odd artifacts
703
+ result[k] = toList(v)
704
+ }
705
+ }
706
+
707
+
708
+ return result
709
+ }
634
710
}
0 commit comments