/**
  * @return UnicornDistributionProvider
  */
 public static function get()
 {
     if (!self::$instance) {
         self::$instance = new UnicornDistributionProvider();
     }
     return self::$instance;
 }
Example #2
0
 /**
  * @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());
     }
 }
 /**
  * Return a distribution provider instance
  * 
  * @return IDistributionProvider
  */
 public static function getProvider()
 {
     return UnicornDistributionProvider::get();
 }