public function fromObject($sourceObject) { parent::fromObject($sourceObject); $this->mediaFiles = KalturaDistributionRemoteMediaFileArray::fromDbArray($sourceObject->getMediaFiles()); if (!$this->distributionProfileId) { return; } if (!$this->entryDistributionId) { return; } $distributionProfile = DistributionProfilePeer::retrieveByPK($this->distributionProfileId); if (!$distributionProfile || $distributionProfile->getStatus() != DistributionProfileStatus::ENABLED) { return; } $this->distributionProfile = KalturaDistributionProfileFactory::createKalturaDistributionProfile($distributionProfile->getProviderType()); $this->distributionProfile->fromObject($distributionProfile); $entryDistribution = EntryDistributionPeer::retrieveByPK($this->entryDistributionId); if ($entryDistribution) { $this->entryDistribution = new KalturaEntryDistribution(); $this->entryDistribution->fromObject($entryDistribution); } $providerType = $sourceObject->getProviderType(); if ($providerType) { if ($providerType == KalturaDistributionProviderType::GENERIC) { $this->providerData = new KalturaGenericDistributionJobProviderData($this); } else { $this->providerData = KalturaPluginManager::loadObject('KalturaDistributionJobProviderData', $providerType, array($this)); } $providerData = $sourceObject->getProviderData(); if ($this->providerData && $providerData && $providerData instanceof kDistributionJobProviderData) { $this->providerData->fromObject($providerData); } } }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaUverseDistributionProfile) { return; } $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); if (count($flavorAssets)) { // if we have specific flavor assets for this distribution, grab the first one $flavorAsset = reset($flavorAssets); } else { // take the source asset $flavorAsset = assetPeer::retrieveOriginalReadyByEntryId($distributionJobData->entryDistribution->entryId); } if ($flavorAsset) { $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $this->localAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); } } $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId); if ($entryDistributionDb) { $this->remoteAssetUrl = $entryDistributionDb->getFromCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_URL); $this->remoteAssetFileName = $entryDistributionDb->getFromCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_FILE_NAME); } else { KalturaLog::err('Entry distribution [' . $distributionJobData->entryDistributionId . '] not found'); } }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); $this->notificationBaseUrl = 'http://' . kConf::get('cdn_api_host'); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaUnicornDistributionProfile) { return; } $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId); $distributionProfileDb = DistributionProfilePeer::retrieveByPK($distributionJobData->distributionProfileId); /* @var $distributionProfileDb UnicornDistributionProfile */ $flavorAssetIds = explode(',', $entryDistributionDb->getFlavorAssetIds()); $flavorAssetId = reset($flavorAssetIds); $flavorAsset = assetPeer::retrieveById($flavorAssetId); $flavorAssetOldVersion = $entryDistributionDb->getFromCustomData(kUnicornDistributionJobProviderData::CUSTOM_DATA_FLAVOR_ASSET_OLD_VERSION); $flavorAssetNewVersion = null; if ($flavorAsset) { $flavorAssetNewVersion = $flavorAsset->getVersion(); } $values = $distributionProfileDb->getAllFieldValues($entryDistributionDb); $this->catalogGuid = $values[UnicornDistributionField::CATALOG_GUID]; $this->title = $values[UnicornDistributionField::TITLE]; $this->flavorAssetVersion = $flavorAssetNewVersion; $this->mediaChanged = $flavorAssetOldVersion != $flavorAssetNewVersion; }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaYoutubeApiDistributionProfile) { return; } $flavorAssets = flavorAssetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); if (count($flavorAssets)) { // if we have specific flavor assets for this distribution, grab the first one $flavorAsset = reset($flavorAssets); } else { // take the source asset $flavorAsset = flavorAssetPeer::retrieveOriginalReadyByEntryId($distributionJobData->entryDistribution->entryId); } if ($flavorAsset) { $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->videoAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, true); } $thumbAssets = thumbAssetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); if (count($thumbAssets)) { $syncKey = reset($thumbAssets)->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->thumbAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, true); } $this->loadPlaylistsFromMetadata($distributionJobData->entryDistribution->entryId, $distributionJobData->distributionProfile); $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId); // if ($entryDistributionDb) // $this->currentPlaylists = $entryDistributionDb->getFromCustomData('currentPlaylists'); // else // KalturaLog::err('Entry distribution ['.$distributionJobData->entryDistributionId.'] not found'); }
/** * @param BatchJob $dbBatchJob * @param kDistributionJobData $data * @return BatchJob */ public static function onDistributionJobFinished(BatchJob $dbBatchJob, kDistributionJobData $data) { $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId()); if (!$entryDistribution) { KalturaLog::err("Entry distribution [" . $data->getEntryDistributionId() . "] not found"); return $dbBatchJob; } $distributionProfileId = $data->getDistributionProfileId(); $distributionProfile = DistributionProfilePeer::retrieveByPK($distributionProfileId); // only feed spec v2 (rights feed) is setting the playlists on submit close action if ($distributionProfile && $distributionProfile instanceof YouTubeDistributionProfile && $distributionProfile->getFeedSpecVersion() == YouTubeDistributionFeedSpecVersion::VERSION_2) { self::saveCurrentPlaylistsToCustomData($data, $entryDistribution); } return $dbBatchJob; }
/** * @param BatchJob $dbBatchJob * @param kDistributionJobData $data * @return BatchJob */ public static function onDistributionJobFinished(BatchJob $dbBatchJob, kDistributionJobData $data) { $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId()); if (!$entryDistribution) { KalturaLog::err("Entry distribution [" . $data->getEntryDistributionId() . "] not found"); return $dbBatchJob; } $providerData = $data->getProviderData(); if ($providerData instanceof kUverseDistributionJobProviderData) { $entryDistribution->putInCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_URL, $providerData->getRemoteAssetUrl()); $entryDistribution->putInCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_FILE_NAME, $providerData->getRemoteAssetFileName()); $entryDistribution->save(); } return $dbBatchJob; }
/** * @param BatchJob $dbBatchJob * @param kDistributionJobData $data * @param BatchJob $twinJob * @return BatchJob */ public static function onDistributionJobFinished(BatchJob $dbBatchJob, kDistributionJobData $data, BatchJob $twinJob = null) { $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId()); if (!$entryDistribution) { KalturaLog::err("Entry distribution [" . $data->getEntryDistributionId() . "] not found"); return $dbBatchJob; } $providerData = $data->getProviderData(); if ($providerData instanceof kAttUverseDistributionJobProviderData) { KalturaLog::debug('Updating AttUverse job provider data in entry distribution custom data'); $entryDistribution->putInCustomData(AttUverseEntryDistributionCustomDataField::REMOTE_ASSET_FILE_URLS, $providerData->getRemoteAssetFileUrls()); $entryDistribution->putInCustomData(AttUverseEntryDistributionCustomDataField::REMOTE_THUMBNAIL_FILE_URLS, $providerData->getRemoteThumbnailFileUrls()); $entryDistribution->save(); } return $dbBatchJob; }
/** * @param BatchJob $dbBatchJob * @param kDistributionJobData $data * @param BatchJob $twinJob * @return BatchJob */ public static function onDistributionJobUpdatedAlmostDone(BatchJob $dbBatchJob, kDistributionJobData $data, BatchJob $twinJob = null) { $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId()); if (!$entryDistribution) { KalturaLog::err("Entry distribution [" . $data->getEntryDistributionId() . "] not found"); return $dbBatchJob; } $providerData = $data->getProviderData(); KalturaLog::crit('provider data type' . get_class($providerData)); if ($providerData instanceof kYouTubeDistributionJobProviderData) { KalturaLog::debug('setting currentPlaylists to entryDistribution custom data'); $entryDistribution->putInCustomData('currentPlaylists', $providerData->getCurrentPlaylists()); $entryDistribution->save(); } return $dbBatchJob; }
/** * @action notify * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY * @param int $id distribution job id */ public function notifyAction($id) { $submitCoreType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT); $updateCoreType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE); $deleteCoreType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE); $validJobTypes = array($submitCoreType, $updateCoreType, $deleteCoreType); $batchJob = BatchJobPeer::retrieveByPK($id); $invalid = false; if (!$batchJob) { $invalid = true; KalturaLog::err("Job [{$id}] not found"); } elseif (!in_array($batchJob->getJobType(), $validJobTypes)) { $invalid = true; KalturaLog::err("Job [{$id}] wrong type [" . $batchJob->getJobType() . "] expected [" . implode(', ', $validJobTypes) . "]"); } elseif ($batchJob->getJobSubType() != UnicornDistributionProvider::get()->getType()) { $invalid = true; KalturaLog::err("Job [{$id}] wrong sub-type [" . $batchJob->getJobSubType() . "] expected [" . UnicornDistributionProvider::get()->getType() . "]"); } elseif ($batchJob->getStatus() != KalturaBatchJobStatus::ALMOST_DONE) { $invalid = true; KalturaLog::err("Job [{$id}] wrong status [" . $batchJob->getStatus() . "] expected [" . KalturaBatchJobStatus::ALMOST_DONE . "]"); } if ($invalid) { throw new KalturaAPIException(KalturaErrors::INVALID_BATCHJOB_ID, $id); } kJobsManager::updateBatchJob($batchJob, KalturaBatchJobStatus::FINISHED); $data = $batchJob->getData(); /* @var $data kDistributionJobData */ $providerData = $data->getProviderData(); /* @var $providerData kUnicornDistributionJobProviderData */ $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId()); if ($entryDistribution) { $entryDistribution->putInCustomData(kUnicornDistributionJobProviderData::CUSTOM_DATA_FLAVOR_ASSET_OLD_VERSION, $providerData->getFlavorAssetVersion()); $entryDistribution->save(); } if ($batchJob->getJobType() == $submitCoreType) { $this->attachRemoteAssetResource($batchJob->getEntry(), $batchJob->getData()); } if ($batchJob->getJobType() == $deleteCoreType) { $this->detachRemoteAssetResource($batchJob->getEntry(), $batchJob->getData()); } }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaCrossKalturaDistributionProfile) { return; } // load previously distributed data from entry distribution $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId); if (!$entryDistributionDb) { KalturaLog::err('Entry distribution [' . $distributionJobData->entryDistributionId . '] not found'); return; } $this->distributedFlavorAssets = $entryDistributionDb->getFromCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_FLAVOR_ASSETS); $this->distributedThumbAssets = $entryDistributionDb->getFromCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_THUMB_ASSETS); $this->distributedMetadata = $entryDistributionDb->getFromCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_METADATA); $this->distributedCaptionAssets = $entryDistributionDb->getFromCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_CAPTION_ASSETS); $this->distributedCuePoints = $entryDistributionDb->getFromCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_CUE_POINTS); }
/** * @param BatchJob $dbBatchJob * @return BatchJob */ public static function onDistributionJobFinished(BatchJob $dbBatchJob) { $data = $dbBatchJob->getData(); $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId()); if (!$entryDistribution) { KalturaLog::err('Entry distribution [' . $data->getEntryDistributionId() . '] not found'); return $dbBatchJob; } $providerData = $data->getProviderData(); if (!$providerData instanceof kCrossKalturaDistributionJobProviderData) { KalturaLog::err('Wrong provider data class [' . get_class($providerData) . ']'); return $dbBatchJob; } $entryDistribution->putInCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_FLAVOR_ASSETS, $providerData->getDistributedFlavorAssets()); $entryDistribution->putInCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_THUMB_ASSETS, $providerData->getDistributedThumbAssets()); $entryDistribution->putInCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_METADATA, $providerData->getDistributedMetadata()); $entryDistribution->putInCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_CAPTION_ASSETS, $providerData->getDistributedCaptionAssets()); $entryDistribution->putInCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_CUE_POINTS, $providerData->getDistributedCuePoints()); $entryDistribution->save(); return $dbBatchJob; }
/** * Called on the server side and enables you to populate the object with any data from the DB * * @param KalturaDistributionJobData $distributionJobData */ public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaFtpDistributionProfile) { return; } $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId); $distributionProfileDb = DistributionProfilePeer::retrieveByPK($distributionJobData->distributionProfileId); if (is_null($entryDistributionDb)) { return KalturaLog::err('Entry distribution #' . $distributionJobData->entryDistributionId . ' not found'); } if (is_null($distributionProfileDb)) { return KalturaLog::err('Distribution profile #' . $distributionJobData->distributionProfileId . ' not found'); } if (!$distributionProfileDb instanceof FtpDistributionProfile) { return KalturaLog::err('Distribution profile #' . $distributionJobData->distributionProfileId . ' is not instance of FtpDistributionProfile'); } $this->filesForDistribution = $this->getDistributionFiles($distributionProfileDb, $entryDistributionDb); KalturaLog::log("Files for distribution: " . print_r($this->filesForDistribution, true)); }
/** * @param BatchJob $dbBatchJob * @param kDistributionFetchReportJobData $data * @param BatchJob $twinJob * @return BatchJob */ public static function onDistributionFetchReportJobFinished(BatchJob $dbBatchJob, kDistributionFetchReportJobData $data, BatchJob $twinJob = null) { $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId()); if (!$entryDistribution) { KalturaLog::err("Entry distribution [" . $data->getEntryDistributionId() . "] not found"); return $dbBatchJob; } $providerData = $data->getProviderData(); /* if($providerData instanceof kIdeticDistributionJobProviderData) { $entryDistribution->putInCustomData('emailed', $providerData->getEmailed()); $entryDistribution->putInCustomData('rated', $providerData->getRated()); $entryDistribution->putInCustomData('blogged', $providerData->getBlogged()); $entryDistribution->putInCustomData('reviewed', $providerData->getReviewed()); $entryDistribution->putInCustomData('bookmarked', $providerData->getBookmarked()); $entryDistribution->putInCustomData('playbackFailed', $providerData->getPlaybackFailed()); $entryDistribution->putInCustomData('timeSpent', $providerData->getTimeSpent()); $entryDistribution->putInCustomData('recommended', $providerData->getRecommended()); $entryDistribution->save(); } */ return $dbBatchJob; }
$fileTransferMgr->login('ftp-int.vzw.real.com', 'vp_foxsports', 'X4ul3ap'); print_r($fileTransferMgr->listDir("/pub/in")); // $fileTransferMgr->putFile($destFile, $srcFile, true); return;*/ $entry = entryPeer::retrieveByPKNoFilter($entryId); $mrss = kMrssManager::getEntryMrss($entry); file_put_contents('mrss.xml', $mrss); KalturaLog::debug("MRSS [{$mrss}]"); $distributionJobData = new KalturaDistributionSubmitJobData(); $dbDistributionProfile = DistributionProfilePeer::retrieveByPK(3); $distributionProfile = new KalturaDailymotionDistributionProfile(); $distributionProfile->fromObject($dbDistributionProfile); $distributionJobData->distributionProfileId = $distributionProfile->id; $distributionJobData->distributionProfile = $distributionProfile; $dbEntryDistribution = EntryDistributionPeer::retrieveByPK(24); $entryDistribution = new KalturaEntryDistribution(); $entryDistribution->fromObject($dbEntryDistribution); $distributionJobData->entryDistributionId = $entryDistribution->id; $distributionJobData->entryDistribution = $entryDistribution; $myp = new DailymotionDistributionProfile(); print_r($myp->validateForSubmission($dbEntryDistribution, "submit")); $providerData = new KalturaDailymotionDistributionJobProviderData($distributionJobData); $distributionJobData->providerData = $providerData; //file_put_contents('out.xml', $providerData->xml); //KalturaLog::debug("XML [$providerData->xml]"); //return; $engine = new DailymotionDistributionEngine(); $engine->submit($distributionJobData); //$xml = new KDOMDocument(); //if(!$xml->loadXML($mrss))
public static function loadObject($baseClass, $enumValue, array $constructorArgs = null) { if ($baseClass == 'ISyncableFile' && isset($constructorArgs['objectId'])) { $objectId = $constructorArgs['objectId']; if ($enumValue == self::getContentDistributionFileSyncObjectTypeCoreValue(ContentDistributionFileSyncObjectType::GENERIC_DISTRIBUTION_ACTION)) { GenericDistributionProviderActionPeer::setUseCriteriaFilter(false); $object = GenericDistributionProviderActionPeer::retrieveByPK($objectId); GenericDistributionProviderActionPeer::setUseCriteriaFilter(true); return $object; } if ($enumValue == self::getContentDistributionFileSyncObjectTypeCoreValue(ContentDistributionFileSyncObjectType::ENTRY_DISTRIBUTION)) { EntryDistributionPeer::setUseCriteriaFilter(false); $object = EntryDistributionPeer::retrieveByPK($objectId); EntryDistributionPeer::setUseCriteriaFilter(true); return $object; } if ($enumValue == self::getContentDistributionFileSyncObjectTypeCoreValue(ContentDistributionFileSyncObjectType::DISTRIBUTION_PROFILE)) { DistributionProfilePeer::setUseCriteriaFilter(false); $object = DistributionProfilePeer::retrieveByPK($objectId); DistributionProfilePeer::setUseCriteriaFilter(true); return $object; } } if ($baseClass == 'kJobData') { if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT)) { return new kDistributionSubmitJobData(); } if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE)) { return new kDistributionUpdateJobData(); } if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE)) { return new kDistributionDeleteJobData(); } if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_FETCH_REPORT)) { return new kDistributionFetchReportJobData(); } if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_ENABLE)) { return new kDistributionEnableJobData(); } if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DISABLE)) { return new kDistributionDisableJobData(); } } if ($baseClass == 'KalturaJobData') { if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT)) { return new KalturaDistributionSubmitJobData(); } if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE)) { return new KalturaDistributionUpdateJobData(); } if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE)) { return new KalturaDistributionDeleteJobData(); } if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_FETCH_REPORT) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_FETCH_REPORT)) { return new KalturaDistributionFetchReportJobData(); } if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_ENABLE) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_ENABLE)) { return new KalturaDistributionEnableJobData(); } if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_DISABLE) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DISABLE)) { return new KalturaDistributionDisableJobData(); } } return null; }
/** * @param BatchJob $dbBatchJob * @param kDistributionDeleteJobData $data * @param BatchJob $twinJob * @return BatchJob */ public static function onDistributionDeleteJobFailed(BatchJob $dbBatchJob, kDistributionDeleteJobData $data, BatchJob $twinJob = null) { $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId()); if (!$entryDistribution) { KalturaLog::err("Entry distribution [" . $data->getEntryDistributionId() . "] not found"); return $dbBatchJob; } $entryDistribution->setErrorType($dbBatchJob->getErrType()); $entryDistribution->setErrorNumber($dbBatchJob->getErrNumber()); $entryDistribution->setErrorDescription($dbBatchJob->getMessage()); $entryDistribution->setStatus(EntryDistributionStatus::ERROR_DELETING); $entryDistribution->setDirtyStatus(null); $entryDistribution->save(); return $dbBatchJob; }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaAttUverseDistributionProfile) { return; } /* @var $distributionProfileDb AttUverseDistributionProfile */ $distributionProfileDb = DistributionProfilePeer::retrieveByPK($distributionJobData->distributionProfileId); $distributedFlavorIds = null; $distributedThumbIds = null; $this->filesForDistribution = new KalturaAttUverseDistributionFileArray(); $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId); //Flavor Assets $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); if (count($flavorAssets)) { $assetLocalIds = array(); foreach ($flavorAssets as $flavorAsset) { $file = new KalturaAttUverseDistributionFile(); $file->assetType = KalturaAssetType::FLAVOR; /* @var $flavorAsset flavorAsset */ $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $assetLocalIds[] = $flavorAsset->getId(); $file->assetId = $flavorAsset->getId(); $file->localFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $defaultFilename = pathinfo($file->localFilePath, PATHINFO_BASENAME); $file->remoteFilename = $distributionProfileDb->getFlavorAssetFilename($entryDistributionDb, $defaultFilename, $flavorAsset->getId()); $this->filesForDistribution[] = $file; } } $distributedFlavorIds = implode(',', $assetLocalIds); } //Thumbnail $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); if (count($thumbAssets)) { $thumbLocalIds = array(); foreach ($thumbAssets as $thumbAsset) { $file = new KalturaAttUverseDistributionFile(); $file->assetType = KalturaAssetType::THUMBNAIL; $syncKey = $thumbAsset->getSyncKey(thumbAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $thumbLocalIds[] = $thumbAsset->getId(); $file->assetId = $thumbAsset->getId(); $file->localFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $defaultFilename = pathinfo($file->localFilePath, PATHINFO_BASENAME); $file->remoteFilename = $distributionProfileDb->getThumbnailAssetFilename($entryDistributionDb, $defaultFilename, $thumbAsset->getId()); $this->filesForDistribution[] = $file; } } $distributedThumbIds = implode(',', $thumbLocalIds); } //additional assets $additionalAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->assetIds)); if (count($additionalAssets)) { $captionLocalIds = array(); foreach ($additionalAssets as $additionalAsset) { $file = new KalturaAttUverseDistributionFile(); $file->assetType = kPluginableEnumsManager::coreToApi(KalturaAssetType::getEnumClass(), $additionalAsset->getType()); $syncKey = $additionalAsset->getSyncKey(CaptionAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); $id = $additionalAsset->getId(); if (kFileSyncUtils::fileSync_exists($syncKey)) { if ($file->assetType == CaptionPlugin::getApiValue(CaptionAssetType::CAPTION) || $file->assetType == AttachmentPlugin::getApiValue(AttachmentAssetType::ATTACHMENT)) { $captionLocalIds[] = $additionalAsset->getId(); $file->assetId = $additionalAsset->getId(); $file->localFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $defaultFilename = pathinfo($file->localFilePath, PATHINFO_BASENAME); $file->remoteFilename = $distributionProfileDb->getAssetFilename($entryDistributionDb, $defaultFilename, $additionalAsset->getId()); $this->filesForDistribution[] = $file; } } } $distributedCaptionIds = implode(',', $captionLocalIds); } //putting distributed flavors ids and distributed thumbnail ids in entry distribution custom data if ($entryDistributionDb) { $entryDistributionDb->putInCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_FLAVOR_IDS, $distributedFlavorIds); $entryDistributionDb->putInCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_THUMBNAIL_IDS, $distributedThumbIds); $entryDistributionDb->putInCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_CAPTION_IDS, $distributedCaptionIds); $entryDistributionDb->save(); } else { KalturaLog::err('Entry distribution [' . $distributionJobData->entryDistributionId . '] not found'); } }
/** * Serves entry distribution returned data * * @action serveReturnedData * @param int $id * @param KalturaDistributionAction $actionType * @return file * * @throws ContentDistributionErrors::ENTRY_DISTRIBUTION_NOT_FOUND * @throws ContentDistributionErrors::ENTRY_DISTRIBUTION_MISSING_LOG * @throws KalturaErrors::FILE_DOESNT_EXIST */ public function serveReturnedDataAction($id, $actionType) { $dbEntryDistribution = EntryDistributionPeer::retrieveByPK($id); if (!$dbEntryDistribution) { throw new KalturaAPIException(ContentDistributionErrors::ENTRY_DISTRIBUTION_NOT_FOUND, $id); } $fileName = "{$id}_{$actionType}_return.xml"; $fileSubType = null; switch ($actionType) { case KalturaDistributionAction::SUBMIT: $fileSubType = EntryDistribution::FILE_SYNC_ENTRY_DISTRIBUTION_SUBMIT_RESULTS; break; case KalturaDistributionAction::UPDATE: $fileSubType = EntryDistribution::FILE_SYNC_ENTRY_DISTRIBUTION_UPDATE_RESULTS; break; case KalturaDistributionAction::DELETE: $fileSubType = EntryDistribution::FILE_SYNC_ENTRY_DISTRIBUTION_DELETE_RESULTS; break; } if (!$fileSubType) { throw new KalturaAPIException(ContentDistributionErrors::ENTRY_DISTRIBUTION_MISSING_LOG, $id); } header("Content-Disposition: attachment; filename=\"{$fileName}\""); return $this->serveFile($dbEntryDistribution, $fileSubType, $fileName, $dbEntryDistribution->getEntryId()); }