@@ -81,9 +81,11 @@ declare function adsabs:query( $query-url as xs:string, $query-payload as xs:str
8181 else
8282 ()
8383 let $method := if (exists ($body)) then $method-if-payload else "GET"
84+ (: apply line-o's fix to workarround the 2025-04-12 ADS infrastructure change
85+ https://github.com/eXist-db/exist/issues/5722 :)
8486 let $request :=
85- <http:request method = "{$method} " href = "{$adsabs:API_ROOT}{$query-url} " >
86- <http:header name = "Authorization" value = "Bearer: {$adsabs:token} " />
87+ <http:request method = "{$method} " href = "{$adsabs:API_ROOT}{$query-url} " override-media-type = "application/json; charset=utf-8; boundary=--" >
88+ <http:header name = "Authorization" value = "Bearer {$adsabs:token} " />
8789 <http:header name = "Content-Type" value = "application/json" />
8890 {$body}
8991 </http:request>
@@ -96,7 +98,7 @@ declare function adsabs:query( $query-url as xs:string, $query-payload as xs:str
9698 then
9799 (: let $log := util:log("info", "response from ads : ") :)
98100 let $json := util:binary-to-string ($response-body)
99- (: let $log := util:log("info", $json ) :)
101+ (: let $log := util:log("info", $json ) :)
100102 let $cache := cache:put ($adsabs:expirable-cache-name, $key, $json) (: always cache last result :)
101103 return $json
102104 else
@@ -266,12 +268,13 @@ declare function adsabs:library($name-or-id, $use-cache as xs:boolean)
266268 let $id := adsabs:get-libraries ()?libraries?*[?name=$name-or-id or ?id=$name-or-id]?id
267269 return parse-json (adsabs:query ("/biblib/libraries/" ||$id, (), $use-cache))
268270};
269- declare function adsabs:library-id ($name){
270- adsabs:get-libraries ()?libraries?*[?public=true () and ?name[.=$name] ]?id
271+ declare function adsabs:library-id ($name-or-id){
272+ (adsabs:get-libraries ()?libraries?*[?public=true () and ( ?name=$name-or-id or ?id=$name-or-id )]?id,$name-or-id)[1 ]
273+
271274};
272275
273- declare function adsabs:library-query ($name){
274- "docs(library/" ||adsabs:library-id ($name)||")"
276+ declare function adsabs:library-query ($name-or-id ){
277+ "docs(library/" ||adsabs:library-id ($name-or-id )||")"
275278};
276279
277280declare function adsabs:library-get-permissions ($name-or-id)
@@ -312,7 +315,7 @@ declare function adsabs:library-get-search-expr($name-or-id)
312315{
313316 let $id := adsabs:get-libraries ()?libraries?*[?name=$name-or-id or ?id=$name-or-id]?id
314317 let $id := if (exists ($id)) then $id else $name-or-id
315- return "docs( library/" || $id|| ")"
318+ return adsabs: library-query ( $id)
316319};
317320
318321
0 commit comments