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());
 }
 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);
 }
 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;
 }
Пример #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());
 }
Пример #5
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));
         }
     }
 }
Пример #6
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());
 }
Пример #7
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;
 }
Пример #8
0
 /**
  * gets a source file of current DC, will make sure all links points to that source
  * are converted to files on all DCs
  *
  * @param FileSyncKey $key
  * @return void
  */
 protected static function convertLinksToFiles(FileSync $fileSync)
 {
     $linkTotalCount = 0;
     /* @var $fileSync FileSync */
     // for each source, find its links and fix them
     $c = new Criteria();
     $c->add(FileSyncPeer::DC, $fileSync->getDc());
     $c->add(FileSyncPeer::FILE_TYPE, array(FileSync::FILE_SYNC_FILE_TYPE_LINK, FileSync::FILE_SYNC_FILE_TYPE_URL), Criteria::IN);
     $c->add(FileSyncPeer::LINKED_ID, $fileSync->getId());
     $c->addAscendingOrderByColumn(FileSyncPeer::PARTNER_ID);
     //relink the links into groups of 100 links
     $c->setLimit(100);
     $links = FileSyncPeer::doSelect($c);
     //check if any links were returned in the do select if not no need to continue
     if (!count($links)) {
         return;
     }
     // choose the first link and convert it to file
     $firstLink = array_shift($links);
     /* @var $firstLink FileSync */
     if ($firstLink) {
         $firstLink->setStatus($fileSync->getStatus());
         $firstLink->setFileSize($fileSync->getFileSize());
         $firstLink->setFileRoot($fileSync->getFileRoot());
         $firstLink->setFilePath($fileSync->getFilePath());
         $firstLink->setFileType($fileSync->getFileType());
         $firstLink->setLinkedId(0);
         // keep it zero instead of null, that's the only way to know it used to be a link.
         $firstLink->setIsDir($fileSync->getIsDir());
         if (!is_null($fileSync->getOriginalDc())) {
             $firstLink->setOriginalDc($fileSync->getOriginalDc());
             $firstLink->unsetOriginalId();
             // recalculate the original id when importing the file sync
         }
         $firstLink->save();
     }
     while (count($links)) {
         // change all the rest of the links to point on the new file sync
         foreach ($links as $link) {
             $linkTotalCount += count($links);
             /* @var $link FileSync */
             $link->setStatus($fileSync->getStatus());
             $link->setLinkedId($firstLink->getId());
             $link->save();
         }
         FileSyncPeer::clearInstancePool();
         $links = FileSyncPeer::doSelect($c);
     }
     if ($firstLink) {
         $firstLink->setLinkCount($linkTotalCount);
         $firstLink->save();
     }
 }
Пример #9
0
 /**
  * @param FileSync $fileSync
  * @return string
  */
 protected function doGetFileSyncUrl(FileSync $fileSync)
 {
     $url = $fileSync->getFilePath();
     return $url;
 }
 protected function doGetFileSyncUrl(FileSync $fileSync)
 {
     $url = $fileSync->getFilePath();
     return $url . "/manifest.f4m";
 }
 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());
 }
 protected function doGetFileSyncUrl(FileSync $fileSync)
 {
     $url = $fileSync->getFilePath();
     $url = preg_replace('/\\.[\\w]+$/', '', $url);
     return $url;
 }
 /**
  * @param kUrlManager $urlManager
  * @param FileSync $fileSync
  * @param flavorAsset $flavorAsset
  * @param string $format
  */
 private function setupUrlManager($urlManager, FileSync $fileSync = null, flavorAsset $flavorAsset = null, $format = null)
 {
     $urlManager->setClipTo($this->clipTo);
     if ($flavorAsset) {
         $urlManager->setContainerFormat($flavorAsset->getContainerFormat());
     }
     if ($flavorAsset && $flavorAsset->getFileExt() !== null) {
         // if the extension is missig use the one from the actual path
         $urlManager->setFileExtension($flavorAsset->getFileExt());
     } else {
         if ($fileSync) {
             $urlManager->setFileExtension(pathinfo($fileSync->getFilePath(), PATHINFO_EXTENSION));
         }
     }
     if (!$format) {
         $format = $this->format;
     }
     $urlManager->setProtocol($format);
 }
Пример #14
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)
 {
     KalturaLog::log(__METHOD__ . " entryId[{$entryId}], partnerId[{$partnerId}], externalStorage id[" . $externalStorage->getId() . "], fileSync id[" . $fileSync->getId() . "], srcFileSyncLocalPath[{$srcFileSyncLocalPath}]");
     $netStorageExportData = new kStorageExportJobData();
     $netStorageExportData->setServerUrl($externalStorage->getStorageUrl());
     $netStorageExportData->setServerUsername($externalStorage->getStorageUsername());
     $netStorageExportData->setServerPassword($externalStorage->getStoragePassword());
     $netStorageExportData->setFtpPassiveMode($externalStorage->getStorageFtpPassiveMode());
     $netStorageExportData->setSrcFileSyncLocalPath($srcFileSyncLocalPath);
     $netStorageExportData->setSrcFileSyncId($fileSync->getId());
     $netStorageExportData->setForce($force);
     $netStorageExportData->setDestFileSyncStoredPath($externalStorage->getStorageBaseDir() . '/' . $fileSync->getFilePath());
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild(false);
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($entryId);
         $batchJob->setPartnerId($partnerId);
     }
     KalturaLog::log("Creating Storage export job, with source file: " . $netStorageExportData->getSrcFileSyncLocalPath());
     return self::addJob($batchJob, $netStorageExportData, BatchJobType::STORAGE_EXPORT, $externalStorage->getProtocol());
 }