private function reconvertEntry($entry_id, $conversion_profile_id, $job_priority) { $entry = entryPeer::retrieveByPK($entry_id); $this->error = ""; if (!$entry) { $error = "Cannot reconvert entry [{$entry_id}]. Might be a deleted entry"; return array($entry_id, null, null, $error); } $flavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($entry_id); if (!$flavorAsset) { $flavorAsset = flavorAssetPeer::retrieveReadyWebByEntryId($entry_id); if (!$flavorAsset) { $flavorAssets = flavorAssetPeer::retrieveByEntryId($entry_id); if (!$flavorAssets) { $error = "Cannot find good enough flavor asset to re-convert from"; return array($entry_id, $entry, null, $error); } $flavorAsset = $flavorAssets[0]; // choose the first one } } $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $filePath = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey); if (!$filePath) { $error = "Cannot find a fileSync for the flavorAsset [" . $flavorAsset->getId() . "]"; return array($entry_id, $entry, null, $error); } $dbBatchJob = new BatchJob(); $dbBatchJob->setEntryId($entry_id); $dbBatchJob->setPartnerId($entry->getPartnerId()); $dbBatchJob->setStatus(BatchJob::BATCHJOB_STATUS_PENDING); $dbBatchJob->setDc(kDataCenterMgr::getCurrentDcId()); $dbBatchJob->setPriority($job_priority); $dbBatchJob->save(); // creates a convert profile job $convertProfileData = new kConvertProfileJobData(); $convertProfileData->setFlavorAssetId($flavorAsset->getId()); $convertProfileData->setInputFileSyncLocalPath($filePath); kJobsManager::addJob($dbBatchJob, $convertProfileData, BatchJobType::CONVERT_PROFILE); // save again afget the addJob $dbBatchJob->save(); return array($entry_id, $entry, $dbBatchJob, $error); }
/** * Get web playable Flavor Assets for Entry * * @action getWebPlayableByEntryId * @param string $entryId * @return KalturaFlavorAssetArray */ public function getWebPlayableByEntryIdAction($entryId) { // entry could be "display_in_search = 2" - in that case we want to pull it although KN is off in services.ct for this action $c = new Criteria(); $c->addAnd(entryPeer::ID, $entryId); $criterionPartnerOrKn = $c->getNewCriterion(entryPeer::PARTNER_ID, $this->getPartnerId()); $criterionPartnerOrKn->addOr($c->getNewCriterion(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK)); $c->addAnd($criterionPartnerOrKn); // there could only be one entry because the query is by primary key. // so using doSelectOne is safe. $dbEntry = entryPeer::doSelectOne($c); if (!$dbEntry) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId); } // if the entry does not belong to the partner but "display_in_search = 2" // we want to turn off the criteria over the flavorAssetPeer if ($dbEntry->getPartnerId() != $this->getPartnerId() && $dbEntry->getDisplayInSearch() == mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK) { flavorAssetPeer::setDefaultCriteriaFilter(null); } $flavorAssetsDb = flavorAssetPeer::retrieveReadyWebByEntryId($entryId); if (count($flavorAssetsDb) == 0) { throw new KalturaAPIException(KalturaErrors::NO_FLAVORS_FOUND); } // re-set default criteria to avoid fetching "private" flavors in laetr queries. // this should be also set in baseService, but we better do it anyway. flavorAssetPeer::setDefaultCriteriaFilter(); $flavorAssets = KalturaFlavorAssetArray::fromDbArray($flavorAssetsDb); return $flavorAssets; }