Exemplo n.º 1
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);
 }
 /**
  * @param string $puser_id
  * @param string $entry
  * @param string $version
  * @param string $file_format
  * @return BatchJob
  */
 public static function addJob($puser_id, $entry, $version, $file_format)
 {
     $entryId = $entry->getId();
     $entryIntId = $entry->getIntId();
     $entryVersion = $version ? $version : $entry->getVersion();
     if ($entry) {
         $partner = $entry->getPartner();
         $email = $partner->getAdminEmail();
     }
     $data = json_encode(array('puserId' => $puser_id, 'entryId' => $entryId, 'entryIntId' => $entryIntId, 'entryVersion' => $entryVersion, 'fileFormat' => $file_format, 'email' => $email));
     $job = new BatchJob();
     $job->setJobType(BatchJobType::FLATTEN);
     $job->setData($data, true);
     $job->setStatus(BatchJob::BATCHJOB_STATUS_PENDING);
     $job->setCheckAgainTimeout(time() + 10);
     $job->setProgress(0);
     $job->setMessage('Queued');
     $job->setDescription('Queued, waiting to run');
     $job->setUpdatesCount(0);
     $job->setEntryId($entryId);
     $job->setPartnerId($entry->getPartnerId());
     $job->setSubpId($entry->getSubpId());
     $job->save();
     return $job;
 }
 /**
  * @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));
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
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());
 }
 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);
 }
Exemplo n.º 7
0
 public static function addParseMultiLanguageCaptionAssetJob($captionAsset, $fileLocation)
 {
     $batchJob = new BatchJob();
     $id = $captionAsset->getId();
     $entryId = $captionAsset->getEntryId();
     $jobData = new kParseMultiLanguageCaptionAssetJobData();
     $jobData->setMultiLanaguageCaptionAssetId($id);
     $jobData->setEntryId($entryId);
     $jobData->setFileLocation($fileLocation);
     $jobType = CaptionPlugin::getBatchJobTypeCoreValue(ParseMultiLanguageCaptionAssetBatchType::PARSE_MULTI_LANGUAGE_CAPTION_ASSET);
     $batchJob->setObjectType(BatchJobObjectType::ASSET);
     $batchJob->setEntryId($entryId);
     $batchJob->setPartnerId($captionAsset->getPartnerId());
     $batchJob->setObjectId($id);
     return kJobsManager::addJob($batchJob, $jobData, $jobType);
 }
Exemplo n.º 8
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);
 }
 /**
  * @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);
 }
 /**
  * @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);
 }
Exemplo n.º 11
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;
 }
Exemplo n.º 12
0
 public static function addintegrationJob($objectType, $objectId, kIntegrationJobData $data)
 {
     $partnerId = kCurrentContext::getCurrentPartnerId();
     $batchJob = new BatchJob();
     $batchJob->setPartnerId($partnerId);
     $batchJob->setObjectType($objectType);
     $batchJob->setObjectId($objectId);
     if ($objectType == BatchJobObjectType::ENTRY) {
         $batchJob->setEntryId($objectId);
     } elseif ($objectType == BatchJobObjectType::ASSET) {
         $asset = assetPeer::retrieveById($objectId);
         if ($asset) {
             $batchJob->setEntryId($asset->getEntryId());
         }
     }
     $batchJob->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS);
     $jobType = IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION);
     $batchJob = kJobsManager::addJob($batchJob, $data, $jobType, $data->getProviderType());
     return kJobsManager::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_PENDING);
 }
Exemplo n.º 13
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $entry_id = $this->getPM("entry_id");
     $entry = entryPeer::retrieveByPK($entry_id);
     if (!$entry) {
         $this->addError(APIErrors::INVALID_ENTRY_ID, "entry", $entry_id);
     } else {
         $job = new BatchJob();
         $job->setJobType(BatchJobType::DVDCREATOR);
         $job->setStatus(BatchJob::BATCHJOB_STATUS_PENDING);
         //$job->setCheckAgainTimeout(time() + 10);
         $job->setEntryId($entry_id);
         $job->setPartnerId($entry->getPartnerId());
         $job->setSubpId($entry->getSubpId());
         $job->save();
         $wrapper = objectWrapperBase::getWrapperClass($job, objectWrapperBase::DETAIL_LEVEL_DETAILED);
         // TODO - remove this code when cache works properly when saving objects (in their save method)
         $wrapper->removeFromCache("batch_job", $job->getId());
         $this->addMsg("batchjob", $wrapper);
     }
 }
Exemplo n.º 14
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $fileField = "csv_file";
     $profileId = $this->getP("profile_id");
     if (count($_FILES) == 0) {
         $this->addError(APIErrors::NO_FILES_RECEIVED);
         return;
     }
     if (!@$_FILES[$fileField]) {
         $this->addError(APIErrors::INVALID_FILE_FIELD, $fileField);
         return;
     }
     // first we copy the file to "content/batchfiles/[partner_id]/"
     $origFilename = $_FILES[$fileField]['name'];
     $fileInfo = pathinfo($origFilename);
     $extension = strtolower($fileInfo['extension']);
     if ($extension != "csv") {
         $this->addError(APIErrors::INVALID_FILE_EXTENSION);
         return;
     }
     $job = new BatchJob();
     $job->setPartnerId($partner_id);
     $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($_FILES[$fileField]['tmp_name'], $syncKey, true);
     } catch (Exception $e) {
         throw new KalturaAPIException(KalturaErrors::BULK_UPLOAD_CREATE_CSV_FILE_SYNC_ERROR);
     }
     $csvPath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
     $data = new kBulkUploadJobData();
     $data->setCsvFilePath($csvPath);
     $data->setUserId($puser_kuser->getPuserId());
     $data->setUploadedBy($puser_kuser->getPuserName());
     $data->setConversionProfileId($profileId);
     kJobsManager::addJob($job, $data, BatchJobType::BULKUPLOAD);
     $this->addMsg("status", "ok");
 }
 /**
  * @param int $eventNotificationType
  * @param kEventNotificationDispatchJobData $jobData
  * @param string $partnerId
  * @param string $entryId
  * @param BatchJob $parentJob
  * @return BatchJob
  */
 protected function addEventNotificationDispatchJob($eventNotificationType, kEventNotificationDispatchJobData $jobData, $partnerId = null, $entryId = null, BatchJob $parentJob = null)
 {
     $jobType = EventNotificationPlugin::getBatchJobTypeCoreValue(EventNotificationBatchType::EVENT_NOTIFICATION_HANDLER);
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild($jobType, $eventNotificationType, false);
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($entryId);
         if (!$partnerId) {
             $partnerId = kCurrentContext::getCurrentPartnerId();
         }
         $batchJob->setPartnerId($partnerId);
     }
     KalturaLog::log("Creating event notification dispatch job on template id [" . $jobData->getTemplateId() . "] engine[{$eventNotificationType}]");
     $batchJob->setObjectId($entryId);
     $batchJob->setObjectType(BatchJobObjectType::ENTRY);
     $batchJob->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS);
     $batchJob = kJobsManager::addJob($batchJob, $jobData, $jobType, $eventNotificationType);
     $jobData->setJobId($batchJob->getId());
     $batchJob->setData($jobData);
     return kJobsManager::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_PENDING);
 }
 /**
  * @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);
     // tmpFilePath and destFilePath will be set later during get exlusive call on the target data center
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild(true, $dc);
     } else {
         $batchJob = new BatchJob();
         $batchJob->setDc($dc);
         $batchJob->setEntryId($entryId);
         $batchJob->setPartnerId($partnerId);
     }
     $batchJob->setFileSize($fileSize);
     KalturaLog::log("Creating Filesync Import job, with file sync id: {$fileSyncId} size: {$fileSize}");
     return kJobsManager::addJob($batchJob, $fileSyncImportData, BatchJobType::FILESYNC_IMPORT);
 }
Exemplo n.º 17
0
 public static function addintegrationJob($objectType, $objectId, kIntegrationJobData $data)
 {
     $partnerId = kCurrentContext::getCurrentPartnerId();
     $providerType = $data->getProviderType();
     $integrationProvider = KalturaPluginManager::loadObject('IIntegrationProvider', $providerType);
     if (!$integrationProvider || !$integrationProvider->validatePermissions($partnerId)) {
         KalturaLog::err("partner {$partnerId} not permitted with provider type {$providerType}");
         return false;
     }
     $batchJob = new BatchJob();
     $batchJob->setPartnerId($partnerId);
     $batchJob->setObjectType($objectType);
     $batchJob->setObjectId($objectId);
     if ($objectType == BatchJobObjectType::ENTRY) {
         $batchJob->setEntryId($objectId);
     } elseif ($objectType == BatchJobObjectType::ASSET) {
         $asset = assetPeer::retrieveById($objectId);
         if ($asset) {
             $batchJob->setEntryId($asset->getEntryId());
         }
     }
     $batchJob->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS);
     $jobType = IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION);
     $batchJob = kJobsManager::addJob($batchJob, $data, $jobType, $providerType);
     if ($integrationProvider->shouldSendCallBack()) {
         $jobId = $batchJob->getId();
         $ks = self::generateKs($partnerId, $jobId);
         $callBackUrl = "http://" . kConf::get('cdn_api_host');
         $callBackUrl .= "/api_v3/index.php/service/integration_integration/action/notify";
         $callBackUrl .= "/id/{$jobId}/ks/{$ks}";
         $data = $batchJob->getData();
         $data->setCallbackNotificationUrl($callBackUrl);
         $batchJob->setData($data);
     }
     return kJobsManager::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_PENDING);
 }
Exemplo n.º 18
0
 /**
  * The type and the sub-type are constant in the batch job, therefore they must be proveided
  * when a new batch job is generated.
  * @return BatchJob
  */
 public function createChild($type, $subType = null, $same_root = true, $dc = null)
 {
     $child = new BatchJob();
     $child->setJobType($type);
     if ($subType !== null) {
         $child->setJobSubType($subType);
     }
     $child->setParentJobId($this->id);
     $child->setPartnerId($this->partner_id);
     $child->setEntryId($this->entry_id);
     $child->setBulkJobId($this->bulk_job_id);
     // the condition is required in the special case of file_sync import jobs which are created on one dc but run from the other
     $child->setDc($dc === null ? $this->dc : $dc);
     if ($same_root && $this->root_job_id) {
         $child->setRootJobId($this->root_job_id);
     } else {
         $child->setRootJobId($this->id);
     }
     return $child;
 }
Exemplo n.º 19
0
 private function addDropFolderContentProcessorJob(DropFolder $folder, DropFolderFile $dropFolderFileForObject, $dropFolderFileIds)
 {
     $batchJobType = DropFolderPlugin::getCoreValue('BatchJobType', DropFolderBatchType::DROP_FOLDER_CONTENT_PROCESSOR);
     $batchJob = new BatchJob();
     $batchJob->setPartnerId($folder->getPartnerId());
     $batchJob->setObjectId($dropFolderFileForObject->getId());
     $batchJob->setObjectType(DropFolderPlugin::getCoreValue('BatchJobObjectType', DropFolderBatchJobObjectType::DROP_FOLDER_FILE));
     $jobData = kDropFolderContentProcessorJobData::getInstance($folder->getType());
     //Required for plugins which require data to be set on the created entry from the drop folder files.
     $jobData->setData($folder, $dropFolderFileForObject, $dropFolderFileIds);
     return kJobsManager::addJob($batchJob, $jobData, $batchJobType, $folder->getType());
 }
Exemplo n.º 20
0
 /**
  * @param int $categoryId
  * @param string $pcToDecrement
  * @param string $pcToIncrement
  * @return BatchJob
  */
 protected static function addReIndexTagsJob($categoryId, $pcToDecrement, $pcToIncrement, $partnerId = null)
 {
     $jobType = TagSearchPlugin::getBatchJobTypeCoreValue(IndexTagsByPrivacyContextJobType::INDEX_TAGS);
     $data = new kIndexTagsByPrivacyContextJobData();
     $data->setChangedCategoryId($categoryId);
     $data->setDeletedPrivacyContexts($pcToDecrement);
     $data->setAddedPrivacyContexts($pcToIncrement);
     $batchJob = new BatchJob();
     $batchJob->setObjectId($categoryId);
     $batchJob->setObjectType(BatchJobObjectType::CATEGORY);
     if (!$partnerId) {
         $partnerId = kCurrentContext::getCurrentPartnerId();
     }
     $batchJob->setPartnerId($partnerId);
     KalturaLog::log("Creating tag re-index job for categoryId [" . $data->getChangedCategoryId() . "] ");
     return kJobsManager::addJob($batchJob, $data, $jobType);
 }
Exemplo n.º 21
0
 /**
  * @param ScheduledTaskProfile $scheduledTaskProfile
  * @param kScheduledTaskJobData $jobData
  * @return BatchJob
  */
 protected function createScheduledTaskJob(ScheduledTaskProfile $scheduledTaskProfile, kScheduledTaskJobData $jobData)
 {
     $scheduledTaskProfileId = $scheduledTaskProfile->getId();
     $jobType = ScheduledTaskPlugin::getBatchJobTypeCoreValue(ScheduledTaskBatchType::SCHEDULED_TASK);
     $objectType = ScheduledTaskPlugin::getBatchJobObjectTypeCoreValue(ScheduledTaskBatchJobObjectType::SCHEDULED_TASK_PROFILE);
     KalturaLog::log("Creating scheduled task dry run job for profile [" . $scheduledTaskProfileId . "]");
     $batchJob = new BatchJob();
     $batchJob->setPartnerId($scheduledTaskProfile->getPartnerId());
     $batchJob->setObjectId($scheduledTaskProfileId);
     $batchJob->setObjectType($objectType);
     $batchJob->setStatus(BatchJob::BATCHJOB_STATUS_PENDING);
     $batchJob = kJobsManager::addJob($batchJob, $jobData, $jobType);
     return $batchJob;
 }
 /**
  * @param EntryDistribution $entryDistribution
  * @param DistributionProfile $distributionProfile
  * @return BatchJob
  */
 protected static function addSubmitDeleteJob(EntryDistribution $entryDistribution, DistributionProfile $distributionProfile)
 {
     $entryDistribution->setStatus(EntryDistributionStatus::DELETING);
     $entryDistribution->setDirtyStatus(null);
     if (!$entryDistribution->save()) {
         KalturaLog::err("Unable to save entry distribution [" . $entryDistribution->getId() . "] status");
         return null;
     }
     $jobData = new kDistributionDeleteJobData();
     $jobData->setDistributionProfileId($entryDistribution->getDistributionProfileId());
     $jobData->setEntryDistributionId($entryDistribution->getId());
     $jobData->setProviderType($distributionProfile->getProviderType());
     $jobData->setRemoteId($entryDistribution->getRemoteId());
     $jobData->setMediaFiles($entryDistribution->getMediaFiles());
     $batchJob = new BatchJob();
     $batchJob->setEntryId($entryDistribution->getEntryId());
     $batchJob->setPartnerId($entryDistribution->getPartnerId());
     $jobType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE);
     $jobSubType = $distributionProfile->getProviderType();
     return kJobsManager::addJob($batchJob, $jobData, $jobType, $jobSubType);
 }
 /**
  * Method adds webcam prepare job to the queue
  * @param int $partnerId
  * @param KalturaMediaEntry $mediaEntry
  * @param string $webcamTokenId
  * @return BatchJob
  */
 public static function addWebcamPrepareJob($partnerId, KalturaMediaEntry $mediaEntry, $webcamTokenId)
 {
     $job = new BatchJob();
     $job->setPartnerId($partnerId);
     $job->setEntryId($mediaEntry->id);
     $data = new kWebcamPrepareJobData();
     $data->setWebcamTokenId($webcamTokenId);
     return self::addJob($job, $data, BatchJobType::WEBCAM_PREPARE);
 }
 /**
  * @return BatchJob
  */
 public function createChild($same_root = true, $dc = null)
 {
     $child = new BatchJob();
     $child->setStatus(self::BATCHJOB_STATUS_PENDING);
     $child->setParentJobId($this->id);
     $child->setPartnerId($this->partner_id);
     $child->setEntryId($this->entry_id);
     $child->setPriority($this->priority);
     $child->setSubpId($this->subp_id);
     $child->setBulkJobId($this->bulk_job_id);
     // the condition is required in the special case of file_sync import jobs which are created on one dc but run from the other
     $child->setDc($dc === null ? $this->dc : $dc);
     if ($same_root && $this->root_job_id) {
         $child->setRootJobId($this->root_job_id);
     } else {
         $child->setRootJobId($this->id);
     }
     $child->save();
     return $child;
 }
 /**
  * Adds new mail job
  * 
  * @action addMailJob
  * @param KalturaMailJobData $mailJobData
  */
 function addMailJobAction(KalturaMailJobData $mailJobData)
 {
     $mailJobData->validatePropertyNotNull("mailType");
     $mailJobData->validatePropertyNotNull("recipientEmail");
     if (is_null($mailJobData->mailPriority)) {
         $mailJobData->mailPriority = kMailJobData::MAIL_PRIORITY_NORMAL;
     }
     if (is_null($mailJobData->fromEmail)) {
         $mailJobData->fromEmail = kConf::get("default_email");
     }
     if (is_null($mailJobData->fromName)) {
         $mailJobData->fromName = kConf::get("default_email_name");
     }
     $batchJob = new BatchJob();
     $batchJob->setPartnerId($this->getPartnerId());
     $mailJobDataDb = $mailJobData->toObject(new kMailJobData());
     kJobsManager::addJob($batchJob, $mailJobDataDb, BatchJobType::MAIL, $mailJobDataDb->getMailType());
 }
Exemplo n.º 26
0
 public static function addExportLiveReportJob($reportType, KalturaLiveReportExportParams $params)
 {
     KalturaLog::debug("adding Export Live Report job");
     // Calculate time offset from server time to UTC
     $dateTimeZoneServer = new DateTimeZone(kConf::get('date_default_timezone'));
     $dateTimeZoneUTC = new DateTimeZone("UTC");
     $dateTimeUTC = new DateTime("now", $dateTimeZoneUTC);
     $timeOffsetSeconds = -1 * $dateTimeZoneServer->getOffset($dateTimeUTC);
     // Create job data
     $jobData = new kLiveReportExportJobData();
     $jobData->entryIds = $params->entryIds;
     $jobData->recipientEmail = $params->recpientEmail;
     $jobData->timeZoneOffset = $timeOffsetSeconds - $params->timeZoneOffset * 60;
     // Convert minutes to seconds
     $jobData->timeReference = time();
     $jobData->applicationUrlTemplate = $params->applicationUrlTemplate;
     $job = new BatchJob();
     $job->setPartnerId(kCurrentContext::getCurrentPartnerId());
     $job->setJobType(BatchJobType::LIVE_REPORT_EXPORT);
     $job->setJobSubType($reportType);
     $job->setData($jobData);
     return self::addJob($job, $jobData, BatchJobType::LIVE_REPORT_EXPORT, $reportType);
 }
Exemplo n.º 27
0
 private function addWidevineRepositoryModifySyncJob($entryId, $partnerId, array $flavorAssets, $entryStartDate, $entryEndDate, $monitorSyncCompletion = true)
 {
     KalturaLog::debug('adding  WidevineRepositorySync job, mode = MODIFY');
     $batchJobType = WidevinePlugin::getCoreValue('BatchJobType', WidevineBatchJobType::WIDEVINE_REPOSITORY_SYNC);
     $batchJob = new BatchJob();
     $batchJob->setPartnerId($partnerId);
     $batchJob->setObjectId($entryId);
     $batchJob->setObjectType(BatchJobObjectType::ENTRY);
     $batchJob->setEntryId($entryId);
     $jobData = new kWidevineRepositorySyncJobData();
     $jobData->setSyncMode(WidevineRepositorySyncMode::MODIFY);
     $jobData->setMonitorSyncCompletion($monitorSyncCompletion);
     $wvAssetIds = array();
     foreach ($flavorAssets as $flavorAsset) {
         /* @var $flavorAsset WidevineFlavorAsset */
         if ($flavorAsset->getWidevineAssetId()) {
             $wvAssetIds[] = $flavorAsset->getWidevineAssetId();
         }
     }
     if (!count($wvAssetIds)) {
         KalturaLog::debug("No valid WV assets found, Widevine Sync job is not created");
         return;
     }
     $jobData->setWvAssetIds(implode(',', $wvAssetIds));
     $jobData->addModifiedAttribute('licenseStartDate', $entryStartDate);
     $jobData->addModifiedAttribute('licenseEndDate', $entryEndDate);
     return kJobsManager::addJob($batchJob, $jobData, $batchJobType);
 }
Exemplo n.º 28
0
 /**
  * @return BatchJob
  */
 public function createChild($same_root = true)
 {
     $child = new BatchJob();
     $child->setStatus(self::BATCHJOB_STATUS_PENDING);
     $child->setParentJobId($this->id);
     $child->setPartnerId($this->partner_id);
     $child->setEntryId($this->entry_id);
     $child->setPriority($this->priority);
     $child->setSubpId($this->subp_id);
     $child->setBulkJobId($this->bulk_job_id);
     $child->setDc($this->dc);
     if ($same_root && $this->root_job_id) {
         $child->setRootJobId($this->root_job_id);
     } else {
         $child->setRootJobId($this->id);
     }
     $child->save();
     return $child;
 }
Exemplo n.º 29
0
 /**
  * @param int $metadataProfileId
  * @param int $srcVersion
  * @param int $destVersion
  * @param string $xsl
  *
  * @return BatchJob
  */
 private static function addTransformMetadataJob($partnerId, $metadataProfileId, $srcVersion, $destVersion, $xsl = null)
 {
     // check if any metadata objects require the transform
     $c = new Criteria();
     $c->add(MetadataPeer::METADATA_PROFILE_ID, $metadataProfileId);
     $c->add(MetadataPeer::METADATA_PROFILE_VERSION, $destVersion, Criteria::LESS_THAN);
     $c->add(MetadataPeer::STATUS, Metadata::STATUS_VALID);
     $metadataCount = MetadataPeer::doCount($c);
     if (!$metadataCount) {
         return null;
     }
     $job = new BatchJob();
     $job->setJobType(BatchJobType::METADATA_TRANSFORM);
     $job->setPartnerId($partnerId);
     $job->setObjectId($metadataProfileId);
     $job->setObjectType(kPluginableEnumsManager::apiToCore('BatchJobObjectType', MetadataBatchJobObjectType::METADATA_PROFILE));
     $data = new kTransformMetadataJobData();
     if ($xsl) {
         $job->save();
         $key = $job->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_CONFIG);
         kFileSyncUtils::file_put_contents($key, $xsl);
         $xslPath = kFileSyncUtils::getLocalFilePathForKey($key);
         $data->setSrcXslPath($xslPath);
     }
     $data->setMetadataProfileId($metadataProfileId);
     $data->setSrcVersion($srcVersion);
     $data->setDestVersion($destVersion);
     return kJobsManager::addJob($job, $data, BatchJobType::METADATA_TRANSFORM);
 }
Exemplo n.º 30
0
 /**
  * @param EntryDistribution $entryDistribution
  * @param DistributionProfile $distributionProfile
  * @return BatchJob
  */
 protected static function addSubmitDeleteJob(EntryDistribution $entryDistribution, DistributionProfile $distributionProfile)
 {
     $entryDistribution->setStatus(EntryDistributionStatus::DELETING);
     if (!$entryDistribution->save()) {
         KalturaLog::err("Unable to save entry distribution [" . $entryDistribution->getId() . "] status");
         $entryDistribution->reload();
         return null;
     }
     $entryDistribution->setDirtyStatus(null);
     //Moved down to ensure previous save is done Atomically
     $entryDistribution->save();
     $jobData = new kDistributionDeleteJobData();
     $jobData->setDistributionProfileId($entryDistribution->getDistributionProfileId());
     $jobData->setEntryDistributionId($entryDistribution->getId());
     $jobData->setProviderType($distributionProfile->getProviderType());
     $jobData->setRemoteId($entryDistribution->getRemoteId());
     $jobData->setMediaFiles($entryDistribution->getMediaFiles());
     $batchJob = new BatchJob();
     $batchJob->setEntryId($entryDistribution->getEntryId());
     $batchJob->setPartnerId($entryDistribution->getPartnerId());
     $batchJob->setObjectId($entryDistribution->getId());
     $batchJob->setObjectType(kPluginableEnumsManager::apiToCore('BatchJobObjectType', ContentDistributionBatchJobObjectType::ENTRY_DISTRIBUTION));
     $jobType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE);
     $jobSubType = $distributionProfile->getProviderType();
     return kJobsManager::addJob($batchJob, $jobData, $jobType, $jobSubType);
 }