/**
  * Regression test for OPUSVIER-2518
  */
 public function testExceptionIfSolrServerIsUnavailable()
 {
     // manipulate solr configuration
     $config = Zend_Registry::get('Zend_Config');
     $host = $config->searchengine->index->host;
     $port = $config->searchengine->index->port;
     $oldValue = $config->searchengine->index->app;
     $config->searchengine->solr->default->service->endpoint->localhost->path = '/solr/corethatdoesnotexist';
     Zend_Registry::set('Zend_Config', $config);
     $downloadList = new Remotecontrol_Model_DownloadList();
     $exception = null;
     try {
         $downloadList->getCvsFile('ddc', '000');
     } catch (Exception $e) {
         $exception = $e;
     }
     $this->assertInstanceOf('Remotecontrol_Model_Exception', $exception);
     $this->assertFalse($exception->collectionIsNotUnique());
     $this->assertTrue($exception->getPrevious() instanceof Opus_SolrSearch_Exception);
     $this->assertEquals($exception->getPrevious()->getCode(), Opus_SolrSearch_Exception::SERVER_UNREACHABLE);
     // restore configuration
     $config = Zend_Registry::get('Zend_Config');
     $config->searchengine->index->app = $oldValue;
     Zend_Registry::set('Zend_Config', $config);
 }
 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);
 }