コード例 #1
0
ファイル: kFlowHelper.php プロジェクト: richhl/kalturaCE
 /**
  * @param BatchJob $dbBatchJob
  * @param kConvertJobData $data
  * @param BatchJob $twinJob
  * @return BatchJob
  */
 public static function handleConvertFailed(BatchJob $dbBatchJob, kConvertJobData $data, BatchJob $twinJob = null)
 {
     KalturaLog::debug("Convert failed with destination file: " . $data->getDestFileSyncLocalPath());
     if ($dbBatchJob->getAbort()) {
         return $dbBatchJob;
     }
     // verifies that flavor asset created
     if (!$data->getFlavorAssetId()) {
         throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $data->getFlavorAssetId());
     }
     $flavorAsset = flavorAssetPeer::retrieveById($data->getFlavorAssetId());
     // verifies that flavor asset exists
     if (!$flavorAsset) {
         throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $data->getFlavorAssetId());
     }
     $flavorAsset->incrementVersion();
     $flavorAsset->save();
     $fallbackCreated = kBusinessPostConvertDL::handleConvertFailed($dbBatchJob, $dbBatchJob->getJobSubType(), $data->getFlavorAssetId(), $data->getFlavorParamsOutputId(), $data->getMediaInfoId());
     if (!$fallbackCreated) {
         $rootBatchJob = $dbBatchJob->getRootJob();
         if ($rootBatchJob && $rootBatchJob->getJobType() == BatchJobType::BULKDOWNLOAD) {
             $entryId = $dbBatchJob->getEntryId();
             $flavorParamsId = $data->getFlavorParamsOutputId();
             $flavorParamsOutput = flavorParamsOutputPeer::retrieveByPK($flavorParamsId);
             $fileFormat = $flavorParamsOutput->getFileExt();
             $entry = $dbBatchJob->getEntry();
             $notificationData = array("puserId" => $entry->getPuserId(), "entryId" => $entry->getId(), "entryIntId" => $entry->getIntId(), "entryVersion" => $entry->getVersion(), "fileFormat" => $flavorAsset->getFileExt(), "conversionQuality" => $entry->getConversionQuality());
             $extraData = array("data" => json_encode($notificationData), "partner_id" => $entry->getPartnerId(), "puser_id" => $entry->getPuserId(), "entry_id" => $entry->getId(), "entry_int_id" => $entry->getIntId(), "entry_version" => $entry->getVersion(), "conversion_quality" => $entry->getConversionQuality(), "status" => $entry->getStatus(), "abort" => $dbBatchJob->getAbort(), "progress" => $dbBatchJob->getProgress(), "message" => $dbBatchJob->getMessage(), "description" => $dbBatchJob->getDescription(), "updates_count" => $dbBatchJob->getUpdatesCount(), "job_type" => BatchJobType::DOWNLOAD, "conversion_error" => "Error while converting [{$entryId}] [{$fileFormat}]", "status" => BatchJob::BATCHJOB_STATUS_FAILED, "progress" => 0, "debug" => __LINE__);
             myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_BATCH_JOB_FAILED, $dbBatchJob, $dbBatchJob->getPartnerId(), null, null, $extraData, $entryId);
         }
     }
     return $dbBatchJob;
 }
コード例 #2
0
ファイル: kFlowHelper.php プロジェクト: GElkayam/server
 /**
  * @param BatchJob $dbBatchJob
  * @param kConvertJobData $data
  * @return BatchJob
  */
 public static function handleConvertFailed(BatchJob $dbBatchJob, kConvertJobData $data)
 {
     if ($dbBatchJob->getExecutionStatus() == BatchJobExecutionStatus::ABORTED) {
         return $dbBatchJob;
     }
     // verifies that flavor asset created
     if (!$data->getFlavorAssetId()) {
         throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $data->getFlavorAssetId());
     }
     $flavorAsset = assetPeer::retrieveById($data->getFlavorAssetId());
     // verifies that flavor asset exists
     if (!$flavorAsset) {
         throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $data->getFlavorAssetId());
     }
     if (!is_null($data->getEngineMessage())) {
         $flavorAsset->setDescription($flavorAsset->getDescription() . "\n" . $data->getEngineMessage());
         $flavorAsset->save();
     }
     // creats the file sync
     if (file_exists($data->getLogFileSyncLocalPath())) {
         $logSyncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_CONVERT_LOG);
         try {
             kFileSyncUtils::moveFromFile($data->getLogFileSyncLocalPath(), $logSyncKey);
         } catch (Exception $e) {
             $err = 'Saving conversion log: ' . $e->getMessage();
             KalturaLog::err($err);
             $desc = $dbBatchJob->getDescription() . "\n" . $err;
             $dbBatchJob->getDescription($desc);
         }
     }
     //		$flavorAsset->incrementVersion();
     //		$flavorAsset->save();
     $fallbackCreated = kBusinessPostConvertDL::handleConvertFailed($dbBatchJob, $dbBatchJob->getJobSubType(), $data->getFlavorAssetId(), $data->getFlavorParamsOutputId(), $data->getMediaInfoId());
     if (!$fallbackCreated) {
         $rootBatchJob = $dbBatchJob->getRootJob();
         if ($rootBatchJob && $rootBatchJob->getJobType() == BatchJobType::BULKDOWNLOAD) {
             $entryId = $dbBatchJob->getEntryId();
             $flavorParamsId = $data->getFlavorParamsOutputId();
             $flavorParamsOutput = assetParamsOutputPeer::retrieveByPK($flavorParamsId);
             $fileFormat = $flavorParamsOutput->getFileExt();
             $entry = $dbBatchJob->getEntry();
             if (!$entry) {
                 return $dbBatchJob;
             }
             $notificationData = array("puserId" => $entry->getPuserId(), "entryId" => $entry->getId(), "entryIntId" => $entry->getIntId(), "entryVersion" => $entry->getVersion(), "fileFormat" => $flavorAsset->getFileExt(), "conversionQuality" => $entry->getConversionQuality());
             $extraData = array("data" => json_encode($notificationData), "partner_id" => $entry->getPartnerId(), "puser_id" => $entry->getPuserId(), "entry_id" => $entry->getId(), "entry_int_id" => $entry->getIntId(), "entry_version" => $entry->getVersion(), "conversion_quality" => $entry->getConversionQuality(), "status" => $entry->getStatus(), "abort" => $dbBatchJob->getExecutionStatus() == BatchJobExecutionStatus::ABORTED, "message" => $dbBatchJob->getMessage(), "description" => $dbBatchJob->getDescription(), "job_type" => BatchJobType::DOWNLOAD, "conversion_error" => "Error while converting [{$entryId}] [{$fileFormat}]", "status" => BatchJob::BATCHJOB_STATUS_FAILED, "progress" => 0, "debug" => __LINE__);
             myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_BATCH_JOB_FAILED, $dbBatchJob, $dbBatchJob->getPartnerId(), null, null, $extraData, $entryId);
         }
     }
     return $dbBatchJob;
 }