Exemplo n.º 1
0
 /**
  * decideThumbGenerate is the decision layer for a single thumbnail generation 
  * 
  * @param entry $entry
  * @param thumbParams $destThumbParams
  * @param BatchJob $parentJob
  * @return thumbAsset 
  */
 public static function decideThumbGenerate(entry $entry, thumbParams $destThumbParams, BatchJob $parentJob = null, $sourceAssetId = null, $runSync = false)
 {
     $srcAsset = null;
     assetPeer::resetInstanceCriteriaFilter();
     if ($sourceAssetId) {
         $srcAsset = assetPeer::retrieveById($sourceAssetId);
     } else {
         if ($destThumbParams->getSourceParamsId()) {
             KalturaLog::debug("Look for flavor params [" . $destThumbParams->getSourceParamsId() . "]");
             $srcAsset = assetPeer::retrieveByEntryIdAndParams($entry->getId(), $destThumbParams->getSourceParamsId());
         }
         if (is_null($srcAsset)) {
             KalturaLog::debug("Look for original flavor");
             $srcAsset = flavorAssetPeer::retrieveOriginalByEntryId($entry->getId());
         }
         if (is_null($srcAsset) || $srcAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) {
             KalturaLog::debug("Look for highest bitrate flavor");
             $srcAsset = flavorAssetPeer::retrieveHighestBitrateByEntryId($entry->getId());
         }
     }
     if (is_null($srcAsset)) {
         throw new APIException(APIErrors::FLAVOR_ASSET_IS_NOT_READY);
     }
     $errDescription = null;
     $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($srcAsset->getId());
     $destThumbParamsOutput = self::validateThumbAndMediaInfo($destThumbParams, $mediaInfo, $errDescription);
     $thumbAsset = thumbAssetPeer::retrieveByEntryIdAndParams($entry->getId(), $destThumbParams->getId());
     if ($thumbAsset) {
         $description = $thumbAsset->getDescription() . "\n" . $errDescription;
         $thumbAsset->setDescription($description);
     } else {
         $thumbAsset = new thumbAsset();
         $thumbAsset->setPartnerId($entry->getPartnerId());
         $thumbAsset->setEntryId($entry->getId());
         $thumbAsset->setDescription($errDescription);
         $thumbAsset->setFlavorParamsId($destThumbParams->getId());
     }
     $thumbAsset->incrementVersion();
     $thumbAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_CONVERTING);
     $thumbAsset->setTags($destThumbParamsOutput->getTags());
     $thumbAsset->setFileExt($destThumbParamsOutput->getFileExt());
     if (!$destThumbParamsOutput) {
         $thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_ERROR);
         $thumbAsset->save();
         return null;
     }
     $thumbAsset->save();
     // save flavor params
     $destThumbParamsOutput->setPartnerId($entry->getPartnerId());
     $destThumbParamsOutput->setEntryId($entry->getId());
     $destThumbParamsOutput->setFlavorAssetId($thumbAsset->getId());
     $destThumbParamsOutput->setFlavorAssetVersion($thumbAsset->getVersion());
     $destThumbParamsOutput->save();
     $srcSyncKey = $srcAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $srcAssetType = $srcAsset->getType();
     if (!$runSync) {
         $job = kJobsManager::addCapturaThumbJob($parentJob, $entry->getPartnerId(), $entry->getId(), $thumbAsset->getId(), $srcSyncKey, $srcAssetType, $destThumbParamsOutput);
         return $thumbAsset;
     }
     $errDescription = null;
     $capturedPath = self::generateThumbnail($srcAsset, $destThumbParamsOutput, $errDescription);
     // failed
     if (!$capturedPath) {
         $thumbAsset->incrementVersion();
         $thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_ERROR);
         $thumbAsset->setDescription($thumbAsset->getDescription() . "\n{$errDescription}");
         $thumbAsset->save();
         return $thumbAsset;
     }
     $thumbAsset->incrementVersion();
     $thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_READY);
     if (file_exists($capturedPath)) {
         list($width, $height, $type, $attr) = getimagesize($capturedPath);
         $thumbAsset->setWidth($width);
         $thumbAsset->setHeight($height);
         $thumbAsset->setSize(filesize($capturedPath));
     }
     $logPath = $capturedPath . '.log';
     if (file_exists($logPath)) {
         $thumbAsset->incLogFileVersion();
         $thumbAsset->save();
         // creats the file sync
         $logSyncKey = $thumbAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_CONVERT_LOG);
         kFileSyncUtils::moveFromFile($logPath, $logSyncKey);
         KalturaLog::debug("Log archived file to: " . kFileSyncUtils::getLocalFilePathForKey($logSyncKey));
     } else {
         $thumbAsset->save();
     }
     $syncKey = $thumbAsset->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     kFileSyncUtils::moveFromFile($capturedPath, $syncKey);
     KalturaLog::debug("Thumbnail archived file to: " . kFileSyncUtils::getLocalFilePathForKey($syncKey));
     if ($thumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
         // increment thumbnail version
         $entry->setThumbnail(".jpg");
         $entry->save();
         $entrySyncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
         $syncFile = kFileSyncUtils::createSyncFileLinkForKey($entrySyncKey, $syncKey, false);
         if ($syncFile) {
             // removes the DEFAULT_THUMB tag from all other thumb assets
             $entryThumbAssets = thumbAssetPeer::retrieveByEntryId($thumbAsset->getEntryId());
             foreach ($entryThumbAssets as $entryThumbAsset) {
                 if ($entryThumbAsset->getId() == $thumbAsset->getId()) {
                     continue;
                 }
                 if (!$entryThumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
                     continue;
                 }
                 $entryThumbAsset->removeTags(array(thumbParams::TAG_DEFAULT_THUMB));
                 $entryThumbAsset->save();
             }
         }
     }
     if (!is_null($thumbAsset->getFlavorParamsId())) {
         kFlowHelper::generateThumbnailsFromFlavor($thumbAsset->getEntryId(), null, $thumbAsset->getFlavorParamsId());
     }
     return $thumbAsset;
 }
Exemplo n.º 2
0
 /**
  * @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;
             }
             $thumbParamsOutput = assetParamsOutputPeer::retrieveByAssetId($entryThumbnail->getId());
             /* @var $thumbParamsOutput thumbParamsOutput */
             if ($thumbParamsOutput->getSourceParamsId() != $flavorAsset->getFlavorParamsId()) {
                 continue;
             }
             $srcSyncKey = $flavorAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
             $srcAssetType = $flavorAsset->getType();
             kJobsManager::addCapturaThumbJob($entryThumbnail->getPartnerId(), $entryThumbnail->getEntryId(), $entryThumbnail->getId(), $srcSyncKey, $flavorAsset->getId(), $srcAssetType, $thumbParamsOutput);
         }
     }
     return $dbBatchJob;
 }
 /**
  * decideThumbGenerate is the decision layer for a single thumbnail generation 
  * 
  * @param entry $entry
  * @param thumbParams $destThumbParams
  * @param BatchJob $parentJob
  * @return thumbAsset 
  */
 public static function decideThumbGenerate(entry $entry, thumbParams $destThumbParams, BatchJob $parentJob = null, $sourceAssetId = null, $runSync = false, $srcAsset = null)
 {
     if (is_null($srcAsset)) {
         $srcAsset = self::getSourceAssetForGenerateThumbnail($sourceAssetId, $destThumbParams->getSourceParamsId(), $entry->getId());
         if (is_null($srcAsset)) {
             throw new APIException(APIErrors::FLAVOR_ASSET_IS_NOT_READY);
         }
     }
     $errDescription = null;
     $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($srcAsset->getId());
     $destThumbParamsOutput = self::validateThumbAndMediaInfo($destThumbParams, $mediaInfo, $errDescription);
     if ($srcAsset->getType() == assetType::FLAVOR && is_null($destThumbParamsOutput->getVideoOffset())) {
         $destThumbParamsOutput->setVideoOffset($entry->getThumbOffset());
     }
     $destThumbParamsOutput->setVideoOffset(min($destThumbParamsOutput->getVideoOffset(), $entry->getDuration()));
     if (!$destThumbParamsOutput->getDensity()) {
         $partner = $entry->getPartner();
         if (!is_null($partner)) {
             $destThumbParamsOutput->setDensity($partner->getDefThumbDensity());
         }
     }
     $thumbAsset = assetPeer::retrieveByEntryIdAndParams($entry->getId(), $destThumbParams->getId());
     if ($thumbAsset) {
         $description = $thumbAsset->getDescription() . "\n" . $errDescription;
         $thumbAsset->setDescription($description);
     } else {
         $thumbAsset = new thumbAsset();
         $thumbAsset->setPartnerId($entry->getPartnerId());
         $thumbAsset->setEntryId($entry->getId());
         $thumbAsset->setDescription($errDescription);
         $thumbAsset->setFlavorParamsId($destThumbParams->getId());
     }
     $thumbAsset->incrementVersion();
     $thumbAsset->setTags($destThumbParamsOutput->getTags());
     $thumbAsset->setFileExt($destThumbParamsOutput->getFileExt());
     if ($thumbAsset->getStatus() != asset::ASSET_STATUS_READY) {
         $thumbAsset->setStatus(asset::ASSET_STATUS_CONVERTING);
     }
     //Sets the default thumb if this the only default thumb
     kBusinessPreConvertDL::setIsDefaultThumb($thumbAsset);
     if (!$destThumbParamsOutput) {
         $thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_ERROR);
         $thumbAsset->save();
         return null;
     }
     $thumbAsset->save();
     // save flavor params
     $destThumbParamsOutput->setPartnerId($entry->getPartnerId());
     $destThumbParamsOutput->setEntryId($entry->getId());
     $destThumbParamsOutput->setFlavorAssetId($thumbAsset->getId());
     $destThumbParamsOutput->setFlavorAssetVersion($thumbAsset->getVersion());
     $destThumbParamsOutput->save();
     $srcSyncKey = $srcAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $srcAssetType = $srcAsset->getType();
     if (!$runSync) {
         $job = kJobsManager::addCapturaThumbJob($parentJob, $entry->getPartnerId(), $entry->getId(), $thumbAsset->getId(), $srcSyncKey, $srcAsset->getId(), $srcAssetType, $destThumbParamsOutput);
         return $thumbAsset;
     }
     $errDescription = null;
     // Since this method is called when trying to crop an existing thumbnail, need to add this check - thumbAssets have no mediaInfo.
     $capturedPath = self::generateThumbnail($srcAsset, $destThumbParamsOutput, $errDescription, $mediaInfo ? $mediaInfo->getVideoRotation() : null);
     // failed
     if (!$capturedPath) {
         $thumbAsset->incrementVersion();
         $thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_ERROR);
         $thumbAsset->setDescription($thumbAsset->getDescription() . "\n{$errDescription}");
         $thumbAsset->save();
         return $thumbAsset;
     }
     $thumbAsset->incrementVersion();
     $thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_READY);
     if (file_exists($capturedPath)) {
         list($width, $height, $type, $attr) = getimagesize($capturedPath);
         $thumbAsset->setWidth($width);
         $thumbAsset->setHeight($height);
         $thumbAsset->setSize(filesize($capturedPath));
     }
     $logPath = $capturedPath . '.log';
     if (file_exists($logPath)) {
         $thumbAsset->incLogFileVersion();
         $thumbAsset->save();
         // creats the file sync
         $logSyncKey = $thumbAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_CONVERT_LOG);
         kFileSyncUtils::moveFromFile($logPath, $logSyncKey);
         KalturaLog::debug("Log archived file to: " . kFileSyncUtils::getLocalFilePathForKey($logSyncKey));
     } else {
         $thumbAsset->save();
     }
     $syncKey = $thumbAsset->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     kFileSyncUtils::moveFromFile($capturedPath, $syncKey);
     KalturaLog::debug("Thumbnail archived file to: " . kFileSyncUtils::getLocalFilePathForKey($syncKey));
     if ($thumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
         // increment thumbnail version
         $entry->setThumbnail(".jpg");
         $entry->setCreateThumb(false);
         $entry->save();
         $entrySyncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
         $syncFile = kFileSyncUtils::createSyncFileLinkForKey($entrySyncKey, $syncKey);
         if ($syncFile) {
             // removes the DEFAULT_THUMB tag from all other thumb assets
             $entryThumbAssets = assetPeer::retrieveThumbnailsByEntryId($thumbAsset->getEntryId());
             foreach ($entryThumbAssets as $entryThumbAsset) {
                 if ($entryThumbAsset->getId() == $thumbAsset->getId()) {
                     continue;
                 }
                 if (!$entryThumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
                     continue;
                 }
                 $entryThumbAsset->removeTags(array(thumbParams::TAG_DEFAULT_THUMB));
                 $entryThumbAsset->save();
             }
         }
     }
     if (!is_null($thumbAsset->getFlavorParamsId())) {
         kFlowHelper::generateThumbnailsFromFlavor($thumbAsset->getEntryId(), null, $thumbAsset->getFlavorParamsId());
     }
     return $thumbAsset;
 }
 /**
  * @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());
             }
         }
         $entryThumbnails = assetPeer::retrieveThumbnailsByEntryId($flavorAsset->getEntryId());
         foreach ($entryThumbnails as $entryThumbnail) {
             /* @var $entryThumbnail thumbAsset */
             if ($entryThumbnail->getStatus() != asset::ASSET_STATUS_WAIT_FOR_CONVERT || !$entryThumbnail->getFlavorParamsId()) {
                 continue;
             }
             $thumbParamsOutput = assetParamsOutputPeer::retrieveByAssetId($entryThumbnail->getId());
             /* @var $thumbParamsOutput thumbParamsOutput */
             if ($thumbParamsOutput->getSourceParamsId() != $flavorAsset->getFlavorParamsId()) {
                 continue;
             }
             $srcSyncKey = $flavorAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
             $srcAssetType = $flavorAsset->getType();
             kJobsManager::addCapturaThumbJob($entryThumbnail->getPartnerId(), $entryThumbnail->getEntryId(), $entryThumbnail->getId(), $srcSyncKey, $flavorAsset->getId(), $srcAssetType, $thumbParamsOutput);
         }
     }
     return $dbBatchJob;
 }