Exemplo n.º 1
0
 /**
  * @see {Opus_Model_Plugin_Interface::postDelete}
  */
 public function postDelete($modelId)
 {
     $cache = new Opus_Model_Xml_Cache();
     $omx = new Opus_Model_Xml();
     // xml version 1
     $omx->setStrategy(new Opus_Model_Xml_Version1());
     $cache->remove($modelId, floor($omx->getStrategyVersion()));
     // xml version 2
     $omx->setStrategy(new Opus_Model_Xml_Version2());
     $cache->remove($modelId, floor($omx->getStrategyVersion()));
 }
Exemplo n.º 2
0
 /**
  * make sure documents related to Collection[Role|]s in subtree are updated 
  * (XML-Cache and server_date_published)
  *
  * @param Opus_Collection Starting point for recursive update to documents
  */
 protected function updateDocuments($model)
 {
     if (is_null($model) || is_null($model->getId())) {
         // TODO explain why this is right
         return;
     }
     $collections = Opus_Db_TableGateway::getInstance('Opus_Db_Collections');
     $collectionIdSelect = $collections->selectSubtreeById($model->getId(), 'id');
     $documentFinder = new Opus_DocumentFinder();
     $documentFinder->setCollectionId($collectionIdSelect);
     // clear affected documents from cache
     $xmlCache = new Opus_Model_Xml_Cache();
     $xmlCache->removeAllEntriesWhereSubSelect($documentFinder->getSelectIds());
     // update ServerDateModified for affected documents
     $date = new Opus_Date();
     $date->setNow();
     Opus_Document::setServerDateModifiedByIds($date, $documentFinder->ids());
 }
Exemplo n.º 3
0
 /**
  * This method tries to load the current model from the xml cache.  Returns
  * null in case of an error/cache miss/cache disabled.  Returns DOMDocument
  * otherwise.
  *
  * @return DOMDocument DOM representation of the current Model.
  */
 private function getDomDocumentFromXmlCache()
 {
     $model = $this->_config->_model;
     $logger = Zend_Registry::get('Zend_Log');
     if (null === $this->_cache) {
         $logger->debug(__METHOD__ . ' skipping cache for ' . get_class($model));
         return null;
     }
     $cached = $this->_cache->hasValidEntry($model->getId(), (int) $this->_strategy->getVersion(), $model->getServerDateModified()->__toString());
     if (true !== $cached) {
         $logger->debug(__METHOD__ . ' cache miss for ' . get_class($model) . '#' . $model->getId());
         return null;
     }
     $logger->debug(__METHOD__ . ' cache hit for ' . get_class($model) . '#' . $model->getId());
     try {
         return $this->_cache->get($model->getId(), (int) $this->_strategy->getVersion());
     } catch (Opus_Model_Exception $e) {
         $logger->warn(__METHOD__ . " Access to XML cache failed on " . get_class($model) . '#' . $model->getId() . ".  Trying to recover.");
     }
     return null;
 }
Exemplo n.º 4
0
 protected function invalidateDocumentCacheFor(Opus_Model_AbstractDb $model)
 {
     $documentFinder = new Opus_DocumentFinder();
     $documentFinder->setDependentModel($model);
     $select = $documentFinder->getSelectIds();
     $ids = $documentFinder->Ids();
     $xmlCache = new Opus_Model_Xml_Cache();
     $xmlCache->removeAllEntriesWhereSubSelect($select);
     $date = new Opus_Date();
     $date->setNow();
     Opus_Document::setServerDateModifiedByIds($date, $ids);
 }