@@ -22,14 +22,17 @@ def federated_get(params = {}, &link)
2222 end
2323
2424 unless portal_status
25+ HTTP . log ( "Error in federation #{ portal_name } is down status cached for 10 minutes" )
2526 next [ OpenStruct . new ( errors : "Problem retrieving #{ portal_name } " ) ]
2627 end
2728
2829 main_thread_locals . each { |key , value | Thread . current [ key ] = value }
2930 begin
30- HTTP . get ( link . call ( conn . url_prefix . to_s . chomp ( '/' ) ) , params , connection : conn )
31+ portal_params = params [ portal_name . to_s . downcase ] || params
32+ HTTP . get ( link . call ( conn . url_prefix . to_s . chomp ( '/' ) ) , portal_params , connection : conn )
3133 rescue Exception => e
32- Rails . cache . write ( "federation_portal_up_#{ portal_name } " , false , expires_in : 10 . minutes )
34+ HTTP . log ( "Error in federation #{ portal_name } is down status cached for 10 minutes" )
35+ Rails . cache . write ( "federation_portal_up_#{ portal_name } " , false , expires_in : 10 . minutes ) unless internal_call? ( conn )
3336 [ OpenStruct . new ( errors : "Problem retrieving #{ link . call ( conn . url_prefix . to_s . chomp ( '/' ) ) || conn . url_prefix } " ) ]
3437 end
3538 end
@@ -39,10 +42,14 @@ def federated_get(params = {}, &link)
3942
4043
4144
42- def request_portals ( params = { } )
43- federate = params . delete ( :federate ) || ::RequestStore . store [ :federated_portals ]
45+ def federated_portals_names ( params = { } )
46+ params [ :federate ] || ::RequestStore . store [ :federated_portals ]
47+ end
4448
49+ def request_portals ( params = { } )
50+ federate = federated_portals_names ( params )
4551 portals = [ LinkedData ::Client ::HTTP . conn ]
52+ params . delete ( :federate )
4653
4754 if federate . is_a? ( Array )
4855 portals += LinkedData ::Client ::HTTP . federated_conn
@@ -55,6 +62,9 @@ def request_portals(params = {})
5562 portals
5663 end
5764
65+ def internal_call? ( conn )
66+ conn . url_prefix . to_s . start_with? ( LinkedData ::Client ::HTTP . conn . url_prefix . to_s )
67+ end
5868
5969 def portal_name_from_id ( id )
6070 LinkedData ::Client ::HTTP . federated_conn . find { |_ , value | value . url_prefix . to_s . eql? ( id ) } &.first || ''
0 commit comments