Exemple #1
0
 /**
  * will return a pair of file_root and file_path
  *
  * @param ISyncableFile $object
  * @param int $subType
  * @param int $storageProfileId
  * @param $version
  */
 public static function getFilePathArr(FileSyncKey $key, $storageProfileId = null)
 {
     KalturaLog::log(__METHOD__ . " - key [{$key}], storageProfileId [{$storageProfileId}]");
     $storageProfile = self::getStorageProfile($storageProfileId);
     if (is_null($storageProfile)) {
         throw new Exception("Storage Profile [{$storageProfileId}] not found");
     }
     $pathManager = $storageProfile->getPathManager();
     $object = kFileSyncUtils::retrieveObjectForSyncKey($key);
     return $pathManager->generateFilePathArr($object, $key->object_sub_type, $key->version);
 }
Exemple #2
0
 /**
  * @param BatchJob $parentJob
  * @param int $partnerId
  * @param string $entryId
  * @param string $thumbAssetId
  * @param FileSyncKey $srcSyncKey
  * @param string $srcAssetId
  * @param int $srcAssetType enum of assetType
  * @param thumbParamsOutput $thumbParams
  * @return BatchJob
  */
 public static function addCapturaThumbJob(BatchJob $parentJob = null, $partnerId, $entryId, $thumbAssetId, FileSyncKey $srcSyncKey, $srcAssetId, $srcAssetType, thumbParamsOutput $thumbParams = null)
 {
     $thumbAsset = assetPeer::retrieveById($thumbAssetId);
     if (!$thumbAsset) {
         KalturaLog::err("No thumbnail asset found for id [{$thumbAssetId}]");
         return null;
     }
     $partner = PartnerPeer::retrieveByPK($thumbAsset->getPartnerId());
     list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, true, false);
     if (!$fileSync) {
         $thumbAsset->setStatus(asset::ASSET_STATUS_ERROR);
         $thumbAsset->setDescription("Source file sync not found: {$srcSyncKey}");
         $thumbAsset->save();
         KalturaLog::err("Source file sync not found: {$srcSyncKey}");
         return null;
     }
     if (!$local) {
         if ($fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL && $partner && $partner->getImportRemoteSourceForConvert()) {
             $url = $fileSync->getExternalUrl($entryId);
             $originalAsset = kFileSyncUtils::retrieveObjectForSyncKey($srcSyncKey);
             if ($originalAsset instanceof flavorAsset) {
                 KalturaLog::debug("Creates import job for remote file sync [{$url}]");
                 if ($thumbParams) {
                     $thumbParams->setSourceParamsId($originalAsset->getFlavorParamsId());
                     $thumbParams->save();
                 }
                 $thumbAsset->setStatus(asset::ASSET_STATUS_WAIT_FOR_CONVERT);
                 $thumbAsset->setDescription("Source file sync is importing: {$srcSyncKey}");
                 $thumbAsset->save();
                 return kJobsManager::addImportJob($parentJob, $thumbAsset->getEntryId(), $partner->getId(), $url, $originalAsset, null, null, true);
             }
             KalturaLog::debug("Downloading remote file sync [{$url}]");
             $downloadPath = myContentStorage::getFSUploadsPath() . '/' . $thumbAsset->getId() . '.jpg';
             if (KCurlWrapper::getDataFromFile($url, $downloadPath)) {
                 kFileSyncUtils::moveFromFile($downloadPath, $srcSyncKey);
                 list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, false, false);
                 if (!$fileSync) {
                     throw new kCoreException("Source file not found for thumbnail capture [{$thumbAssetId}]", kCoreException::SOURCE_FILE_NOT_FOUND);
                 }
             }
         } else {
             throw new kCoreException("Source file not found for thumbnail capture [{$thumbAssetId}]", kCoreException::SOURCE_FILE_NOT_FOUND);
         }
     }
     $localPath = $fileSync->getFullPath();
     $remoteUrl = $fileSync->getExternalUrl($entryId);
     // creates convert data
     $data = new kCaptureThumbJobData();
     $data->setThumbAssetId($thumbAssetId);
     $data->setSrcAssetId($srcAssetId);
     $data->setSrcAssetType($srcAssetType);
     $data->setSrcFileSyncLocalPath($localPath);
     $data->setSrcFileSyncRemoteUrl($remoteUrl);
     $data->setThumbParamsOutputId($thumbParams->getId());
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild(BatchJobType::CAPTURE_THUMB);
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($entryId);
         $batchJob->setPartnerId($partnerId);
     }
     $batchJob->setObjectId($thumbAssetId);
     $batchJob->setObjectType(BatchJobObjectType::ASSET);
     return kJobsManager::addJob($batchJob, $data, BatchJobType::CAPTURE_THUMB);
 }
 /**
  * @param BatchJob $dbBatchJob
  * @param kConvertCollectionJobData $data
  * @return BatchJob
  */
 public static function handleDeleteFileFinished(BatchJob $dbBatchJob, kDeleteFileJobData $data)
 {
     KalturaLog::debug("File delete finished for file path: " . $data->getLocalFileSyncPath() . ", data center: " . $dbBatchJob->getDc());
     //Change status of the filesync to "purged"
     $fileSyncFroDeletedFile = kFileSyncUtils::retrieveObjectForSyncKey($data->getSyncKey());
     $fileSyncFroDeletedFile->setStatus(FileSync::FILE_SYNC_STATUS_PURGED);
     $fileSyncFroDeletedFile->save();
     return $dbBatchJob;
 }