Skip to content
Snippets Groups Projects
Commit c0e89167 authored by Demian Katz's avatar Demian Katz
Browse files

More code simplification.

parent 7a50b608
No related merge requests found
...@@ -189,19 +189,19 @@ class Backend extends AbstractBackend ...@@ -189,19 +189,19 @@ class Backend extends AbstractBackend
public function search(AbstractQuery $query, $offset, $limit, public function search(AbstractQuery $query, $offset, $limit,
ParamBag $params = null ParamBag $params = null
) { ) {
//process EDS API communication tokens. // process EDS API communication tokens.
$authenticationToken = $this->getAuthenticationToken(); $authenticationToken = $this->getAuthenticationToken();
$sessionToken = $this->getSessionToken(); $sessionToken = $this->getSessionToken();
$this->debugPrint( $this->debugPrint(
"Authentication Token: $authenticationToken, SessionToken: $sessionToken" "Authentication Token: $authenticationToken, SessionToken: $sessionToken"
); );
//check to see if there is a parameter to only process this call as a setup // check to see if there is a parameter to only process this call as a setup
if (null != $params->get('setuponly') && true == $params->get('setuponly')) { if (true == $params->get('setuponly')) {
return false; return false;
} }
//create query parameters from VuFind data // create query parameters from VuFind data
$queryString = !empty($query) ? $query->getAllTerms() : ''; $queryString = !empty($query) ? $query->getAllTerms() : '';
$paramsString = implode('&', $params->request()); $paramsString = implode('&', $params->request());
$this->debugPrint( $this->debugPrint(
...@@ -226,47 +226,31 @@ class Backend extends AbstractBackend ...@@ -226,47 +226,31 @@ class Backend extends AbstractBackend
$response = $this->client $response = $this->client
->search($searchModel, $authenticationToken, $sessionToken); ->search($searchModel, $authenticationToken, $sessionToken);
} catch (\EbscoEdsApiException $e) { } catch (\EbscoEdsApiException $e) {
// if the auth token was invalid, try once more // if the auth or session token was invalid, try once more
if ($e->getApiErrorCode() == 104) { switch ($e->getApiErrorCode()) {
case 104:
case 108:
case 109:
try { try {
$authenticationToken = $this->getAuthenticationToken(true); // For error 104, retry auth token; for 108/9, retry sess token:
if ($e->getApiErrorCode() == 104) {
$authenticationToken = $this->getAuthenticationToken(true);
} else {
$sessionToken = $this->getSessionToken(true);
}
$response = $this->client $response = $this->client
->search($searchModel, $authenticationToken, $sessionToken); ->search($searchModel, $authenticationToken, $sessionToken);
} catch(Exception $e) { } catch(Exception $e) {
throw new BackendException( throw new BackendException($e->getMessage(), $e->getCode(), $e);
$e->getMessage(),
$e->getCode(),
$e
);
} }
} else if (108 == $e->getApiErrorCode() break;
|| 109 == $e->getApiErrorCode() default:
) {
try {
$sessionToken = $this->getSessionToken(true);
$response = $this->client
->search($searchModel, $authenticationToken, $sessionToken);
} catch(Exception $e) {
throw new BackendException(
$e->getMessage(),
$e->getCode(),
$e
);
}
} else {
$response = array(); $response = array();
break;
} }
} catch(Exception $e) { } catch(Exception $e) {
$this->debugPrint("Exception found: " . $e->getMessage()); $this->debugPrint("Exception found: " . $e->getMessage());
throw new BackendException($e->getMessage(), $e->getCode(), $e);
throw new BackendException(
$e->getMessage(),
$e->getCode(),
$e
);
} }
$collection = $this->createRecordCollection($response); $collection = $this->createRecordCollection($response);
$this->injectSourceIdentifier($collection); $this->injectSourceIdentifier($collection);
......
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