public function testError() { try { $this->sc->serviceDocument($this->references->getReference('journal')); } catch (Exception $ex) { $this->assertStringStartsWith('Client error response', $ex->getMessage()); return; } $this->fail('no exception.'); }
public function setUp() { parent::setUp(); $this->sc = $this->getContainer()->get('swordclient'); $client = new Client(); $this->history = new History(); $client->getEmitter()->attach($this->history); $mock = new Mock([$this->getReceiptResponse(), $this->getStatementResponse()]); $client->getEmitter()->attach($mock); $this->sc->setClient($client); $deposit = $this->references->getReference('deposit'); $deposit->setAuContainer($this->references->getReference('aucontainer')); $this->xml = $this->sc->statement($deposit); }
public function setUp() { parent::setUp(); $this->sc = $this->getContainer()->get('swordclient'); $client = new Client(); $this->history = new History(); $client->getEmitter()->attach($this->history); $mock = new Mock([$this->getServiceDocumentResponse(), $this->getCreateDepositResponse()]); $client->getEmitter()->attach($mock); $this->sc->setClient($client); $deposit = $this->references->getReference('deposit'); $deposit->setAuContainer($this->references->getReference('aucontainer')); // try { $this->sc->createDeposit($deposit); // } catch (Exception $e) { // // expected, because the response XML isn't valid. // } }
/** * Download all the content from one journal. * * Requests a SWORD deposit statement from LOCKSSOMatic, and uses the * sword:originalDeposit element to fetch the content. * * @param Journal $journal */ public function downloadJournal(Journal $journal) { foreach ($journal->getDeposits() as $deposit) { $statement = $this->swordClient->statement($deposit); $originals = $statement->xpath('//sword:originalDeposit'); foreach ($originals as $element) { $this->fetch($deposit, $element['href']); } } }
/** * 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'; }
public function testUploadChecksum() { $this->assertEquals('SHA-1 MD5', $this->sc->getUploadChecksum()); }
/** * 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); }