Exemple #1
0
 /**
  * @param BatchJob $parentJob
  * @param flavorAsset $asset
  * @param array $files
  * @return BatchJob
  */
 public static function addConcatJob(BatchJob $parentJob = null, flavorAsset $asset, array $files, $offset = null, $duration = null)
 {
     $jobData = new kConcatJobData();
     $jobData->setSrcFiles($files);
     $jobData->setFlavorAssetId($asset->getId());
     $jobData->setOffset($offset);
     $jobData->setDuration($duration);
     $entry = $asset->getentry();
     if ($entry && $entry->getStatus() != entryStatus::READY) {
         $entry->setStatus(entryStatus::PRECONVERT);
         $entry->save();
     }
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild(BatchJobType::CONCAT);
     } else {
         $batchJob = new BatchJob();
         $batchJob->setPartnerId($asset->getPartnerId());
     }
     $batchJob->setEntryId($asset->getEntryId());
     $batchJob->setObjectId($jobData->getFlavorAssetId());
     $batchJob->setObjectType(BatchJobObjectType::ASSET);
     return self::addJob($batchJob, $jobData, BatchJobType::CONCAT);
 }
Exemple #2
0
 /**
  * @param BatchJob $dbBatchJob
  * @param kConcatJobData $data
  * @return BatchJob
  */
 public static function handleConcatFinished(BatchJob $dbBatchJob, kConcatJobData $data)
 {
     if ($dbBatchJob->getExecutionStatus() == BatchJobExecutionStatus::ABORTED) {
         return $dbBatchJob;
     }
     if (!file_exists($data->getDestFilePath())) {
         throw new APIException(APIErrors::INVALID_FILE_NAME, $data->getDestFilePath());
     }
     $flavorAsset = assetPeer::retrieveByIdNoFilter($data->getFlavorAssetId());
     if (!$flavorAsset) {
         throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $data->getFlavorAssetId());
     }
     if ($flavorAsset->getStatus() == asset::ASSET_STATUS_DELETED) {
         return $dbBatchJob;
     }
     $flavorAsset->incrementVersion();
     $ext = pathinfo($data->getDestFilePath(), PATHINFO_EXTENSION);
     if ($ext) {
         $flavorAsset->setFileExt($ext);
     }
     $flavorAsset->save();
     $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     kFileSyncUtils::moveFromFile($data->getDestFilePath(), $syncKey);
     kEventsManager::raiseEvent(new kObjectAddedEvent($flavorAsset, $dbBatchJob));
     return $dbBatchJob;
 }