Inheritance: extends BaseBatchJob, implements ISyncableFile
 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;
 }
 /**
  * Will investigate a single entry
  */
 public function execute()
 {
     $mode = $this->getP("mode", "get");
     $c = new Criteria();
     //		$c->add ( BatchJobPeer::JOB_TYPE , BatchJobType::DELETE );
     $peer = new BatchJobPeer();
     $location_id = "loc1";
     $server_id = "ser1";
     $execution_time = 400;
     $number_of_objects = 1;
     if ($mode == "free") {
         $id = $this->getP("id");
         $this->res = kBatchExclusiveLock::freeExclusive($id, $peer, $location_id, $server_id);
     } elseif ($mode == "update") {
         $id = $this->getP("id");
         $obj = new BatchJob();
         $obj->setProgress(77);
         $this->res = kBatchExclusiveLock::updateExclusive($id, $peer, $location_id, $server_id, $obj);
     } else {
         $partner_group = new myPartnerGroups("+1;0;-3,4");
         $this->res = null;
         $cloned_c = clone $c;
         while ($partner_group->applyPartnerGroupToCriteria($cloned_c, $peer)) {
             $this->res = kBatchExclusiveLock::getExclusive($cloned_c, $peer, $location_id, $server_id, $execution_time, $number_of_objects);
             if ($this->res) {
                 break;
             }
             $cloned_c = clone $c;
         }
     }
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 public function getScope()
 {
     $scope = parent::getScope();
     $scope->setPartnerId($this->dbBatchJob->getPartnerId());
     $scope->setParentRaisedJob($this->dbBatchJob);
     return $scope;
 }
 /**
  * @param CaptionAsset $captionAsset
  * @param BatchJob $parentJob
  * @throws kCoreException FILE_NOT_FOUND
  * @return BatchJob
  */
 public function addParseCaptionAssetJob(CaptionAsset $captionAsset, BatchJob $parentJob = null)
 {
     $syncKey = $captionAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
     $fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
     if (!$fileSync) {
         if (!PermissionPeer::isValidForPartner(CaptionPermissionName::IMPORT_REMOTE_CAPTION_FOR_INDEXING, $captionAsset->getPartnerId())) {
             throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
         }
         $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
         if (!$fileSync) {
             throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
         }
         $fullPath = myContentStorage::getFSUploadsPath() . '/' . $captionAsset->getId() . '.tmp';
         if (!kFile::downloadUrlToFile($fileSync->getExternalUrl($captionAsset->getEntryId()), $fullPath)) {
             throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
         }
         kFileSyncUtils::moveFromFile($fullPath, $syncKey, true, false, true);
     }
     $jobData = new kParseCaptionAssetJobData();
     $jobData->setCaptionAssetId($captionAsset->getId());
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild();
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($captionAsset->getEntryId());
         $batchJob->setPartnerId($captionAsset->getPartnerId());
     }
     return kJobsManager::addJob($batchJob, $jobData, CaptionSearchPlugin::getBatchJobTypeCoreValue(CaptionSearchBatchJobType::PARSE_CAPTION_ASSET));
 }
Ejemplo n.º 6
0
 /**
  * @param string $entryId
  * @param FileSync $object
  * @param int $fileSyncId
  * @param string $sourceFileUrl
  * @return BatchJob
  */
 public static function addFileSyncImportJob($entryId, FileSync $fileSync, $sourceFileUrl, BatchJob $parentJob = null, $fileSize = null)
 {
     $partnerId = $fileSync->getPartnerId();
     $fileSyncId = $fileSync->getId();
     $dc = $fileSync->getDc();
     KalturaLog::log(__METHOD__ . " entryId[{$entryId}], partnerId[{$partnerId}], fileSyncId[{$fileSyncId}], sourceFileUrl[{$sourceFileUrl}]");
     $fileSyncImportData = new kFileSyncImportJobData();
     $fileSyncImportData->setSourceUrl($sourceFileUrl);
     $fileSyncImportData->setFilesyncId($fileSyncId);
     $fileSyncImportData->setFileSize($fileSize);
     // tmpFilePath and destFilePath will be set later during get exlusive call on the target data center
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild(BatchJobType::FILESYNC_IMPORT, null, true, $dc);
     } else {
         $batchJob = new BatchJob();
         $batchJob->setDc($dc);
         $batchJob->setEntryId($entryId);
         $batchJob->setPartnerId($partnerId);
     }
     $batchJob->setObjectId($fileSyncId);
     $batchJob->setObjectType(BatchJobObjectType::FILE_SYNC);
     //In case file sync is of type data and holds flavor asset than we need to check if its the source asset that is being synced and raise it sync priority
     if ($fileSync->getObjectType() == FileSyncObjectType::FLAVOR_ASSET && $fileSync->getObjectSubType() == entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA && $fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_FILE) {
         $assetdb = assetPeer::retrieveById($fileSync->getObjectId());
         if ($assetdb) {
             $isSourceAsset = $assetdb->getIsOriginal();
             if ($isSourceAsset) {
                 $fileSyncImportData->setIsSourceAsset(true);
             }
         }
     }
     KalturaLog::log("Creating Filesync Import job, with file sync id: {$fileSyncId} size: {$fileSize}");
     return kJobsManager::addJob($batchJob, $fileSyncImportData, BatchJobType::FILESYNC_IMPORT);
 }
Ejemplo n.º 7
0
 /**
  * This function calculates the priority of the job.
  * @param BatchJob $batchJob
  * @return integer the calculated priority
  */
 public function calculatePriority(BatchJob $batchJob)
 {
     $parentJob = $batchJob->getParentJob();
     if (!is_null($parentJob) && !is_null($parentJob->getLockInfo())) {
         return $parentJob->getLockInfo()->getPriority();
     }
     return self::BATCH_JOB_DEFAULT_PRIORITY;
 }
 /**
  * @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;
     }
 }
Ejemplo n.º 9
0
 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
  * @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;
     }
 }
Ejemplo n.º 11
0
 public function shouldConsumeJobStatusEvent(BatchJob $dbBatchJob)
 {
     if ($dbBatchJob->getJobType() == BatchJobType::STORAGE_EXPORT && $dbBatchJob->getJobSubType() == KontikiPlugin::getStorageProfileProtocolCoreValue(KontikiStorageProfileProtocol::KONTIKI)) {
         if (KontikiPlugin::isAllowedPartner($dbBatchJob->getPartnerId())) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 12
0
 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;
 }
 public function getScope()
 {
     $scope = parent::getScope();
     if ($this->raisedJob) {
         $scope->setPartnerId($this->raisedJob->getPartnerId());
         $scope->setParentRaisedJob($this->raisedJob);
     } elseif (method_exists($this->object, 'getPartnerId')) {
         $scope->setPartnerId($this->object->getPartnerId());
     }
     return $scope;
 }
 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;
 }
Ejemplo n.º 16
0
 /**
  * @param string $entryId
  * @param int $partnerId
  * @param int $fileSyncId
  * @param string $sourceFileUrl
  * @return BatchJob
  */
 public static function addFileSyncImportJob($entryId, $partnerId, $fileSyncId, $sourceFileUrl)
 {
     KalturaLog::log(__METHOD__ . " entryId[{$entryId}], partnerId[{$partnerId}], fileSyncId[{$fileSyncId}], sourceFileUrl[{$sourceFileUrl}]");
     $fileSyncImportData = new kFileSyncImportJobData();
     $fileSyncImportData->setSourceUrl($sourceFileUrl);
     $fileSyncImportData->setFilesyncId($fileSyncId);
     // tmpFilePath and destFilePath will be set later during get exlusive call on the target data center
     $batchJob = new BatchJob();
     $batchJob->setEntryId($entryId);
     $batchJob->setPartnerId($partnerId);
     KalturaLog::log("Creating Filesync Import job, with file sync id: {$fileSyncId}");
     return kJobsManager::addJob($batchJob, $fileSyncImportData, BatchJobType::FILESYNC_IMPORT);
 }
 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;
     }
 }
Ejemplo n.º 18
0
 private function sendEmail($password)
 {
     $batchJob = new BatchJob();
     $batchJob->setPartnerId(Partner::ADMIN_CONSOLE_PARTNER_ID);
     $jobData = new kMailJobData();
     $jobData->setMailPriority(kMailJobData::MAIL_PRIORITY_NORMAL);
     $jobData->setStatus(kMailJobData::MAIL_STATUS_PENDING);
     $jobData->setBodyParamsArray(array($password));
     $jobData->setMailType(112);
     $jobData->setFromEmail(kConf::get("default_email"));
     $jobData->setFromName(kConf::get("default_email_name"));
     $jobData->setRecipientEmail($this->getEmail());
     $jobData->setSubjectParamsArray(array());
     kJobsManager::addJob($batchJob, $jobData, BatchJobType::MAIL, $jobData->getMailType());
 }
Ejemplo n.º 19
0
 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 function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $prefix = null;
     $notData = new kNotificationJobData();
     $notData->setData('');
     $notData->setType(kNotificationJobData::NOTIFICATION_TYPE_TEST);
     $notData->setUserId($puser_id);
     $job = new BatchJob();
     $job->setId(kNotificationJobData::NOTIFICATION_TYPE_TEST + (int) time());
     $job->setData($notData);
     $job->setPartnerId($partner_id);
     $partner = PartnerPeer::retrieveByPK($partner_id);
     list($url, $signature_key) = myNotificationMgr::getPartnerNotificationInfo($partner);
     list($params, $raw_siganture) = myNotificationMgr::prepareNotificationData($url, $signature_key, $job, $prefix);
     $this->send($url, $params);
 }
 /**
  * @param BatchJob $parentJob
  * @param int $partnerId
  * @param string $entryId
  * @param string $flavorAssetId
  * @param string $srcFilePath
  * @param VirusScanEngineType $virusScanEngine
  * @param int $scanProfileId
  * @return BatchJob
  */
 public static function addVirusScanJob(BatchJob $parentJob = null, $partnerId, $entryId, $flavorAssetId, $srcFilePath, $virusScanEngine, $virusFoundAction)
 {
     $jobData = new kVirusScanJobData();
     $jobData->setSrcFilePath($srcFilePath);
     $jobData->setFlavorAssetId($flavorAssetId);
     $jobData->setVirusFoundAction($virusFoundAction);
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild();
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($entryId);
         $batchJob->setPartnerId($partnerId);
     }
     $jobType = VirusScanPlugin::getBatchJobTypeCoreValue(VirusScanBatchJobType::VIRUS_SCAN);
     return self::addJob($batchJob, $jobData, $jobType, $virusScanEngine);
 }
 /**
  * @param int $eventNotificationType
  * @param kEventNotificationDispatchJobData $jobData
  * @param string $partnerId
  * @param string $entryId
  * @param BatchJob $parentJob
  * @return BatchJob
  */
 public static function addEventNotificationDispatchJob($eventNotificationType, kEventNotificationDispatchJobData $jobData, $partnerId = null, $entryId = null, BatchJob $parentJob = null)
 {
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild(false);
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($entryId);
         if (!$partnerId) {
             $partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
         }
         $batchJob->setPartnerId($partnerId ? $partnerId : kCurrentContext::$partner_id);
     }
     KalturaLog::log("Creating event notification dispatch job on template id [" . $jobData->getTemplateId() . "] engine[{$eventNotificationType}]");
     $jobType = EventNotificationPlugin::getBatchJobTypeCoreValue(EventNotificationBatchType::EVENT_NOTIFICATION_HANDLER);
     return kJobsManager::addJob($batchJob, $jobData, $jobType, $eventNotificationType);
 }
Ejemplo n.º 23
0
 private function reconvertEntry($entry_id, $conversion_profile_id, $job_priority)
 {
     $entry = entryPeer::retrieveByPK($entry_id);
     $this->error = "";
     if (!$entry) {
         $error = "Cannot reconvert entry [{$entry_id}]. Might be a deleted entry";
         return array($entry_id, null, null, $error);
     }
     $flavorAsset = assetPeer::retrieveOriginalByEntryId($entry_id);
     if (!$flavorAsset) {
         $flavorAsset = assetPeer::retrieveReadyWebByEntryId($entry_id);
         if (!$flavorAsset) {
             $flavorAssets = assetPeer::retrieveFlavorsByEntryId($entry_id);
             if (!$flavorAssets) {
                 $error = "Cannot find good enough flavor asset to re-convert from";
                 return array($entry_id, $entry, null, $error);
             }
             $flavorAsset = $flavorAssets[0];
             // choose the first one
         }
     }
     $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $filePath = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
     if (!$filePath) {
         $error = "Cannot find a fileSync for the flavorAsset [" . $flavorAsset->getId() . "]";
         return array($entry_id, $entry, null, $error);
     }
     $dbBatchJob = new BatchJob();
     $dbBatchJob->setEntryId($entry_id);
     $dbBatchJob->setPartnerId($entry->getPartnerId());
     $dbBatchJob->setStatus(BatchJob::BATCHJOB_STATUS_PENDING);
     $dbBatchJob->setDc(kDataCenterMgr::getCurrentDcId());
     //$dbBatchJob->setPriority ( $job_priority ); Not supported anymore
     $dbBatchJob->setObjectId($entry_id);
     $dbBatchJob->setObjectType(BatchJobObjectType::ENTRY);
     $dbBatchJob->setJobType(BatchJobType::CONVERT_PROFILE);
     $dbBatchJob->save();
     // creates a convert profile job
     $convertProfileData = new kConvertProfileJobData();
     $convertProfileData->setFlavorAssetId($flavorAsset->getId());
     $convertProfileData->setInputFileSyncLocalPath($filePath);
     kJobsManager::addJob($dbBatchJob, $convertProfileData, BatchJobType::CONVERT_PROFILE);
     // save again afget the addJob
     $dbBatchJob->save();
     return array($entry_id, $entry, $dbBatchJob, $error);
 }
Ejemplo n.º 24
0
 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;
 }
Ejemplo n.º 25
0
 /**
  * Add new bulk upload batch job
  * Conversion profile id can be specified in the API or in the CSV file, the one in the CSV file will be stronger.
  * If no conversion profile was specified, partner's default will be used
  * 
  * @action add
  * @param int $conversionProfileId Convertion profile id to use for converting the current bulk (-1 to use partner's default)
  * @param file $csvFileData CSV File
  * @return KalturaBulkUpload
  */
 function addAction($conversionProfileId, $csvFileData)
 {
     // first we copy the file to "content/batchfiles/[partner_id]/"
     $origFilename = $csvFileData["name"];
     $fileInfo = pathinfo($origFilename);
     $extension = strtolower($fileInfo["extension"]);
     if ($extension != "csv") {
         throw new KalturaAPIException(KalturaErrors::INVALID_FILE_EXTENSION);
     }
     $job = new BatchJob();
     $job->setPartnerId($this->getPartnerId());
     $job->save();
     $syncKey = $job->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_BULKUPLOADCSV);
     //		kFileSyncUtils::file_put_contents($syncKey, file_get_contents($csvFileData["tmp_name"]));
     try {
         kFileSyncUtils::moveFromFile($csvFileData["tmp_name"], $syncKey, true);
     } catch (Exception $e) {
         throw new KalturaAPIException(KalturaErrors::BULK_UPLOAD_CREATE_CSV_FILE_SYNC_ERROR);
     }
     $csvPath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
     $data = new KalturaBulkUploadJobData();
     $data->csvFilePath = $csvPath;
     $data->userId = $this->getKuser()->getPuserId();
     $data->uploadedBy = $this->getKuser()->getScreenName();
     if ($conversionProfileId === -1) {
         $conversionProfileId = $this->getPartner()->getDefaultConversionProfileId();
     }
     $kmcVersion = $this->getPartner()->getKmcVersion();
     $check = null;
     if ($kmcVersion < 2) {
         $check = ConversionProfilePeer::retrieveByPK($conversionProfileId);
     } else {
         $check = conversionProfile2Peer::retrieveByPK($conversionProfileId);
     }
     if (!$check) {
         throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $conversionProfileId);
     }
     $data->conversionProfileId = $conversionProfileId;
     $dbJob = kJobsManager::addJob($job, $data->toObject(), KalturaBatchJobType::BULKUPLOAD);
     $bulkUpload = new KalturaBulkUpload();
     $bulkUpload->fromObject($dbJob);
     return $bulkUpload;
 }
 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;
 }
 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;
     }
 }
 /**
  * @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;
 }
 /**
  * @param BatchJob $job
  * @param $errorDescription
  * @return BatchJob
  */
 protected function finishJobWithError(BatchJob $job, $errorDescription)
 {
     $job->setStatus(BatchJob::BATCHJOB_STATUS_FAILED);
     $job->setDescription($job->getDescription() . '\\n' . $errorDescription);
     $job->save();
     return $job;
 }