/**
  *
  * @param Opus_SolrSearch_Exception $exception
  * @param boolean $usePlainMessage set to true if exception message should not be translated
  */
 public function __construct($exception, $usePlainMessage = false)
 {
     parent::__construct($exception->getMessage(), $exception->getCode(), $exception->getPrevious());
     if ($exception->isServerUnreachable()) {
         if ($usePlainMessage) {
             $this->message = 'search server is not responding -- try again later';
         } else {
             $this->message = 'error_search_unavailable';
         }
         $this->setHttpResponseCode(503);
         return;
     }
     if ($exception->isInvalidQuery()) {
         if ($usePlainMessage) {
             $this->message = 'search query is invalid -- check syntax';
         } else {
             $this->message = 'error_search_invalidquery';
         }
         $this->setHttpResponseCode(500);
         return;
     }
     if ($usePlainMessage) {
         $this->message = 'unknown error while executing search query';
     } else {
         $this->message = 'error_search_unknown';
     }
     $this->setHttpResponseCode(500);
 }
 public function listAction()
 {
     $request = $this->getRequest();
     $role = $request->getParam('role');
     $number = $request->getParam('number');
     $downloadList = new Remotecontrol_Model_DownloadList();
     $this->_helper->viewRenderer->setNoRender(true);
     $this->_helper->layout()->disableLayout();
     try {
         $this->getResponse()->setBody($downloadList->getCvsFile($role, $number));
     } catch (Remotecontrol_Model_Exception $e) {
         if ($e->getPrevious() instanceof Opus_Search_Exception) {
             throw new Application_SearchException($e->getPrevious(), true);
         }
         if ($e->collectionIsNotUnique()) {
             $e = new Application_Exception();
             $e->setHttpResponseCode(501);
             throw $e;
         }
         $e = new Application_Exception();
         $e->setHttpResponseCode(400);
         throw $e;
     }
     $this->getResponse()->setHeader('Content-Type', 'text/plain; charset=UTF-8', true);
     $filename = $role . '_' . $number;
     $this->getResponse()->setHeader('Content-Disposition', 'attachment; filename=' . $filename . '.csv', true);
 }
Example #3
0
 private function handleSolrError(Opus_SolrSearch_Exception $exception)
 {
     $this->_helper->layout()->enableLayout();
     $this->log->err(__METHOD__ . ' : ' . $exception);
     if ($exception->isServerUnreachable()) {
         $e = new Application_Exception('error_search_unavailable');
         $e->setHttpResponseCode(503);
         throw $e;
     } elseif ($exception->isInvalidQuery()) {
         $e = new Application_Exception('error_search_invalidquery');
         $e->setHttpResponseCode(500);
         throw $e;
     } else {
         $e = new Application_Exception('error_search_unknown');
         $e->setHttpResponseCode(500);
         throw $e;
     }
 }