本文整理汇总了PHP中BatchJob::getSyncKey方法的典型用法代码示例。如果您正苦于以下问题:PHP BatchJob::getSyncKey方法的具体用法?PHP BatchJob::getSyncKey怎么用?PHP BatchJob::getSyncKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BatchJob
的用法示例。
在下文中一共展示了BatchJob::getSyncKey方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAction
/**
* 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;
}
示例2: executeImpl
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");
}
示例3: onBulkUploadJobStatusUpdated
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;
}
}
示例4: addTransformMetadataJob
/**
* @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);
}
示例5: addBulkUploadJob
/**
* Function adds bulk upload job to the queue
* @param Partner $partner
* @param kBulkUploadJobData $jobData
* @param string $bulkUploadType
* @throws APIException
* @return BatchJob
*/
public static function addBulkUploadJob(Partner $partner, kBulkUploadJobData $jobData, $bulkUploadType = null)
{
$job = new BatchJob();
$job->setPartnerId($partner->getId());
$job->setJobType(BatchJobType::BULKUPLOAD);
$job->setJobSubType($bulkUploadType);
$job->save();
$syncKey = $job->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_BULKUPLOAD);
// kFileSyncUtils::file_put_contents($syncKey, file_get_contents($csvFileData["tmp_name"]));
try {
kFileSyncUtils::moveFromFile($jobData->getFilePath(), $syncKey, true);
} catch (Exception $e) {
throw new APIException(APIErrors::BULK_UPLOAD_CREATE_CSV_FILE_SYNC_ERROR);
}
$filePath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
if (is_null($jobData)) {
throw new APIException(APIErrors::BULK_UPLOAD_BULK_UPLOAD_TYPE_NOT_VALID, $bulkUploadType);
}
if (!$jobData->getBulkUploadObjectType()) {
$jobData->setBulkUploadObjectType(BulkUploadObjectType::ENTRY);
}
$jobData->setFilePath($filePath);
if ($jobData->getBulkUploadObjectType() == BulkUploadObjectType::ENTRY && !$jobData->getObjectData()->getConversionProfileId()) {
$jobData->setConversionProfileId($partner->getDefaultConversionProfileId());
$kmcVersion = $partner->getKmcVersion();
$check = null;
if ($kmcVersion < 2) {
$check = ConversionProfilePeer::retrieveByPK($jobData->getConversionProfileId());
} else {
$check = conversionProfile2Peer::retrieveByPK($jobData->getConversionProfileId());
}
if (!$check) {
throw new APIException(APIErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $jobData->getConversionProfileId());
}
}
return kJobsManager::addJob($job, $jobData, BatchJobType::BULKUPLOAD, kPluginableEnumsManager::apiToCore("BulkUploadType", $bulkUploadType));
}
示例6: addConvertIsmCollectionJob
/**
* addConvertIsmCollectionJob creates a convert collection job
*
* @param string $tag
* @param FileSyncKey $srcSyncKey
* @param entry $entry
* @param BatchJob $parentJob
* @param array<flavorParamsOutput> $flavorParamsOutputs
* @return BatchJob
*/
public static function addConvertIsmCollectionJob($tag, FileSyncKey $srcSyncKey, entry $entry, BatchJob $parentJob = null, array $flavorParamsOutputs, $dbConvertCollectionJob = null)
{
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, true, false);
$localPath = null;
$remoteUrl = null;
if ($fileSync) {
if ($fileSync->getFileType() != FileSync::FILE_SYNC_FILE_TYPE_URL) {
$localPath = $fileSync->getFullPath();
}
$remoteUrl = $fileSync->getExternalUrl();
}
// increment entry version
$ismVersion = $entry->incrementIsmVersion();
$entry->save();
$fileName = $entry->generateFileName(0, $ismVersion);
// creates convert data
$convertCollectionData = new kConvertCollectionJobData();
$convertCollectionData->setSrcFileSyncLocalPath($localPath);
$convertCollectionData->setSrcFileSyncRemoteUrl($remoteUrl);
$convertCollectionData->setDestFileName($fileName);
// check bitrates duplications
$bitrates = array();
$finalFlavorParamsOutputs = array();
foreach ($flavorParamsOutputs as $flavorParamsOutput) {
if (!isset($bitrates[$flavorParamsOutput->getVideoBitrate()])) {
$bitrates[$flavorParamsOutput->getVideoBitrate()] = array();
}
$bitrates[$flavorParamsOutput->getVideoBitrate()][] = $flavorParamsOutput->getId();
$finalFlavorParamsOutputs[$flavorParamsOutput->getId()] = $flavorParamsOutput;
}
foreach ($bitrates as $bitrate => $flavorParamsOutputIds) {
if (count($flavorParamsOutputIds) == 1) {
// no bitrate dupliaction
continue;
}
$tempFlavorParamsOutputs = array();
foreach ($flavorParamsOutputIds as $index => $flavorParamsOutputId) {
$tempFlavorParamsOutputs[] = $finalFlavorParamsOutputs[$flavorParamsOutputId];
}
// sort the flavors by height
usort($tempFlavorParamsOutputs, array('kBusinessConvertDL', 'compareFlavorsByHeight'));
// increment the bitrate so it will be a bit different for each flavor
$index = 0;
foreach ($tempFlavorParamsOutputs as $flavorParamsOutput) {
$finalFlavorParamsOutputs[$flavorParamsOutput->getId()]->setVideoBitrate($bitrate + $index++);
}
}
foreach ($finalFlavorParamsOutputs as $flavorParamsOutput) {
$convertCollectionFlavorData = new kConvertCollectionFlavorData();
$convertCollectionFlavorData->setFlavorAssetId($flavorParamsOutput->getFlavorAssetId());
$convertCollectionFlavorData->setFlavorParamsOutputId($flavorParamsOutput->getId());
$convertCollectionFlavorData->setReadyBehavior($flavorParamsOutput->getReadyBehavior());
$convertCollectionFlavorData->setVideoBitrate($flavorParamsOutput->getVideoBitrate());
$convertCollectionFlavorData->setAudioBitrate($flavorParamsOutput->getAudioBitrate());
$convertCollectionFlavorData->setAudioBitrate($flavorParamsOutput->getAudioBitrate());
$convertCollectionData->addFlavor($convertCollectionFlavorData);
}
$currentConversionEngine = conversionEngineType::EXPRESSION_ENCODER3;
KalturaLog::log("Using conversion engine [{$currentConversionEngine}]");
if (!$dbConvertCollectionJob) {
// creats a child convert job
if ($parentJob) {
$dbConvertCollectionJob = $parentJob->createChild();
KalturaLog::log("Created from parent convert job with entry id [" . $dbConvertCollectionJob->getEntryId() . "]");
} else {
$dbConvertCollectionJob = new BatchJob();
$dbConvertCollectionJob->setEntryId($entry->getId());
$dbConvertCollectionJob->setPartnerId($entry->getPartnerId());
$dbConvertCollectionJob->save();
KalturaLog::log("Created from convert collection job with entry id [" . $dbConvertCollectionJob->getEntryId() . "]");
}
}
KalturaLog::log("Calling CDLProceessFlavorsForCollection with [" . count($finalFlavorParamsOutputs) . "] flavor params");
$xml = KDLWrap::CDLProceessFlavorsForCollection($finalFlavorParamsOutputs);
$xml = str_replace(KDLCmdlinePlaceholders::OutFileName, $fileName, $xml);
$syncKey = $dbConvertCollectionJob->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_CONFIG);
kFileSyncUtils::file_put_contents($syncKey, $xml);
$fileSync = kFileSyncUtils::getLocalFileSyncForKey($syncKey);
$remoteUrl = $fileSync->getExternalUrl();
$localPath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
$commandLines = array(conversionEngineType::EXPRESSION_ENCODER3 => KDLCmdlinePlaceholders::InFileName . ' ' . KDLCmdlinePlaceholders::ConfigFileName);
$commandLinesStr = flavorParamsOutput::buildCommandLinesStr($commandLines);
$convertCollectionData->setInputXmlLocalPath($localPath);
$convertCollectionData->setInputXmlRemoteUrl($remoteUrl);
$convertCollectionData->setCommandLinesStr($commandLinesStr);
$dbConvertCollectionJob->setFileSize(filesize($convertCollectionData->getSrcFileSyncLocalPath()));
return kJobsManager::addJob($dbConvertCollectionJob, $convertCollectionData, BatchJobType::CONVERT_COLLECTION, $currentConversionEngine);
}