Skip to content
Snippets Groups Projects
Commit 867b8125 authored by Mathias Maaß's avatar Mathias Maaß Committed by André Lahmann
Browse files

refs #20679 [finc] reduce DAIA/PAIA requests

* update FincILS.ini with latest contents of DAIA.ini and PAIA.ini
* Fix PAIA notification caching
* Cache PAIA fees response
* Cache PAIA user details

co-authored by André Lahmann <lahmann@ub.uni-leipzig.de>
parent d6b80161
Branches
Tags
No related merge requests found
; General configuration ; General configuration
[General] [General]
; Set the time to live (ttl) for cached data (default is 30 seconds).
;cacheLifetime = 90
; This setting defines the connection timeout for testing the availability of the ILS ; This setting defines the connection timeout for testing the availability of the ILS
; in seconds (default is 1 second). ; in seconds (default is 1 second).
ilsTestTimeout = 30 ilsTestTimeout = 30
...@@ -13,6 +16,12 @@ queryIls[] = 'getFacetAvail:Local' ...@@ -13,6 +16,12 @@ queryIls[] = 'getFacetAvail:Local'
;[DAIA] ;[DAIA]
; The base URL for the DAIA webservice. ; The base URL for the DAIA webservice.
;baseUrl = "http://localhost/daiawachtl/daia/" ;baseUrl = "http://localhost/daiawachtl/daia/"
; Set a DAIA specific timeout in seconds to be used for DAIA http requests (defaults
; to Zend defaults or as defined in
; vendor/vufind-org/vufindhttp/src/VuFindHttp/HttpService.php)
;timeout = 30
; The prefix prepended to the VuFind record Id resulting in the document URI ; The prefix prepended to the VuFind record Id resulting in the document URI
; used for the DAIA request (default = ppn:) (the prefix usually defines the ; used for the DAIA request (default = ppn:) (the prefix usually defines the
; field which the DAIA server uses for the loookup - e.g. ppn: or isbn:). ; field which the DAIA server uses for the loookup - e.g. ppn: or isbn:).
...@@ -22,7 +31,7 @@ queryIls[] = 'getFacetAvail:Local' ...@@ -22,7 +31,7 @@ queryIls[] = 'getFacetAvail:Local'
;daiaResponseFormat = json ;daiaResponseFormat = json
; Set multiQuery to true if your DAIA webservice supports queries with multiple ; Set multiQuery to true if your DAIA webservice supports queries with multiple
; ids (cf. http://gbv.github.io/daiaspec/daia.html#query-api). ; ids (cf. https://gbv.github.io/daia/daia.html#query-parameters).
; Default is false. ; Default is false.
;multiQuery = false ;multiQuery = false
...@@ -31,7 +40,7 @@ queryIls[] = 'getFacetAvail:Local' ...@@ -31,7 +40,7 @@ queryIls[] = 'getFacetAvail:Local'
; daiaContentTypes is not set, Content-Type HTTP header is NOT checked. ; daiaContentTypes is not set, Content-Type HTTP header is NOT checked.
; ;
; expected Content-Types for DAIA XML format: ; expected Content-Types for DAIA XML format:
; (seperate multiple values by commata, for example: ; (separate multiple values by commas, for example:
; daiaContentTypes['xml'] = "application/xml, text/xml" ; daiaContentTypes['xml'] = "application/xml, text/xml"
;daiaContentTypes['xml'] = "application/xml" ;daiaContentTypes['xml'] = "application/xml"
...@@ -43,8 +52,17 @@ queryIls[] = 'getFacetAvail:Local' ...@@ -43,8 +52,17 @@ queryIls[] = 'getFacetAvail:Local'
; Enable caching for DAIA items (default is false). ; Enable caching for DAIA items (default is false).
;daiaCache = false ;daiaCache = false
; Set the time to live (ttl) for cached DAIA data (default is 30 seconds). ; DAIA does not support placing holds (this functionality is covered by PAIA) but is
;daiaCacheLifetime = 90 ; able to provide a link to the OPAC to perform such an action. Regarding placing
; holds/recalls such link is usually given as href for an unavailable service.
; Uncomment the below section Holds with the setting 'function' to show a link to
; the OPAC (if it was provided in the DAIA response) instead of a VuFind
; Holds-Button.
; If PAIA is used in combination with the DAIA driver, handling holds etc. should be
; left to the logic in the PAIA driver - thus keep this section commented out if you
; are using PAIA as well.
; [Holds]
; function = getHoldLink
;FincILS configuration ;FincILS configuration
; refer to ticket #4499 for further info on configuring it ; refer to ticket #4499 for further info on configuring it
...@@ -60,7 +78,8 @@ queryIls[] = 'getFacetAvail:Local' ...@@ -60,7 +78,8 @@ queryIls[] = 'getFacetAvail:Local'
; vendor/vufind-org/vufindhttp/src/VuFindHttp/HttpService.php) ; vendor/vufind-org/vufindhttp/src/VuFindHttp/HttpService.php)
;timeout = 30 ;timeout = 30
; Enable caching for PAIA items (default is false). ; Enable caching for PAIA items (default is false). TTL for cached data will be the
; same as for DAIA cache (see cacheLifetime setting in DAIA.ini).
;paiaCache = false ;paiaCache = false
; A PAIA auth server acts as OAuth authorization server (RFC 6749) with ; A PAIA auth server acts as OAuth authorization server (RFC 6749) with
...@@ -84,6 +103,66 @@ queryIls[] = 'getFacetAvail:Local' ...@@ -84,6 +103,66 @@ queryIls[] = 'getFacetAvail:Local'
;root_username = 'root' ;root_username = 'root'
;root_password = '' ;root_password = ''
; Driver configuration, usually you can leave it untouched
; Without customization the PAIA driver will offer to place a recall for items with
; unavailable service loan but set href for loan. The recall will be performed via
; PAIA request.
; The pre-defined HMACKeys (id:item_id:doc_id) should suffice to place a recall. No
; extra fields are allowed (if you need those you might be able to cover this
; functionality in a custom driver by using PAIA confirm/conditions).
[Holds]
; HMACKeys - A list of form element names that will be analyzed for consistency
; during form processing. Most users should not need to change this setting.
HMACKeys = "id:item_id:doc_id"
; PAIA status which should be mapped to Holds
; status are: 1 = reserved (not available yet but later)
; 2 = ordered (and not yet ready to be picked up)
; 3 = held by patron
; 4 = provided (and ready to be picked up)
status = "1:4"
; Without customization the PAIA driver will offer to place a storageretrievalrequest
; for items with available service loan and set href for loan. The
; storageretrievalrequest will be performed via PAIA request (technically the same as
; for recall, but with different frontend templates etc.).
; The pre-defined HMACKeys (id:item_id:doc_id) should suffice to request an item. No
; extra fields are allowed (if you need those you might be able to cover this
; functionality in a custom driver by using PAIA confirm/conditions).
[StorageRetrievalRequests]
; HMACKeys - A list of form element names that will be analyzed for consistency
; during form processing. Most users should not need to change this setting.
HMACKeys = id:item_id:doc_id
; PAIA status which should be mapped to StorageRetrievalRequests
; status are: 1 = reserved (not available yet but later)
; 2 = ordered (and not yet ready to be picked up)
; 3 = held by patron
; 4 = provided (and ready to be picked up)
status = "2"
; All kinds of transactions by a specific patron. Transactions are eg checked out
; items
[Transactions]
; PAIA status which should be mapped to Transactions
; status are: 1 = reserved (not available yet but later)
; 2 = ordered (and not yet ready to be picked up)
; 3 = held by patron
; 4 = provided (and ready to be picked up)
status = "3"
; The PAIA driver supports renewals in MyResearch views. The renewal will be
; performed via PAIA renew.
; The pre-defined HMACKeys (id:item_id:doc_id) should suffice to renew an item. No
; extra fields are allowed (if you need those you might be able to cover this
; functionality in a custom driver by using PAIA confirm/conditions).
[Renewals]
; HMACKeys - A list of form element names that will be analyzed for consistency
; during form processing. Most users should not need to change this setting.
HMACKeys = "id:item_id:doc_id"
; FincILS specific
; Enable EmailHold to allow placing orders via Email instead of direct ILS ; Enable EmailHold to allow placing orders via Email instead of direct ILS
; interaction. ; interaction.
;[EmailHold] ;[EmailHold]
......
...@@ -304,13 +304,23 @@ class PAIA extends \VuFind\ILS\Driver\PAIA ...@@ -304,13 +304,23 @@ class PAIA extends \VuFind\ILS\Driver\PAIA
throw new ILSException('You are not entitled to read fees.'); throw new ILSException('You are not entitled to read fees.');
} }
try { if ($this->paiaCacheEnabled) {
$fees = $this->paiaGetAsArray( $fees = $this->getCachedData($this->_feesCacheKey($patron));
'core/' . $patron['cat_username'] . '/fees' }
);
} catch (\Exception $e) { if (!isset($fees) || $fees == null) {
// all error handling is done in paiaHandleErrors so pass on the excpetion try {
throw $e; $fees = $this->paiaGetAsArray(
'core/' . $patron['cat_username'] . '/fees'
);
} catch (\Exception $e) {
// all error handling is done in paiaHandleErrors so pass on the excpetion
throw $e;
}
if ($this->paiaCacheEnabled) {
$this->putCachedData($this->_feesCacheKey($patron), $fees);
}
} }
// PAIA simple data type money: a monetary value with currency (format // PAIA simple data type money: a monetary value with currency (format
...@@ -755,18 +765,34 @@ class PAIA extends \VuFind\ILS\Driver\PAIA ...@@ -755,18 +765,34 @@ class PAIA extends \VuFind\ILS\Driver\PAIA
} }
/** /**
* Helper function to generate cache key * Helper function to generate cache key for fees.
* @param array $patron *
* @param array $patron Array with patron information
*
* @return string * @return string
*/ */
private function notificationsCacheKey($patron) private function _feesCacheKey($patron)
{
return $patron['cat_username'] . '_fees';
}
/**
* Helper function to generate cache key for notifications.
*
* @param array $patron Array with patron information
*
* @return string
*/
private function _notificationsCacheKey($patron)
{ {
return $patron['cat_username'] . '_notifications'; return $patron['cat_username'] . '_notifications';
} }
/** /**
* Helper function to retrieve notification ID * Helper function to retrieve notification ID
*
* @param string $messageId * @param string $messageId
*
* @return string * @return string
*/ */
protected function getPaiaNotificationsId($messageId) protected function getPaiaNotificationsId($messageId)
...@@ -797,8 +823,8 @@ class PAIA extends \VuFind\ILS\Driver\PAIA ...@@ -797,8 +823,8 @@ class PAIA extends \VuFind\ILS\Driver\PAIA
} }
if ($this->paiaCacheEnabled) { if ($this->paiaCacheEnabled) {
$response = $this->getCachedData($this->notificationsCacheKey($patron)); $response = $this->getCachedData($this->_notificationsCacheKey($patron));
if (!empty($response)) { if ($response !== null) {
return $response; return $response;
} }
} }
...@@ -833,7 +859,7 @@ class PAIA extends \VuFind\ILS\Driver\PAIA ...@@ -833,7 +859,7 @@ class PAIA extends \VuFind\ILS\Driver\PAIA
} }
if ($this->paiaCacheEnabled) { if ($this->paiaCacheEnabled) {
$this->putCachedData($this->notificationsCacheKey($patron), $response); $this->putCachedData($this->_notificationsCacheKey($patron), $response);
} }
return $response; return $response;
...@@ -866,7 +892,7 @@ class PAIA extends \VuFind\ILS\Driver\PAIA ...@@ -866,7 +892,7 @@ class PAIA extends \VuFind\ILS\Driver\PAIA
} }
if (!$keepCache && $this->paiaCacheEnabled) { if (!$keepCache && $this->paiaCacheEnabled) {
$this->removeCachedData($this->notificationsCacheKey($patron)); $this->removeCachedData($this->_notificationsCacheKey($patron));
} }
return $response; return $response;
...@@ -887,7 +913,7 @@ class PAIA extends \VuFind\ILS\Driver\PAIA ...@@ -887,7 +913,7 @@ class PAIA extends \VuFind\ILS\Driver\PAIA
} }
if ($this->paiaCacheEnabled) { if ($this->paiaCacheEnabled) {
$this->removeCachedData($this->notificationsCacheKey($patron)); $this->removeCachedData($this->_notificationsCacheKey($patron));
} }
return true; return true;
...@@ -1384,19 +1410,26 @@ class PAIA extends \VuFind\ILS\Driver\PAIA ...@@ -1384,19 +1410,26 @@ class PAIA extends \VuFind\ILS\Driver\PAIA
throw new ILSException('You are not entitled to read patron.'); throw new ILSException('You are not entitled to read patron.');
} }
$responseJson = $this->paiaGetRequest( $cacheKey = function ($patron) {
'core/' . $patron, return $patron . '_user_details';
$this->getSession()->access_token };
);
try { $response = null;
$responseArray = $this->paiaParseJsonAsArray($responseJson);
} catch (ILSException $e) { if ($this->paiaCacheEnabled) {
// all error handling is done in paiaHandleErrors so pass on the $response = $this->getCachedData($cacheKey($patron));
// excpetion
throw $e;
} }
return $this->paiaParseUserDetails($patron, $responseArray);
if ($response === null) {
// all error handling is done in paiaHandleErrors so pass on the excpetion
$response = $this->paiaGetAsArray('core/' . $patron);
if ($this->paiaCacheEnabled) {
$this->putCachedData($cacheKey($patron), $response);
}
}
return $this->paiaParseUserDetails($patron, $response);
} }
/** /**
......
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