/**
  * @param EntryDistribution $entryDistribution
  * @param DistributionProfile $distributionProfile
  * @return BatchJob
  */
 protected static function addSubmitAddJob(EntryDistribution $entryDistribution, DistributionProfile $distributionProfile)
 {
     $jobData = new kDistributionSubmitJobData();
     $jobData->setDistributionProfileId($entryDistribution->getDistributionProfileId());
     $jobData->setEntryDistributionId($entryDistribution->getId());
     $jobData->setProviderType($distributionProfile->getProviderType());
     $batchJob = new BatchJob();
     $batchJob->setEntryId($entryDistribution->getEntryId());
     $batchJob->setPartnerId($entryDistribution->getPartnerId());
     $jobType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT);
     $jobSubType = $distributionProfile->getProviderType();
     return kJobsManager::addJob($batchJob, $jobData, $jobType, $jobSubType);
 }
예제 #2
0
 protected function attachRemoteAssetResource(entry $entry, kDistributionSubmitJobData $data)
 {
     $distributionProfile = DistributionProfilePeer::retrieveByPK($data->getDistributionProfileId());
     /* @var $distributionProfile UnicornDistributionProfile */
     $domainGuid = $distributionProfile->getDomainGuid();
     $applicationGuid = $distributionProfile->getAdFreeApplicationGuid();
     $assetParamsId = $distributionProfile->getRemoteAssetParamsId();
     $mediaItemGuid = $data->getRemoteId();
     $url = "{$domainGuid}/{$applicationGuid}/{$mediaItemGuid}/content.m3u8";
     $entry->setSource(KalturaSourceType::URL);
     $entry->save();
     $isNewAsset = false;
     $asset = assetPeer::retrieveByEntryIdAndParams($entry->getId(), $assetParamsId);
     if (!$asset) {
         $isNewAsset = true;
         $assetParams = assetParamsPeer::retrieveByPK($assetParamsId);
         $asset = assetPeer::getNewAsset($assetParams->getType());
         $asset->setPartnerId($entry->getPartnerId());
         $asset->setEntryId($entry->getId());
         $asset->setStatus(asset::FLAVOR_ASSET_STATUS_QUEUED);
         $asset->setFlavorParamsId($assetParamsId);
         $asset->setFromAssetParams($assetParams);
         if ($assetParams->hasTag(assetParams::TAG_SOURCE)) {
             $asset->setIsOriginal(true);
         }
     }
     $asset->incrementVersion();
     $asset->setFileExt('m3u8');
     $asset->setStatus(asset::FLAVOR_ASSET_STATUS_READY);
     $asset->save();
     $syncKey = $asset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $storageProfile = StorageProfilePeer::retrieveByPK($distributionProfile->getStorageProfileId());
     $fileSync = kFileSyncUtils::createReadyExternalSyncFileForKey($syncKey, $url, $storageProfile);
     if ($isNewAsset) {
         kEventsManager::raiseEvent(new kObjectAddedEvent($asset));
     }
     kEventsManager::raiseEvent(new kObjectDataChangedEvent($asset));
     kBusinessPostConvertDL::handleConvertFinished(null, $asset);
 }
 /**
  * @param EntryDistribution $entryDistribution
  * @param DistributionProfile $distributionProfile
  * @return BatchJob
  */
 protected static function addSubmitAddJob(EntryDistribution $entryDistribution, DistributionProfile $distributionProfile)
 {
     if ($entryDistribution->getStatus() == EntryDistributionStatus::SUBMITTING) {
         KalturaLog::debug("Entry distribution [" . $entryDistribution->getId() . "] already submitting");
         return null;
     }
     $entryDistribution->setStatus(EntryDistributionStatus::SUBMITTING);
     $entryDistribution->setDirtyStatus(null);
     if (!$entryDistribution->save()) {
         KalturaLog::err("Unable to save entry distribution [" . $entryDistribution->getId() . "] status");
         return null;
     }
     $dc = $distributionProfile->getRecommendedDcForExecute();
     if (is_null($dc)) {
         $dc = kDataCenterMgr::getCurrentDcId();
     }
     $jobType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT);
     if ($distributionProfile->getProvider()->isLocalFileRequired($jobType)) {
         $readyForSubmit = self::prepareDistributionJob($entryDistribution, $distributionProfile, $dc);
         if (!$readyForSubmit) {
             $entryDistribution->setStatus(EntryDistributionStatus::IMPORT_SUBMITTING);
             $entryDistribution->save();
             return null;
         }
     }
     $jobData = new kDistributionSubmitJobData();
     $jobData->setDistributionProfileId($entryDistribution->getDistributionProfileId());
     $jobData->setEntryDistributionId($entryDistribution->getId());
     $jobData->setProviderType($distributionProfile->getProviderType());
     $batchJob = new BatchJob();
     $batchJob->setDc($dc);
     $batchJob->setEntryId($entryDistribution->getEntryId());
     $batchJob->setPartnerId($entryDistribution->getPartnerId());
     $jobSubType = $distributionProfile->getProviderType();
     return kJobsManager::addJob($batchJob, $jobData, $jobType, $jobSubType);
 }
 /**
  * @param BatchJob $dbBatchJob
  * @param kDistributionSubmitJobData $data
  * @param BatchJob $twinJob
  * @return BatchJob
  */
 public static function onDistributionSubmitJobFailed(BatchJob $dbBatchJob, kDistributionSubmitJobData $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_SUBMITTING);
     $entryDistribution->setDirtyStatus(null);
     $entryDistribution->save();
     return $dbBatchJob;
 }
 /**
  * @param EntryDistribution $entryDistribution
  * @param DistributionProfile $distributionProfile
  * @return BatchJob
  */
 protected static function addSubmitAddJob(EntryDistribution $entryDistribution, DistributionProfile $distributionProfile)
 {
     if ($entryDistribution->getStatus() == EntryDistributionStatus::SUBMITTING) {
         KalturaLog::info("Entry distribution [" . $entryDistribution->getId() . "] already submitting");
         return null;
     }
     $entryDistribution->setStatus(EntryDistributionStatus::SUBMITTING);
     if (!$entryDistribution->save()) {
         KalturaLog::err("Unable to save entry distribution [" . $entryDistribution->getId() . "] status");
         $entryDistribution->reload();
         //Reload in case object was chnaged
         return null;
     }
     $entryDistribution->setDirtyStatus(null);
     //Moved down to ensure previous save is done Atomically
     $entryDistribution->save();
     $dc = $distributionProfile->getRecommendedDcForExecute();
     if (is_null($dc)) {
         $dc = kDataCenterMgr::getCurrentDcId();
     }
     $jobType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT);
     if ($distributionProfile->getProvider()->isLocalFileRequired($jobType)) {
         $readyForSubmit = self::prepareDistributionJob($entryDistribution, $distributionProfile, $dc);
         if (!$readyForSubmit) {
             $entryDistribution->setStatus(EntryDistributionStatus::IMPORT_SUBMITTING);
             $entryDistribution->save();
             return null;
         }
     }
     $jobData = new kDistributionSubmitJobData();
     $jobData->setDistributionProfileId($entryDistribution->getDistributionProfileId());
     $jobData->setEntryDistributionId($entryDistribution->getId());
     $jobData->setProviderType($distributionProfile->getProviderType());
     $batchJob = new BatchJob();
     $batchJob->setDc($dc);
     $batchJob->setEntryId($entryDistribution->getEntryId());
     $batchJob->setPartnerId($entryDistribution->getPartnerId());
     $batchJob->setObjectId($entryDistribution->getId());
     $batchJob->setObjectType(kPluginableEnumsManager::apiToCore('BatchJobObjectType', ContentDistributionBatchJobObjectType::ENTRY_DISTRIBUTION));
     $jobSubType = $distributionProfile->getProviderType();
     return kJobsManager::addJob($batchJob, $jobData, $jobType, $jobSubType);
 }