diff --git a/module/finc/config/dds-form.php b/module/finc/config/dds-form.php index 25bc048be9ebcb4c059c47aeb38cb70388e61a38..1fcb1903776403d48a9eebca09448e08b83a3a72 100644 --- a/module/finc/config/dds-form.php +++ b/module/finc/config/dds-form.php @@ -105,7 +105,7 @@ return [ 'empty_option' => '', ], 'attributes' => [ - 'required' => false, + 'required' => true, 'id' => 'division', ], ], diff --git a/module/finc/src/finc/Controller/DocumentDeliveryServiceController.php b/module/finc/src/finc/Controller/DocumentDeliveryServiceController.php index 23d91a76fd2b71f3d99fd9731d5a900dabd6f4cf..6d5f2b5148220374a3f79fd9392ee7f526ebfdfb 100644 --- a/module/finc/src/finc/Controller/DocumentDeliveryServiceController.php +++ b/module/finc/src/finc/Controller/DocumentDeliveryServiceController.php @@ -281,15 +281,7 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase ->send(); if (!$response->isSuccess()) { - if ($response->getContent()) { - $responseArray = $this->parseJsonAsArray($response->getContent()); - if (array_key_exists('error', $responseArray)) { - $message = $responseArray['error']; - } - } else { - $message = 'HTTP status ' . $response->getStatusCode() . ' received'; - } - throw new DDSException($message); + $this->throwErrorMessage($response); } $responseArray = $this->parseJsonAsArray($response->getBody()); @@ -585,6 +577,23 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase ); } } + + /** + * @param \Zend\Http\Response $response + * @throws DDSException + */ + protected function throwErrorMessage(\Zend\Http\Response $response): void + { + $message = 'HTTP status ' . $response->getStatusCode() . ' received'; + if ($response->getContent()) { + $responseArray = $this->parseJsonAsArray($response->getContent()); + if ($responseArray && array_key_exists('error', $responseArray)) { + $message = $responseArray['error']; + } + } + + throw new DDSException($message); + } /** * Retrieve data after successful sending previous record. Beware and keep @@ -962,17 +971,8 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase ); exit; } - - $responseArray = $this->parseJsonAsArray($response->getContent()); - if ($responseArray !== null && array_key_exists('error', $responseArray)) { - $message = $responseArray['error']; - } - } else { - $message = 'HTTP status ' . $response->getStatusCode() . ' received'; - } - if (!empty($message)) { - throw new DDSException($message); } + $this->throwErrorMessage($response); } return $this->parseJsonAsArray($response->getBody()); @@ -1026,15 +1026,7 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase ->send(); if (!$response->isSuccess()) { - if ($response->getContent()) { - $responseArray = $this->parseJsonAsArray($response->getContent()); - if (array_key_exists('error', $responseArray)) { - $message = $responseArray['error']; - } - } else { - $message = 'HTTP status ' . $response->getStatusCode() . ' received'; - } - throw new DDSException($message); + $this->throwErrorMessage($response); } $responseArray = $this->parseJsonAsArray($response->getBody());