Esempio n. 1
0
 protected function _preStore()
 {
     $type = $this->getType();
     $value = $this->getValue();
     if (isset($type) and isset($value) and $type === 'urn') {
         $finder = new Opus_DocumentFinder();
         $docIds = $finder->setIdentifierTypeValue('urn', $value)->ids();
         $errorMsg = "urn collision (documents " . implode(",", $docIds) . ")";
         if ($this->isNewRecord() and count($docIds) > 0) {
             throw new Opus_Identifier_UrnAlreadyExistsException($errorMsg);
         }
         if (count($docIds) > 1) {
             throw new Opus_Identifier_UrnAlreadyExistsException($errorMsg);
         }
         if (count($docIds) == 1 and !in_array($this->getParentId(), $docIds)) {
             throw new Opus_Identifier_UrnAlreadyExistsException($errorMsg);
         }
     }
     return parent::_preStore();
 }
Esempio n. 2
0
 /**
  * Return the primary key of the Link Model if it has been persisted.
  *
  * @return array|null Primary key or Null if the Linked Model has not been persisted.
  */
 public function getId()
 {
     // The given id consists of the ids of the referenced linked models,
     // but there is no evidence that the LinkModel itself has been persisted yet.
     // We so have to validate, if the LinkModel is persistent or still transient.
     if (true === $this->isNewRecord()) {
         // its a new record, so return null
         return null;
     }
     // its not a new record, so we can hand over to the parent method
     return parent::getId();
 }
Esempio n. 3
0
 /**
  * This model is valid IFF both link model *and* linked model are valid.
  *
  * @return boolean
  */
 public function isValid()
 {
     return $this->_model->isValid() && parent::isValid();
 }
Esempio n. 4
0
 /**
  * Deletes a file from filespace and if directory are empty it will be deleted too.
  *
  * @see    library/Opus/Model/Opus_Model_AbstractDb#doDelete()
  * @throws Opus_Storage_Exception if not a file, or empty directory could not be deleted
  * @throws Opus_Storage_FileNotFoundException  if file does not exist
  * @throws Opus_Storage_FileAccessException if file could not be deleted
  * @return void
  */
 public function doDelete($token)
 {
     parent::doDelete($token);
     $this->getStorage()->deleteFile($this->getPathName());
     // TODO: Check return value of removeEmptyDirectory()?
     $this->getStorage()->removeEmptyDirectory();
 }