Beispiel #1
0
 public static function abortDbBatchJob(BatchJob $dbBatchJob, $force = false)
 {
     // No need to abort finished job
     if (in_array($dbBatchJob->getStatus(), BatchJobPeer::getClosedStatusList())) {
         if ($force) {
             $dbBatchJob->setExecutionStatus(BatchJobExecutionStatus::ABORTED);
             $dbBatchJob->save();
         }
         return $dbBatchJob;
     }
     $lockObject = $dbBatchJob->getBatchJobLock();
     if (is_null($lockObject)) {
         KalturaLog::err("Batch job [" . $dbBatchJob->getId() . "] doesn't have a lock object and can't be deleted. Status (" . $dbBatchJob->getStatus() . ")");
         return $dbBatchJob;
     }
     // Update status
     $con = Propel::getConnection();
     $update = new Criteria();
     $update->add(BatchJobLockPeer::STATUS, BatchJob::BATCHJOB_STATUS_ABORTED);
     $update->add(BatchJobLockPeer::VERSION, $lockObject->getVersion() + 1);
     $updateCondition = new Criteria();
     $updateCondition->add(BatchJobLockPeer::ID, $lockObject->getId(), Criteria::EQUAL);
     $updateCondition->add(BatchJobLockPeer::VERSION, $lockObject->getVersion(), Criteria::EQUAL);
     $updateCondition->add(BatchJobLockPeer::SCHEDULER_ID, null, Criteria::ISNULL);
     $affectedRows = BasePeer::doUpdate($updateCondition, $update, $con);
     if ($affectedRows) {
         $dbBatchJob->setExecutionStatus(BatchJobExecutionStatus::ABORTED);
         $dbBatchJob = self::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_ABORTED);
     } else {
         $dbBatchJob->setExecutionStatus(BatchJobExecutionStatus::ABORTED);
         $dbBatchJob->save();
     }
     self::abortChildJobs($dbBatchJob);
     return $dbBatchJob;
 }
 /**
  * @param kBatchJobStatusEventConsumer $consumer
  * @return bool true if should continue to the next consumer
  */
 protected function doConsume(KalturaEventConsumer $consumer)
 {
     if (!$consumer->shouldConsumeJobStatusEvent($this->dbBatchJob)) {
         return true;
     }
     KalturaLog::debug(get_class($this) . " event consumed by " . get_class($consumer) . " job id [" . $this->dbBatchJob->getId() . "] type [" . $this->dbBatchJob->getJobType() . "] sub type [" . $this->dbBatchJob->getJobSubType() . "] status [" . $this->dbBatchJob->getStatus() . "]");
     return $consumer->updatedJob($this->dbBatchJob, $this->twinJob);
 }
 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;
 }
 protected function doConsume(KalturaEventConsumer $consumer)
 {
     if (!$consumer->shouldConsumeIntegrationCloseEvent($this->object, $this->modifiedColumns)) {
         return true;
     }
     KalturaLog::debug('consumer [' . get_class($consumer) . '] started handling [' . get_class($this) . '] batch-job id [' . $this->batchJob->getId() . '] status [' . $this->batchJob->getStatus() . ']');
     $result = $consumer->integrationJobClosed($this->batchJob);
     KalturaLog::debug('consumer [' . get_class($consumer) . '] finished handling [' . get_class($this) . '] batch-job id [' . $this->batchJob->getId() . '] status [' . $this->batchJob->getStatus() . ']');
     return $result;
 }
 /**
  * @param kBatchJobStatusEventConsumer $consumer
  * @return bool true if should continue to the next consumer
  */
 protected function doConsume(KalturaEventConsumer $consumer)
 {
     if (!$consumer->shouldConsumeJobStatusEvent($this->dbBatchJob)) {
         return true;
     }
     KalturaLog::debug('consumer [' . get_class($consumer) . '] started handling [' . get_class($this) . '] job id [' . $this->dbBatchJob->getId() . '] type [' . $this->dbBatchJob->getJobType() . '] sub type [' . $this->dbBatchJob->getJobSubType() . '] status [' . $this->dbBatchJob->getStatus() . ']');
     $result = $consumer->updatedJob($this->dbBatchJob);
     KalturaLog::debug('consumer [' . get_class($consumer) . '] finished handling [' . get_class($this) . '] job id [' . $this->dbBatchJob->getId() . '] type [' . $this->dbBatchJob->getJobType() . '] sub type [' . $this->dbBatchJob->getJobSubType() . '] status [' . $this->dbBatchJob->getStatus() . ']');
     return $result;
 }
 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;
 }
 public function updatedJob(BatchJob $dbBatchJob, BatchJob $twinJob = null)
 {
     if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED) {
         return self::onDistributionJobFinished($dbBatchJob);
     }
     return true;
 }
 public function shouldConsumeJobStatusEvent(BatchJob $dbBatchJob)
 {
     if ($dbBatchJob->getJobType() != IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION)) {
         return false;
     }
     $closedStatusList = array(BatchJob::BATCHJOB_STATUS_FINISHED, BatchJob::BATCHJOB_STATUS_FAILED, BatchJob::BATCHJOB_STATUS_ABORTED, BatchJob::BATCHJOB_STATUS_FATAL, BatchJob::BATCHJOB_STATUS_FINISHED_PARTIALLY);
     return in_array($dbBatchJob->getStatus(), $closedStatusList);
 }
 /**
  * @param BatchJob $dbBatchJob
  * @param kDistributionJobData $data
  * @param BatchJob $twinJob
  * @return BatchJob
  */
 public static function onDistributionJobUpdated(BatchJob $dbBatchJob, kDistributionJobData $data, BatchJob $twinJob = null)
 {
     switch ($dbBatchJob->getStatus()) {
         case BatchJob::BATCHJOB_STATUS_ALMOST_DONE:
             return self::onDistributionJobUpdatedAlmostDone($dbBatchJob, $data, $twinJob);
         default:
             return $dbBatchJob;
     }
 }
 /**
  * @param BatchJob $dbBatchJob
  * @param kDistributionJobData $data
  * @return BatchJob
  */
 public static function onDistributionJobUpdated(BatchJob $dbBatchJob, kDistributionJobData $data)
 {
     switch ($dbBatchJob->getStatus()) {
         case BatchJob::BATCHJOB_STATUS_FINISHED:
             return self::onDistributionJobFinished($dbBatchJob, $data);
         default:
             return $dbBatchJob;
     }
 }
 public function shouldConsumeJobStatusEvent(BatchJob $dbBatchJob)
 {
     if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FAILED) {
         $parseMultiBatchJobType = CaptionPlugin::getBatchJobTypeCoreValue(ParseMultiLanguageCaptionAssetBatchType::PARSE_MULTI_LANGUAGE_CAPTION_ASSET);
         if ($dbBatchJob->getJobType() == $parseMultiBatchJobType) {
             return true;
         }
     }
     return false;
 }
 /**
  * @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;
     }
 }
 protected function updatedImport(BatchJob $dbBatchJob, kDropFolderImportJobData $data, BatchJob $twinJob = null)
 {
     switch ($dbBatchJob->getStatus()) {
         case BatchJob::BATCHJOB_STATUS_FINISHED:
             return $this->updatedImportFinished($dbBatchJob, $data, $twinJob);
         case BatchJob::BATCHJOB_STATUS_FAILED:
         case BatchJob::BATCHJOB_STATUS_FATAL:
             return $this->updatedImportFailed($dbBatchJob, $data, $twinJob);
         default:
             return $dbBatchJob;
     }
 }
 public function shouldConsumeJobStatusEvent(BatchJob $dbBatchJob)
 {
     if ($dbBatchJob->getJobType() != EventNotificationPlugin::getBatchJobTypeCoreValue(EventNotificationBatchType::EVENT_NOTIFICATION_HANDLER)) {
         return false;
     }
     if ($dbBatchJob->getJobSubType() != BusinessProcessNotificationPlugin::getBusinessProcessNotificationTemplateTypeCoreValue(BusinessProcessNotificationTemplateType::BPM_START)) {
         return false;
     }
     if ($dbBatchJob->getStatus() != BatchJob::BATCHJOB_STATUS_FINISHED) {
         return false;
     }
     return true;
 }
 protected function updatedTransformMetadata(BatchJob $dbBatchJob, kTransformMetadataJobData $data, BatchJob $twinJob = null)
 {
     switch ($dbBatchJob->getStatus()) {
         case BatchJob::BATCHJOB_STATUS_PENDING:
             return $this->updatedTransformMetadataPending($dbBatchJob, $data, $twinJob);
         case BatchJob::BATCHJOB_STATUS_FINISHED:
             return $this->updatedTransformMetadataFinished($dbBatchJob, $data, $twinJob);
         case BatchJob::BATCHJOB_STATUS_FAILED:
         case BatchJob::BATCHJOB_STATUS_FATAL:
             return $this->updatedTransformMetadataFailed($dbBatchJob, $data, $twinJob);
         default:
             return $dbBatchJob;
     }
 }
 protected function updatedFileSyncImport(BatchJob $dbBatchJob, kFileSyncImportJobData $data, BatchJob $twinJob = null)
 {
     switch ($dbBatchJob->getStatus()) {
         // success
         case BatchJob::BATCHJOB_STATUS_FINISHED:
             return $this->updatedFileSyncImportFinished($dbBatchJob, $data, $twinJob);
             // failure
         // failure
         case BatchJob::BATCHJOB_STATUS_ABORTED:
         case BatchJob::BATCHJOB_STATUS_FATAL:
         case BatchJob::BATCHJOB_STATUS_FAILED:
             return $this->updatedFileSyncImportFailed($dbBatchJob, $data, $twinJob);
         default:
             return $dbBatchJob;
     }
 }
 public static function abortDbBatchJob(BatchJob $dbBatchJob, $force = false)
 {
     if (!$force && in_array($dbBatchJob->getStatus(), BatchJobPeer::getClosedStatusList())) {
         return $dbBatchJob;
     }
     $dbBatchJob->setAbort(1);
     // 1 = true
     // if not currently locked
     if (!$dbBatchJob->getSchedulerId()) {
         $dbBatchJob = self::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_ABORTED);
     } else {
         $dbBatchJob->save();
     }
     // aborts all child jobs
     self::abortChildJobs($dbBatchJob);
     return $dbBatchJob;
 }
Beispiel #18
0
 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;
 }
 private function onBulkUploadJobStatusUpdated(BatchJob $dbBatchJob)
 {
     $xmlDropFolderFile = DropFolderFilePeer::retrieveByPK($dbBatchJob->getObjectId());
     if (!$xmlDropFolderFile) {
         return;
     }
     KalturaLog::debug('object id ' . $dbBatchJob->getObjectId());
     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:
             KalturaLog::debug("Handling Bulk Upload finished");
             $xmlDropFolderFile->setStatus(DropFolderFileStatus::HANDLED);
             $xmlDropFolderFile->save();
             break;
         case BatchJob::BATCHJOB_STATUS_FAILED:
         case BatchJob::BATCHJOB_STATUS_FATAL:
             KalturaLog::debug("Handling Bulk Upload failed");
             $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 updatedJob(BatchJob $dbBatchJob, BatchJob $twinJob = null)
 {
     if ($dbBatchJob->getStatus() != BatchJob::BATCHJOB_STATUS_PENDING) {
         return true;
     }
     if ($dbBatchJob->getJobType() == BatchJobType::PROVISION_PROVIDE) {
         $entry = $dbBatchJob->getEntry(false, false);
         $partner = $entry->getPartner();
         $limeLightLiveParamsJSON = $partner->getLiveStreamProvisionParams();
         $limeLightLiveParams = json_decode($limeLightLiveParamsJSON);
         if (!isset($limeLightLiveParams->Limelight) || !isset($limeLightLiveParams->Limelight->limelightPrimaryPublishUrl) || !isset($limeLightLiveParams->Limelight->limelightSecondaryPublishUrl) || !isset($limeLightLiveParams->Limelight->limelightStreamUrl)) {
             kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_FAILED);
             return true;
         }
         $data = $dbBatchJob->getData();
         $data->setPrimaryBroadcastingUrl($limeLightLiveParams->Limelight->limelightPrimaryPublishUrl);
         $data->setSecondaryBroadcastingUrl($limeLightLiveParams->Limelight->limelightSecondaryPublishUrl);
         $data->setRtmp($limeLightLiveParams->Limelight->limelightStreamUrl);
         $data->setStreamName($entry->getId() . '_%i');
         $dbBatchJob->setData($data);
     }
     kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_FINISHED);
     return true;
 }
 /**
  * Update all the drop folder files processed by the batch job according to batch job status:
  * 1. Retry - set files status to NO_MATCH
  * 2. Failure - set to ERROR_HANDLING
  * @param BatchJob $dbBatchJob
  * @param kDropFolderContentProcessorJobData $data
  */
 private function onContentProcessorJobStatusUpdated(BatchJob $dbBatchJob, kDropFolderContentProcessorJobData $data)
 {
     $idsArray = explode(',', $data->getDropFolderFileIds());
     $dropFolderFiles = DropFolderFilePeer::retrieveByPKs($idsArray);
     if (!$dropFolderFiles) {
         return;
     }
     switch ($dbBatchJob->getStatus()) {
         case BatchJob::BATCHJOB_STATUS_RETRY:
             //TODO: check  error code
             KalturaLog::info('Batch job status RETRY => set files [' . $data->getDropFolderFileIds() . '] to NO_MATCH');
             foreach ($dropFolderFiles as $dropFolderFile) {
                 $dropFolderFile->setStatus(DropFolderFileStatus::NO_MATCH);
                 $dropFolderFile->save();
             }
             break;
         case BatchJob::BATCHJOB_STATUS_FAILED:
         case BatchJob::BATCHJOB_STATUS_FATAL:
             KalturaLog::info('Batch job FAILED => set files [' . $data->getDropFolderFileIds() . '] to ERROR_HANDLING');
             foreach ($dropFolderFiles as $dropFolderFile) {
                 $this->setFileError($dropFolderFile, DropFolderFileStatus::ERROR_HANDLING, DropFolderFileErrorCode::ERROR_IN_CONTENT_PROCESSOR, DropFolderPlugin::ERROR_IN_CONTENT_PROCESSOR_MESSAGE);
             }
             break;
     }
 }
Beispiel #24
0
 /**
  * @param BatchJob $dbBatchJob
  * @param BatchJob $twinJob
  * @return bool true if should continue to the next consumer
  */
 public function updatedJob(BatchJob $dbBatchJob, BatchJob $twinJob = null)
 {
     if ($dbBatchJob->getStatus() != BatchJob::BATCHJOB_STATUS_FINISHED) {
         return true;
     }
     // convert profile finished - export source flavor
     if ($dbBatchJob->getJobType() == BatchJobType::CONVERT_PROFILE) {
         $externalStorages = StorageProfilePeer::retrieveAutomaticByPartnerId($dbBatchJob->getPartnerId());
         foreach ($externalStorages as $externalStorage) {
             if ($externalStorage->getTrigger() == StorageProfile::STORAGE_TEMP_TRIGGER_FLAVOR_READY || $externalStorage->getTrigger() == StorageProfile::STORAGE_TEMP_TRIGGER_MODERATION_APPROVED && $dbBatchJob->getEntry()->getModerationStatus() == entry::ENTRY_MODERATION_STATUS_APPROVED) {
                 $sourceFlavor = flavorAssetPeer::retrieveOriginalReadyByEntryId($dbBatchJob->getEntryId());
                 if ($sourceFlavor) {
                     $this->exportFlavorAsset($sourceFlavor, $externalStorage);
                 }
             }
         }
     }
     // convert collection finished - export ism and ismc files
     if ($dbBatchJob->getJobType() == BatchJobType::CONVERT_COLLECTION && $dbBatchJob->getJobSubType() == conversionEngineType::EXPRESSION_ENCODER3) {
         $entry = $dbBatchJob->getEntry();
         $externalStorages = StorageProfilePeer::retrieveAutomaticByPartnerId($dbBatchJob->getPartnerId());
         foreach ($externalStorages as $externalStorage) {
             if ($externalStorage->getTrigger() == StorageProfile::STORAGE_TEMP_TRIGGER_FLAVOR_READY || $externalStorage->getTrigger() == StorageProfile::STORAGE_TEMP_TRIGGER_MODERATION_APPROVED && $entry->getModerationStatus() == entry::ENTRY_MODERATION_STATUS_APPROVED) {
                 $ismKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
                 if (kFileSyncUtils::fileSync_exists($ismKey)) {
                     $this->export($entry, $externalStorage, $ismKey);
                 }
                 $ismcKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
                 if (kFileSyncUtils::fileSync_exists($ismcKey)) {
                     $this->export($entry, $externalStorage, $ismcKey);
                 }
             }
         }
     }
     return true;
 }
Beispiel #25
0
 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;
 }
Beispiel #26
0
 /**
  * @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;
 }
Beispiel #27
0
 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;
 }
 public function updatedJob(BatchJob $dbBatchJob, BatchJob $twinJob = null)
 {
     // convert profile finished - export source flavor
     if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED) {
         return self::exportSourceAssetFromJob($dbBatchJob);
     }
     return true;
 }
Beispiel #29
0
 public function updatedJob(BatchJob $dbBatchJob)
 {
     $dbBatchJobLock = $dbBatchJob->getBatchJobLock();
     try {
         if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FAILED || $dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FATAL) {
             kJobsManager::abortChildJobs($dbBatchJob);
         }
         $jobType = $dbBatchJob->getJobType();
         switch ($jobType) {
             case BatchJobType::IMPORT:
                 $dbBatchJob = $this->updatedImport($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::EXTRACT_MEDIA:
                 $dbBatchJob = $this->updatedExtractMedia($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::CONVERT:
                 $dbBatchJob = $this->updatedConvert($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::POSTCONVERT:
                 $dbBatchJob = $this->updatedPostConvert($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::BULKUPLOAD:
                 $dbBatchJob = $this->updatedBulkUpload($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::CONVERT_PROFILE:
                 $dbBatchJob = $this->updatedConvertProfile($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::BULKDOWNLOAD:
                 $dbBatchJob = $this->updatedBulkDownload($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::PROVISION_PROVIDE:
                 $dbBatchJob = $this->updatedProvisionProvide($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::PROVISION_DELETE:
                 $dbBatchJob = $this->updatedProvisionDelete($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::CONVERT_COLLECTION:
                 $dbBatchJob = $this->updatedConvertCollection($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::STORAGE_EXPORT:
                 $dbBatchJob = $this->updatedStorageExport($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::MOVE_CATEGORY_ENTRIES:
                 $dbBatchJob = $this->updatedMoveCategoryEntries($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::STORAGE_DELETE:
                 $dbBatchJob = $this->updatedStorageDelete($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::CAPTURE_THUMB:
                 $dbBatchJob = $this->updatedCaptureThumb($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::DELETE_FILE:
                 $dbBatchJob = $this->updatedDeleteFile($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::INDEX:
                 $dbBatchJob = $this->updatedIndex($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::COPY:
                 $dbBatchJob = $this->updatedCopy($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::DELETE:
                 $dbBatchJob = $this->updatedDelete($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::CONCAT:
                 $dbBatchJob = $this->updatedConcat($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::CONVERT_LIVE_SEGMENT:
                 $dbBatchJob = $this->updatedConvertLiveSegment($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::LIVE_REPORT_EXPORT:
                 $dbBatchJob = $this->updatedLiveReportExport($dbBatchJob, $dbBatchJob->getData());
                 break;
             default:
                 break;
         }
         if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_RETRY) {
             if ($dbBatchJobLock && $dbBatchJobLock->getExecutionAttempts() >= BatchJobLockPeer::getMaxExecutionAttempts($jobType)) {
                 $dbBatchJob = kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_FAILED);
             }
         }
         if (in_array($dbBatchJob->getStatus(), BatchJobPeer::getClosedStatusList())) {
             $jobEntry = $dbBatchJob->getEntry();
             if ($jobEntry && $jobEntry->getMarkedForDeletion()) {
                 myEntryUtils::deleteEntry($jobEntry, null, true);
             }
         }
     } catch (Exception $ex) {
         self::alert($dbBatchJob, $ex);
         KalturaLog::err("Error:" . $ex->getMessage());
     }
     return true;
 }
 protected function updatedVirusScan(BatchJob $dbBatchJob, kVirusScanJobData $data)
 {
     switch ($dbBatchJob->getStatus()) {
         case BatchJob::BATCHJOB_STATUS_FINISHED:
             return $this->updatedVirusScanFinished($dbBatchJob, $data);
         case BatchJob::BATCHJOB_STATUS_FAILED:
         case BatchJob::BATCHJOB_STATUS_FATAL:
             return $this->updatedVirusScanFailed($dbBatchJob, $data);
         default:
             return $dbBatchJob;
     }
 }