本文整理汇总了PHP中BatchJob::setMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP BatchJob::setMessage方法的具体用法?PHP BatchJob::setMessage怎么用?PHP BatchJob::setMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BatchJob
的用法示例。
在下文中一共展示了BatchJob::setMessage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addJob
/**
* @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;
}
示例2: failBatchJob
public static function failBatchJob(BatchJob $batchJob, $errDescription)
{
$batchJob->setMessage($errDescription);
$description = $batchJob->getDescription() . "\n{$errDescription}";
$batchJob->setDescription($description);
return self::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_FAILED);
}
示例3: handleImportFinished
/**
* @param BatchJob $dbBatchJob
* @param kImportJobData $data
* @return BatchJob
*/
public static function handleImportFinished(BatchJob $dbBatchJob, kImportJobData $data)
{
if ($dbBatchJob->getExecutionStatus() == BatchJobExecutionStatus::ABORTED) {
return $dbBatchJob;
}
if (!file_exists($data->getDestFileLocalPath())) {
throw new APIException(APIErrors::INVALID_FILE_NAME, $data->getDestFileLocalPath());
}
// get entry
$entryId = $dbBatchJob->getEntryId();
$dbEntry = entryPeer::retrieveByPKNoFilter($entryId);
// IMAGE media entries
if ($dbEntry->getType() == entryType::MEDIA_CLIP && $dbEntry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
//setting the entry's data so it can be used for creating file-syncs' file-path version & extension - in kFileSyncUtils::moveFromFile
//without saving - the updated entry object exists in the instance pool
$dbEntry->setData(".jpg");
$syncKey = $dbEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
try {
kFileSyncUtils::moveFromFile($data->getDestFileLocalPath(), $syncKey, true, false, $data->getCacheOnly());
} catch (Exception $e) {
if ($dbEntry->getStatus() == entryStatus::NO_CONTENT) {
$dbEntry->setStatus(entryStatus::ERROR_CONVERTING);
$dbEntry->save();
}
throw $e;
}
$dbEntry->setStatus(entryStatus::READY);
$dbEntry->save();
return $dbBatchJob;
}
$flavorAsset = null;
if ($data->getFlavorAssetId()) {
$flavorAsset = assetPeer::retrieveById($data->getFlavorAssetId());
}
$isNewFlavor = false;
if (!$flavorAsset) {
$msg = null;
$flavorAsset = kFlowHelper::createOriginalFlavorAsset($dbBatchJob->getPartnerId(), $dbBatchJob->getEntryId(), $msg);
if (!$flavorAsset) {
KalturaLog::err("Flavor asset not created for entry [" . $dbBatchJob->getEntryId() . "]");
kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING);
$dbBatchJob->setMessage($msg);
$dbBatchJob->setDescription($dbBatchJob->getDescription() . "\n" . $msg);
return $dbBatchJob;
}
$isNewFlavor = true;
}
$isNewContent = true;
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if (kFileSyncUtils::fileSync_exists($syncKey)) {
$isNewContent = false;
}
$ext = pathinfo($data->getDestFileLocalPath(), PATHINFO_EXTENSION);
KalturaLog::info("Imported file extension: {$ext}");
if (!$flavorAsset->getVersion()) {
$flavorAsset->incrementVersion();
}
if ($ext) {
$flavorAsset->setFileExt($ext);
}
if ($flavorAsset instanceof thumbAsset) {
list($width, $height, $type, $attr) = getimagesize($data->getDestFileLocalPath());
$flavorAsset->setWidth($width);
$flavorAsset->setHeight($height);
$flavorAsset->setSize(filesize($data->getDestFileLocalPath()));
}
$flavorAsset->save();
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
kFileSyncUtils::moveFromFile($data->getDestFileLocalPath(), $syncKey, true, false, $data->getCacheOnly());
// set the path in the job data
$localFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
$data->setDestFileLocalPath($localFilePath);
$data->setFlavorAssetId($flavorAsset->getId());
$dbBatchJob->setData($data);
$dbBatchJob->save();
$convertProfileExist = self::activateConvertProfileJob($dbBatchJob->getEntryId(), $localFilePath);
if (($isNewContent || $dbEntry->getStatus() == entryStatus::IMPORT) && !$convertProfileExist) {
// check if status == import for importing file of type url (filesync exists, and we want to raise event for conversion profile to start)
kEventsManager::raiseEvent(new kObjectAddedEvent($flavorAsset, $dbBatchJob));
}
if (!$isNewFlavor) {
$entryFlavors = assetPeer::retrieveByEntryIdAndStatus($flavorAsset->getEntryId(), flavorAsset::FLAVOR_ASSET_STATUS_WAIT_FOR_CONVERT);
$originalFlavorAsset = assetPeer::retrieveOriginalByEntryId($flavorAsset->getEntryId());
foreach ($entryFlavors as $entryFlavor) {
/* @var $entryFlavor flavorAsset */
if ($entryFlavor->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_WAIT_FOR_CONVERT && $entryFlavor->getFlavorParamsId()) {
$flavor = assetParamsOutputPeer::retrieveByAsset($entryFlavor);
kBusinessPreConvertDL::decideFlavorConvert($entryFlavor, $flavor, $originalFlavorAsset, null, null, $dbBatchJob);
}
}
$entryThumbnails = assetPeer::retrieveThumbnailsByEntryId($flavorAsset->getEntryId());
foreach ($entryThumbnails as $entryThumbnail) {
/* @var $entryThumbnail thumbAsset */
if ($entryThumbnail->getStatus() != asset::ASSET_STATUS_WAIT_FOR_CONVERT || !$entryThumbnail->getFlavorParamsId()) {
continue;
//.........这里部分代码省略.........
示例4: handleImportFinished
/**
* @param BatchJob $dbBatchJob
* @param kImportJobData $data
* @param BatchJob $twinJob
* @return BatchJob
*/
public static function handleImportFinished(BatchJob $dbBatchJob, kImportJobData $data, BatchJob $twinJob = null)
{
KalturaLog::debug("Import finished, with file: " . $data->getDestFileLocalPath());
if ($dbBatchJob->getAbort()) {
return $dbBatchJob;
}
if (!$twinJob) {
if (!file_exists($data->getDestFileLocalPath())) {
throw new APIException(APIErrors::INVALID_FILE_NAME, $data->getDestFileLocalPath());
}
}
// get entry
$entryId = $dbBatchJob->getEntryId();
$dbEntry = entryPeer::retrieveByPKNoFilter($entryId);
// IMAGE media entries
if ($dbEntry->getType() == entryType::MEDIA_CLIP && $dbEntry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$syncKey = $dbEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
try {
kFileSyncUtils::moveFromFile($data->getDestFileLocalPath(), $syncKey, true, false, $data->getCacheOnly());
} catch (Exception $e) {
if ($dbEntry->getStatus() == entryStatus::NO_CONTENT) {
$dbEntry->setStatus(entryStatus::ERROR_CONVERTING);
$dbEntry->save();
}
throw $e;
}
$dbEntry->setStatus(entryStatus::READY);
$dbEntry->save();
return $dbBatchJob;
}
$flavorAsset = null;
if ($data->getFlavorAssetId()) {
$flavorAsset = assetPeer::retrieveById($data->getFlavorAssetId());
}
$isNewFlavor = false;
if (!$flavorAsset) {
$msg = null;
$flavorAsset = kFlowHelper::createOriginalFlavorAsset($dbBatchJob->getPartnerId(), $dbBatchJob->getEntryId(), $msg);
if (!$flavorAsset) {
KalturaLog::err("Flavor asset not created for entry [" . $dbBatchJob->getEntryId() . "]");
kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING);
$dbBatchJob->setMessage($msg);
$dbBatchJob->setDescription($dbBatchJob->getDescription() . "\n" . $msg);
return $dbBatchJob;
}
$isNewFlavor = true;
}
$isNewContent = true;
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if (kFileSyncUtils::fileSync_exists($syncKey)) {
$isNewContent = false;
}
if ($twinJob) {
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
// copy file sync
$twinData = $twinJob->getData();
if ($twinData instanceof kImportJobData) {
$twinFlavorAsset = assetPeer::retrieveById($twinData->getFlavorAssetId());
if ($twinFlavorAsset) {
$twinSyncKey = $twinFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if ($twinSyncKey && kFileSyncUtils::file_exists($twinSyncKey)) {
kFileSyncUtils::softCopy($twinSyncKey, $syncKey);
}
}
}
} else {
$ext = pathinfo($data->getDestFileLocalPath(), PATHINFO_EXTENSION);
KalturaLog::info("Imported file extension: {$ext}");
if (!$flavorAsset->getVersion()) {
$flavorAsset->incrementVersion();
}
$flavorAsset->setFileExt($ext);
$flavorAsset->save();
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
kFileSyncUtils::moveFromFile($data->getDestFileLocalPath(), $syncKey, true, false, $data->getCacheOnly());
}
// set the path in the job data
$localFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
$data->setDestFileLocalPath($localFilePath);
$data->setFlavorAssetId($flavorAsset->getId());
$dbBatchJob->setData($data);
$dbBatchJob->save();
if ($isNewContent || $dbEntry->getStatus() == entryStatus::IMPORT) {
// check if status == import for importing file of type url (filesync exists, and we want to raise event for conversion profile to start)
kEventsManager::raiseEvent(new kObjectAddedEvent($flavorAsset, $dbBatchJob));
}
if (!$isNewFlavor && $flavorAsset->getIsOriginal()) {
$entryFlavors = assetPeer::retrieveFlavorsByEntryId($flavorAsset->getEntryId());
foreach ($entryFlavors as $entryFlavor) {
/* @var $entryFlavor flavorAsset */
if ($entryFlavor->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_WAIT_FOR_CONVERT && $entryFlavor->getFlavorParamsId()) {
kBusinessPreConvertDL::decideAddEntryFlavor($dbBatchJob, $flavorAsset->getEntryId(), $entryFlavor->getFlavorParamsId());
}
}
//.........这里部分代码省略.........