public function shouldConsumeJobStatusEvent(BatchJob $dbBatchJob) { if ($dbBatchJob->getJobType() == IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION) && $dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_DONT_PROCESS && $dbBatchJob->getData()->getTriggerType() == BpmEventNotificationIntegrationPlugin::getIntegrationTriggerCoreValue(BpmEventNotificationIntegrationTrigger::BPM_EVENT_NOTIFICATION)) { return true; } return false; }
protected function copyModifiedColumns(BatchJobLog $batchJobLog, BatchJob $batchJob, array $modifiedColumns) { $shouldSkipInTranslation = array(BatchJobPeer::LOCK_INFO, BatchJobPeer::HISTORY, BatchJobPeer::BATCH_JOB_LOCK_ID, BatchJobPeer::EXECUTION_STATUS); foreach ($modifiedColumns as $modifiedColumn) { $fieldPosLog = -1; try { if (in_array($modifiedColumn, $shouldSkipInTranslation)) { if ($modifiedColumn == BatchJobPeer::EXECUTION_STATUS) { $batchJobLog->setAbort($batchJob->getExecutionStatus() == BatchJobExecutionStatus::ABORTED); } continue; } $fieldName = BatchJobPeer::translateFieldName($modifiedColumn, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME); $fieldPosJob = BatchJobPeer::translateFieldName($modifiedColumn, BasePeer::TYPE_COLNAME, BasePeer::TYPE_NUM); $fieldPosLog = BatchJobLogPeer::translateFieldName($fieldName, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM); } catch (PropelException $e) { KalturaLog::err("Could not set value for BatchJobLog field {$fieldName}, exception thrown: " . $e->getMessage()); } if ($fieldPosLog != -1) { $batchJobLog->setByPosition($fieldPosLog, $batchJob->getByPosition($fieldPosJob)); } if ($modifiedColumn == BatchJobPeer::DATA) { //set param_1 for the $batchJobLog $batchJobData = $batchJob->getData(); /* @var $batchJobData kBulkUploadJobData */ $batchJobLog->setParam1($batchJobData->getBulkUploadObjectType()); } } return $batchJobLog; }
public function shouldConsumeJobStatusEvent(BatchJob $dbBatchJob) { // consume import jobs with data of type kDropFolderImportJobData if ($dbBatchJob->getJobType() == BatchJobType::IMPORT && get_class($dbBatchJob->getData()) == 'kDropFolderImportJobData') { return true; } return false; }
public function updatedJob(BatchJob $dbBatchJob) { $data = $dbBatchJob->getData(); $providerData = $data->getProviderData(); $entryId = $providerData->getEntryId(); $partnerId = $dbBatchJob->getPartnerId(); $spokenLanguage = $providerData->getSpokenLanguage(); if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_DONT_PROCESS) { $transcript = $this->getAssetsByLanguage($entryId, array(TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT)), $spokenLanguage, true); if (!$transcript) { $transcript = new TranscriptAsset(); $transcript->setType(TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT)); $transcript->setEntryId($entryId); $transcript->setPartnerId($partnerId); $transcript->setLanguage($spokenLanguage); $transcript->setContainerFormat(AttachmentType::TEXT); $transcript->setAccuracy(self::DEFAULT_ACCURACY); } $transcript->setStatus(AttachmentAsset::ASSET_STATUS_QUEUED); $transcript->save(); return true; } $formatsString = $providerData->getCaptionAssetFormats(); if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED) { $clientHelper = VoicebasePlugin::getClientHelper($providerData->getApiKey(), $providerData->getApiPassword()); $externalEntryExists = $clientHelper->checkExistingExternalContent($entryId); if (!$externalEntryExists) { KalturaLog::err('remote content does not exist'); return true; } $formatsArray = explode(',', $formatsString); $formatsArray[] = "TXT"; $contentsArray = $clientHelper->getRemoteTranscripts($entryId, $formatsArray); KalturaLog::debug('contents are - ' . print_r($contentsArray, true)); $transcript = $this->getAssetsByLanguage($entryId, array(TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT)), $spokenLanguage, true); $captions = $this->getAssetsByLanguage($entryId, array(CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)), $spokenLanguage); $this->setObjectContent($transcript, $contentsArray["TXT"], null, true); unset($contentsArray["TXT"]); foreach ($contentsArray as $format => $content) { $captionFormatConst = constant("KalturaCaptionType::" . $format); if (isset($captions[$captionFormatConst])) { $caption = $captions[$captionFormatConst]; } else { $caption = new CaptionAsset(); $caption->setEntryId($entryId); $caption->setPartnerId($partnerId); $caption->setLanguage($spokenLanguage); $caption->setContainerFormat($captionFormatConst); $caption->setAccuracy(self::DEFAULT_ACCURACY); $caption->setStatus(CaptionAsset::ASSET_STATUS_QUEUED); $caption->save(); } $this->setObjectContent($caption, $content, $format); } } return true; }
/** * @param BatchJob $dbBatchJob * @return bool true if should continue to the next consumer */ public function updatedJob(BatchJob $dbBatchJob) { $data = $dbBatchJob->getData(); switch ($dbBatchJob->getStatus()) { case BatchJob::BATCHJOB_STATUS_FINISHED: return self::handleJobFinished($dbBatchJob, $data); default: return $dbBatchJob; } }
public function updatedJob(BatchJob $dbBatchJob) { switch ($dbBatchJob->getStatus()) { case BatchJob::BATCHJOB_STATUS_FINISHED: $data = $dbBatchJob->getData(); $kontikiFileSync = FileSyncPeer::retrieveByPK($data->getSrcFileSyncId()); /* @var $data kStorageExportJobData */ $asset = assetPeer::retrieveByFileSync($kontikiFileSync); $asset->setTags(KontikiPlugin::KONTIKI_ASSET_TAG); $asset->save(); //Get Kontiki file sync and set the external URL $kontikiFileSync->setFileRoot(""); $kontikiFileSync->setFilePath($data->getContentMoid()); $kontikiFileSync->save(); break; } return true; }
public function updatedJob(BatchJob $dbBatchJob) { $data = $dbBatchJob->getData(); if (!$data instanceof kDistributionJobData) { return true; } $doubleClickCoreValueType = kPluginableEnumsManager::apiToCore('DistributionProviderType', DoubleClickDistributionPlugin::getApiValue(DoubleClickDistributionProviderType::DOUBLECLICK)); if ($data->getProviderType() != $doubleClickCoreValueType) { return true; } if ($dbBatchJob->getStatus() != BatchJob::BATCHJOB_STATUS_PENDING) { return true; } $jobTypesToFinish = array(ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_FETCH_REPORT), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_ENABLE), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DISABLE)); if (in_array($dbBatchJob->getJobType(), $jobTypesToFinish)) { kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_FINISHED); } return true; }
public function updatedJob(BatchJob $dbBatchJob, BatchJob $twinJob = null) { $data = $dbBatchJob->getData(); if (!$data instanceof kDistributionJobData) { return true; } $attUverseCoreValueType = kPluginableEnumsManager::apiToCore('DistributionProviderType', AttUverseDistributionPlugin::getApiValue(AttUverseDistributionProviderType::ATT_UVERSE)); if ($data->getProviderType() != $attUverseCoreValueType) { return true; } $jobTypesToFinish = array(ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE)); if (in_array($dbBatchJob->getJobType(), $jobTypesToFinish) && $dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED) { return self::onDistributionJobFinished($dbBatchJob, $data, $twinJob); } if ($dbBatchJob->getJobType() == ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE) && $dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_PENDING) { kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_FINISHED); } return true; }
protected function copyModifiedColumns(BatchJobLog $batchJobLog, BatchJob $batchJob, array $modifiedColumns) { foreach ($modifiedColumns as $modifiedColumn) { try { $fieldName = BatchJobPeer::translateFieldName($modifiedColumn, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME); $fieldPosJob = BatchJobPeer::translateFieldName($modifiedColumn, BasePeer::TYPE_COLNAME, BasePeer::TYPE_NUM); $fieldPosLog = BatchJobLogPeer::translateFieldName($fieldName, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM); } catch (PropelException $e) { KalturaLog::err("Could not set value for BatchJobLog field {$fieldName}, exception thrown: " . $e->getMessage()); } $batchJobLog->setByPosition($fieldPosLog, $batchJob->getByPosition($fieldPosJob)); if ($modifiedColumn == BatchJobPeer::DATA) { //set param_1 for the $batchJobLog $batchJobData = $batchJob->getData(); /* @var $batchJobData kBulkUploadJobData */ $batchJobLog->setParam1($batchJobData->getBulkUploadObjectType()); } } return $batchJobLog; }
/** * @param BatchJob $dbBatchJob * @return BatchJob */ public static function onDistributionJobFinished(BatchJob $dbBatchJob) { $data = $dbBatchJob->getData(); $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId()); if (!$entryDistribution) { KalturaLog::err('Entry distribution [' . $data->getEntryDistributionId() . '] not found'); return $dbBatchJob; } $providerData = $data->getProviderData(); if (!$providerData instanceof kCrossKalturaDistributionJobProviderData) { KalturaLog::err('Wrong provider data class [' . get_class($providerData) . ']'); return $dbBatchJob; } $entryDistribution->putInCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_FLAVOR_ASSETS, $providerData->getDistributedFlavorAssets()); $entryDistribution->putInCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_THUMB_ASSETS, $providerData->getDistributedThumbAssets()); $entryDistribution->putInCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_METADATA, $providerData->getDistributedMetadata()); $entryDistribution->putInCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_CAPTION_ASSETS, $providerData->getDistributedCaptionAssets()); $entryDistribution->putInCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_CUE_POINTS, $providerData->getDistributedCuePoints()); $entryDistribution->save(); return $dbBatchJob; }
private function onBulkUploadJobStatusUpdated(BatchJob $dbBatchJob) { $xmlDropFolderFile = DropFolderFilePeer::retrieveByPK($dbBatchJob->getObjectId()); if (!$xmlDropFolderFile) { return; } switch ($dbBatchJob->getStatus()) { case BatchJob::BATCHJOB_STATUS_QUEUED: $jobData = $dbBatchJob->getData(); if (!is_null($jobData->getFilePath())) { $syncKey = $dbBatchJob->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_BULKUPLOAD); try { kFileSyncUtils::moveFromFile($jobData->getFilePath(), $syncKey, true); } catch (Exception $e) { KalturaLog::err($e); throw new APIException(APIErrors::BULK_UPLOAD_CREATE_CSV_FILE_SYNC_ERROR); } $filePath = kFileSyncUtils::getLocalFilePathForKey($syncKey); $jobData->setFilePath($filePath); //save new info on the batch job $dbBatchJob->setData($jobData); $dbBatchJob->save(); } break; case BatchJob::BATCHJOB_STATUS_FINISHED: case BatchJob::BATCHJOB_STATUS_FINISHED_PARTIALLY: $xmlDropFolderFile->setStatus(DropFolderFileStatus::HANDLED); $xmlDropFolderFile->save(); break; case BatchJob::BATCHJOB_STATUS_FAILED: case BatchJob::BATCHJOB_STATUS_FATAL: $relatedFiles = DropFolderFilePeer::retrieveByLeadIdAndStatuses($xmlDropFolderFile->getId(), array(DropFolderFileStatus::PROCESSING)); foreach ($relatedFiles as $relatedFile) { $this->setFileError($relatedFile, DropFolderFileStatus::ERROR_HANDLING, DropFolderXmlBulkUploadPlugin::getErrorCodeCoreValue(DropFolderXmlBulkUploadErrorCode::ERROR_IN_BULK_UPLOAD), DropFolderXmlBulkUploadPlugin::ERROR_IN_BULK_UPLOAD_MESSAGE); } break; } }
public function toData(BatchJob $dbBatchJob) { $dbData = null; if (is_null($this->jobType)) { $this->jobType = kPluginableEnumsManager::coreToApi('BatchJobType', $dbBatchJob->getJobType()); } switch ($dbBatchJob->getJobType()) { case KalturaBatchJobType::BULKUPLOAD: $dbData = new kBulkUploadJobData(); if (is_null($this->data)) { $this->data = new KalturaBulkUploadJobData(); } break; case KalturaBatchJobType::CONVERT: $dbData = new kConvertJobData(); if (is_null($this->data)) { $this->data = new KalturaConvertJobData(); } break; case KalturaBatchJobType::CONVERT_PROFILE: $dbData = new kConvertProfileJobData(); if (is_null($this->data)) { $this->data = new KalturaConvertProfileJobData(); } break; case KalturaBatchJobType::EXTRACT_MEDIA: $dbData = new kExtractMediaJobData(); if (is_null($this->data)) { $this->data = new KalturaExtractMediaJobData(); } break; case KalturaBatchJobType::IMPORT: $dbData = new kImportJobData(); if (is_null($this->data)) { $this->data = new KalturaImportJobData(); } break; case KalturaBatchJobType::POSTCONVERT: $dbData = new kPostConvertJobData(); if (is_null($this->data)) { $this->data = new KalturaPostConvertJobData(); } break; case KalturaBatchJobType::MAIL: $dbData = new kMailJobData(); if (is_null($this->data)) { $this->data = new KalturaMailJobData(); } break; case KalturaBatchJobType::NOTIFICATION: $dbData = new kNotificationJobData(); if (is_null($this->data)) { $this->data = new KalturaNotificationJobData(); } break; case KalturaBatchJobType::BULKDOWNLOAD: $dbData = new kBulkDownloadJobData(); if (is_null($this->data)) { $this->data = new KalturaBulkDownloadJobData(); } break; case KalturaBatchJobType::FLATTEN: $dbData = new kFlattenJobData(); if (is_null($this->data)) { $this->data = new KalturaFlattenJobData(); } break; case KalturaBatchJobType::PROVISION_PROVIDE: case KalturaBatchJobType::PROVISION_DELETE: $jobSubType = $dbBatchJob->getJobSubType(); $dbData = kAkamaiProvisionJobData::getInstance($jobSubType); if (is_null($this->data)) { $this->data = KalturaProvisionJobData::getJobDataInstance($jobSubType); } break; case KalturaBatchJobType::CONVERT_COLLECTION: $dbData = new kConvertCollectionJobData(); if (is_null($this->data)) { $this->data = new KalturaConvertCollectionJobData(); } break; case KalturaBatchJobType::STORAGE_EXPORT: $dbData = new kStorageExportJobData(); if (is_null($this->data)) { $this->data = new KalturaStorageExportJobData(); } break; case KalturaBatchJobType::MOVE_CATEGORY_ENTRIES: $dbData = new kMoveCategoryEntriesJobData(); if (is_null($this->data)) { $this->data = new KalturaMoveCategoryEntriesJobData(); } break; case KalturaBatchJobType::STORAGE_DELETE: $dbData = new kStorageDeleteJobData(); if (is_null($this->data)) { $this->data = new KalturaStorageDeleteJobData(); } break; case KalturaBatchJobType::CAPTURE_THUMB: $dbData = new kCaptureThumbJobData(); if (is_null($this->data)) { $this->data = new KalturaCaptureThumbJobData(); } break; case KalturaBatchJobType::INDEX: $dbData = new kIndexJobData(); if (is_null($this->data)) { $this->data = new KalturaIndexJobData(); } break; case KalturaBatchJobType::COPY: $dbData = new kCopyJobData(); if (is_null($this->data)) { $this->data = new KalturaCopyJobData(); } break; case KalturaBatchJobType::DELETE: $dbData = new kDeleteJobData(); if (is_null($this->data)) { $this->data = new KalturaDeleteJobData(); } break; case KalturaBatchJobType::DELETE_FILE: $dbData = new kDeleteFileJobData(); if (is_null($this->data)) { $this->data = new KalturaDeleteFileJobData(); } break; case KalturaBatchJobType::CONVERT_LIVE_SEGMENT: $dbData = new kConvertLiveSegmentJobData(); if (is_null($this->data)) { $this->data = new KalturaConvertLiveSegmentJobData(); } break; case KalturaBatchJobType::CONCAT: $dbData = new kConcatJobData(); if (is_null($this->data)) { $this->data = new KalturaConcatJobData(); } break; case KalturaBatchJobType::COPY_PARTNER: $dbData = new kCopyPartnerJobData(); if (is_null($this->data)) { $this->data = new KalturaCopyPartnerJobData(); } break; case KalturaBatchJobType::RECALCULATE_CACHE: switch ($dbBatchJob->getJobSubType()) { case RecalculateCacheType::RESPONSE_PROFILE: $dbData = new kRecalculateResponseProfileCacheJobData(); if (is_null($this->data)) { $this->data = new KalturaRecalculateResponseProfileCacheJobData(); } break; } break; default: $dbData = KalturaPluginManager::loadObject('kJobData', $dbBatchJob->getJobType()); if (is_null($this->data)) { $this->data = KalturaPluginManager::loadObject('KalturaJobData', $this->jobType); } } if (is_null($dbBatchJob->getData())) { $dbBatchJob->setData($dbData); } if ($this->data instanceof KalturaJobData) { $dbData = $this->data->toObject($dbBatchJob->getData()); $dbBatchJob->setData($dbData); } return $dbData; }
/** * @param BatchJob $dbBatchJob * @param kExtractMediaJobData $data * @param BatchJob $twinJob * @return BatchJob */ public static function handleExtractMediaClosed(BatchJob $dbBatchJob, kExtractMediaJobData $data, BatchJob $twinJob = null) { KalturaLog::debug("Extract media closed"); if ($dbBatchJob->getAbort()) { return $dbBatchJob; } $rootBatchJob = $dbBatchJob->getRootJob(); if (!$rootBatchJob) { return $dbBatchJob; } if ($twinJob) { // copy media info $twinData = $twinJob->getData(); if ($twinData->getMediaInfoId()) { $twinMediaInfo = mediaInfoPeer::retrieveByPK($twinData->getMediaInfoId()); if ($twinMediaInfo) { $mediaInfo = $twinMediaInfo->copy(); $mediaInfo->setFlavorAssetId($data->getFlavorAssetId()); $mediaInfo = kBatchManager::addMediaInfo($mediaInfo); $data->setMediaInfoId($mediaInfo->getId()); $dbBatchJob->setData($data); $dbBatchJob->save(); } } } if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED) { $entry = $dbBatchJob->getEntry(); if ($entry->getStatus() < entryStatus::READY) { kBatchManager::updateEntry($dbBatchJob, entryStatus::PRECONVERT); } } switch ($dbBatchJob->getJobSubType()) { case mediaInfo::ASSET_TYPE_ENTRY_INPUT: if ($rootBatchJob->getJobType() == BatchJobType::CONVERT_PROFILE) { $conversionsCreated = kBusinessPreConvertDL::decideProfileConvert($dbBatchJob, $rootBatchJob, $data->getMediaInfoId()); if ($conversionsCreated) { // handle the source flavor as if it was converted, makes the entry ready according to ready behavior rules $currentFlavorAsset = flavorAssetPeer::retrieveById($data->getFlavorAssetId()); if ($currentFlavorAsset) { $dbBatchJob = kBusinessPostConvertDL::handleConvertFinished($dbBatchJob, $currentFlavorAsset); } } } break; case mediaInfo::ASSET_TYPE_FLAVOR_INPUT: if ($rootBatchJob->getJobType() == BatchJobType::REMOTE_CONVERT) { $remoteConvertData = $rootBatchJob->getData(); $errDescription = null; $syncKey = null; // TODO - how to get or create the sync key? $newConvertJob = kBusinessPreConvertDL::decideFlavorConvert($syncKey, $remoteConvertData->getFlavorParamsOutputId(), $errDescription, $remoteConvertData->getMediaInfoId(), $dbBatchJob); if (!$newConvertJob) { kJobsManager::failBatchJob($rootBatchJob); } } break; default: // currently do nothing break; } return $dbBatchJob; }
public static function handleConvertFailed(BatchJob $dbBatchJob, $engineType, $flavorAssetId, $flavorParamsOutputId, $mediaInfoId) { $flavorAsset = assetPeer::retrieveById($flavorAssetId); // verifies that flavor asset exists if (!$flavorAsset) { throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $flavorAssetId); } $flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR); $flavorAsset->save(); // try to create a convert job with the next engine if (!is_null($engineType)) { $data = $dbBatchJob->getData(); if ($data instanceof kConvartableJobData) { $data->incrementOperationSet(); $dbBatchJob->setData($data); $dbBatchJob->save(); } $newDbBatchJob = kBusinessPreConvertDL::redecideFlavorConvert($flavorAssetId, $flavorParamsOutputId, $mediaInfoId, $dbBatchJob, $engineType); if ($newDbBatchJob) { return true; } } // find the root job $rootBatchJob = $dbBatchJob->getRootJob(); if (!$rootBatchJob) { return false; } // the root is already failed if ($rootBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FAILED || $rootBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FATAL) { return false; } // bulk download root job no need to handle if ($rootBatchJob->getJobType() == BatchJobType::BULKDOWNLOAD) { kJobsManager::failBatchJob($rootBatchJob, "Convert job " . $dbBatchJob->getId() . " failed"); return false; } if (is_null($flavorParamsOutputId)) { kJobsManager::failBatchJob($rootBatchJob, "Job " . $dbBatchJob->getId() . " failed"); kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING); return false; } $readyBehavior = $dbBatchJob->getData()->getReadyBehavior(); if ($readyBehavior == flavorParamsConversionProfile::READY_BEHAVIOR_REQUIRED) { kJobsManager::failBatchJob($rootBatchJob, "Job " . $dbBatchJob->getId() . " failed"); kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING); return false; } // failing the root profile job if all child jobs failed if ($rootBatchJob->getJobType() != BatchJobType::CONVERT_PROFILE) { return false; } $siblingJobs = $rootBatchJob->getChildJobs(); foreach ($siblingJobs as $siblingJob) { /* @var $siblingJob BatchJob */ // not conversion job and should be ignored if ($siblingJob->getJobType() != BatchJobType::CONVERT && $siblingJob->getJobType() != BatchJobType::POSTCONVERT) { continue; } $jobData = $siblingJob->getData(); if (!$jobData || !$jobData instanceof kConvertJobData && !$jobData instanceof kPostConvertJobData) { KalturaLog::err("Job id [" . $siblingJob->getId() . "] has no valid job data"); continue; } // found child flavor asset that hasn't failed, no need to fail the root job $siblingFlavorAssetId = $jobData->getFlavorAssetId(); $siblingFlavorAsset = assetPeer::retrieveById($siblingFlavorAssetId); if ($siblingFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_ERROR && $siblingFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_NOT_APPLICABLE && $siblingFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_DELETED) { return false; } } // all conversions failed, should fail the root job kJobsManager::failBatchJob($rootBatchJob, "All conversions failed"); kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING); return false; }
public static function prepareNotificationData($url, $signature_key, BatchJob $job, $prefix = null) { $type = $job->getData()->getType(); $params = array("notification_id" => $job->getId(), "notification_type" => $job->getData()->getTypeAsString(), "puser_id" => $job->getData()->getUserId(), "partner_id" => $job->getPartnerId()); if (kNotificationJobData::isEntryNotification($type)) { $params["entry_id"] = $job->getData()->getObjectId(); } //$params["entryId"] = $not->getObjectId(); if (kNotificationJobData::isKshowNotification($type)) { $params["kshow_id"] = $job->getData()->getObjectId(); } // $params["kshowId"] = $not->getObjectId(); $object_data_params = myNotificationMgr::getDataAsArray($job->getData()->getData()); if ($object_data_params) { $params = array_merge($params, $object_data_params); } $params = self::fixParams($params, $prefix); $params['signed_fields'] = ''; foreach ($params as $key => $value) { $params['signed_fields'] .= $key . ','; } return self::signParams($signature_key, $params); }
/** * @param BatchJob $parentJob * @param int $postConvertAssetType * @param string $srcFileSyncLocalPath * @param int $flavorAssetId * @param int $flavorParamsOutputId * @param bool $createThumb * @param int $thumbOffset * @param string $customData * @return BatchJob */ public static function addPostConvertJob(BatchJob $parentJob = null, $postConvertAssetType, $srcFileSyncLocalPath, $flavorAssetId, $flavorParamsOutputId, $createThumb = false, $thumbOffset = 3) { $postConvertData = new kPostConvertJobData(); $postConvertData->setPostConvertAssetType($postConvertAssetType); $postConvertData->setSrcFileSyncLocalPath($srcFileSyncLocalPath); $postConvertData->setFlavorParamsOutputId($flavorParamsOutputId); $postConvertData->setFlavorAssetId($flavorAssetId); $postConvertData->setThumbOffset($thumbOffset); $postConvertData->setCreateThumb($createThumb); if ($parentJob) { $parentData = $parentJob->getData(); if ($parentData instanceof kConvartableJobData) { $postConvertData->setCurrentOperationSet($parentData->getCurrentOperationSet()); $postConvertData->setCurrentOperationIndex($parentData->getCurrentOperationIndex()); } } $flavorAsset = assetPeer::retrieveById($flavorAssetId); $flavorParamsOutput = null; if ($createThumb) { $flavorParamsOutput = assetParamsOutputPeer::retrieveByPK($flavorParamsOutputId); if (!$flavorParamsOutput) { if ($flavorAsset) { $postConvertData->setThumbHeight($flavorAsset->getHeight()); $postConvertData->setThumbBitrate($flavorAsset->getBitrate()); } else { $postConvertData->setCreateThumb(false); } } elseif (!$flavorParamsOutput->getVideoBitrate()) { $postConvertData->setCreateThumb(false); } elseif ($flavorParamsOutput->getSourceRemoteStorageProfileId() != StorageProfile::STORAGE_KALTURA_DC) { $postConvertData->setCreateThumb(false); } elseif ($flavorAsset) { $entry = $flavorAsset->getentry(); if ($entry) { $thisFlavorHeight = $flavorParamsOutput->getHeight(); $thisFlavorBitrate = $flavorParamsOutput->getVideoBitrate(); $createThumb = false; if ($entry->getThumbBitrate() < $thisFlavorBitrate) { $createThumb = true; } elseif ($entry->getThumbBitrate() == $thisFlavorBitrate && $entry->getThumbHeight() < $thisFlavorHeight) { $createThumb = true; } if ($createThumb) { $postConvertData->setCreateThumb(true); $postConvertData->setThumbHeight($thisFlavorHeight); $postConvertData->setThumbBitrate($thisFlavorBitrate); } } } } $batchJob = null; $mediaParserType = $flavorParamsOutput ? $flavorParamsOutput->getMediaParserType() : mediaParserType::MEDIAINFO; if ($parentJob) { //Job will be created with parent job as his root job $useSameRoot = true; if ($parentJob->getJobType() == BatchJobType::CONVERT_PROFILE) { $useSameRoot = false; } $batchJob = $parentJob->createChild(BatchJobType::POSTCONVERT, $mediaParserType, $useSameRoot); } else { $batchJob = new BatchJob(); $batchJob->setEntryId($flavorAsset->getEntryId()); $batchJob->setPartnerId($flavorAsset->getPartnerId()); } $batchJob->setObjectId($flavorAsset->getId()); $batchJob->setObjectType(BatchJobObjectType::ASSET); KalturaLog::log("Post Convert created with file: " . $postConvertData->getSrcFileSyncLocalPath()); return kJobsManager::addJob($batchJob, $postConvertData, BatchJobType::POSTCONVERT, $mediaParserType); }
/** * batch decideProfileConvert is the decision layer for a conversion profile * * @param BatchJob $parentJob * @param BatchJob $convertProfileJob * @param int $mediaInfoId * @return bool true if created all required conversions */ public static function decideProfileConvert(BatchJob $parentJob, BatchJob $convertProfileJob, $mediaInfoId = null) { KalturaLog::log("Conversion decision layer used for entry [" . $parentJob->getEntryId() . "]"); $convertProfileData = $convertProfileJob->getData(); $entryId = $convertProfileJob->getEntryId(); $entry = $convertProfileJob->getEntry(); if (!$entry) { throw new APIException(APIErrors::INVALID_ENTRY, $convertProfileJob, $entryId); } $profile = myPartnerUtils::getConversionProfile2ForEntry($entryId); if (!$profile) { $errDescription = "Conversion profile for entryId [{$entryId}] not found"; self::setError($errDescription, $convertProfileJob, BatchJobType::CONVERT_PROFILE, $convertProfileJob->getEntryId()); return false; } $originalFlavorAsset = assetPeer::retrieveOriginalByEntryId($entryId); if (is_null($originalFlavorAsset)) { $errDescription = 'Original flavor asset not found'; self::setError($errDescription, $convertProfileJob, BatchJobType::CONVERT_PROFILE, $convertProfileJob->getEntryId()); return false; } // gets the list of flavor params of the conversion profile $list = flavorParamsConversionProfilePeer::retrieveByConversionProfile($profile->getId()); if (!count($list)) { $errDescription = "No flavors match the profile id [{$profile->getId()}]"; self::setError($errDescription, $convertProfileJob, BatchJobType::CONVERT_PROFILE, $convertProfileJob->getEntryId()); $originalFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_DELETED); $originalFlavorAsset->setDeletedAt(time()); $originalFlavorAsset->save(); return false; } $mediaInfo = null; if ($mediaInfoId) { $mediaInfo = mediaInfoPeer::retrieveByPK($mediaInfoId); } $shouldConvert = self::shouldConvertProfileFlavors($profile, $mediaInfo, $originalFlavorAsset); // gets the ids of the flavor params $flavorsIds = array(); $conversionProfileFlavorParams = array(); foreach ($list as $flavorParamsConversionProfile) { $flavorsId = $flavorParamsConversionProfile->getFlavorParamsId(); $flavorsIds[] = $flavorsId; $conversionProfileFlavorParams[$flavorsId] = $flavorParamsConversionProfile; } KalturaLog::info("Flavors in conversion profile [" . implode(',', $flavorsIds) . "]"); $sourceFlavor = null; $flavors = assetParamsPeer::retrieveFlavorsByPKs($flavorsIds); $ingestedNeeded = self::checkConvertProfileParams($flavors, $conversionProfileFlavorParams, $entry, $sourceFlavor); KalturaLog::log(count($flavors) . " destination flavors found for this profile[" . $profile->getId() . "]"); if (!$sourceFlavor) { KalturaLog::log("Source flavor params not found"); $originalFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_TEMP); $originalFlavorAsset->save(); /* * Check for 'auto-intermediate-source */ $res = self::decideSourceFlavorConvert($entryId, null, $originalFlavorAsset, $profile->getId(), $flavors, $mediaInfo, $parentJob, $convertProfileJob); if (!$res) { $originalFlavorAsset->incrementInterFlowCount(); $originalFlavorAsset->save(); return false; } $originalFlavorAsset->removeInterFlowCount(); $originalFlavorAsset->save(); } elseif ($shouldConvert) { KalturaLog::log("Source flavor params [" . $sourceFlavor->getId() . "] found"); $originalFlavorAsset->setFlavorParamsId($sourceFlavor->getId()); $res = self::decideSourceFlavorConvert($entryId, $sourceFlavor, $originalFlavorAsset, $profile->getId(), $flavors, $mediaInfo, $parentJob, $convertProfileJob); if (!$res) { $originalFlavorAsset->incrementInterFlowCount(); $originalFlavorAsset->save(); return false; } $originalFlavorAsset->removeInterFlowCount(); $originalFlavorAsset->setStatusLocalReady(); $originalFlavorAsset->save(); $entry->save(); kFlowHelper::generateThumbnailsFromFlavor($parentJob->getEntryId(), $parentJob); } if (!count($flavors)) { $shouldConvert = false; } if (!$shouldConvert) { if ($ingestedNeeded) { kJobsManager::updateBatchJob($convertProfileJob, BatchJob::BATCHJOB_STATUS_FINISHED); return false; } else { self::bypassConversion($originalFlavorAsset, $entry, $convertProfileJob); return true; } } try { return self::decideProfileFlavorsConvert($parentJob, $convertProfileJob, $flavors, $conversionProfileFlavorParams, $profile->getId(), $mediaInfo); } catch (Exception $e) { $code = $e->getCode(); if ($code == KDLErrors::SanityInvalidFrameDim || $code == KDLErrors::NoValidMediaStream) { throw $e; } } }
/** * Returns the log file for bulk upload job * @param BatchJob $batchJob bulk upload batchjob */ public static function writeBulkUploadLogFile($batchJob) { if ($batchJob->getJobSubType() && $batchJob->getJobSubType() != self::getBulkUploadTypeCoreValue(BulkUploadCsvType::CSV)) { return; } header("Content-Type: text/plain; charset=UTF-8"); $criteria = new Criteria(); $criteria->add(BulkUploadResultPeer::BULK_UPLOAD_JOB_ID, $batchJob->getId()); $criteria->addAscendingOrderByColumn(BulkUploadResultPeer::LINE_INDEX); $criteria->setLimit(100); $bulkUploadResults = BulkUploadResultPeer::doSelect($criteria); if (!count($bulkUploadResults)) { die("Log file is not ready"); } $STDOUT = fopen('php://output', 'w'); $data = $batchJob->getData(); /* @var $data kBulkUploadJobData */ //Add header row to the output CSV only if partner level permission for it exists $partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id; if (PermissionPeer::isValidForPartner(self::FEATURE_CSV_HEADER_ROW, $partnerId)) { $headerRow = $data->getColumns(); $headerRow[] = "resultStatus"; $headerRow[] = "objectId"; $headerRow[] = "objectStatus"; $headerRow[] = "errorDescription"; fputcsv($STDOUT, $headerRow); } $handledResults = 0; while (count($bulkUploadResults)) { $handledResults += count($bulkUploadResults); foreach ($bulkUploadResults as $bulkUploadResult) { /* @var $bulkUploadResult BulkUploadResult */ $values = str_getcsv($bulkUploadResult->getRowData()); // switch ($bulkUploadResult->getObjectType()) // { // case BulkUploadObjectType::ENTRY: // $values = self::writeEntryBulkUploadResults($bulkUploadResult, $data); // break; // case BulkUploadObjectType::CATEGORY: // $values = self::writeCategoryBulkUploadResults($bulkUploadResult, $data); // break; // case BulkUploadObjectType::CATEGORY_USER: // $values = self::writeCategoryUserBulkUploadResults($bulkUploadResult, $data); // break; // case BulkUploadObjectType::USER: // $values = self::writeUserBulkUploadResults($bulkUploadResult, $data); // break; // default: // // break; // } $values[] = $bulkUploadResult->getStatus(); $values[] = $bulkUploadResult->getObjectId(); $values[] = $bulkUploadResult->getObjectStatus(); $values[] = preg_replace('/[\\n\\r\\t]/', ' ', $bulkUploadResult->getErrorDescription()); fputcsv($STDOUT, $values); } if (count($bulkUploadResults) < $criteria->getLimit()) { break; } kMemoryManager::clearMemory(); $criteria->setOffset($handledResults); $bulkUploadResults = BulkUploadResultPeer::doSelect($criteria); } fclose($STDOUT); kFile::closeDbConnections(); exit; }
/** * @param BatchJob $parentJob * @param int $jobSubType * @param string $srcFileSyncLocalPath * @param int $flavorAssetId * @param int $flavorParamsOutputId * @param bool $createThumb * @param int $thumbOffset * @return BatchJob */ public static function addPostConvertJob(BatchJob $parentJob, $jobSubType, $srcFileSyncLocalPath, $flavorAssetId, $flavorParamsOutputId, $createThumb = false, $thumbOffset = 3) { $postConvertData = new kPostConvertJobData(); $postConvertData->setSrcFileSyncLocalPath($srcFileSyncLocalPath); $postConvertData->setFlavorParamsOutputId($flavorParamsOutputId); $postConvertData->setFlavorAssetId($flavorAssetId); $postConvertData->setThumbOffset($thumbOffset); $postConvertData->setCreateThumb($createThumb); $parentData = $parentJob->getData(); if ($parentData instanceof kConvartableJobData) { $postConvertData->setCurrentOperationSet($parentData->getCurrentOperationSet()); $postConvertData->setCurrentOperationIndex($parentData->getCurrentOperationIndex()); } if ($createThumb) { $flavorParamsOutput = flavorParamsOutputPeer::retrieveByPK($flavorParamsOutputId); if (!$flavorParamsOutput) { $flavorAsset = flavorAssetPeer::retrieveById($flavorAssetId); if ($flavorAsset) { $postConvertData->setThumbHeight($flavorAsset->getHeight()); $postConvertData->setThumbBitrate($flavorAsset->getBitrate()); } else { $postConvertData->setCreateThumb(false); } } elseif (!$flavorParamsOutput->getVideoBitrate()) { $postConvertData->setCreateThumb(false); } else { $entry = $parentJob->getEntry(); $rootBatchJob = $parentJob->getRootJob(); if ($rootBatchJob && $rootBatchJob->getJobType() == BatchJobType::CONVERT_PROFILE) { $thisFlavorHeight = $flavorParamsOutput->getHeight(); $thisFlavorBitrate = $flavorParamsOutput->getVideoBitrate(); $rootBatchJobData = $rootBatchJob->getData(); $createThumb = false; if ($rootBatchJobData->getThumbBitrate() < $thisFlavorBitrate) { $createThumb = true; } elseif ($rootBatchJobData->getThumbBitrate() == $thisFlavorBitrate && $rootBatchJobData->getThumbHeight() < $thisFlavorHeight) { $createThumb = true; } if ($createThumb) { $postConvertData->setCreateThumb(true); $postConvertData->setThumbHeight($thisFlavorHeight); $postConvertData->setThumbBitrate($thisFlavorBitrate); } } elseif (!$entry->getThumbnailVersion()) { $thisFlavorHeight = $flavorParamsOutput->getHeight(); $thisFlavorBitrate = $flavorParamsOutput->getVideoBitrate(); $postConvertData->setCreateThumb(true); $postConvertData->setThumbHeight($thisFlavorHeight); $postConvertData->setThumbBitrate($thisFlavorBitrate); } } } KalturaLog::log("Post Convert created with file: " . $postConvertData->getSrcFileSyncLocalPath()); return kJobsManager::addJob($parentJob->createChild(), $postConvertData, BatchJobType::POSTCONVERT, $jobSubType); }
public static function handleConvertFailed(BatchJob $dbBatchJob, $engineType, $flavorAssetId, $flavorParamsOutputId, $mediaInfoId) { $flavorAsset = assetPeer::retrieveById($flavorAssetId); // verifies that flavor asset exists if (!$flavorAsset) { throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $flavorAssetId); } /* * On Webex error, roll back the inter-src asset version in order to allow the retry to get ARF as a source, * rather than the invlaid WMV file (product of bad nbrplayer session) */ if ($dbBatchJob->getErrNumber() == BatchJobAppErrors::BLACK_OR_SILENT_CONTENT) { $prevVer = $flavorAsset->getPreviousVersion(); $currVer = $flavorAsset->getVersion(); KalturaLog::log("Webex conversion - Garbled Audio or Black frame or Silence. Rolling back asset/file-sync version - curr({$currVer}), prev({$prevVer})"); if (isset($prevVer)) { $syncKey = $flavorAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET, $currVer); if (isset($syncKey)) { kFileSyncUtils::deleteSyncFileForKey($syncKey, false, true); $flavorAsset->setVersion($prevVer); $flavorAsset->setPreviousVersion(null); KalturaLog::log("Webex conversion - Rolled back"); } } } $flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR); $flavorAsset->save(); // try to create a convert job with the next engine if (!is_null($engineType)) { $data = $dbBatchJob->getData(); if ($data instanceof kConvartableJobData) { $data->incrementOperationSet(); $dbBatchJob->setData($data); $dbBatchJob->save(); } $newDbBatchJob = kBusinessPreConvertDL::redecideFlavorConvert($flavorAssetId, $flavorParamsOutputId, $mediaInfoId, $dbBatchJob, $engineType); if ($newDbBatchJob) { return true; } } // find the root job $rootBatchJob = $dbBatchJob->getRootJob(); if (!$rootBatchJob) { return false; } // the root is already failed if ($rootBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FAILED || $rootBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FATAL) { return false; } // bulk download root job no need to handle if ($rootBatchJob->getJobType() == BatchJobType::BULKDOWNLOAD) { kJobsManager::failBatchJob($rootBatchJob, "Convert job " . $dbBatchJob->getId() . " failed"); return false; } if (is_null($flavorParamsOutputId)) { kJobsManager::failBatchJob($rootBatchJob, "Job " . $dbBatchJob->getId() . " failed"); kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING); return false; } $readyBehavior = $dbBatchJob->getData()->getReadyBehavior(); if ($readyBehavior == flavorParamsConversionProfile::READY_BEHAVIOR_REQUIRED) { kJobsManager::failBatchJob($rootBatchJob, "Job " . $dbBatchJob->getId() . " failed"); kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING); return false; } // failing the root profile job if all child jobs failed if ($rootBatchJob->getJobType() != BatchJobType::CONVERT_PROFILE) { return false; } $siblingJobs = $rootBatchJob->getChildJobs(); foreach ($siblingJobs as $siblingJob) { /* @var $siblingJob BatchJob */ // not conversion job and should be ignored if ($siblingJob->getJobType() != BatchJobType::CONVERT && $siblingJob->getJobType() != BatchJobType::POSTCONVERT) { continue; } $jobData = $siblingJob->getData(); if (!$jobData || !$jobData instanceof kConvertJobData && !$jobData instanceof kPostConvertJobData) { KalturaLog::err("Job id [" . $siblingJob->getId() . "] has no valid job data"); continue; } // found child flavor asset that hasn't failed, no need to fail the root job $siblingFlavorAssetId = $jobData->getFlavorAssetId(); $siblingFlavorAsset = assetPeer::retrieveById($siblingFlavorAssetId); if ($siblingFlavorAsset && $siblingFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_ERROR && $siblingFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_NOT_APPLICABLE && $siblingFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_DELETED) { return false; } } // all conversions failed, should fail the root job kJobsManager::failBatchJob($rootBatchJob, "All conversions failed"); kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING); return false; }
/** * Returns the log file for bulk upload job * @param BatchJob $batchJob bulk upload batchjob * @return SimpleXMLElement */ public static function getBulkUploadMrssXml($batchJob) { $actionsMap = array(BulkUploadAction::ADD => 'add', BulkUploadAction::UPDATE => 'update', BulkUploadAction::DELETE => 'delete'); $bulkUploadResults = BulkUploadResultPeer::retrieveByBulkUploadId($batchJob->getId()); if (!count($bulkUploadResults)) { return null; } header("Content-Type: text/xml; charset=UTF-8"); $data = $batchJob->getData(); $xmlElement = new SimpleXMLElement('<mrss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>'); $xmlElement->addAttribute('version', '2.0'); // $xmlElement->addAttribute('xmlns:content', 'http://www.w3.org/2001/XMLSchema-instance'); // $xmlElement->addAttribute('xmlns', 'http://' . kConf::get('www_host') . '/' . SchemaType::SYNDICATION); // $xmlElement->addAttribute('xsi:noNamespaceSchemaLocation', 'http://' . kConf::get('cdn_host') . '/api_v3/service/schema/action/serve/type/' . SchemaType::SYNDICATION); $channel = $xmlElement->addChild('channel'); // insert all entries to instance pool $pks = array(); foreach ($bulkUploadResults as $bulkUploadResult) { /* @var $bulkUploadResult BulkUploadResult */ $pks[] = $bulkUploadResult->getEntryId(); } entryPeer::retrieveByPKs($pks); foreach ($bulkUploadResults as $bulkUploadResult) { /* @var $bulkUploadResult BulkUploadResult */ $item = $channel->addChild('item'); $result = $item->addChild('result'); $result->addChild('errorDescription', self::stringToSafeXml($bulkUploadResult->getErrorDescription())); // $result->addChild('entryStatus', self::stringToSafeXml($bulkUploadResult->getEntryStatus())); // $result->addChild('entryStatusName', self::stringToSafeXml($title)); $action = isset($actionsMap[$bulkUploadResult->getAction()]) ? $actionsMap[$bulkUploadResult->getAction()] : $actionsMap[BulkUploadAction::ADD]; $item->addChild('action', $action); $entry = $bulkUploadResult->getObject(); if (!$entry) { continue; } kMrssManager::getEntryMrssXml($entry, $item); } return $xmlElement; }
/** * @param BatchJob $dbBatchJob * @param kExtractMediaJobData $data * @param BatchJob $twinJob * @return BatchJob */ public static function handleExtractMediaClosed(BatchJob $dbBatchJob, kExtractMediaJobData $data, BatchJob $twinJob = null) { KalturaLog::debug("Extract media closed"); if ($dbBatchJob->getAbort()) { return $dbBatchJob; } $rootBatchJob = $dbBatchJob->getRootJob(); if (!$rootBatchJob) { return $dbBatchJob; } if ($twinJob) { // copy media info $twinData = $twinJob->getData(); if ($twinData->getMediaInfoId()) { $twinMediaInfo = mediaInfoPeer::retrieveByPK($twinData->getMediaInfoId()); if ($twinMediaInfo) { $mediaInfo = $twinMediaInfo->copy(); $mediaInfo->setFlavorAssetId($data->getFlavorAssetId()); $mediaInfo = kBatchManager::addMediaInfo($mediaInfo); $data->setMediaInfoId($mediaInfo->getId()); $dbBatchJob->setData($data); $dbBatchJob->save(); } } } if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED) { $entry = entryPeer::retrieveByPKNoFilter($dbBatchJob->getEntryId()); if ($entry->getStatus() != entryStatus::READY && $entry->getStatus() != entryStatus::DELETED) { kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::PRECONVERT); } } if ($rootBatchJob->getJobType() == BatchJobType::CONVERT_PROFILE) { kBusinessPreConvertDL::decideProfileConvert($dbBatchJob, $rootBatchJob, $data->getMediaInfoId()); // handle the source flavor as if it was converted, makes the entry ready according to ready behavior rules $currentFlavorAsset = assetPeer::retrieveById($data->getFlavorAssetId()); if ($currentFlavorAsset && $currentFlavorAsset->getStatus() == asset::FLAVOR_ASSET_STATUS_READY) { $dbBatchJob = kBusinessPostConvertDL::handleConvertFinished($dbBatchJob, $currentFlavorAsset); } } return $dbBatchJob; }
/** * Returns the log file for bulk upload job * @param BatchJob $batchJob bulk upload batchjob */ public static function writeBulkUploadLogFile($batchJob) { if ($batchJob->getJobSubType() && $batchJob->getJobSubType() != self::getBulkUploadTypeCoreValue(BulkUploadFilterType::FILTER)) { return; } //TODO: header("Content-Type: text/plain; charset=UTF-8"); $criteria = new Criteria(); $criteria->add(BulkUploadResultPeer::BULK_UPLOAD_JOB_ID, $batchJob->getId()); $criteria->addAscendingOrderByColumn(BulkUploadResultPeer::LINE_INDEX); $criteria->setLimit(100); $bulkUploadResults = BulkUploadResultPeer::doSelect($criteria); if (!count($bulkUploadResults)) { die("Log file is not ready"); } $STDOUT = fopen('php://output', 'w'); $data = $batchJob->getData(); /* @var $data kBulkUploadFilterJobData */ $handledResults = 0; while (count($bulkUploadResults)) { $handledResults += count($bulkUploadResults); foreach ($bulkUploadResults as $bulkUploadResult) { $values = array(); $values['bulkUploadResultStatus'] = $bulkUploadResult->getStatus(); $values['objectId'] = $bulkUploadResult->getObjectId(); $values['objectStatus'] = $bulkUploadResult->getObjectStatus(); $values['errorDescription'] = preg_replace('/[\\n\\r\\t]/', ' ', $bulkUploadResult->getErrorDescription()); fwrite($STDOUT, print_r($values, true)); } if (count($bulkUploadResults) < $criteria->getLimit()) { break; } kMemoryManager::clearMemory(); $criteria->setOffset($handledResults); $bulkUploadResults = BulkUploadResultPeer::doSelect($criteria); } fclose($STDOUT); kFile::closeDbConnections(); exit; }
/** * batch decideProfileConvert is the decision layer for a conversion profile * * @param BatchJob $parentJob * @param BatchJob $convertProfileJob * @param int $mediaInfoId * @return bool true if created all required conversions */ public static function decideProfileConvert(BatchJob $parentJob, BatchJob $convertProfileJob, $mediaInfoId = null) { KalturaLog::log("Conversion decision layer used for entry [" . $parentJob->getEntryId() . "]"); $convertProfileData = $convertProfileJob->getData(); $entryId = $convertProfileJob->getEntryId(); $entry = $convertProfileJob->getEntry(); if (!$entry) { throw new APIException(APIErrors::INVALID_ENTRY, $convertProfileJob, $entryId); } $profile = myPartnerUtils::getConversionProfile2ForEntry($entryId); if (!$profile) { $errDescription = "Conversion profile for entryId [{$entryId}] not found"; $convertProfileJob = kJobsManager::failBatchJob($convertProfileJob, $errDescription, BatchJobType::CONVERT_PROFILE); kBatchManager::updateEntry($convertProfileJob, entryStatus::ERROR_CONVERTING); KalturaLog::err("No flavors created: {$errDescription}"); return false; } $originalFlavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($entryId); if (is_null($originalFlavorAsset)) { $errDescription = 'Original flavor asset not found'; KalturaLog::err($errDescription); $convertProfileJob = kJobsManager::failBatchJob($convertProfileJob, $errDescription, BatchJobType::CONVERT_PROFILE); kBatchManager::updateEntry($convertProfileJob, entryStatus::ERROR_CONVERTING); return false; } $shouldConvert = true; // gets the list of flavor params of the conversion profile $list = flavorParamsConversionProfilePeer::retrieveByConversionProfile($profile->getId()); if (!count($list)) { $errDescription = "No flavors match the profile id [{$profile->getId()}]"; KalturaLog::err($errDescription); $convertProfileJob = kJobsManager::failBatchJob($convertProfileJob, $errDescription, BatchJobType::CONVERT_PROFILE); kBatchManager::updateEntry($convertProfileJob, entryStatus::ERROR_CONVERTING); $originalFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_DELETED); $originalFlavorAsset->setDeletedAt(time()); $originalFlavorAsset->save(); return false; } $mediaInfo = null; if ($mediaInfoId) { $mediaInfo = mediaInfoPeer::retrieveByPK($mediaInfoId); } if ($profile->getCreationMode() == ConversionProfile2::CONVERSION_PROFILE_2_CREATION_MODE_AUTOMATIC_BYPASS_FLV) { KalturaLog::log("The profile created from old conversion profile with bypass flv"); $isFlv = false; if ($mediaInfo) { $isFlv = KDLWrap::CDLIsFLV($mediaInfo); } if ($isFlv && $originalFlavorAsset->hasTag(flavorParams::TAG_MBR)) { KalturaLog::log("The source is mbr and flv, conversion will be bypassed"); $shouldConvert = false; } else { KalturaLog::log("The source is NOT mbr or flv, conversion will NOT be bypassed"); } } // gets the ids of the flavor params $flavorsIds = array(); $conversionProfileFlavorParams = array(); foreach ($list as $flavorParamsConversionProfile) { $flavorsId = $flavorParamsConversionProfile->getFlavorParamsId(); $flavorsIds[] = $flavorsId; $conversionProfileFlavorParams[$flavorsId] = $flavorParamsConversionProfile; } $dynamicFlavorAttributes = $entry->getDynamicFlavorAttributes(); $sourceFlavor = null; $flavors = flavorParamsPeer::retrieveByPKs($flavorsIds); foreach ($flavors as $index => $flavor) { if (isset($dynamicFlavorAttributes[$flavor->getId()])) { foreach ($dynamicFlavorAttributes[$flavor->getId()] as $attributeName => $attributeValue) { $flavor->setDynamicAttribute($attributeName, $attributeValue); } } if ($flavor->hasTag(flavorParams::TAG_SOURCE)) { $sourceFlavor = $flavor; unset($flavors[$index]); } } KalturaLog::log(count($flavors) . " destination flavors found for this profile[" . $profile->getId() . "]"); if (!$sourceFlavor) { KalturaLog::log("Source flavor params not found"); $originalFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_TEMP); $originalFlavorAsset->save(); } elseif ($shouldConvert) { KalturaLog::log("Source flavor params [" . $sourceFlavor->getId() . "] found"); $originalFlavorAsset->setFlavorParamsId($sourceFlavor->getId()); if ($sourceFlavor->getOperators() || $sourceFlavor->getConversionEngines()) { KalturaLog::log("Source flavor asset requires conversion"); $srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $errDescription = null; $sourceFlavorOutput = self::validateFlavorAndMediaInfo($sourceFlavor, $mediaInfo, $errDescription); // save flavor params $sourceFlavorOutput->setPartnerId($sourceFlavorOutput->getPartnerId()); $sourceFlavorOutput->setEntryId($entryId); $sourceFlavorOutput->setFlavorAssetId($originalFlavorAsset->getId()); $sourceFlavorOutput->setFlavorAssetVersion($originalFlavorAsset->getVersion()); $sourceFlavorOutput->save(); if ($errDescription) { $originalFlavorAsset->setDescription($originalFlavorAsset->getDescription() . "\n{$errDescription}"); } $errDescription = kBusinessConvertDL::parseFlavorDescription($sourceFlavorOutput); if ($errDescription) { $originalFlavorAsset->setDescription($originalFlavorAsset->getDescription() . "\n{$errDescription}"); } // decided by the business logic layer if ($sourceFlavorOutput->_create_anyway) { KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] selected to be created anyway"); } else { if (!$sourceFlavorOutput->IsValid()) { KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is invalid"); $originalFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR); $originalFlavorAsset->save(); $errDescription = "Source flavor could not be converted"; KalturaLog::err($errDescription); $convertProfileJob = kJobsManager::failBatchJob($convertProfileJob, $errDescription, BatchJobType::CONVERT_PROFILE); kBatchManager::updateEntry($convertProfileJob, entryStatus::ERROR_CONVERTING); return false; } if ($sourceFlavorOutput->_force) { KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is forced"); } elseif ($sourceFlavorOutput->_isNonComply) { KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is none-comply"); } else { KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is valid"); } } $originalFlavorAsset->incrementVersion(); $originalFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_QUEUED); $originalFlavorAsset->addTags($sourceFlavor->getTagsArray()); $originalFlavorAsset->setFileExt($sourceFlavorOutput->getFileExt()); $originalFlavorAsset->save(); // save flavor params $sourceFlavorOutput->setFlavorAssetVersion($originalFlavorAsset->getVersion()); $sourceFlavorOutput->save(); kJobsManager::addFlavorConvertJob($srcSyncKey, $sourceFlavorOutput, $originalFlavorAsset->getId(), $mediaInfoId, $parentJob); return false; } $originalFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_READY); $originalFlavorAsset->save(); $entry->addFlavorParamsId($sourceFlavor->getId()); $entry->save(); kFlowHelper::generateThumbnailsFromFlavor($parentJob->getEntryId(), $parentJob); } if (!count($flavors)) { $shouldConvert = false; } if (!$shouldConvert) { self::bypassConversion($originalFlavorAsset, $entry, $convertProfileJob); return true; } return self::decideProfileFlavorsConvert($parentJob, $convertProfileJob, $flavors, $conversionProfileFlavorParams, $mediaInfo); }
public function updatedJob(BatchJob $dbBatchJob) { $data = $dbBatchJob->getData(); $providerData = $data->getProviderData(); $entryId = $providerData->getEntryId(); $partnerId = $dbBatchJob->getPartnerId(); $spokenLanguage = $providerData->getSpokenLanguage(); $transcript = $this->getAssetsByLanguage($entryId, array(TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT)), $spokenLanguage, true); if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FAILED) { if ($transcript) { $transcript->setStatus(AttachmentAsset::FLAVOR_ASSET_STATUS_ERROR); $transcript->save(); } } if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_DONT_PROCESS) { if (!$transcript) { $transcript = new TranscriptAsset(); $transcript->setType(TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT)); $transcript->setEntryId($entryId); $transcript->setPartnerId($partnerId); $transcript->setLanguage($spokenLanguage); $transcript->setContainerFormat(AttachmentType::TEXT); } $transcript->setStatus(AttachmentAsset::ASSET_STATUS_QUEUED); $transcript->save(); return true; } $formatsString = $providerData->getCaptionAssetFormats(); if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED) { $clientHelper = Cielo24Plugin::getClientHelper($providerData->getUsername(), $providerData->getPassword()); $remoteJobId = $clientHelper->getRemoteFinishedJobId($entryId); if (!$remoteJobId) { KalturaLog::err('remote content does not exist'); return true; } $formatsArray = explode(',', $formatsString); $transcriptContent = $clientHelper->getRemoteTranscript($remoteJobId); KalturaLog::debug("transcript content - {$transcriptContent}"); $captionsContentArray = $clientHelper->getRemoteCaptions($remoteJobId, $formatsArray); KalturaLog::debug("captions content - " . print_r($captionsContentArray, true)); $captions = $this->getAssetsByLanguage($entryId, array(CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)), $spokenLanguage); switch ($providerData->getFidelity()) { case KalturaCielo24Fidelity::MECHANICAL: $accuracyRate = self::MECHNICAL_TRANSCRIPTION_ACCURACY_VALUE; break; case KalturaCielo24Fidelity::PREMIUM: $accuracyRate = self::PREMIUM_TRANSCRIPTION_ACCURACY_VALUE; break; case KalturaCielo24Fidelity::PROFESSIONAL: $accuracyRate = self::PROFESSIONAL_TRANSCRIPTION_ACCURACY_VALUE; break; } $this->setObjectContent($transcript, $transcriptContent, $accuracyRate, null, true); foreach ($captionsContentArray as $format => $content) { $captionFormatConst = constant("KalturaCaptionType::" . $format); if (isset($captions[$captionFormatConst])) { $caption = $captions[$captionFormatConst]; } else { $caption = new CaptionAsset(); $caption->setEntryId($entryId); $caption->setPartnerId($partnerId); $caption->setLanguage($spokenLanguage); $caption->setContainerFormat($captionFormatConst); $caption->setStatus(CaptionAsset::ASSET_STATUS_QUEUED); $caption->save(); } $this->setObjectContent($caption, $content, $accuracyRate, $format); } } return true; }
/** * Returns the log file for bulk upload job * @param BatchJob $batchJob bulk upload batchjob * @param bool $addHeaderRow flag signifying whether the header row should be added to the CSV. Default value is false. */ public static function writeBulkUploadLogFile($batchJob, $addHeaderRow = false) { if ($batchJob->getJobSubType() != null && $batchJob->getJobSubType() != self::getBulkUploadTypeCoreValue(BulkUploadCsvType::CSV)) { return; } header("Content-Type: text/plain; charset=UTF-8"); $bulkUploadResults = BulkUploadResultPeer::retrieveByBulkUploadId($batchJob->getId()); if (!count($bulkUploadResults)) { die("Log file is not ready"); } $STDOUT = fopen('php://output', 'w'); $data = $batchJob->getData(); /* @var $data kBulkUploadJobData */ //Add header row to the output CSV if ($addHeaderRow) { $headerRow = self::getHeaderRow($data->getBulkUploadObjectType()); $headerRow[] = "action"; $headerRow[] = "resultStatus"; $headerRow[] = "objectId"; $headerRow[] = "objectStatus"; $headerRow[] = "errorDescription"; fputcsv($STDOUT, $headerRow); } foreach ($bulkUploadResults as $bulkUploadResult) { /* @var $bulkUploadResult BulkUploadResult */ switch ($bulkUploadResult->getObjectType()) { case BulkUploadObjectType::ENTRY: $values = self::writeEntryBulkUploadResults($bulkUploadResult, $data); break; case BulkUploadObjectType::CATEGORY: $values = self::writeCategoryBulkUploadResults($bulkUploadResult, $data); break; case BulkUploadObjectType::CATEGORY_USER: $values = self::writeCategoryUserBulkUploadResults($bulkUploadResult, $data); break; case BulkUploadObjectType::USER: $values = self::writeUserBulkUploadResults($bulkUploadResult, $data); break; default: break; } $values[] = $bulkUploadResult->getAction(); $values[] = $bulkUploadResult->getStatus(); $values[] = $bulkUploadResult->getObjectId(); $values[] = $bulkUploadResult->getObjectStatus(); $values[] = preg_replace('/[\\n\\r\\t]/', ' ', $bulkUploadResult->getErrorDescription()); fputcsv($STDOUT, $values); } fclose($STDOUT); kFile::closeDbConnections(); exit; }
public function shouldConsumeJobStatusEvent(BatchJob $dbBatchJob) { $jobType = $dbBatchJob->getJobType(); $data = $dbBatchJob->getData(); // copy cue points only if it's the first file and this is the primary server if ($jobType == BatchJobType::CONVERT_LIVE_SEGMENT && $dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED && $data->getFileIndex() == 0 && $data->getMediaServerIndex() == MediaServerIndex::PRIMARY) { $asset = assetPeer::retrieveByIdNoFilter($data->getAssetId()); if ($asset->hasTag(assetParams::TAG_RECORDING_ANCHOR)) { return true; } } elseif ($jobType == BatchJobType::CONCAT && $dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED) { $convertLiveSegmentJobData = $dbBatchJob->getParentJob()->getData(); $asset = assetPeer::retrieveByIdNoFilter($convertLiveSegmentJobData->getAssetId()); if ($asset->hasTag(assetParams::TAG_RECORDING_ANCHOR)) { return true; } } return false; }
/** * Returns the log file for bulk upload job * @param BatchJob $batchJob bulk upload batchjob * @return SimpleXMLElement */ public static function getBulkUploadMrssXml($batchJob) { $actionsMap = array(BulkUploadAction::ADD => 'add', BulkUploadAction::UPDATE => 'update', BulkUploadAction::DELETE => 'delete'); $criteria = new Criteria(); $criteria->add(BulkUploadResultPeer::BULK_UPLOAD_JOB_ID, $batchJob->getId()); $criteria->addAscendingOrderByColumn(BulkUploadResultPeer::LINE_INDEX); $criteria->setLimit(100); $bulkUploadResults = BulkUploadResultPeer::doSelect($criteria); if (!count($bulkUploadResults)) { return null; } header("Content-Type: text/xml; charset=UTF-8"); $data = $batchJob->getData(); $xmlElement = new SimpleXMLElement('<mrss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>'); $xmlElement->addAttribute('version', '2.0'); $channel = $xmlElement->addChild('channel'); $handledResults = 0; while (count($bulkUploadResults)) { $handledResults += count($bulkUploadResults); // insert all entries to instance pool $pks = array(); foreach ($bulkUploadResults as $bulkUploadResult) { /* @var $bulkUploadResult BulkUploadResult */ $pks[] = $bulkUploadResult->getEntryId(); } entryPeer::retrieveByPKs($pks); foreach ($bulkUploadResults as $bulkUploadResult) { /* @var $bulkUploadResult BulkUploadResult */ $item = $channel->addChild('item'); $result = $item->addChild('result'); $result->addChild('errorDescription', self::stringToSafeXml($bulkUploadResult->getErrorDescription())); // $result->addChild('entryStatus', self::stringToSafeXml($bulkUploadResult->getEntryStatus())); // $result->addChild('entryStatusName', self::stringToSafeXml($title)); $action = isset($actionsMap[$bulkUploadResult->getAction()]) ? $actionsMap[$bulkUploadResult->getAction()] : $actionsMap[BulkUploadAction::ADD]; $item->addChild('action', $action); $entry = $bulkUploadResult->getObject(); if (!$entry) { continue; } kMrssManager::getEntryMrssXml($entry, $item); } if (count($bulkUploadResults) < $criteria->getLimit()) { break; } kMemoryManager::clearMemory(); $criteria->setOffset($handledResults); $bulkUploadResults = BulkUploadResultPeer::doSelect($criteria); } return $xmlElement; }
private function isImportMatch(BatchJob $dbBatchJob) { $jobStatuses = array(BatchJob::BATCHJOB_STATUS_FINISHED, BatchJob::BATCHJOB_STATUS_FAILED, BatchJob::BATCHJOB_STATUS_FATAL); $isMatch = $dbBatchJob->getJobType() == BatchJobType::IMPORT && $dbBatchJob->getData() instanceof kDropFolderImportJobData && in_array($dbBatchJob->getStatus(), $jobStatuses); return $isMatch; }
public function toData(BatchJob $dbBatchJob) { $dbData = null; if (is_null($this->jobType)) { $this->jobType = kPluginableEnumsManager::coreToApi('BatchJobType', $dbBatchJob->getJobType()); } switch ($dbBatchJob->getJobType()) { case KalturaBatchJobType::BULKUPLOAD: $dbData = new kBulkUploadJobData(); if (is_null($this->data)) { $this->data = new KalturaBulkUploadJobData(); } break; case KalturaBatchJobType::CONVERT: $dbData = new kConvertJobData(); if (is_null($this->data)) { $this->data = new KalturaConvertJobData(); } break; case KalturaBatchJobType::CONVERT_PROFILE: $dbData = new kConvertProfileJobData(); if (is_null($this->data)) { $this->data = new KalturaConvertProfileJobData(); } break; case KalturaBatchJobType::EXTRACT_MEDIA: $dbData = new kExtractMediaJobData(); if (is_null($this->data)) { $this->data = new KalturaExtractMediaJobData(); } break; case KalturaBatchJobType::IMPORT: $dbData = new kImportJobData(); if (is_null($this->data)) { $this->data = new KalturaImportJobData(); } break; case KalturaBatchJobType::POSTCONVERT: $dbData = new kPostConvertJobData(); if (is_null($this->data)) { $this->data = new KalturaPostConvertJobData(); } break; case KalturaBatchJobType::PULL: $dbData = new kPullJobData(); if (is_null($this->data)) { $this->data = new KalturaPullJobData(); } break; case KalturaBatchJobType::REMOTE_CONVERT: $dbData = new kRemoteConvertJobData(); if (is_null($this->data)) { $this->data = new KalturaRemoteConvertJobData(); } break; case KalturaBatchJobType::MAIL: $dbData = new kMailJobData(); if (is_null($this->data)) { $this->data = new KalturaMailJobData(); } break; case KalturaBatchJobType::NOTIFICATION: $dbData = new kNotificationJobData(); if (is_null($this->data)) { $this->data = new KalturaNotificationJobData(); } break; case KalturaBatchJobType::BULKDOWNLOAD: $dbData = new kBulkDownloadJobData(); if (is_null($this->data)) { $this->data = new KalturaBulkDownloadJobData(); } break; case KalturaBatchJobType::FLATTEN: $dbData = new kFlattenJobData(); if (is_null($this->data)) { $this->data = new KalturaFlattenJobData(); } break; case KalturaBatchJobType::PROVISION_PROVIDE: case KalturaBatchJobType::PROVISION_DELETE: $dbData = new kProvisionJobData(); if (is_null($this->data)) { $this->data = new KalturaProvisionJobData(); } break; case KalturaBatchJobType::CONVERT_COLLECTION: $dbData = new kConvertCollectionJobData(); if (is_null($this->data)) { $this->data = new KalturaConvertCollectionJobData(); } break; case KalturaBatchJobType::STORAGE_EXPORT: $dbData = new kStorageExportJobData(); if (is_null($this->data)) { $this->data = new KalturaStorageExportJobData(); } break; case KalturaBatchJobType::STORAGE_DELETE: $dbData = new kStorageDeleteJobData(); if (is_null($this->data)) { $this->data = new KalturaStorageDeleteJobData(); } break; case KalturaBatchJobType::CAPTURE_THUMB: $dbData = new kCaptureThumbJobData(); if (is_null($this->data)) { $this->data = new KalturaCaptureThumbJobData(); } break; default: $dbData = KalturaPluginManager::loadObject('kJobData', $dbBatchJob->getJobType()); if (is_null($this->data)) { $this->data = KalturaPluginManager::loadObject('KalturaJobData', $this->jobType); } } if (is_null($dbBatchJob->getData())) { $dbBatchJob->setData($dbData); } if ($this->data instanceof KalturaJobData) { $dbData = $this->data->toObject($dbBatchJob->getData()); $dbBatchJob->setData($dbData); } return $dbData; }