/**
  * @param string $srcWAMSAssetId
  * @param string $targetPath
  */
 public function __construct($srcWAMSAssetId, $targetPath)
 {
     KalturaLog::debug("Creation instance of KWAMSThumbnailMaker srcWAMSAssetId = [{$srcWAMSAssetId}] targetPath = [{$targetPath}]");
     $this->srcWAMSAssetId = $srcWAMSAssetId;
     $this->targetPath = $targetPath;
     DbManager::setConfig(kConf::getDB());
     DbManager::initialize();
     $fileSync = FileSyncPeer::retrieveByWamsAssetId($srcWAMSAssetId);
     if (!empty($fileSync)) {
         $this->partnerId = $fileSync->getPartnerId();
     }
 }
 /**
  * Creates instance of class and initializes properties
  * @param string $type
  * @param string $filePath
  * @param KSchedularTaskConfig $taskConfig
  */
 public function __construct($type, $filePath, KSchedularTaskConfig $taskConfig, KalturaBatchJob $job, $wamsAssetId)
 {
     $this->wamsAssetId = $wamsAssetId;
     $this->filePath = $filePath;
     $this->mediaInfoParser = parent::getParser($type, $filePath, $taskConfig, $job);
     $this->partnerId = $job->partnerId;
     DbManager::setConfig(kConf::getDB());
     DbManager::initialize();
     $fileSync = FileSyncPeer::retrieveByWamsAssetId($this->wamsAssetId);
     if ($fileSync) {
         $flavorAsset = kFileSyncUtils::retrieveObjectForFileSync($fileSync);
         if ($flavorAsset instanceof asset) {
             $this->originalMediaInfo = mediaInfoPeer::retrieveOriginalByEntryId($flavorAsset->getEntryId());
             $entry = $flavorAsset->getentry();
             if ($entry) {
                 $this->mediaType = $entry->getMediaType();
             }
         }
     }
 }
 private function getEntryName($assetId)
 {
     $fileSync = FileSyncPeer::retrieveByWamsAssetId($assetId);
     if (!$fileSync) {
         return null;
     }
     $asset = kFileSyncUtils::retrieveObjectForFileSync($fileSync);
     if (!$asset) {
         return null;
     }
     $entry = $asset->getentry();
     if (!$entry) {
         return null;
     }
     $replacedId = $entry->getReplacedEntryId();
     if (!empty($replacedId)) {
         $entry = entryPeer::retrieveByPK($replacedId);
     }
     return $entry->getName();
 }
 private function dumpFile($file_path, $file_name, $wams_asset_id = null, $wams_url = null)
 {
     $relocate = $this->getRequestParameter("relocate");
     $directServe = $this->getRequestParameter("direct_serve");
     if (!$relocate) {
         $url = $_SERVER["REQUEST_URI"];
         if (strpos($url, "?") !== false) {
             $url .= "&relocate=";
         } else {
             $url .= "/relocate/";
         }
         $url .= $this->encodeUrl($file_name);
         kFile::cacheRedirect($url);
         header("Location: {$url}");
         die;
     } else {
         if (!$directServe) {
             header("Content-Disposition: attachment; filename=\"{$file_name}\"");
         }
         if (!empty($wams_asset_id)) {
             $fileSync = FileSyncPeer::retrieveByWamsAssetId($wams_asset_id);
             kWAMS::getInstance($fileSync->getPartnerId())->dumpFile($wams_asset_id, pathinfo($file_name, PATHINFO_EXTENSION));
         } else {
             $mime_type = kFile::mimeType($file_path);
             kFile::dumpFile($file_path, $mime_type);
         }
     }
 }