示例#1
0
 public static function updateBatchJob(BatchJob $batchJob, $status, BatchJob $twinJob = null)
 {
     $batchJob->setStatus($status);
     $batchJob->save();
     $event = new kBatchJobStatusEvent($batchJob, $twinJob);
     kEventsManager::raiseEvent($event);
     $batchJob->reload();
     return $batchJob;
 }
示例#2
0
 /**
  * @param BatchJob $batchJob
  * @param int $status
  * @return BatchJob
  */
 public static function updateBatchJob(BatchJob $batchJob, $status)
 {
     $batchJob->setStatus($status);
     $changed = $batchJob->save();
     if (!$changed) {
         return $batchJob;
     }
     $event = new kBatchJobStatusEvent($batchJob);
     kEventsManager::raiseEvent($event);
     $batchJob->reload();
     return $batchJob;
 }
示例#3
0
 public function postUpdate(PropelPDO $con = null)
 {
     $objectDeleted = false;
     if ($this->isColumnModified(conversionProfile2Peer::DELETED_AT) && !is_null($this->getDeletedAt())) {
         $objectDeleted = true;
     }
     $ret = parent::postUpdate($con);
     if ($objectDeleted) {
         kEventsManager::raiseEvent(new kObjectDeletedEvent($this));
     }
     return $ret;
 }
示例#4
0
 public function postUpdate(PropelPDO $con = null)
 {
     $objectDeleted = false;
     if ($this->isColumnModified(AnnotationPeer::STATUS) && $this->getStatus() == AnnotationStatus::ANNOTATION_STATUS_DELETED) {
         $objectDeleted = true;
     }
     $ret = parent::postUpdate($con);
     if ($objectDeleted) {
         kEventsManager::raiseEvent(new kObjectDeletedEvent($this));
     }
     return $ret;
 }
示例#5
0
 public function postUpdate(PropelPDO $con = null)
 {
     $objectDeleted = false;
     if ($this->isColumnModified(MetadataProfilePeer::STATUS) && $this->getStatus() == self::STATUS_DEPRECATED) {
         $objectDeleted = true;
     }
     $ret = parent::postUpdate($con);
     if ($objectDeleted) {
         kEventsManager::raiseEvent(new kObjectDeletedEvent($this));
     }
     return $ret;
 }
示例#6
0
 public function postUpdate(PropelPDO $con = null)
 {
     $objectDeleted = false;
     if ($this->isColumnModified(BasesyndicationFeedPeer::STATUS) && $this->getStatus() == self::SYNDICATION_DELETED) {
         $objectDeleted = true;
     }
     $ret = parent::postUpdate($con);
     if ($objectDeleted) {
         kEventsManager::raiseEvent(new kObjectDeletedEvent($this));
     }
     return $ret;
 }
示例#7
0
 public function postUpdate(PropelPDO $con = null)
 {
     $objectDeleted = false;
     if ($this->isColumnModified(UploadTokenPeer::STATUS) && $this->getStatus() == self::UPLOAD_TOKEN_DELETED) {
         $objectDeleted = true;
     }
     $ret = parent::postUpdate($con);
     if ($objectDeleted) {
         kEventsManager::raiseEvent(new kObjectDeletedEvent($this));
     }
     return $ret;
 }
 private function resumeEvents($flavorAsset)
 {
     $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $c = FileSyncPeer::getCriteriaForFileSyncKey($syncKey);
     $fileSyncList = FileSyncPeer::doSelect($c);
     foreach ($fileSyncList as $fileSync) {
         // resume file sync added event
         kEventsManager::continueEvent(new kObjectAddedEvent($fileSync), 'kVirusScanFlowManager');
     }
     // resume flavor asset added event consumption
     kEventsManager::continueEvent(new kObjectAddedEvent($flavorAsset), 'kVirusScanFlowManager');
 }
示例#9
0
 public function postUpdate(PropelPDO $con = null)
 {
     $objectDeleted = false;
     if ($this->isColumnModified(flavorAssetPeer::STATUS) && $this->getStatus() == self::FLAVOR_ASSET_STATUS_DELETED || $this->isColumnModified(flavorAssetPeer::DELETED_AT) && !is_null($this->getDeletedAt(null))) {
         $objectDeleted = true;
     }
     $ret = parent::postUpdate($con);
     if ($objectDeleted) {
         kEventsManager::raiseEvent(new kObjectDeletedEvent($this));
     }
     return $ret;
 }
 /**
  * @param int $entryId
  */
 protected function entryDeleted($entryId)
 {
     $c = new Criteria();
     $c->add(CuePointPeer::ENTRY_ID, $entryId);
     CuePointPeer::setUseCriteriaFilter(false);
     $cuePoints = CuePointPeer::doSelect($c);
     $update = new Criteria();
     $update->add(CuePointPeer::STATUS, CuePointStatus::DELETED);
     $con = Propel::getConnection(myDbHelper::DB_HELPER_CONN_MASTER);
     BasePeer::doUpdate($c, $update, $con);
     foreach ($cuePoints as $cuePoint) {
         kEventsManager::raiseEvent(new kObjectDeletedEvent($cuePoint));
     }
 }
 public function postUpdate(PropelPDO $con = null)
 {
     if ($this->alreadyInSave) {
         return parent::postUpdate($con);
     }
     $objectDeleted = false;
     if ($this->isColumnModified(accessControlPeer::DELETED_AT) && !is_null($this->getDeletedAt())) {
         $objectDeleted = true;
     }
     $ret = parent::postUpdate($con);
     if ($objectDeleted) {
         kEventsManager::raiseEvent(new kObjectDeletedEvent($this));
     }
     return $ret;
 }
示例#12
0
 /**
  * @param int $entryId
  */
 protected function entryDeleted($entryId)
 {
     $c = new Criteria();
     $c->add(AnnotationPeer::ENTRY_ID, $entryId);
     $c->add(AnnotationPeer::STATUS, AnnotationStatus::ANNOTATION_STATUS_DELETED, Criteria::NOT_EQUAL);
     AnnotationPeer::setUseCriteriaFilter(false);
     $annotations = AnnotationPeer::doSelect($c);
     foreach ($annotations as $annotation) {
         kEventsManager::raiseEvent(new kObjectDeletedEvent($annotation));
     }
     $update = new Criteria();
     $update->add(AnnotationPeer::STATUS, AnnotationStatus::ANNOTATION_STATUS_DELETED);
     $con = Propel::getConnection(AnnotationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     BasePeer::doUpdate($c, $update, $con);
 }
 public function postUpdate(PropelPDO $con = null)
 {
     if ($this->alreadyInSave) {
         return parent::postUpdate($con);
     }
     $objectDeleted = false;
     if ($this->isColumnModified(ShortLinkPeer::STATUS) && $this->getStatus() == ShortLinkStatus::DELETED) {
         $objectDeleted = true;
     }
     $ret = parent::postUpdate($con);
     if ($objectDeleted) {
         kEventsManager::raiseEvent(new kObjectDeletedEvent($this));
     }
     return $ret;
 }
示例#14
0
 /**
  * Add new document entry after the specific document file was uploaded and the upload token id exists
  *
  * @action addFromUploadedFile
  * @param KalturaDocumentEntry $documentEntry Document entry metadata
  * @param string $uploadTokenId Upload token id
  * @return KalturaDocumentEntry The new document entry
  * 
  * @throws KalturaErrors::PROPERTY_VALIDATION_MIN_LENGTH
  * @throws KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL
  * @throws KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN
  */
 function addFromUploadedFileAction(KalturaDocumentEntry $documentEntry, $uploadTokenId)
 {
     try {
         // check that the uploaded file exists
         $entryFullPath = kUploadTokenMgr::getFullPathByUploadTokenId($uploadTokenId);
     } catch (kCoreException $ex) {
         if ($ex->getCode() == kUploadTokenException::UPLOAD_TOKEN_INVALID_STATUS) {
         }
         throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_INVALID_STATUS_FOR_ADD_ENTRY);
         throw $ex;
     }
     if (!file_exists($entryFullPath)) {
         $remoteDCHost = kUploadTokenMgr::getRemoteHostForUploadToken($uploadTokenId, kDataCenterMgr::getCurrentDcId());
         if ($remoteDCHost) {
             kFile::dumpApiRequest($remoteDCHost);
         } else {
             throw new KalturaAPIException(KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN);
         }
     }
     $dbEntry = $this->prepareEntryForInsert($documentEntry);
     $dbEntry->setSource(KalturaSourceType::FILE);
     $dbEntry->setSourceLink("file:{$entryFullPath}");
     $dbEntry->save();
     $te = new TrackEntry();
     $te->setEntryId($dbEntry->getId());
     $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY);
     $te->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA_SOURCE_FILE");
     TrackEntry::addTrackEntry($te);
     $msg = null;
     $flavorAsset = kFlowHelper::createOriginalFlavorAsset($this->getPartnerId(), $dbEntry->getId(), $msg);
     if (!$flavorAsset) {
         KalturaLog::err("Flavor asset not created for entry [" . $dbEntry->getId() . "] reason [{$msg}]");
         $dbEntry->setStatus(entryStatus::ERROR_CONVERTING);
         $dbEntry->save();
     } else {
         $ext = pathinfo($entryFullPath, PATHINFO_EXTENSION);
         KalturaLog::info("Uploaded file extension: {$ext}");
         $flavorAsset->setFileExt($ext);
         $flavorAsset->save();
         $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         kFileSyncUtils::moveFromFile($entryFullPath, $syncKey);
         kEventsManager::raiseEvent(new kObjectAddedEvent($flavorAsset));
     }
     kUploadTokenMgr::closeUploadTokenById($uploadTokenId);
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry);
     $documentEntry->fromObject($dbEntry);
     return $documentEntry;
 }
示例#15
0
 protected static function loadConsumers()
 {
     $cachePath = kConf::get('cache_root_path') . '/EventConsumers.cache';
     if (file_exists($cachePath)) {
         self::$consumers = unserialize(file_get_contents($cachePath));
         return;
     }
     $coreConsumers = kConf::get('event_consumers');
     $pluginConsumers = array();
     $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaEventConsumers');
     foreach ($pluginInstances as $pluginInstance) {
         foreach ($pluginInstance->getEventConsumers() as $pluginConsumer) {
             $pluginConsumers[] = $pluginConsumer;
         }
     }
     $consumers = array_merge($coreConsumers, $pluginConsumers);
     $consumersLists = array();
     foreach ($consumers as $consumer) {
         if (!class_exists($consumer)) {
             continue;
         }
         $clazz = new ReflectionClass($consumer);
         $interfaces = $clazz->getInterfaces();
         foreach ($interfaces as $interface) {
             if ($interface->name == self::BASE_CONSUMER_INTERFACE) {
                 continue;
             }
             if (!$interface->implementsInterface(self::BASE_CONSUMER_INTERFACE)) {
                 continue;
             }
             if (!isset($consumersLists[$interface->name])) {
                 $consumersLists[$interface->name] = array();
             }
             $consumersLists[$interface->name][] = $consumer;
         }
     }
     foreach ($consumersLists as $interfaceName => $interfaceConsumersArray) {
         usort($interfaceConsumersArray, array('kEventsManager', 'compareConsumers'));
         self::$consumers[$interfaceName] = $interfaceConsumersArray;
     }
     $cacheDir = dirname($cachePath);
     if (!file_exists($cacheDir)) {
         kFile::fullMkfileDir($cacheDir, 0777, true);
     }
     @file_put_contents($cachePath, serialize(self::$consumers));
 }
 /**
  * @param int $objectType
  * @param string $objectId
  */
 protected function deleteMetadataObjects($objectType, $objectId)
 {
     $c = new Criteria();
     $c->add(MetadataPeer::OBJECT_TYPE, $objectType);
     $c->add(MetadataPeer::OBJECT_ID, $objectId);
     $c->add(MetadataPeer::STATUS, Metadata::STATUS_DELETED, Criteria::NOT_EQUAL);
     $peer = null;
     MetadataPeer::setUseCriteriaFilter(false);
     $metadatas = MetadataPeer::doSelect($c);
     foreach ($metadatas as $metadata) {
         kEventsManager::raiseEvent(new kObjectDeletedEvent($metadata));
     }
     $update = new Criteria();
     $update->add(MetadataPeer::STATUS, Metadata::STATUS_DELETED);
     $con = Propel::getConnection(MetadataPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     BasePeer::doUpdate($c, $update, $con);
 }
 /**
  * updates entry distribution sun status in the search engine
  *
  * @action updateSunStatus
  */
 function updateSunStatusAction()
 {
     $updatedEntries = array();
     // serach all records that their sun status changed to after sunset
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::STATUS, EntryDistributionStatus::READY);
     $criteria->add(EntryDistributionPeer::SUN_STATUS, EntryDistributionSunStatus::AFTER_SUNSET, Criteria::NOT_EQUAL);
     $crit1 = $criteria->getNewCriterion(EntryDistributionPeer::SUNSET, time(), Criteria::LESS_THAN);
     $criteria->add($crit1);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         /* @var $entryDistribution EntryDistribution */
         $entryId = $entryDistribution->getEntryId();
         if (isset($updatedEntries[$entryId])) {
             continue;
         }
         $updatedEntries[$entryId] = true;
         kEventsManager::raiseEvent(new kObjectUpdatedEvent($entryDistribution));
         // raise the updated events to trigger index in search engine (sphinx)
         kEventsManager::flushEvents();
         // save entry changes to sphinx
         kMemoryManager::clearMemory();
     }
     $updatedEntries = array();
     // serach all records that their sun status changed to after sunrise
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::STATUS, EntryDistributionStatus::QUEUED);
     $criteria->add(EntryDistributionPeer::SUN_STATUS, EntryDistributionSunStatus::BEFORE_SUNRISE);
     $criteria->add(EntryDistributionPeer::SUNRISE, time(), Criteria::LESS_THAN);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         /* @var $entryDistribution EntryDistribution */
         $entryId = $entryDistribution->getEntryId();
         if (isset($updatedEntries[$entryId])) {
             continue;
         }
         $updatedEntries[$entryId] = true;
         kEventsManager::raiseEvent(new kObjectUpdatedEvent($entryDistribution));
         // raise the updated events to trigger index in search engine (sphinx)
         kEventsManager::flushEvents();
         // save entry changes to sphinx
         kMemoryManager::clearMemory();
     }
 }
示例#18
0
 /**
  * Parse content of caption asset and index it
  *
  * @action parse
  * @param string $captionAssetId
  * @throws KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND
  */
 function parseAction($captionAssetId)
 {
     $captionAsset = assetPeer::retrieveById($captionAssetId);
     if (!$captionAsset) {
         throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND, $captionAssetId);
     }
     $captionAssetItems = CaptionAssetItemPeer::retrieveByAssetId($captionAssetId);
     foreach ($captionAssetItems as $captionAssetItem) {
         /* @var $captionAssetItem CaptionAssetItem */
         $captionAssetItem->delete();
     }
     // make sure that all old items are deleted from the sphinx before creating the new ones
     kEventsManager::flushEvents();
     $syncKey = $captionAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $content = kFileSyncUtils::file_get_contents($syncKey, true, false);
     if (!$content) {
         return;
     }
     $captionsContentManager = kCaptionsContentManager::getCoreContentManager($captionAsset->getContainerFormat());
     if (!$captionsContentManager) {
         return;
     }
     $itemsData = $captionsContentManager->parse($content);
     foreach ($itemsData as $itemData) {
         $item = new CaptionAssetItem();
         $item->setCaptionAssetId($captionAsset->getId());
         $item->setEntryId($captionAsset->getEntryId());
         $item->setPartnerId($captionAsset->getPartnerId());
         $item->setStartTime($itemData['startTime']);
         $item->setEndTime($itemData['endTime']);
         $content = '';
         foreach ($itemData['content'] as $curChunk) {
             $content .= $curChunk['text'];
         }
         //Make sure there are no invalid chars in the caption asset items to avoid braking the search request by providing invalid XML
         $content = kString::stripUtf8InvalidChars($content);
         $content = kXml::stripXMLInvalidChars($content);
         $item->setContent($content);
         $item->save();
     }
 }
 /**
  * updates entry distribution sun status in the search engine
  * 
  * @action updateSunStatus
  */
 function updateSunStatusAction()
 {
     // serach all records that their sun status changed to after sunset
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::SUN_STATUS, EntryDistributionSunStatus::AFTER_SUNSET, Criteria::NOT_EQUAL);
     $crit1 = $criteria->getNewCriterion(EntryDistributionPeer::SUNSET, time(), Criteria::LESS_THAN);
     $criteria->add($crit1);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         // raise the updated events to trigger index in search engine (sphinx)
         kEventsManager::raiseEvent(new kObjectUpdatedEvent($entryDistribution));
     }
     // serach all records that their sun status changed to after sunrise
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::SUN_STATUS, EntryDistributionSunStatus::BEFORE_SUNRISE);
     $criteria->add(EntryDistributionPeer::SUNRISE, time(), Criteria::LESS_THAN);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         // raise the updated events to trigger index in search engine (sphinx)
         kEventsManager::raiseEvent(new kObjectUpdatedEvent($entryDistribution));
     }
 }
 public function execute()
 {
     // can't read using $_REQUEST because the 'myaction' paramter is created in a routing.yml rule
     $service_name = $this->getRequestParameter("myaction");
     // remove all '_' and set to lowercase
     $myaction_name = trim(strtolower(str_replace("_", "", $service_name)));
     $clazz_name = $myaction_name . "Action";
     //		echo "[$myaction_name] [$clazz_name]<br>";
     //		$clazz = get_class ( $clazz_name );
     //$multi_request = $this->getRequestParameter( "multirequest" , null );
     $multi_request = $myaction_name == "multirequest";
     if ($multi_request) {
         $multi_request = new myMultiRequest($_REQUEST, $this);
         $response = $multi_request->execute();
     } else {
         $include_result = @(include_once "{$clazz_name}.class.php");
         if ($include_result) {
             $myaction = new $clazz_name($this);
             $myaction->setInputParams($_REQUEST);
             $response = $myaction->execute();
             kEventsManager::flushEvents();
         } else {
             $format = $this->getP("format");
             $response = "Error: Invalid service [{$service_name}]";
         }
     }
     $format = $this->getP("format");
     if ($format == kalturaWebserviceRenderer::RESPONSE_TYPE_PHP_ARRAY || $format == kalturaWebserviceRenderer::RESPONSE_TYPE_PHP_OBJECT) {
         //$this->setHttpHeader ( "Content-Type" , "text/html; charset=utf-8" );
         $response = "<pre>" . print_r($response, true) . "</pre>";
     }
     // uncomment in order to cache api responses
     if (kConf::get('enable_cache')) {
         $this->cacheResponse($response);
     }
     $ret = $this->renderText($response);
     KExternalErrors::terminateDispatch();
     return $ret;
 }
示例#21
0
文件: entry.php 项目: AdiTal/server
 public function postInsert(PropelPDO $con = null)
 {
     if (!$this->wasObjectSaved()) {
         return;
     }
     parent::postInsert($con);
     if (!$this->alreadyInSave) {
         kEventsManager::raiseEvent(new kObjectAddedEvent($this));
     }
 }
示例#22
0
 /**
  * Code to be run after updating the object in database
  * @param PropelPDO $con
  */
 public function postUpdate(PropelPDO $con = null)
 {
     if ($this->isModified()) {
         kEventsManager::raiseEvent(new kObjectChangedEvent($this, $this->tempModifiedColumns));
     }
     $this->tempModifiedColumns = array();
 }
示例#23
0
 /**
  * Code to be run after persisting the object
  * @param PropelPDO $con
  */
 public function postSave(PropelPDO $con = null)
 {
     kEventsManager::raiseEvent(new kObjectSavedEvent($this));
     $this->oldColumnsValues = array();
     parent::postSave($con);
 }
 /**
  * Code to be run after updating the object in database
  * @param PropelPDO $con
  */
 public function postUpdate(PropelPDO $con = null)
 {
     if ($this->alreadyInSave) {
         return;
     }
     if ($this->isModified()) {
         kQueryCache::invalidateQueryCache($this);
         kEventsManager::raiseEvent(new kObjectChangedEvent($this, $this->tempModifiedColumns));
     }
     $this->tempModifiedColumns = array();
     parent::postUpdate($con);
 }
示例#25
0
文件: Basekshow.php 项目: wzur/server
 /**
  * Code to be run after updating the object in database
  * @param PropelPDO $con
  */
 public function postUpdate(PropelPDO $con = null)
 {
     if ($this->alreadyInSave) {
         return;
     }
     if ($this->isModified()) {
         kQueryCache::invalidateQueryCache($this);
         $modifiedColumns = $this->tempModifiedColumns;
         $modifiedColumns[kObjectChangedEvent::CUSTOM_DATA_OLD_VALUES] = $this->oldCustomDataValues;
         kEventsManager::raiseEvent(new kObjectChangedEvent($this, $modifiedColumns));
     }
     $this->tempModifiedColumns = array();
     parent::postUpdate($con);
 }
示例#26
0
文件: Tag.php 项目: DBezemer/server
 public function indexToSearchIndex()
 {
     kEventsManager::raiseEventDeferred(new kObjectReadyForIndexEvent($this));
 }
 /**
  * Update content of attachment asset
  *
  * @action setContent
  * @param string $id
  * @param KalturaContentResource $contentResource
  * @return KalturaAttachmentAsset
  * @throws KalturaAttachmentErrors::ATTACHMENT_ASSET_ID_NOT_FOUND
  * @throws KalturaErrors::UPLOAD_TOKEN_INVALID_STATUS_FOR_ADD_ENTRY
  * @throws KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN
  * @throws KalturaErrors::RECORDED_WEBCAM_FILE_NOT_FOUND
  * @throws KalturaAttachmentErrors::ATTACHMENT_ASSET_ID_NOT_FOUND
  * @throws KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND
  * @throws KalturaErrors::RESOURCE_TYPE_NOT_SUPPORTED 
  * @validateUser asset::entry id edit
  */
 function setContentAction($id, KalturaContentResource $contentResource)
 {
     $dbAttachmentAsset = assetPeer::retrieveById($id);
     if (!$dbAttachmentAsset || !$dbAttachmentAsset instanceof AttachmentAsset) {
         throw new KalturaAPIException(KalturaAttachmentErrors::ATTACHMENT_ASSET_ID_NOT_FOUND, $id);
     }
     $dbEntry = $dbAttachmentAsset->getentry();
     if (!$dbEntry || !in_array($dbEntry->getType(), $this->mediaTypes)) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $dbAttachmentAsset->getEntryId());
     }
     $previousStatus = $dbAttachmentAsset->getStatus();
     $contentResource->validateEntry($dbAttachmentAsset->getentry());
     $contentResource->validateAsset($dbAttachmentAsset);
     $kContentResource = $contentResource->toObject();
     $this->attachContentResource($dbAttachmentAsset, $kContentResource);
     $contentResource->entryHandled($dbAttachmentAsset->getentry());
     kEventsManager::raiseEvent(new kObjectDataChangedEvent($dbAttachmentAsset));
     $newStatuses = array(AttachmentAsset::ASSET_STATUS_READY, AttachmentAsset::ASSET_STATUS_VALIDATING, AttachmentAsset::ASSET_STATUS_TEMP);
     if ($previousStatus == AttachmentAsset::ASSET_STATUS_QUEUED && in_array($dbAttachmentAsset->getStatus(), $newStatuses)) {
         kEventsManager::raiseEvent(new kObjectAddedEvent($dbAttachmentAsset));
     }
     $attachmentAsset = new KalturaAttachmentAsset();
     $attachmentAsset->fromObject($dbAttachmentAsset);
     return $attachmentAsset;
 }
示例#28
0
 protected function deleteCuePoints(Criteria $c)
 {
     CuePointPeer::setUseCriteriaFilter(false);
     $cuePoints = CuePointPeer::doSelect($c);
     $update = new Criteria();
     $update->add(CuePointPeer::STATUS, CuePointStatus::DELETED);
     $con = Propel::getConnection(myDbHelper::DB_HELPER_CONN_MASTER);
     BasePeer::doUpdate($c, $update, $con);
     CuePointPeer::setUseCriteriaFilter(true);
     foreach ($cuePoints as $cuePoint) {
         $cuePoint->setStatus(CuePointStatus::DELETED);
         $cuePoint->indexToSearchIndex();
         kEventsManager::raiseEvent(new kObjectDeletedEvent($cuePoint));
     }
 }
 /**
  * Code to be run before updating the object in database
  * @param PropelPDO $con
  * @return boolean
  */
 public function preUpdate(PropelPDO $con = null)
 {
     if ($this->isModified()) {
         kEventsManager::raiseEvent(new kObjectChangedEvent($this, $this->modifiedColumns));
     }
     return true;
 }
示例#30
0
 /**
  * @param FileSyncKey $key
  * @param $file_root
  * @param $real_path
  * @return SyncFile
  */
 public static function createSyncFileLinkForKey(FileSyncKey $target_key, FileSyncKey $source_key)
 {
     KalturaLog::debug("target_key [{$target_key}], source_key [{$source_key}]");
     // TODO - see that if in strict mode - there are no duplicate keys -> update existing records AND set the other DC's records to PENDING
     $dc = kDataCenterMgr::getCurrentDc();
     $dc_id = $dc["id"];
     // load all source file syncs
     $c = new Criteria();
     $c = FileSyncPeer::getCriteriaForFileSyncKey($source_key);
     $file_sync_list = FileSyncPeer::doSelect($c);
     if (!$file_sync_list) {
         KalturaLog::notice("Warning: no source. target_key [{$target_key}], source_key [{$source_key}] ");
         return null;
     }
     $source_file_syncs = array();
     foreach ($file_sync_list as $file_sync) {
         $file_sync = self::resolve($file_sync);
         // we only want to link to a source and not to a link.
         $source_file_syncs[] = $file_sync;
     }
     // find the current dc file sync
     $current_dc_source_file = null;
     foreach ($source_file_syncs as $source_file_sync) {
         if ($source_file_sync->getDc() == $dc_id) {
             $current_dc_source_file = $source_file_sync;
         }
     }
     if (!$current_dc_source_file) {
         $current_dc_source_file = reset($source_file_syncs);
     }
     // create the remote file syncs
     foreach ($source_file_syncs as $source_file_sync) {
         $remote_dc_file_sync = FileSync::createForFileSyncKey($target_key);
         $remote_dc_file_sync->setDc($source_file_sync->getDc());
         $remote_dc_file_sync->setStatus($source_file_sync->getStatus());
         $remote_dc_file_sync->setOriginal($current_dc_source_file == $source_file_sync);
         $remote_dc_file_sync->setFileSize(-1);
         if ($source_file_sync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL) {
             $remote_dc_file_sync->setFileType(FileSync::FILE_SYNC_FILE_TYPE_URL);
             $remote_dc_file_sync->setFileRoot($source_file_sync->getFileRoot());
             $remote_dc_file_sync->setFilePath($source_file_sync->getFilePath());
         } else {
             $remote_dc_file_sync->setFileType(FileSync::FILE_SYNC_FILE_TYPE_LINK);
         }
         $remote_dc_file_sync->setLinkedId($source_file_sync->getId());
         self::incrementLinkCountForFileSync($source_file_sync);
         $remote_dc_file_sync->setPartnerID($target_key->partner_id);
         $remote_dc_file_sync->save();
         if ($current_dc_source_file == $source_file_sync) {
             $current_dc_target_file = $remote_dc_file_sync;
         } else {
             kEventsManager::raiseEvent(new kObjectAddedEvent($remote_dc_file_sync));
         }
     }
     kEventsManager::raiseEvent(new kObjectAddedEvent($current_dc_target_file));
 }