/**
  * @param EntryDistribution $entryDistribution
  * @param DistributionProfile $distributionProfile
  * @param bool $submitWhenReady
  * @return BatchJob
  */
 public static function submitAddEntryDistribution(EntryDistribution $entryDistribution, DistributionProfile $distributionProfile, $submitWhenReady = true)
 {
     if ($distributionProfile->getStatus() != DistributionProfileStatus::ENABLED || $distributionProfile->getSubmitEnabled() == DistributionProfileActionStatus::DISABLED) {
         return null;
     }
     $validStatus = array(EntryDistributionStatus::ERROR_DELETING, EntryDistributionStatus::ERROR_SUBMITTING, EntryDistributionStatus::ERROR_UPDATING, EntryDistributionStatus::PENDING, EntryDistributionStatus::QUEUED, EntryDistributionStatus::READY, EntryDistributionStatus::REMOVED);
     if (!in_array($entryDistribution->getStatus(), $validStatus)) {
         KalturaLog::notice("wrong entry distribution status [" . $entryDistribution->getStatus() . "]");
         return null;
     }
     if ($submitWhenReady && $entryDistribution->getStatus() != EntryDistributionStatus::QUEUED) {
         $entryDistribution->setStatus(EntryDistributionStatus::QUEUED);
         $entryDistribution->save();
     }
     $validationErrors = $entryDistribution->getValidationErrors();
     if (!count($validationErrors)) {
         $sunrise = $entryDistribution->getSunrise(null);
         if ($sunrise) {
             $distributionProvider = $distributionProfile->getProvider();
             if (!$distributionProvider->isScheduleUpdateEnabled() && !$distributionProvider->isAvailabilityUpdateEnabled()) {
                 $sunrise -= $distributionProvider->getJobIntervalBeforeSunrise();
                 if ($sunrise > time()) {
                     KalturaLog::log("Will be sent on exact time [{$sunrise}] for sunrise time [" . $entryDistribution->getSunrise() . "]");
                     $entryDistribution->setDirtyStatus(EntryDistributionDirtyStatus::SUBMIT_REQUIRED);
                     $entryDistribution->save();
                     return null;
                 }
             }
         }
         return self::addSubmitAddJob($entryDistribution, $distributionProfile);
     }
     KalturaLog::log("Validation errors found");
     $entry = entryPeer::retrieveByPK($entryDistribution->getEntryId());
     if (!$entry) {
         KalturaLog::err("Entry [" . $entryDistribution->getEntryId() . "] not found");
         return null;
     }
     $autoCreateFlavors = $distributionProfile->getAutoCreateFlavorsArray();
     $autoCreateThumbs = $distributionProfile->getAutoCreateThumbArray();
     foreach ($validationErrors as $validationError) {
         if ($validationError->getErrorType() == DistributionErrorType::MISSING_FLAVOR && in_array($validationError->getData(), $autoCreateFlavors)) {
             $errDescription = null;
             KalturaLog::log("Adding flavor [" . $validationError->getData() . "] to entry [" . $entryDistribution->getEntryId() . "]");
             kBusinessPreConvertDL::decideAddEntryFlavor(null, $entryDistribution->getEntryId(), $validationError->getData(), $errDescription);
             if ($errDescription) {
                 KalturaLog::log($errDescription);
             }
         }
         if ($validationError->getErrorType() == DistributionErrorType::MISSING_THUMBNAIL && in_array($validationError->getData(), $autoCreateThumbs)) {
             $destThumbParams = thumbParamsPeer::retrieveByPK($validationError->getData());
             if ($destThumbParams) {
                 KalturaLog::log("Adding thumbnail [" . $validationError->getData() . "] to entry [" . $entryDistribution->getEntryId() . "]");
                 kBusinessPreConvertDL::decideThumbGenerate($entry, $destThumbParams);
             } else {
                 KalturaLog::err("Required thumbnail params not found [" . $validationError->getData() . "]");
             }
         }
     }
     return null;
 }
示例#2
0
 /**
  * Delete Thumb Params by ID
  * 
  * @action delete
  * @param int $id
  */
 public function deleteAction($id)
 {
     $thumbParamsDb = thumbParamsPeer::retrieveByPK($id);
     if (!$thumbParamsDb) {
         throw new KalturaAPIException(KalturaErrors::FLAVOR_PARAMS_ID_NOT_FOUND, $id);
     }
     $thumbParamsDb->setDeletedAt(time());
     $thumbParamsDb->save();
 }
示例#3
0
 /**
  * @action regenerate
  * @param string $thumbAssetId
  * @return KalturaThumbAsset
  * 
  * @throws KalturaErrors::THUMB_ASSET_ID_NOT_FOUND
  * @throws KalturaErrors::ENTRY_TYPE_NOT_SUPPORTED
  * @throws KalturaErrors::ENTRY_MEDIA_TYPE_NOT_SUPPORTED
  * @throws KalturaErrors::THUMB_ASSET_PARAMS_ID_NOT_FOUND
  * @throws KalturaErrors::INVALID_ENTRY_STATUS
  */
 public function regenerateAction($thumbAssetId)
 {
     $thumbAsset = thumbAssetPeer::retrieveById($thumbAssetId);
     if (!$thumbAsset) {
         throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_ID_NOT_FOUND, $thumbAssetId);
     }
     if (is_null($thumbAsset->getFlavorParamsId())) {
         throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_PARAMS_ID_NOT_FOUND, null);
     }
     $destThumbParams = thumbParamsPeer::retrieveByPK($thumbAsset->getFlavorParamsId());
     if (!$destThumbParams) {
         throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_PARAMS_ID_NOT_FOUND, $thumbAsset->getFlavorParamsId());
     }
     $entry = $thumbAsset->getentry();
     if ($entry->getType() != entryType::MEDIA_CLIP) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_TYPE_NOT_SUPPORTED, $entry->getType());
     }
     if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_VIDEO) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_MEDIA_TYPE_NOT_SUPPORTED, $entry->getMediaType());
     }
     $validStatuses = array(entryStatus::ERROR_CONVERTING, entryStatus::PRECONVERT, entryStatus::READY);
     if (!in_array($entry->getStatus(), $validStatuses)) {
         throw new KalturaAPIException(KalturaErrors::INVALID_ENTRY_STATUS);
     }
     $dbThumbAsset = kBusinessPreConvertDL::decideThumbGenerate($entry, $destThumbParams);
     if (!$dbThumbAsset) {
         return null;
     }
     $thumbAsset = new KalturaThumbAsset();
     $thumbAsset->fromObject($dbThumbAsset);
     return $thumbAsset;
 }