Template für das Primo-System
volle Serverurl, inklusive trailing slash (z.B.: http://portal.ub.tu-berlin.de/primo_library/libweb/action/)
Login-URL für Interne (Studenten)
Login-URL für Externe
(veraltet) Institutsid der Bücherei im Primosystem
declare function local:raise($err){
string($err) ! (if (matches(., "Anmeldung fehlgeschlagen|The login credentials are incorrect|Benutzerkonto abgelaufen oder ungültige UserID und/oder Passwort|The username you entered cannot be identified|Wrong username or password|Ungültige Ausweisnummer und/oder Passwort")) then vl:raise-login(.)
else vl:raise(.))
};
$primo-explore := contains($baseurl, '/primo-explore')
server := substring-before($baseurl, "/primo-explore"),
vid := extract($baseurl, "vid=([^"||$amp||"]+)", 1)
xquery version "3.0-videlibri";
let $answer := json($raw) return
(
institute := ( $answer.beacon.alternative-institution-code, get("institute"), $vid )[.][1],
authentication := $answer.authentication,
authentication-header := ""
)
declare function local:raise($err){
string($err) ! (if (matches(., "Anmeldung fehlgeschlagen|The login credentials are incorrect|Benutzerkonto abgelaufen oder ungültige UserID und/oder Passwort|The username you entered cannot be identified|Wrong username or password|Ungültige Ausweisnummer und/oder Passwort")) then vl:raise-login(.)
else vl:raise(.))
};()
i := 1, datasend := false()
$request := let $auth := $authentication((if ($type ge 1) then $type else 1))
let $targeturl := x"{uri-encode($server)}/primo-explore/account?vid={uri-encode($vid)}"
let $preurl := $server || "/primo_library/libweb/primoExploreLogin"
return if ($auth.authentication-system = "ALMA") then
request-combine(
{"url": $preurl, "method": "POST"},
{"authenticationProfile": $auth.profile-name,
"institution": $institute,
"password": $password,
"targetUrl": $targeturl,
"username": $username,
"view": $vid}
)
else $preurl || x"?institution={uri-encode($institute)}&target-url={uri-encode($targeturl)}&authenticationProfile={uri-encode($auth.profile-name)}&auth={uri-encode($auth.authentication-system)}&isSilent=false"
$request := get("login-url-" || (if ($type ge 1) then $type else 1), ()),
if ($request) then () else $request := get("login-url")
let $j := json($raw) where $j("jwtData") return (
$i := 10000,
authentication-header := $j("jwtData")
)
{i:=10000}
{local:raise(.)}
{local:raise(.)}
{local:raise(.)}
{local:raise(.)}
{local:raise(.)}
{local:raise(.)}
{$request}
{$request}
{$request}
{$request}
$i := $i + 1
vl:raise-internal("Zuviele Weiterleitungen beim Login. Aktuelle Seite: " || base-uri() || substring(join(//body), 1, 1000))
videlibri:delete-current-books()
videlibri:delete-current-books()
Accept: application/json,*/*
Authorization: Bearer {$authentication-header}
xquery version "3.0-videlibri";
if (not(matches($raw, "^\s*[\[{]"))) then vl:raise(inner-text())
else let $answer := json($raw) return
for $loan in $answer.data.loans.loan() return
$book := $loan!{
"category": itemcategoryname,
"year": year,
"author": author,
"id": callnumber,
"issueDate": parse-date(loandate, "yyyymmdd"),
"title": title,
"libraryBranch": mainlocationname,
"_itemid": itemid,
"_loanid": loanid,
"dueDate": parse-date(duedate, "yyyymmdd"),
"status": loanstatus,
"statusId": if (renew eq "Y") then "curious" else "critical",
"barcode": itembarcode
}
Accept: application/json,*/*
Authorization: Bearer {$authentication-header}
xquery version "3.0-videlibri";
let $answer := json($raw) let $data := $answer.data return
for $type in ("hold", "request", "ill")
let $types := $type || "s"
for $loan in $data($types)($type)() return
$book := $loan!{
"cancelable": cancel eq "Y",
"libraryBranch": pickuplocationname,
"author": author,
"title": title,
"status": holdstatus,
"statusId": if (available eq "Y") then "provided" else "ordered",
"_requestid": requestid,
"_request_type": $types,
"issueDate": parse-date(requestdate, "yyyymmdd")
}
Content-Type: application/json; charset=utf-8
Accept: application/json,*/*
Authorization: Bearer {$authentication-header}
POST
{{"id": {$b._loanid} }}
Content-Type: application/json; charset=utf-8
Accept: application/json,*/*
Authorization: Bearer {$authentication-header}
POST
{{"request_id": {$b._requestid}, "request_type": {$b._request_type} }}
{"author": "creator", "title": "title", "keywords": "subject", "isbn": "isbn", "year": "cdate"}
redirect:=()