public function indexAction() { $docId = $this->getRequest()->getParam('docId', null); $container = null; $fileHandle = null; try { $container = new Oai_Model_Container($docId, $this->_logger); $fileHandle = $container->getFileHandle(); } catch (Oai_Model_Exception $e) { $this->view->errorMessage = $e->getMessage(); $this->getResponse()->setHttpResponseCode(500); return $this->render('error'); } // prepare response $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $this->getResponse()->setHeader('Content-Type', $fileHandle->getMimeType(), true)->setHeader('Content-Disposition', 'attachment; filename=' . $container->getName() . $fileHandle->getExtension(), true); $this->_helper->SendFile->setLogger($this->_logger); try { $this->_helper->SendFile($fileHandle->getPath()); } catch (Exception $e) { $this->_logger->err($e->getMessage()); $this->getResponse()->clearAllHeaders(); $this->getResponse()->clearBody(); $this->getResponse()->setHttpResponseCode(500); } $fileHandle->delete(); }
public function testFunctionGetName() { $doc = $this->createTestDocument(); $doc->setServerState('published'); $file = new Opus_File(); $file->setPathName('foo.pdf'); $file->setVisibleInOai(false); $doc->addFile($file); $doc->store(); $container = new Oai_Model_Container($doc->getId()); $this->assertEquals($doc->getId(), $container->getName()); }