Example #1
0
 /**
  * Provide an endpoint for the PLN staging server to retrieve a deposit
  * @param array $args
  * @param Request $request
  */
 function deposits($args, &$request)
 {
     $journal =& $request->getJournal();
     $depositDao =& DAORegistry::getDAO('DepositDAO');
     $fileManager = new FileManager();
     $dispatcher = $request->getDispatcher();
     $depositUuid = !isset($args[0]) || empty($args[0]) ? null : $args[0];
     // sanitize the input
     if (!preg_match('/^[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}$/', $depositUuid)) {
         error_log(__("plugins.generic.pln.error.handler.uuid.invalid"));
         $dispatcher->handle404();
         return FALSE;
     }
     $deposit =& $depositDao->getDepositByUUID($journal->getId(), $depositUuid);
     if (!$deposit) {
         error_log(__("plugins.generic.pln.error.handler.uuid.notfound"));
         $dispatcher->handle404();
         return FALSE;
     }
     $depositPackage = new DepositPackage($deposit, null);
     $depositBag = $depositPackage->getPackageFilePath();
     if (!$fileManager->fileExists($depositBag)) {
         error_log("plugins.generic.pln.error.handler.file.notfound");
         $dispatcher->handle404();
         return FALSE;
     }
     return $fileManager->downloadFile($depositBag, mime_content_type($depositBag), TRUE);
 }
Example #2
0
 /**
  * Provide an endpoint for the PLN staging server to retrieve a deposit
  * @param array $args
  * @param Request $request
  */
 function deposits($args, &$request)
 {
     $journal =& $request->getJournal();
     $plnPlugin =& PluginRegistry::getPlugin('generic', PLN_PLUGIN_NAME);
     $depositDao =& DAORegistry::getDAO('DepositDAO');
     $fileManager = new FileManager();
     $depositUuid = !isset($args[0]) || empty($args[0]) ? null : $args[0];
     // sanitize the input
     if (!preg_match('/^[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}$/', $depositUuid)) {
         return FALSE;
     }
     $deposit =& $depositDao->getDepositByUUID($journal->getId(), $depositUuid);
     if (!$deposit) {
         return FALSE;
     }
     $depositPackage = new DepositPackage($deposit);
     $depositBag = $depositPackage->getPackageFilePath();
     if (!$fileManager->fileExists($depositBag)) {
         return FALSE;
     }
     //TODO: Additional check here for journal UUID in HTTP header from staging server
     return $fileManager->downloadFile($depositBag, mime_content_type($depositBag), TRUE);
 }
Example #3
0
 /**
  * Create packages for any deposits that don't have any or have been updated
  */
 function _processNeedPackaging(&$journal)
 {
     $depositDao =& DAORegistry::getDAO('DepositDAO');
     $depositQueue =& $depositDao->getNeedPackaging($journal->getId());
     $fileManager = new JournalFileManager($journal);
     $plnDir = $fileManager->filesDir . PLN_PLUGIN_ARCHIVE_FOLDER;
     // make sure the pln work directory exists
     // TOOD: use FileManager calls instead of PHP ones where possible
     if ($fileManager->fileExists($plnDir, 'dir') !== true) {
         $fileManager->mkdirtree($plnDir);
     }
     // loop though all of the deposits that need packaging
     while ($deposit =& $depositQueue->next()) {
         $depositPackage = new DepositPackage($deposit, $this);
         $depositPackage->packageDeposit();
         unset($deposit);
     }
 }