Commit 3e44838e authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

move to ExPath HTTP client

parent f5efb5a9
......@@ -27,7 +27,10 @@ declare function app:project-id($node as node(), $model as map(*)) {
: @param $model a map containing arbitrary data - used to pass information between template calls
:)
declare function app:publications($node as node(), $model as map(*)) {
httpclient:get(xs:anyURI('https://www.uni-goettingen.de/de/publikationen/303721.html'), true(), ())//ul[@class="txtlist"][1]/li[position() < 4]
let $request := <hc:request method="get" href="https://www.uni-goettingen.de/de/publikationen/303721.html" />
let $response := hc:send-request($request)[2]
return
$response//ul[@class="txtlist"][1]/li[position() < 4]
};
(:~
......@@ -38,7 +41,9 @@ httpclient:get(xs:anyURI('https://www.uni-goettingen.de/de/publikationen/303721.
: @param $model a map containing arbitrary data - used to pass information between template calls
:)
declare function app:presentations($node as node(), $model as map(*)) {
for $item in httpclient:get(xs:anyURI('https://www.uni-goettingen.de/de/vortr%C3%A4ge-und-pr%C3%A4sentationen/303717.html'), true(), ())//ul[@class="txtlist"][1]/li[position() < 5]
let $request := <hc:request method="get" href="https://www.uni-goettingen.de/de/vortr%C3%A4ge-und-pr%C3%A4sentationen/303717.html" />
let $response := hc:send-request($request)[2]
for $item in $response//ul[@class="txtlist"][1]/li[position() < 5]
return
element li { for $i in $item/node() return local:nodeTest($i) }
};
......
......@@ -308,13 +308,12 @@ let $gndCollection := "/db/sade-projects/textgrid/data/xml/gnd/"
let $filename := $gndid || ".xml"
let $docname := $gndCollection || $filename
let $url := "https://d-nb.info/gnd/" || $gndid || "/about/lds.rdf"
let $persist := false()
let $request-headers := ()
let $request := <hc:request method="get" href="{$url}" />
let $response :=
if( doc-available( $docname ))
then doc( $docname )
else
httpclient:get(xs:anyURI($url), $persist, $request-headers)
hc:send-request($request)[2]
let $store :=
if(config:get("sade.develop") = "true")
then
......@@ -335,9 +334,8 @@ declare function ixp:wikidata-wikipedia($wikidata-id as xs:string)
as xs:string?{
let $query := escape-uri("SELECT ?s WHERE{?s schema:about wd:" || $wikidata-id || ".}", true())
let $url := "https://query.wikidata.org/sparql?query=" || $query
let $persist := false()
let $request-headers := ()
let $uris := httpclient:get(xs:anyURI($url), $persist, $request-headers)//*:uri/string()
let $request := <hc:reqeust method="get" href="{$url}" />
let $uris := hc:send-request($request)[2]//*:uri/string()
return (
$uris[matches(., "de\.wikipedia")],
$uris[matches(., "en\.wikipedia")],
......@@ -661,7 +659,9 @@ for $bibl in $bibls
declare function ixp:get-gnd-data($url as xs:string)
as element(rdf:RDF){
httpclient:get(xs:anyURI($url || "/about/rdf"), false(), ())//rdf:RDF
let $request := <hc:request method="get"/>
return
hc:send-request($request, $url || "/about/rdf")[2]//rdf:RDF
};
(: ################################################### :)
......
......@@ -185,7 +185,7 @@ return
declare function local:login($col) {
(: check for db availability :)
if(httpclient:get(xs:anyURI("http://localhost:8080"), false(), ())/@statusCode = 200)
if(hc:send-request(<hc:request method="get"/>, "http://localhost:8080")[1]/@status = 200)
then
if(false() = xmldb:login($col, config:get('sade.user'), config:get("sade.password")))
then (xmldb:login($col, "admin", ""))
......
......@@ -522,14 +522,14 @@ declare function f-misc:textgridStatus($node as node(), $model as map(*)) {
let $getStatus :=
if( $needUpdate )
then
let $status := httpclient:get(xs:anyURI($url), false(), ())//xhtml:div[contains(@class, 'repstatus')][not( contains(@class, 'ok') )]
let $status := hc:send-request(<hc:request method="get" href="{$url}"/>)[2]//xhtml:div[contains(@class, 'repstatus')][not( contains(@class, 'ok') )]
let $status := if( exists( $status ) ) then $status else <ok/>
return
(xmldb:login($col, config:get("sade.user"), config:get("sade.password")),
xmldb:store($col, $res, $status))
else if($active and $lastMod < (current-dateTime() - xs:dayTimeDuration("PT2H")))
then
let $status := httpclient:get(xs:anyURI($url), false(), ())//xhtml:div[contains(@class, 'repstatus')][not( contains(@class, 'ok') )]
let $status := hc:send-request(<hc:request method="get" href="{$url}"/>)[2]//xhtml:div[contains(@class, 'repstatus')][not( contains(@class, 'ok') )]
let $status := if( exists( $status ) ) then $status else <ok/>
return
(xmldb:login($col, config:get("sade.user"), config:get("sade.password")), xmldb:store($col, $res, $status))
......@@ -562,14 +562,14 @@ declare function f-misc:serverStatus($node as node(), $model as map(*)) {
let $getStatus :=
if( $needUpdate )
then
let $status := httpclient:get(xs:anyURI($url), false(), ())//*:li[contains(., "Fontane")]/ancestor::*:div[contains(@class, "alert")]
let $status := hc:send-request(<hc:request method="get" href="{$url}"/>)[2]//*:li[contains(., "Fontane")]/ancestor::*:div[contains(@class, "alert")]
let $status := if( exists( $status ) ) then $status else <ok/>
return
(xmldb:login($col, config:get("sade.user"), config:get("sade.password")),
xmldb:store($col, $res, $status))
else if($active and $lastMod < (current-dateTime() - xs:dayTimeDuration("PT2H")))
then
let $status := httpclient:get(xs:anyURI($url), false(), ())//*:li[contains(., "Fontane")]/ancestor::*:div[contains(@class, "alert")]
let $status := hc:send-request(<hc:request method="get" href="{$url}"/>)[2]//*:li[contains(., "Fontane")]/ancestor::*:div[contains(@class, "alert")]
let $status := if( exists( $status ) ) then $status else <ok/>
return
(xmldb:login($col, config:get("sade.user"), config:get("sade.password")), xmldb:store($col, $res, $status))
......
......@@ -41,8 +41,9 @@ declare
function tbleapi:stream-image($uri as xs:string, $xmlid as xs:string, $format as xs:string)
{
let $url := tbleapi:get-url($uri, $xmlid, $format)
let $request := httpclient:get($url, false(), ())
let $data := $request/httpclient:body/text()
let $request := <hc:request method="get" href="{ $url }" />
let $response := hc:send-request($request)
let $data := $response[2]
let $binary-data :=
try { $data => xs:base64Binary() }
catch * {
......@@ -50,7 +51,7 @@ let $binary-data :=
QName("err", "load1"),
string-join(("&#10;Could not load data from TextGrid: ", $data, $err:code, $err:description), "&#10;"))
}
let $mime := string($request/httpclient:body/@mimetype)
let $mime := string($response[1]/hc:body/@media-type)
return
$binary-data
......
......@@ -113,13 +113,15 @@ declare function wiki:revision-remote($id as xs:string)
as xs:int {
let $wikiList :=
try {
((xs:anyURI(config:get("dokuwiki.url")
|| '/feed.php?type=rss2&amp;num=500&amp;ns=fontane&amp;minor=1&amp;mode=list&amp;u='
|| config:get("dokuwiki.user")
|| '&amp;p='
|| config:get("dokuwiki.password"))
=> httpclient:get(false(), ()))/httpclient:body/node()
)
let $url :=
config:get("dokuwiki.url")
|| '/feed.php?type=rss2&amp;num=500&amp;ns=fontane&amp;minor=1&amp;mode=list&amp;u='
|| config:get("dokuwiki.user")
|| '&amp;p='
|| config:get("dokuwiki.password")
let $request := <hc:request method="get" href="{ $url }" />
return
hc:send-request($request)[2]
} catch * {
error(QName("FONTANE", "DOKU05"), "Unable to connect to RSS feed. Are there valid credentials provided?" )
}
......@@ -176,20 +178,16 @@ return
error(QName("FONTANE", "DOKU02"), "Resource is locked." )
else (: proceed :)
let $lock := wiki:lock-resource($id)
let $url as xs:anyURI :=
(config:get("dokuwiki.url")
let $url :=
config:get("dokuwiki.url")
|| '/doku.php?id=fontane:' || $id
|| '&amp;rev=' || $remote
||'&amp;u='|| config:get("dokuwiki.user")
||'&amp;p='|| config:get("dokuwiki.password")
||'&amp;do=export_xhtml')
=> xs:anyURI(),
$persist := false(),
$request-headers:= (),
$options:= <options><property name="http://cyberneko.org/html/properties/default-encoding" value="UTF-8"/></options>,
|| '&amp;u='|| config:get("dokuwiki.user")
|| '&amp;p='|| config:get("dokuwiki.password")
|| '&amp;do=export_xhtml',
$export :=
try {
httpclient:get($url, $persist, $request-headers, $options)//*[@class="dokuwiki export"]
hc:send-request(<hc:request method="get" href="{ $url }" />)[2]//*[@class="dokuwiki export"]
} catch * {
error(QName("FONTANE", "DOKU04"), "unable to load resource." )
},
......@@ -410,10 +408,12 @@ try {
let $path := system:get-exist-home() || '/tools/jetty/webapps/portal/public/doku/'
let $credentials := '&amp;u='|| config:get("dokuwiki.user") ||'&amp;p='|| config:get("dokuwiki.password")
let $url:= xs:anyURI(config:get("dokuwiki.url")||'/doku.php?id=fontane:'|| $id ||'&amp;do=export_xhtml' || $credentials),
$persist := false(),
$request-headers:= <http:header name="Accept-Charset" value="UTF-8"/>,
$result:= httpclient:get($url, $persist, $request-headers)//div[@class="dokuwiki export"]/*[not(@id='dw__toc')]
let $url:= config:get("dokuwiki.url")||'/doku.php?id=fontane:'|| $id ||'&amp;do=export_xhtml' || $credentials,
$request :=
<hc:request method="get" href="{ $url }">
<hc:header name="Accept-Charset" value="UTF-8"/>,
</hc:request>,
$result:= hc:send-request($request)[2]//div[@class="dokuwiki export"]/*[not(@id='dw__toc')]
let $images := distinct-values( $result//img/substring-after(@data-original, 'fontane:') )
return
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment