コード例 #1
0
 /**
  * Regression test for OPUSVIER-2564
  */
 public function testForInvalidSetSpecsInGetRecord79()
 {
     $collectionRole = Opus_CollectionRole::fetchByOaiName('pacs');
     $this->assertNotNull($collectionRole);
     $this->assertContains(79, $collectionRole->getDocumentIdsInSet('pacs:07.75.+h'));
     $this->assertContains(79, $collectionRole->getDocumentIdsInSet('pacs:85.85.+j'));
     $this->dispatch('/oai?verb=GetRecord&metadataPrefix=oai_dc&identifier=oai:opus4.demo:79');
     $body = $this->getResponse()->getBody();
     $this->assertContains('<setSpec>pacs:07.07.Df</setSpec>', $body);
     $this->assertContains(':79</identifier>', $body);
     // Regression test for OPUSVIER-2564: invalid SetSpec characters
     $this->assertNotContains('<setSpec>pacs:07.75.', $body);
     $this->assertNotContains('<setSpec>pacs:85.85.', $body);
 }
コード例 #2
0
 /**
  * Verwende OaiName um CollectionRole zu finden.
  */
 protected function _getModel($identifier)
 {
     return Opus_CollectionRole::fetchByOaiName($identifier);
 }
コード例 #3
0
ファイル: FormElement.php プロジェクト: alexukua/opus4
 public function setCurrentCollectionId($setRoot = false)
 {
     if (!$setRoot) {
         $collectionRole = Opus_CollectionRole::fetchByOaiName($this->collectionRole);
         if (!is_null($collectionRole)) {
             $rootCollection = $collectionRole->getRootCollection();
             if (!is_null($rootCollection)) {
                 $collectionId = $rootCollection->getId();
                 $this->log->debug("CollectionRoot: " . $this->collectionRole . " * CollectionId: " . $collectionId);
                 $this->collectionId = $collectionId;
             }
         }
     }
 }
コード例 #4
0
 /**
  * Retrieve all document ids for a valid oai request.
  *
  * @param array &$oaiRequest
  * @return array
  */
 public function query(array $oaiRequest)
 {
     $finder = new Opus_DocumentFinder();
     // add server state restrictions
     $finder->setServerStateInList($this->deliveringDocumentStates);
     $metadataPrefix = $oaiRequest['metadataPrefix'];
     if ('xMetaDissPlus' === $metadataPrefix || 'xMetaDiss' === $metadataPrefix) {
         $finder->setFilesVisibleInOai();
     }
     if ('xMetaDiss' === $metadataPrefix) {
         $finder->setTypeInList($this->xMetaDissRestriction);
     }
     if ('epicur' === $metadataPrefix) {
         $finder->setIdentifierTypeExists('urn');
     }
     if (array_key_exists('set', $oaiRequest)) {
         $setarray = explode(':', $oaiRequest['set']);
         if (!isset($setarray[0])) {
             return array();
         }
         if ($setarray[0] == 'doc-type') {
             if (count($setarray) === 2 and !empty($setarray[1])) {
                 $finder->setType($setarray[1]);
             } else {
                 return array();
             }
         } else {
             if ($setarray[0] == 'bibliography') {
                 if (count($setarray) !== 2 or empty($setarray[1])) {
                     return array();
                 }
                 $setValue = $setarray[1];
                 $bibliographyMap = array("true" => 1, "false" => 0);
                 if (false === isset($setValue, $bibliographyMap[$setValue])) {
                     return array();
                 }
                 $finder->setBelongsToBibliography($bibliographyMap[$setValue]);
             } else {
                 if (count($setarray) < 1 or count($setarray) > 2) {
                     $msg = "Invalid SetSpec: Must be in format 'set:subset'.";
                     throw new Oai_Model_Exception($msg);
                 }
                 // Trying to locate collection role and filter documents.
                 $role = Opus_CollectionRole::fetchByOaiName($setarray[0]);
                 if (is_null($role)) {
                     $msg = "Invalid SetSpec: Top level set does not exist.";
                     throw new Oai_Model_Exception($msg);
                 }
                 $finder->setCollectionRoleId($role->getId());
                 // Trying to locate given collection and filter documents.
                 if (count($setarray) == 2) {
                     $subsetName = $setarray[1];
                     $foundSubsets = array_filter($role->getOaiSetNames(), function ($s) use($subsetName) {
                         return $s['oai_subset'] === $subsetName;
                     });
                     if (count($foundSubsets) < 1) {
                         $msg = "Invalid SetSpec: Subset does not exist.";
                         throw new Oai_Model_Exception($msg);
                     }
                     foreach ($foundSubsets as $subset) {
                         if ($subset['oai_subset'] !== $subsetName) {
                             $msg = "Invalid SetSpec: Internal error.";
                             throw new Oai_Model_Exception($msg);
                         }
                         $finder->setCollectionId($subset['id']);
                     }
                 }
             }
         }
     }
     if (array_key_exists('from', $oaiRequest) and !empty($oaiRequest['from'])) {
         $from = DateTime::createFromFormat('Y-m-d', $oaiRequest['from']);
         $finder->setServerDateModifiedAfter($from->format('Y-m-d'));
     }
     if (array_key_exists('until', $oaiRequest)) {
         $until = DateTime::createFromFormat('Y-m-d', $oaiRequest['until']);
         $until->add(new DateInterval('P1D'));
         $finder->setServerDateModifiedBefore($until->format('Y-m-d'));
     }
     return $finder->ids();
 }