@@ -81,6 +81,47 @@ public function __construct(
8181 $ this ->configReader = $ configReader ; // MSUL PC-1416 New param to read msul.ini
8282 }
8383
84+ /**
85+ * MSUL -- Can remove once PR 4810 is in our VuFind version
86+ * Initialize the driver.
87+ *
88+ * Check or renew our auth token
89+ *
90+ * @return void
91+ */
92+ public function init ()
93+ {
94+ $ factory = $ this ->sessionFactory ;
95+ $ this ->sessionCache = $ factory ($ this ->tenant );
96+ $ cacheType = 'session ' ;
97+ if ($ this ->useGlobalTokenCache ()) {
98+ $ globalTokenData = (array )($ this ->getCachedData ('token ' ) ?? []);
99+ if (count ($ globalTokenData ) === 2 ) {
100+ $ cacheType = 'global ' ;
101+ [$ this ->sessionCache ->folio_token , $ this ->sessionCache ->folio_token_expiration ] = $ globalTokenData ;
102+ }
103+ }
104+ if ($ this ->sessionCache ->folio_token ?? false ) {
105+ $ this ->token = $ this ->sessionCache ->folio_token ;
106+ $ this ->tokenExpiration = $ this ->sessionCache ->folio_token_expiration ?? null ;
107+ $ this ->debug (
108+ 'Token taken from ' . $ cacheType . ' cache: ' . substr ($ this ->token , 0 , 30 ) . '... '
109+ );
110+ }
111+ // MSU: added try/catch (PR 4810)
112+ try {
113+ if ($ this ->token == null ) {
114+ $ this ->renewTenantToken ();
115+ } else {
116+ $ this ->checkTenantToken ();
117+ }
118+ } catch (\Exception $ e ) {
119+ // Errors in init() should not be fatal, it could prevent using EDS when FOLIO fails
120+ $ this ->token = $ this ->tokenExpiration = null ;
121+ $ this ->logError ('Failed to get a token to initialize the FOLIO driver: ' . $ e ->getMessage ());
122+ }
123+ }
124+
84125 /**
85126 * Given an instance object or identifer, or a holding or item identifier,
86127 * determine an appropriate value to use as VuFind's bibliographic ID.
0 commit comments