Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support in EngineMessage and reflect in on the flavor. #798

Merged
merged 1 commit into from
Jan 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions alpha/apps/kaltura/lib/batch2/kFlowHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,15 +507,21 @@ public static function handleConvertFinished(BatchJob $dbBatchJob, kConvertJobDa
if(!$flavorAsset)
throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $data->getFlavorAssetId());

$flavorAsset->setDescription($flavorAsset->getDescription() . "\n" . $dbBatchJob->getMessage());
$shouldSave = false;
if(!is_null($data->getEngineMessage())) {
$flavorAsset->setDescription($flavorAsset->getDescription() . "\n" . $data->getEngineMessage());
$shouldSave = true;
}

$flavorParamsOutput = $data->getFlavorParamsOutput();

if($data->getDestFileSyncLocalPath())
{
$flavorAsset->incrementVersion();
$flavorAsset->save();
}
if($data->getDestFileSyncLocalPath()) {
$flavorAsset->incrementVersion();
$shouldSave = true;
}

if($shouldSave)
$flavorAsset->save();

if(count($data->getExtraDestFileSyncs()))
{
Expand Down Expand Up @@ -940,10 +946,10 @@ public static function handleConvertFailed(BatchJob $dbBatchJob, kConvertJobData
if(!$flavorAsset)
throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $data->getFlavorAssetId());

$description = $flavorAsset->getDescription();
$description .= "\n" . $dbBatchJob->getMessage();
$flavorAsset->setDescription($description);
$flavorAsset->save();
if(!is_null($data->getEngineMessage())) {
$flavorAsset->setDescription($flavorAsset->getDescription() . "\n" . $data->getEngineMessage());
$flavorAsset->save();
}

// creats the file sync
if(file_exists($data->getLogFileSyncLocalPath()))
Expand Down
24 changes: 23 additions & 1 deletion alpha/apps/kaltura/lib/batch2/model/kConvertJobData.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ class kConvertJobData extends kConvartableJobData
*/
private $extraDestFileSyncs;

/**
* @var string
*/
private $engineMessage;

/**
* @return the $destFileSyncLocalPath
*/
Expand Down Expand Up @@ -287,5 +292,22 @@ public function getExtraDestFileSyncs() {
*/
public function setExtraDestFileSyncs($destFileSyncs) {
$this->extraDestFileSyncs = $destFileSyncs;
}
}

/**
* @return the $engineMessage
*/
public function getEngineMessage() {
return $this->engineMessage;
}

/**
* @param string $engineMessage
*/
public function setEngineMessage($engineMessage) {
$this->engineMessage = $engineMessage;
}



}
6 changes: 6 additions & 0 deletions api_v3/lib/types/batch/KalturaConvertJobData.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ class KalturaConvertJobData extends KalturaConvartableJobData
* @var KalturaDestFileSyncDescriptorArray
*/
public $extraDestFileSyncs;

/**
* @var string
*/
public $engineMessage;

private static $map_between_objects = array
(
Expand All @@ -57,6 +62,7 @@ class KalturaConvertJobData extends KalturaConvartableJobData
"remoteMediaId" ,
"customData" ,
"extraDestFileSyncs",
"engineMessage",
);

public function getMapBetweenObjects ( )
Expand Down
16 changes: 5 additions & 11 deletions batch/batches/Convert/KAsyncConvert.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,7 @@ protected function convertJob(KalturaBatchJob $job, KalturaConvertJobData $data)
$this->stopMonitor();

$jobMessage = "engine [" . get_class($this->operationEngine) . "] converted successfully. ";
if($this->operationEngine->getMessage())
$jobMessage = " Engine message [ " . $jobMessage.$this->operationEngine->getMessage() . "]";


if(!$isDone)
{
return $this->closeJob($job, null, null, $jobMessage, KalturaBatchJobStatus::ALMOST_DONE, $data);
Expand All @@ -222,6 +220,7 @@ protected function convertJob(KalturaBatchJob $job, KalturaConvertJobData $data)
}
catch(KOperationEngineException $e)
{
$data = $this->operationEngine->getData();
$log = $this->operationEngine->getLogData();
//removing unsuported XML chars
$log = preg_replace('/[^\t\n\r\x{20}-\x{d7ff}\x{e000}-\x{fffd}\x{10000}-\x{10ffff}]/u','',$log);
Expand All @@ -237,9 +236,8 @@ protected function convertJob(KalturaBatchJob $job, KalturaConvertJobData $data)
}
}
$err = "engine [" . get_class($this->operationEngine) . "] converted failed: " . $e->getMessage();
if($this->operationEngine->getMessage())
$err .= " Engine message [ " . $this->operationEngine->getMessage() . "]";
return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::CONVERSION_FAILED, $err, KalturaBatchJobStatus::FAILED);

return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::CONVERSION_FAILED, $err, KalturaBatchJobStatus::FAILED, $data);
}
}

Expand Down Expand Up @@ -328,11 +326,7 @@ private function moveFile(KalturaBatchJob $job, KalturaConvertJobData $data)
$data->logFileSyncLocalPath = '';
}

$jobMessage = $job->message;
if($this->operationEngine->getMessage())
$jobMessage .= " Engine message [ " . $this->operationEngine->getMessage() . "]";

return $this->closeJob($job, null, null, $jobMessage, $job->status, $data);
return $this->closeJob($job, null, null, $job->message, $job->status, $data);
}

private function moveExtraFiles(KalturaConvertJobData &$data, $sharedFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ public function operate(kOperator $operator = null, $inFilePath, $configFilePath
// - Test file type
$errorMsg = $this->checkFileType($realInFilePath, $this->SUPPORTED_FILE_TYPES);
if(!is_null($errorMsg))
$this->message = $errorMsg;
$this->data->engineMessage = $errorMsg;

// Test password required
if($this->testPasswordRequired($realInFilePath)) {
$this->message = "Password required.";
$this->data->engineMessage = "Password required.";
}

parent::operate($operator, $realInFilePath, $configFilePath);
Expand All @@ -87,7 +87,7 @@ public function operate(kOperator $operator = null, $inFilePath, $configFilePath
$firstImage = $outDirPath . DIRECTORY_SEPARATOR . $imagesList[0];
$errorMsg = $this->testBlackImage($identifyExe, $firstImage, $errorMsg);
if(!is_null($errorMsg)) {
$this->message = $errorMsg;
$this->data->engineMessage = $errorMsg;
}

$imagesListXML = $this->createImagesListXML($imagesList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function operate(kOperator $operator = null, $inFilePath, $configFilePath
// Test file type
$errorMsg = $this->checkFileType($realInFilePath, $this->SUPPORTED_FILE_TYPES);
if(!is_null($errorMsg))
$this->message = $errorMsg;
$this->data->engineMessage = $errorMsg;

parent::operate($operator, $realInFilePath, $configFilePath);

Expand Down Expand Up @@ -202,7 +202,7 @@ private function validateOutput($inFilePath, $outFilePath)
$outputNum = $this->getNumberOfPages($outputPdfInfo);
if($inputNum != $outputNum) {
$errorMsg = "Output file doesn't match expected page count (input: $inputNum, output: $outputNum)";
$this->message = $errorMsg;
$this->data->engineMessage = $errorMsg;
}
}
}
Expand Down