public function setJobData(StorageProfile $storage, FileSync $fileSync)
 {
     /* @var $storage KontikiStorageProfile */
     $this->setServerUrl($storage->getStorageUrl());
     $this->setServiceToken($storage->getServiceToken());
     if ($fileSync->getObjectType() != FileSyncObjectType::ASSET) {
         throw new kCoreException("Incompatible filesync type", kCoreException::INTERNAL_SERVER_ERROR);
     }
     $this->setContentMoid($fileSync->getFilePath());
 }
Ejemplo n.º 2
0
 protected function doGetFileSyncUrl(FileSync $fileSync)
 {
     $storageProfile = StorageProfilePeer::retrieveByPK($this->params->getStorageId());
     /* @var $storageProfile KontikiStorageProfile */
     $kontikiAPIWrapper = new KontikiAPIWrapper($storageProfile->getStorageUrl());
     $playbackResource = $kontikiAPIWrapper->getPlaybackResource(KontikiPlugin::SERVICE_TOKEN_PREFIX . base64_encode($storageProfile->getServiceToken()), $fileSync->getFilePath());
     if (!$playbackResource) {
         return null;
     }
     return strval($playbackResource->urn) . ";realmId:" . strval($playbackResource->realmId) . ";realmTicket:" . strval($playbackResource->realmTicket);
 }
 public function setStorageExportJobData(StorageProfile $externalStorage, FileSync $fileSync, $srcFileSyncLocalPath, $force = false)
 {
     /* @var $externalStorage KontikiStorageProfile */
     $this->setServerUrl($externalStorage->getStorageUrl());
     $this->setServiceToken($externalStorage->getServiceToken());
     $this->setSrcFileSyncId($fileSync->getId());
     if ($fileSync->getObjectType() != FileSyncObjectType::ASSET) {
         throw new kCoreException("Incompatible filesync type", kCoreException::INTERNAL_SERVER_ERROR);
     }
     $this->setFlavorAssetId($fileSync->getObjectId());
 }
Ejemplo n.º 4
0
 /**
  * @var StorageProfile $storage
  * @var FileSync $fileSync
  */
 public function setJobData(StorageProfile $storage, FileSync $filesync)
 {
     $this->setServerUrl($storage->getStorageUrl());
     $this->setServerUsername($storage->getStorageUsername());
     $this->setServerPassword($storage->getStoragePassword());
     $this->setServerPrivateKey($storage->getPrivateKey());
     $this->setServerPublicKey($storage->getPublicKey());
     $this->setServerPassPhrase($storage->getPassPhrase());
     $this->setFtpPassiveMode($storage->getStorageFtpPassiveMode());
     $this->setSrcFileSyncId($filesync->getId());
     $this->setDestFileSyncStoredPath($storage->getStorageBaseDir() . '/' . $filesync->getFilePath());
 }
Ejemplo n.º 5
0
 /**
  * @param string $entryId
  * @param FileSync $object
  * @param int $fileSyncId
  * @param string $sourceFileUrl
  * @return BatchJob
  */
 public static function addFileSyncImportJob($entryId, FileSync $fileSync, $sourceFileUrl, BatchJob $parentJob = null, $fileSize = null)
 {
     $partnerId = $fileSync->getPartnerId();
     $fileSyncId = $fileSync->getId();
     $dc = $fileSync->getDc();
     KalturaLog::log(__METHOD__ . " entryId[{$entryId}], partnerId[{$partnerId}], fileSyncId[{$fileSyncId}], sourceFileUrl[{$sourceFileUrl}]");
     $fileSyncImportData = new kFileSyncImportJobData();
     $fileSyncImportData->setSourceUrl($sourceFileUrl);
     $fileSyncImportData->setFilesyncId($fileSyncId);
     $fileSyncImportData->setFileSize($fileSize);
     // tmpFilePath and destFilePath will be set later during get exlusive call on the target data center
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild(BatchJobType::FILESYNC_IMPORT, null, true, $dc);
     } else {
         $batchJob = new BatchJob();
         $batchJob->setDc($dc);
         $batchJob->setEntryId($entryId);
         $batchJob->setPartnerId($partnerId);
     }
     $batchJob->setObjectId($fileSyncId);
     $batchJob->setObjectType(BatchJobObjectType::FILE_SYNC);
     //In case file sync is of type data and holds flavor asset than we need to check if its the source asset that is being synced and raise it sync priority
     if ($fileSync->getObjectType() == FileSyncObjectType::FLAVOR_ASSET && $fileSync->getObjectSubType() == entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA && $fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_FILE) {
         $assetdb = assetPeer::retrieveById($fileSync->getObjectId());
         if ($assetdb) {
             $isSourceAsset = $assetdb->getIsOriginal();
             if ($isSourceAsset) {
                 $fileSyncImportData->setIsSourceAsset(true);
             }
         }
     }
     KalturaLog::log("Creating Filesync Import job, with file sync id: {$fileSyncId} size: {$fileSize}");
     return kJobsManager::addJob($batchJob, $fileSyncImportData, BatchJobType::FILESYNC_IMPORT);
 }
Ejemplo n.º 6
0
 /**
  * Derives the delivery profile dynamic attributes from the file sync and the flavor asset.
  * @param FileSync $fileSync
  * @param flavorAsset $flavorAsset
  */
 public function initDeliveryDynamicAttributes(FileSync $fileSync = null, flavorAsset $flavorAsset = null)
 {
     if ($flavorAsset) {
         $this->params->setContainerFormat($flavorAsset->getContainerFormat());
     }
     if ($flavorAsset && $flavorAsset->getFileExt() !== null) {
         // if the extension is missing use the one from the actual path
         $this->params->setFileExtension($flavorAsset->getFileExt());
     } else {
         if ($fileSync) {
             $this->params->setFileExtension(pathinfo($fileSync->getFilePath(), PATHINFO_EXTENSION));
         }
     }
 }
Ejemplo n.º 7
0
 public function setStorageExportJobData(StorageProfile $externalStorage, FileSync $fileSync, $srcFileSyncLocalPath, $force = false)
 {
     $this->setServerUrl($externalStorage->getStorageUrl());
     $this->setServerUsername($externalStorage->getStorageUsername());
     $this->setServerPassword($externalStorage->getStoragePassword());
     $this->setServerPrivateKey($externalStorage->getPrivateKey());
     $this->setServerPublicKey($externalStorage->getPublicKey());
     $this->setServerPassPhrase($externalStorage->getPassPhrase());
     $this->setFtpPassiveMode($externalStorage->getStorageFtpPassiveMode());
     $this->setSrcFileSyncLocalPath($srcFileSyncLocalPath);
     $this->setSrcFileSyncId($fileSync->getId());
     $this->setForce($force);
     $this->setDestFileSyncStoredPath($externalStorage->getStorageBaseDir() . '/' . $fileSync->getFilePath());
     $this->setCreateLink($externalStorage->getCreateFileLink());
 }
Ejemplo n.º 8
0
 protected function doGetFileSyncUrl(FileSync $fileSync)
 {
     $url = $fileSync->getFilePath();
     if ($this->getUseIntelliseek() && $this->params->getSeekFromTime() > 0) {
         $fromTime = floor($this->params->getSeekFromTime() / 1000);
         /*
          * Akamai servers fail to return subset of the last second of the video.
          * The URL will return the two last seconds of the video in such cases. 
          **/
         $entry = entryPeer::retrieveByPK($this->params->getEntryId());
         if ($entry) {
             $fromTime = min($fromTime, $entry->getDurationInt() - 1);
         }
         $url .= "?aktimeoffset={$fromTime}";
     }
     return $url;
 }
Ejemplo n.º 9
0
 /**
  * @param FileSync $object
  * @return bool true if should continue to the next consumer
  */
 private function addedFileSync(FileSync $object)
 {
     if (!$object instanceof FileSync || $object->getStatus() != FileSync::FILE_SYNC_STATUS_PENDING || $object->getFileType() != FileSync::FILE_SYNC_FILE_TYPE_FILE) {
         return true;
     }
     if ($object->getObjectType() != FileSyncObjectType::FLAVOR_ASSET) {
         return true;
     }
     $flavorAssetId = $object->getObjectId();
     $flavorAsset = flavorAssetPeer::retrieveById($flavorAssetId);
     if (!$flavorAsset || !$flavorAsset->getIsOriginal()) {
         return true;
     }
     if ($this->saveIfShouldScan($flavorAsset)) {
         // file sync belongs to a flavor asset in status pending and suits a virus scan profile
         return false;
         // stop all remaining consumers
     }
     return true;
 }
Ejemplo n.º 10
0
 /**
  * 
  * @param FileSyncKey $key
  * @return FileSync
  */
 public static function createForFileSyncKey(FileSyncKey $key)
 {
     $file_sync = new FileSync();
     $file_sync->setObjectId($key->object_id);
     $file_sync->setObjectType($key->object_type);
     $file_sync->setObjectSubType($key->object_sub_type);
     $file_sync->setVersion($key->version);
     if ($key->partner_id) {
         $file_sync->setPartnerId($key->partner_id);
     }
     return $file_sync;
 }
 /**
  * @param string $entryId
  * @param FileSync $object
  * @param int $fileSyncId
  * @param string $sourceFileUrl
  * @return BatchJob
  */
 public static function addFileSyncImportJob($entryId, FileSync $fileSync, $sourceFileUrl, BatchJob $parentJob = null, $fileSize = null)
 {
     $partnerId = $fileSync->getPartnerId();
     $fileSyncId = $fileSync->getId();
     $dc = $fileSync->getDc();
     KalturaLog::log(__METHOD__ . " entryId[{$entryId}], partnerId[{$partnerId}], fileSyncId[{$fileSyncId}], sourceFileUrl[{$sourceFileUrl}]");
     $fileSyncImportData = new kFileSyncImportJobData();
     $fileSyncImportData->setSourceUrl($sourceFileUrl);
     $fileSyncImportData->setFilesyncId($fileSyncId);
     // tmpFilePath and destFilePath will be set later during get exlusive call on the target data center
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild(true, $dc);
     } else {
         $batchJob = new BatchJob();
         $batchJob->setDc($dc);
         $batchJob->setEntryId($entryId);
         $batchJob->setPartnerId($partnerId);
     }
     $batchJob->setFileSize($fileSize);
     KalturaLog::log("Creating Filesync Import job, with file sync id: {$fileSyncId} size: {$fileSize}");
     return kJobsManager::addJob($batchJob, $fileSyncImportData, BatchJobType::FILESYNC_IMPORT);
 }
Ejemplo n.º 12
0
 public static function updateThumbnailFromFile($dbEntry, $filePath, $fileSyncType = entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB)
 {
     $dbEntry->setThumbnail(".jpg");
     // this will increase the thumbnail version
     $dbEntry->save();
     $fileSyncKey = $dbEntry->getSyncKey($fileSyncType);
     $fileSync = FileSync::createForFileSyncKey($fileSyncKey);
     kFileSyncUtils::file_put_contents($fileSyncKey, file_get_contents($filePath));
     $wrapper = objectWrapperBase::getWrapperClass($dbEntry);
     $wrapper->removeFromCache("entry", $dbEntry->getId());
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE_THUMBNAIL, $dbEntry);
     $mediaEntry = KalturaEntryFactory::getInstanceByType($dbEntry->getType());
     $mediaEntry->fromObject($dbEntry);
     self::disableAutoThumbnailCreation($dbEntry->getId());
     return $mediaEntry;
 }
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     if (!$puser_kuser) {
         $this->addError(APIErrors::INVALID_USER_ID, $puser_id);
         return;
     }
     $entry_id = $this->getPM("entry_id");
     $entry = entryPeer::retrieveByPK($entry_id);
     // TODO - verify the user is allowed to modify the entry
     if ($entry->getKshowId() === kshow::SANDBOX_ID) {
         $this->addError(APIErrors::SANDBOX_ALERT);
         return;
     }
     $entry->setThumbnail(".jpg");
     $entry->setCreateThumb(false);
     $entry->save();
     if (isset($HTTP_RAW_POST_DATA)) {
         $thumb_data = $HTTP_RAW_POST_DATA;
     } else {
         $thumb_data = file_get_contents("php://input");
     }
     $thumb_data_size = strlen($thumb_data);
     $fileSyncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
     $fileSync = FileSync::createForFileSyncKey($fileSyncKey);
     kFileSyncUtils::file_put_contents($fileSyncKey, $thumb_data);
     // update the metadata in case of a roughcut
     if ($entry->getType() == entryType::MIX) {
         $sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
         $xml_doc = new DOMDocument();
         $xml_doc->loadXML(kFileSyncUtils::file_get_contents($sync_key));
         if (myMetadataUtils::updateThumbUrl($xml_doc, $entry->getThumbnailUrl())) {
             $entry->setMetadata(null, $xml_doc->saveXML(), true, null, null);
             //$entry->getVersion() );
         }
         myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE_THUMBNAIL, $entry);
     }
     $this->res = $entry->getBigThumbnailUrl();
     $wrapper = objectWrapperBase::getWrapperClass($entry, objectWrapperBase::DETAIL_LEVEL_REGULAR);
     $wrapper->removeFromCache("entry", $entry->getId());
     $this->addMsg("entry", $wrapper);
 }
Ejemplo n.º 14
0
 public function getEntryId(FileSync $fileSync)
 {
     if ($fileSync->getObjectType() == FileSyncObjectType::ENTRY) {
         return $fileSync->getObjectId();
     }
     if ($fileSync->getObjectType() == FileSyncObjectType::BATCHJOB) {
         $job = BatchJobPeer::retrieveByPK($fileSync->getObjectId());
         if ($job) {
             return $job->getEntryId();
         }
     }
     if ($fileSync->getObjectType() == FileSyncObjectType::FLAVOR_ASSET) {
         $flavor = flavorAssetPeer::retrieveById($fileSync->getObjectId());
         if ($flavor) {
             return $flavor->getEntryId();
         }
     }
     return null;
 }
 private function doGetServeIsmUrl(FileSync $fileSync, $partnerPath, StorageProfile $storage = null)
 {
     $serverUrl = $this->getUrl();
     if ($fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_FILE) {
         $path = $partnerPath;
         $path .= '/serveIsm/objectId/' . $fileSync->getObjectId() . '_' . $fileSync->getObjectSubType() . '_' . $fileSync->getVersion();
         $path .= '.' . pathinfo($fileSync->getFilePath(), PATHINFO_EXTENSION) . '/manifest';
     } else {
         if ($storage) {
             $serverUrl = $this->getUrl();
         }
         $path = '/' . $fileSync->getFilePath() . '/manifest';
     }
     $matches = null;
     if (preg_match('/(https?:\\/\\/[^\\/]+)(.*)/', $serverUrl, $matches)) {
         $path = $matches[2] . $path;
     }
     $path = str_replace('//', '/', $path);
     return $path;
 }
Ejemplo n.º 16
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      FileSync $value A FileSync object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(FileSync $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) {
             self::$instances[$key] = $obj;
             kMemoryManager::registerPeer('FileSyncPeer');
         }
     }
 }
 public static function addStorageDeleteJob(BatchJob $parentJob = null, $entryId = null, StorageProfile $storage, FileSync $fileSync)
 {
     $netStorageDeleteData = new kStorageDeleteJobData();
     $netStorageDeleteData->setServerUrl($storage->getStorageUrl());
     $netStorageDeleteData->setServerUsername($storage->getStorageUsername());
     $netStorageDeleteData->setServerPassword($storage->getStoragePassword());
     $netStorageDeleteData->setFtpPassiveMode($storage->getStorageFtpPassiveMode());
     $netStorageDeleteData->setSrcFileSyncId($fileSync->getId());
     $netStorageDeleteData->setDestFileSyncStoredPath($storage->getStorageBaseDir() . '/' . $fileSync->getFilePath());
     if ($parentJob) {
         $batchJob = $parentJob->createChild(false);
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($entryId);
         $batchJob->setPartnerId($storage->getPartnerId());
     }
     KalturaLog::log("Creating Net-Storage Delete job, with source file: " . $netStorageDeleteData->getSrcFileSyncLocalPath());
     return self::addJob($batchJob, $netStorageDeleteData, BatchJobType::STORAGE_DELETE, $storage->getProtocol());
 }
Ejemplo n.º 18
0
 /**
  * @param FileSync $fileSync
  * @return string
  */
 protected function doGetFileSyncUrl(FileSync $fileSync)
 {
     $url = $fileSync->getFilePath();
     return $url;
 }
Ejemplo n.º 19
0
 /**
  * @param BatchJob $parentJob
  * @param string $entryId
  * @param int $partnerId
  * @param StorageProfile $externalStorage
  * @param SyncFile $fileSync
  * @param string $srcFileSyncLocalPath
  * @param bool $force
  * 
  * @return BatchJob
  */
 public static function addStorageExportJob(BatchJob $parentJob = null, $entryId, $partnerId, StorageProfile $externalStorage, FileSync $fileSync, $srcFileSyncLocalPath, $force = false, $dc = null)
 {
     KalturaLog::debug("entryId[{$entryId}], partnerId[{$partnerId}], externalStorage id[" . $externalStorage->getId() . "], fileSync id[" . $fileSync->getId() . "], srcFileSyncLocalPath[{$srcFileSyncLocalPath}]");
     $netStorageExportData = kStorageExportJobData::getInstance($externalStorage->getProtocol());
     $netStorageExportData->setStorageExportJobData($externalStorage, $fileSync, $srcFileSyncLocalPath);
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild(BatchJobType::STORAGE_EXPORT, $externalStorage->getProtocol(), false);
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($entryId);
         $batchJob->setPartnerId($partnerId);
     }
     $batchJob->setObjectId($fileSync->getId());
     $batchJob->setObjectType(BatchJobObjectType::FILE_SYNC);
     $batchJob->setJobSubType($externalStorage->getProtocol());
     $batchJob->setDc($dc);
     KalturaLog::log("Creating Storage export job, with source file: " . $netStorageExportData->getSrcFileSyncLocalPath());
     return self::addJob($batchJob, $netStorageExportData, BatchJobType::STORAGE_EXPORT, $externalStorage->getProtocol());
 }
 protected function doGetFileSyncUrl(FileSync $fileSync)
 {
     $url = $fileSync->getFilePath();
     $url = preg_replace('/\\.[\\w]+$/', '', $url);
     return $url;
 }
Ejemplo n.º 21
0
 protected function doGetFileSyncUrl(FileSync $fileSync)
 {
     $url = $fileSync->getFilePath();
     return $url . "/manifest.f4m";
 }
Ejemplo n.º 22
0
 public static function retrieveByFileSync(FileSync $fileSync)
 {
     if ($fileSync->getObjectType() != FileSyncObjectType::ASSET) {
         return null;
     }
     if ($fileSync->getObjectSubType() != asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET && $fileSync->getObjectSubType() != asset::FILE_SYNC_ASSET_SUB_TYPE_ISM && $fileSync->getObjectSubType() != asset::FILE_SYNC_ASSET_SUB_TYPE_ISMC) {
         return null;
     }
     $asset = assetPeer::retrieveById($fileSync->getObjectId());
     return $asset;
 }
Ejemplo n.º 23
0
 private static function conditionalAssetLocalFileSyncsDelete(FileSync $fileSync, asset $asset)
 {
     $unClosedStatuses = array(asset::ASSET_STATUS_QUEUED, asset::ASSET_STATUS_CONVERTING, asset::ASSET_STATUS_WAIT_FOR_CONVERT, asset::ASSET_STATUS_EXPORTING);
     $unClosedAssets = assetPeer::retrieveReadyByEntryId($asset->getEntryId(), null, $unClosedStatuses);
     if (count($unClosedAssets)) {
         $asset->setFileSyncVersionsToDelete(array($fileSync->getVersion()));
         $asset->save();
         return;
     }
     $assetsToDelete = assetPeer::retrieveReadyByEntryId($asset->getEntryId());
     self::deleteAssetLocalFileSyncsByAssetArray($assetsToDelete);
     self::deleteAssetLocalFileSyncs($fileSync->getVersion(), $asset);
 }
 /**
  *
  * @param FileSync $key
  * @return ISyncableFile
  */
 public static function retrieveObjectForFileSync(FileSync $file_sync)
 {
     KalturaLog::log(__METHOD__ . " - FileSync id [" . $file_sync->getId() . "]");
     return kFileSyncObjectManager::retrieveObject($file_sync->getObjectType(), $file_sync->getObjectId());
 }
Ejemplo n.º 25
0
 /**
  * @param FileSync $fileSync
  */
 protected static function purgeFileSync(FileSync $fileSync)
 {
     KalturaLog::info("Purging file sync [" . $fileSync->getId() . "]");
     $fullPath = $fileSync->getFullPath();
     if ($fullPath && file_exists($fullPath)) {
         KalturaLog::debug("Purging file sync [" . $fileSync->getId() . "] path [{$fullPath}]");
         if (is_dir($fullPath)) {
             $command = "rm -fr {$fullPath}";
             KalturaLog::debug("Executing: {$command}");
             if (self::$dryRun) {
                 self::incrementSummary('dirs');
             } else {
                 $returnedValue = null;
                 passthru($command, $returnedValue);
                 if ($returnedValue === 0) {
                     self::incrementSummary('dirs');
                 } else {
                     KalturaLog::err("Failed purging file sync [" . $fileSync->getId() . "] directory path [{$fullPath}]");
                     return;
                 }
             }
         } else {
             $fileSize = filesize($fullPath);
             if (self::$dryRun || unlink($fullPath)) {
                 self::incrementSummary('bytes', $fileSize);
                 self::incrementSummary('files');
             } else {
                 KalturaLog::err("Failed purging file sync [" . $fileSync->getId() . "] file path [{$fullPath}]");
                 return;
             }
         }
     } else {
         KalturaLog::debug("File sync [" . $fileSync->getId() . "] path [{$fullPath}] does not exist");
     }
     $fileSync->setStatus(FileSync::FILE_SYNC_STATUS_PURGED);
     $fileSync->save();
 }
Ejemplo n.º 26
0
 private function deleteOldFileSyncVersions(FileSync $newFileSync)
 {
     KalturaLog::debug('Deleting old file_sync versions for [' . $newFileSync->getId() . ']');
     if (kConf::hasParam('num_of_old_file_sync_versions_to_keep')) {
         $keepCount = kConf::get('num_of_old_file_sync_versions_to_keep');
         if (!is_numeric($newFileSync->getVersion())) {
             return;
         }
         $intVersion = intval($newFileSync->getVersion());
         $c = new Criteria();
         $c->add(FileSyncPeer::OBJECT_ID, $newFileSync->getObjectId());
         $c->add(FileSyncPeer::OBJECT_TYPE, $newFileSync->getObjectType());
         $c->add(FileSyncPeer::OBJECT_SUB_TYPE, $newFileSync->getObjectSubType());
         $c->add(FileSyncPeer::STATUS, array(FileSync::FILE_SYNC_STATUS_PURGED, FileSync::FILE_SYNC_STATUS_DELETED), Criteria::NOT_IN);
         $c->setLimit(40);
         //we limit the number of files to delete in one run so there will be no out of memory issues
         $fileSyncs = FileSyncPeer::doSelect($c);
         foreach ($fileSyncs as $fileSync) {
             if (is_numeric($fileSync->getVersion())) {
                 $currentIntVersion = intval($fileSync->getVersion());
                 if ($intVersion - $keepCount > $currentIntVersion) {
                     $key = kFileSyncUtils::getKeyForFileSync($fileSync);
                     self::deleteSyncFileForKey($key);
                 }
             }
         }
     }
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      FileSync $value A FileSync object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(FileSync $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Ejemplo n.º 28
0
 /**
  * Will fetch the content of the $file_sync.
  * If the $local_file_path is specifid, will place the cotnet there
  * @param FileSync $file_sync
  * @return string
  */
 public static function retrieveFileFromRemoteDataCenter(FileSync $file_sync)
 {
     KalturaLog::log("File sync [{$file_sync->getId()}]");
     // LOG retrieval
     $cmd_line = self::createCmdForRemoteDataCenter($file_sync);
     $local_file_path = self::getLocalTempPathForFileSync($file_sync);
     if (!file_exists($local_file_path)) {
         KalturaLog::log("Executing " . $cmd_line);
         exec($cmd_line);
         clearstatcache();
         if (!file_exists($local_file_path)) {
             KalturaLog::err("Temp file not retrieved [{$local_file_path}]");
             return false;
         }
     } else {
         KalturaLog::log("Already exists in temp folder [{$local_file_path}]");
     }
     return file_get_contents($local_file_path);
 }
Ejemplo n.º 29
0
 /**
  * @param FileSync $fileSync
  */
 protected function fileSyncDelete(FileSync $fileSync, BatchJob $raisedJob = null)
 {
     $partnerId = $fileSync->getPartnerId();
     $purgePermission = PermissionPeer::isValidForPartner('PURGE_FILES_ON_DELETE', $partnerId);
     if ($purgePermission) {
         $syncKey = kFileSyncUtils::getKeyForFileSync($fileSync);
         kJobsManager::addDeleteFileJob($raisedJob, null, $partnerId, $syncKey, $fileSync->getFullPath(), $fileSync->getDc());
     }
 }
Ejemplo n.º 30
0
 /**
  * @param BaseObject $object
  */
 public function fileSyncCreated(FileSync $fileSync)
 {
     KalturaLog::debug("id [" . $fileSync->getId() . "]");
     $object = kFileSyncUtils::retrieveObjectForFileSync($fileSync);
     if (!$object || !$object instanceof ISyncableFile) {
         KalturaLog::debug("Not instance of ISyncableFile");
         return;
     }
     $auditTrail = self::createAuditTrail($object, AuditTrail::AUDIT_TRAIL_ACTION_FILE_SYNC_CREATED);
     if (!$auditTrail) {
         KalturaLog::debug("No audit created");
         return;
     }
     $data = new kAuditTrailFileSyncCreateInfo();
     $data->setVersion($fileSync->getVersion());
     $data->setObjectSubType($fileSync->getObjectSubType());
     $data->setDc($fileSync->getDc());
     $data->setOriginal($fileSync->getOriginal());
     $data->setFileType($fileSync->getFileType());
     $auditTrail->setData($data);
     $auditTrail->save();
 }