/**
  * Add the metadata from the database to the bag-info.txt file.
  *
  * @param BagIt   $bag
  * @param Deposit $deposit
  */
 protected function addMetadata(BagIt $bag, Deposit $deposit)
 {
     $bag->bagInfoData = array();
     // @todo this is very very bad. Once BagItPHP is updated it should be $bag->clearAllBagInfo();
     $bag->setBagInfoData('External-Identifier', $deposit->getDepositUuid());
     $bag->setBagInfoData('PKP-PLN-Deposit-UUID', $deposit->getDepositUuid());
     $bag->setBagInfoData('PKP-PLN-Deposit-Received', $deposit->getReceived()->format('c'));
     $bag->setBagInfoData('PKP-PLN-Deposit-Volume', $deposit->getVolume());
     $bag->setBagInfoData('PKP-PLN-Deposit-Issue', $deposit->getIssue());
     $bag->setBagInfoData('PKP-PLN-Deposit-PubDate', $deposit->getPubDate()->format('c'));
     $journal = $deposit->getJournal();
     $bag->setBagInfoData('PKP-PLN-Journal-UUID', $journal->getUuid());
     $bag->setBagInfoData('PKP-PLN-Journal-Title', $journal->getTitle());
     $bag->setBagInfoData('PKP-PLN-Journal-ISSN', $journal->getIssn());
     $bag->setBagInfoData('PKP-PLN-Journal-URL', $journal->getUrl());
     $bag->setBagInfoData('PKP-PLN-Journal-Email', $journal->getEmail());
     $bag->setBagInfoData('PKP-PLN-Publisher-Name', $journal->getPublisherName());
     $bag->setBagInfoData('PKP-PLN-Publisher-URL', $journal->getPublisherUrl());
     foreach ($deposit->getLicense() as $key => $value) {
         $bag->setBagInfoData('PKP-PLN-' . $key, $value);
     }
 }
예제 #2
0
 /**
  * Get the path to a processed, staged, bag.
  *
  * @param Deposit $deposit
  *
  * @return type
  */
 public final function getStagingBagPath(Deposit $deposit)
 {
     $path = $this->getStagingDir($deposit->getJournal());
     return $path . '/' . $deposit->getDepositUuid() . '.zip';
 }
예제 #3
0
 /**
  * Process one deposit. Fetch the data and write it to the file system.
  * Updates the deposit status.
  *
  * @param Deposit $deposit
  *
  * @return type
  */
 protected function processDeposit(Deposit $deposit)
 {
     $this->logger->notice("harvest - {$deposit->getDepositUuid()}");
     $this->checkSize($deposit);
     $response = $this->fetchDeposit($deposit->getUrl(), $deposit->getSize());
     $deposit->setFileType($response->getHeader('Content-Type'));
     $filePath = $this->filePaths->getHarvestFile($deposit);
     return $this->writeDeposit($filePath, $response);
 }
 public function testDepositUuid()
 {
     $this->assertEquals('28FF5B33-D3C4-440C-B87A-16D402D10D93', $this->deposit->getDepositUuid());
 }
예제 #5
0
 /**
  * Process one deposit. Fetch the data and write it to the file system.
  * Updates the deposit status.
  *
  * @param Deposit $deposit
  *
  * @return type
  */
 protected function processDeposit(Deposit $deposit)
 {
     $this->logger->notice("Sending deposit {$deposit->getDepositUuid()}");
     return $this->client->createDeposit($deposit);
 }
예제 #6
0
 /**
  * Build the URL for the deposit receipt.
  *
  * @param Deposit $deposit
  *
  * @return string
  */
 public function buildDepositReceiptUrl(Deposit $deposit)
 {
     return $this->router->getGenerator()->generate('statement', array('journal_uuid' => $deposit->getJournal()->getUuid(), 'deposit_uuid' => $deposit->getDepositUuid()), UrlGeneratorInterface::ABSOLUTE_URL);
 }
예제 #7
0
 /**
  * Process one deposit. Fetch the data and write it to the file system.
  * Updates the deposit status, and may remove the processing files if 
  * LOCKSSOatic reports agreement.
  *
  * @param Deposit $deposit
  *
  * @return type
  */
 protected function processDeposit(Deposit $deposit, $force = false)
 {
     if ($deposit->getPlnState() === 'agreement') {
         $this->logger->notice($deposit->getDepositUuid());
         $this->delFileTree($this->filePaths->getHarvestFile($deposit), $force);
         $this->delFileTree($this->filePaths->getProcessingBagPath($deposit), $force);
         // $this->delFileTree($this->filePaths->getStagingBagPath($deposit), $force);
     }
 }
예제 #8
0
 /**
  * Process one deposit. Fetch the data and write it to the file system.
  * Updates the deposit status, and may remove the processing files if
  * LOCKSSOatic reports agreement.
  *
  * @param Deposit $deposit
  *
  * @return type
  */
 protected function processDeposit(Deposit $deposit)
 {
     $this->logger->notice("Checking deposit {$deposit->getDepositUuid()}");
     $statement = $this->client->statement($deposit);
     $status = (string) $statement->xpath('//atom:category[@scheme="http://purl.org/net/sword/terms/state"]/@term')[0];
     $this->logger->notice('Deposit is ' . $status);
     $deposit->setPlnState($status);
     if ($status === 'agreement' && $this->cleanup) {
         $this->logger->notice("Deposit complete. Removing processing files for deposit {$deposit->getId()}.");
         unlink($this->filePaths->getHarvestFile($deposit));
         $this->deltree($this->filePaths->getProcessingBagPath($deposit));
         unlink($this->filePaths->getStagingBagPath($deposit));
     }
     return $status === 'agreement';
 }
예제 #9
0
 /**
  * Send a deposit to LOM via HTTP.
  *
  * @param Deposit $deposit
  *
  * @return bool true on success
  */
 public function createDeposit(Deposit $deposit)
 {
     $this->serviceDocument($deposit->getJournal());
     $xml = $this->templating->render('AppBundle:SwordClient:deposit.xml.twig', array('title' => 'Deposit from OJS part ' . $deposit->getAuContainer()->getId(), 'publisher' => 'Public Knowledge Project Staging Server', 'deposit' => $deposit, 'baseUri' => $this->router->generate('home', array(), UrlGeneratorInterface::ABSOLUTE_URL), 'plnJournalTitle' => $this->plnJournalTitle));
     if ($this->saveDepositXml) {
         $atomPath = $this->filePaths->getStagingDir($deposit->getJournal()) . '/' . $deposit->getDepositUuid() . '.xml';
         file_put_contents($atomPath, $xml);
     }
     try {
         $client = $this->getClient();
         $request = $client->createRequest('POST', $this->colIri);
         $request->setBody(Stream::factory($xml));
         $response = $client->send($request);
         $responseXml = new SimpleXMLElement($response->getBody());
     } catch (RequestException $e) {
         $this->logger->critical($e->getMessage());
         if ($e->hasResponse()) {
             $xml = $e->getResponse()->xml();
             $xml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom');
             $xml->registerXPathNamespace('sword', 'http://purl.org/net/sword/');
             $this->logger->critical('Summary: ' . (string) $xml->xpath('//atom:summary')[0]);
             $this->logger->warning('Detail: ' . (string) $xml->xpath('//sword:verboseDescription')[0]);
         }
         return false;
     } catch (Exception $e) {
         $this->logger->critical("Error parsing deposit response from server: {$e->getMessage()}");
         return false;
     }
     $deposit->setDepositReceipt($response->getHeader('Location'));
     $deposit->setDepositDate(new DateTime());
     // TODO should I do something wtih responseXML here?
     $this->namespaces->registerNamespaces($responseXml);
     return true;
 }