Example #1
0
 protected static function getStorageProfile($storageProfileId = null)
 {
     if (is_null($storageProfileId)) {
         return kDataCenterMgr::getCurrentStorageProfile();
     }
     return StorageProfilePeer::retrieveByPK($storageProfileId);
 }
 /**
  * @return kUrlTokenizer
  */
 public function getTokenizer()
 {
     $secret = null;
     switch ($this->protocol) {
         case StorageProfile::PLAY_FORMAT_HTTP:
             if (@$this->params['http_auth_salt']) {
                 $storageProfile = StorageProfilePeer::retrieveByPK($this->storageProfileId);
                 if ($storageProfile) {
                     // get parameters
                     $window = $this->params['http_auth_seconds'];
                     $secret = $this->params['http_auth_salt'];
                     $useDummyHost = false;
                     $httpBaseUrl = rtrim($storageProfile->getDeliveryHttpBaseUrl(), '/');
                 }
             }
             break;
         case StorageProfile::PLAY_FORMAT_RTMP:
             if (@$this->params['rtmp_auth_salt']) {
                 $window = $this->params['rtmp_auth_seconds'];
                 $secret = $this->params['rtmp_auth_salt'];
                 $useDummyHost = true;
                 $httpBaseUrl = '';
             }
             break;
     }
     if ($secret) {
         if (is_null($window) || !is_int($window)) {
             $window = self::DEFAULT_ACCESS_WINDOW_SECONDS;
         }
         return new kMirrorImageUrlTokenizer($window, $secret, $useDummyHost, $httpBaseUrl);
     }
     return null;
 }
Example #3
0
 public static function retrieveExternalByPartnerId($partnerId, $con = null)
 {
     $criteria = new Criteria(StorageProfilePeer::DATABASE_NAME);
     $criteria->add(StorageProfilePeer::PARTNER_ID, $partnerId);
     $criteria->add(StorageProfilePeer::STATUS, array(StorageProfile::STORAGE_STATUS_AUTOMATIC, StorageProfile::STORAGE_STATUS_MANUAL), Criteria::IN);
     return StorageProfilePeer::doSelect($criteria, $con);
 }
Example #4
0
 public function clearMemory()
 {
     accessControlPeer::clearInstancePool();
     BatchJobPeer::clearInstancePool();
     BulkUploadResultPeer::clearInstancePool();
     categoryPeer::clearInstancePool();
     EmailIngestionProfilePeer::clearInstancePool();
     entryPeer::clearInstancePool();
     FileSyncPeer::clearInstancePool();
     flavorAssetPeer::clearInstancePool();
     flavorParamsConversionProfilePeer::clearInstancePool();
     flavorParamsOutputPeer::clearInstancePool();
     flavorParamsPeer::clearInstancePool();
     kshowPeer::clearInstancePool();
     mediaInfoPeer::clearInstancePool();
     moderationFlagPeer::clearInstancePool();
     moderationPeer::clearInstancePool();
     notificationPeer::clearInstancePool();
     roughcutEntryPeer::clearInstancePool();
     SchedulerConfigPeer::clearInstancePool();
     SchedulerPeer::clearInstancePool();
     SchedulerStatusPeer::clearInstancePool();
     SchedulerWorkerPeer::clearInstancePool();
     StorageProfilePeer::clearInstancePool();
     syndicationFeedPeer::clearInstancePool();
     TrackEntryPeer::clearInstancePool();
     uiConfPeer::clearInstancePool();
     UploadTokenPeer::clearInstancePool();
     // TODO clear default filters
     // TODO call all memory cleaner plugins
     if (function_exists('gc_collect_cycles')) {
         // php 5.3 and above
         gc_collect_cycles();
     }
 }
Example #5
0
 /**
  * @return StorageProfile
  */
 public static function getCurrentStorageProfile()
 {
     if (self::$currentStorageProfile) {
         return self::$currentStorageProfile;
     }
     self::$currentStorageProfile = StorageProfilePeer::retrieveByPK(self::getCurrentDcId());
     return self::$currentStorageProfile;
 }
 public function validateEntry(entry $dbEntry)
 {
     parent::validateEntry($dbEntry);
     $this->validatePropertyNotNull('storageProfileId');
     $storageProfile = StorageProfilePeer::retrieveByPK($this->storageProfileId);
     if (!$storageProfile) {
         throw new KalturaAPIException(KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND, $this->storageProfileId);
     }
 }
 public function validateForUsage($sourceObject, $propertiesToSkip = array())
 {
     parent::validateForUsage($sourceObject, $propertiesToSkip);
     $this->validatePropertyNotNull('storageProfileId');
     $storageProfile = StorageProfilePeer::retrieveByPK($this->storageProfileId);
     if (!$storageProfile) {
         throw new KalturaAPIException(KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND, $this->storageProfileId);
     }
 }
Example #8
0
 /**
  * @param int $storageProfileId
  * @return kUrlManager
  */
 public static function getUrlManagerByStorageProfile($storageProfileId)
 {
     $class = 'kUrlManager';
     $storageProfile = StorageProfilePeer::retrieveByPK($storageProfileId);
     if ($storageProfile && $storageProfile->getUrlManagerClass() && class_exists($storageProfile->getUrlManagerClass())) {
         $class = $storageProfile->getUrlManagerClass();
     }
     KalturaLog::log("Uses url manager [{$class}]");
     return new $class($storageProfileId);
 }
 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);
 }
Example #10
0
 public function getExternalUrl($entryId, $format = PlaybackProtocol::HTTP)
 {
     $storage = StorageProfilePeer::retrieveByPK($this->getDc());
     if (!$storage || $storage->getProtocol() == StorageProfile::STORAGE_KALTURA_DC) {
         return kDataCenterMgr::getInternalRemoteUrl($this);
     }
     $urlManager = DeliveryProfilePeer::getRemoteDeliveryByStorageId(DeliveryProfileDynamicAttributes::init($this->getDc(), $entryId, PlaybackProtocol::HTTP, infraRequestUtils::getProtocol()));
     if (is_null($urlManager) && infraRequestUtils::getProtocol() != 'http') {
         $urlManager = DeliveryProfilePeer::getRemoteDeliveryByStorageId(DeliveryProfileDynamicAttributes::init($this->getDc(), $entryId));
     }
     if (is_null($urlManager)) {
         return null;
     }
     $url = $urlManager->getFileSyncUrl($this);
     $baseUrl = $urlManager->getUrl();
     $url = ltrim($url, "/");
     if (strpos($url, "://") === false) {
         $url = rtrim($baseUrl, "/") . "/" . $url;
     }
     return $url;
 }
 protected function doGetFileSyncUrl(FileSync $fileSync)
 {
     $storage = StorageProfilePeer::retrieveByPK($fileSync->getDc());
     if (!$storage) {
         return parent::doGetFileSyncUrl($fileSync);
     }
     $partnerPath = myPartnerUtils::getUrlForPartner($fileSync->getPartnerId(), $fileSync->getPartnerId() * 100);
     $objectSubType = $fileSync->getObjectSubType();
     if ($fileSync->getObjectType() == FileSyncObjectType::ENTRY && $objectSubType == entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM) {
         return $this->doGetServeIsmUrl($fileSync, $partnerPath, $storage);
     }
     //To Remove - Until the migration process from asset sub type 3 to asset sub type 1 will be completed we need to support both formats
     if ($fileSync->getObjectType() == FileSyncObjectType::FLAVOR_ASSET && $objectSubType == flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISM) {
         return $this->doGetServeIsmUrl($fileSync, $partnerPath, $storage);
     }
     if ($fileSync->getObjectType() == FileSyncObjectType::FLAVOR_ASSET && $objectSubType == flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET) {
         $asset = assetPeer::retrieveById($fileSync->getObjectId());
         if ($asset->hasTag(assetParams::TAG_ISM_MANIFEST)) {
             return $this->doGetServeIsmUrl($fileSync, $partnerPath, $storage);
         }
     }
     return parent::doGetFileSyncUrl($fileSync);
 }
Example #12
0
/**
 * Parameters 
 * -------------- 
 */
function setDeliveryId($partnerId, $storageId, $deliveryIds)
{
    // don't add to database if one of the parameters is missing or is an empty string
    if (!$partnerId && !$storageId || !$deliveryIds) {
        die('Missing parameter');
    }
    if ($partnerId) {
        $partner = PartnerPeer::retrieveByPK($partnerId);
        if (!$partner) {
            die("No such partner with id [{$partnerId}]." . PHP_EOL);
        }
        $partner->setDeliveryProfileIds($deliveryIds);
        $partner->save();
    }
    if ($storageId) {
        $storage = StorageProfilePeer::retrieveByPK($storageId);
        if (!$storageId) {
            die("No such storage profile with id [{$storageId}]." . PHP_EOL);
        }
        $storage->setDeliveryProfileIds($deliveryIds);
        $storage->save();
    }
}
Example #13
0
 /**
  * @param IRemoteStorageResource $resource
  * @param entry $dbEntry
  * @param asset $dbAsset
  * @return asset
  * @throws KalturaErrors::ORIGINAL_FLAVOR_ASSET_NOT_CREATED
  * @throws KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND
  */
 protected function attachRemoteStorageResource(IRemoteStorageResource $resource, entry $dbEntry, asset $dbAsset = null)
 {
     $resources = $resource->getResources();
     $fileExt = $resource->getFileExt();
     $dbEntry->setSource(KalturaSourceType::URL);
     // TODO - move image handling to media service
     if ($dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
         $syncKey = $dbEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
         foreach ($resources as $currentResource) {
             $storageProfile = StorageProfilePeer::retrieveByPK($currentResource->getStorageProfileId());
             $fileSync = kFileSyncUtils::createReadyExternalSyncFileForKey($syncKey, $currentResource->getUrl(), $storageProfile);
         }
         $dbEntry->setStatus(entryStatus::READY);
         $dbEntry->save();
         return null;
     }
     $dbEntry->save();
     $isNewAsset = false;
     if (!$dbAsset) {
         $isNewAsset = true;
         $dbAsset = kFlowHelper::createOriginalFlavorAsset($this->getPartnerId(), $dbEntry->getId());
     }
     if (!$dbAsset) {
         KalturaLog::err("Flavor asset not created for entry [" . $dbEntry->getId() . "]");
         if ($dbEntry->getStatus() == entryStatus::NO_CONTENT) {
             $dbEntry->setStatus(entryStatus::ERROR_CONVERTING);
             $dbEntry->save();
         }
         throw new KalturaAPIException(KalturaErrors::ORIGINAL_FLAVOR_ASSET_NOT_CREATED);
     }
     $syncKey = $dbAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     foreach ($resources as $currentResource) {
         $storageProfile = StorageProfilePeer::retrieveByPK($currentResource->getStorageProfileId());
         $fileSync = kFileSyncUtils::createReadyExternalSyncFileForKey($syncKey, $currentResource->getUrl(), $storageProfile);
     }
     $dbAsset->setFileExt($fileExt);
     if ($dbAsset instanceof flavorAsset && !$dbAsset->getIsOriginal()) {
         $dbAsset->setStatus(asset::FLAVOR_ASSET_STATUS_READY);
     }
     $dbAsset->save();
     if ($isNewAsset) {
         kEventsManager::raiseEvent(new kObjectAddedEvent($dbAsset));
     }
     kEventsManager::raiseEvent(new kObjectDataChangedEvent($dbAsset));
     if ($dbAsset instanceof flavorAsset && !$dbAsset->getIsOriginal()) {
         kBusinessPostConvertDL::handleConvertFinished(null, $dbAsset);
     }
     return $dbAsset;
 }
 /**
  * @param FileSync $fileSync
  * @return string
  */
 protected function doGetFileSyncUrl(FileSync $fileSync)
 {
     $fileSync = kFileSyncUtils::resolve($fileSync);
     $storage = StorageProfilePeer::retrieveByPK($fileSync->getDc());
     if (!$storage) {
         return parent::doGetFileSyncUrl($fileSync);
     }
     $serverUrl = $storage->getDeliveryIisBaseUrl();
     $partnerPath = myPartnerUtils::getUrlForPartner($fileSync->getPartnerId(), $fileSync->getPartnerId() * 100);
     if ($this->protocol == StorageProfile::PLAY_FORMAT_APPLE_HTTP && isset($this->params["hd_ios"])) {
         $path = $fileSync->getFilePath();
         $urlSuffix = str_replace('\\', '/', $path) . "/index_0_av.m3u8";
         $urlPrefix = "http://" . $this->params["hd_ios"] . '/i/';
         return $urlPrefix . ltrim($urlSuffix, '/');
     }
     if ($this->protocol == "hdnetworksmil" && isset($this->params["hd_flash"])) {
         $path = $fileSync->getFilePath();
         $urlSuffix = str_replace('\\', '/', $path);
         $urlPrefix = "http://" . $this->params["hd_flash"];
         return $urlPrefix . '/' . ltrim($urlSuffix, '/');
     }
     if ($fileSync->getObjectSubType() != entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM) {
         return parent::doGetFileSyncUrl($fileSync);
     }
     $serverUrl = myPartnerUtils::getIisHost($fileSync->getPartnerId(), "http");
     $path = $partnerPath . '/serveIsm/objectId/' . $fileSync->getObjectId() . '_' . $fileSync->getObjectSubType() . '_' . $fileSync->getVersion() . '.' . pathinfo(kFileSyncUtils::resolve($fileSync)->getFilePath(), PATHINFO_EXTENSION) . '/manifest';
     $matches = null;
     if (preg_match('/(https?:\\/\\/[^\\/]+)(.*)/', $serverUrl, $matches)) {
         $path = $matches[2] . $path;
     }
     $path = str_replace('//', '/', $path);
     return $path;
 }
 public function validateStorageId($partnerId)
 {
     if (is_null($this->storageId) || $this->storageId instanceof KalturaNullField) {
         return;
     }
     $storage = StorageProfilePeer::retrieveByPK($this->storageId);
     if (!$storage) {
         throw new KalturaAPIException(KalturaErrors::SYNDICATION_FEED_INVALID_STORAGE_ID);
     }
     $partner = PartnerPeer::retrieveByPK($partnerId);
     // storage doesn't belong to the partner
     if ($storage->getPartnerId() != $partner->getId()) {
         throw new KalturaAPIException(KalturaErrors::SYNDICATION_FEED_INVALID_STORAGE_ID);
     }
     // partner configured to use kaltura data centers only
     if ($partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) {
         throw new KalturaAPIException(KalturaErrors::SYNDICATION_FEED_KALTURA_DC_ONLY);
     }
 }
 /**
  * Builds a Criteria object containing the primary key for this object.
  *
  * Unlike buildCriteria() this method includes the primary key values regardless
  * of whether or not they have been modified.
  *
  * @return     Criteria The Criteria object containing value(s) for primary key(s).
  */
 public function buildPkeyCriteria()
 {
     $criteria = new Criteria(StorageProfilePeer::DATABASE_NAME);
     $criteria->add(StorageProfilePeer::ID, $this->id);
     if ($this->alreadyInSave && count($this->modifiedColumns) == 2 && $this->isColumnModified(StorageProfilePeer::UPDATED_AT)) {
         $theModifiedColumn = null;
         foreach ($this->modifiedColumns as $modifiedColumn) {
             if ($modifiedColumn != StorageProfilePeer::UPDATED_AT) {
                 $theModifiedColumn = $modifiedColumn;
             }
         }
         $atomicColumns = StorageProfilePeer::getAtomicColumns();
         if (in_array($theModifiedColumn, $atomicColumns)) {
             $criteria->add($theModifiedColumn, $this->getByName($theModifiedColumn, BasePeer::TYPE_COLNAME), Criteria::NOT_EQUAL);
         }
     }
     return $criteria;
 }
Example #17
0
 /**
  * @action export
  * Action for manually exporting an entry
  * @param string $entryId
  * @param int $storageProfileId
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  * @throws KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND
  * @return KalturaBaseEntry The exported entry
  */
 public function exportAction($entryId, $storageProfileId)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $dbStorageProfile = StorageProfilePeer::retrieveByPK($storageProfileId);
     if (!$dbStorageProfile) {
         throw new KalturaAPIException(KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND, $storageProfileId);
     }
     $scope = $dbStorageProfile->getScope();
     $scope->setEntryId($entryId);
     if (!$dbStorageProfile->fulfillsRules($scope)) {
         throw new KalturaAPIException(KalturaErrors::STORAGE_PROFILE_RULES_NOT_FULFILLED, $storageProfileId);
     }
     try {
         kStorageExporter::exportEntry($dbEntry, $dbStorageProfile);
     } catch (kCoreException $e) {
         if ($e->getCode() == kCoreException::PROFILE_STATUS_DISABLED) {
             throw new KalturaAPIException(APIErrors::PROFILE_STATUS_DISABLED, $entryId);
         }
     }
     //TODO: implement export errors
     $entry = KalturaEntryFactory::getInstanceByType($dbEntry->getType());
     $entry->fromObject($dbEntry, $this->getResponseProfile());
     return $entry;
 }
Example #18
0
<?php

require_once dirname(__FILE__) . '/../bootstrap.php';
if ($argc < 3) {
    echo "Arguments missing.\n\n";
    echo "Usage: php exportToNetStorage.php {partner id} {storage profile id} {max number of entries}(optional)\n";
    exit;
}
$partnerId = $argv[1];
$storageProfileId = $argv[2];
$maxEntriesToExport = isset($argv[3]) ? $argv[3] : -1;
if (empty($maxEntriesToExport) || $maxEntriesToExport <= 0) {
    $maxEntriesToExport = -1;
}
$storageProfile = StorageProfilePeer::retrieveByPK($storageProfileId);
if (!$storageProfile) {
    echo "Invalid storage profile id [{$storageProfileId}].\n\n";
    echo "Usage: php exportToNetStorage.php {partner id} {storage profile id}\n";
    exit;
}
$flavorParamsIds = $storageProfile->getFlavorParamsIds();
KalturaLog::log("flavorParamsIds [{$flavorParamsIds}]");
$flavorParamsArr = null;
if (!is_null($flavorParamsIds) && strlen(trim($flavorParamsIds))) {
    $flavorParamsArr = explode(',', $flavorParamsIds);
}
$moreEntries = true;
$maxConcurrentJobs = 20;
$totalExported = 0;
$lastCreatedAt = null;
$processedIds = array();
 public function validateStorageId()
 {
     if (!$this->storageId) {
         return true;
     }
     $storage = StorageProfilePeer::retrieveByPK($this->storageId);
     // no storage found
     if (!$storage) {
         die;
     }
     $partner = $this->entry->getPartner();
     // partner configured to use kaltura data centers only
     if ($partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) {
         die;
     }
     // storage doesn't belong to the partner
     if ($storage->getPartnerId() != $partner->getId()) {
         die;
     }
 }
Example #20
0
 private static function getExternalStorageUrl(Partner $partner, asset $asset, FileSyncKey $key, $servePlayManifest = false, $playManifestClientTag = null, $storageId = null)
 {
     if (!$partner->getStorageServePriority() || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) {
         return null;
     }
     if (is_null($storageId) && $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST) {
         if (kFileSyncUtils::getReadyInternalFileSyncForKey($key)) {
             // check if having file sync on kaltura dcs
             return null;
         }
     }
     $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key, $storageId);
     if (!$fileSync) {
         return null;
     }
     $storage = StorageProfilePeer::retrieveByPK($fileSync->getDc());
     if (!$storage) {
         return null;
     }
     if ($servePlayManifest) {
         // in case of an https request, if a delivery profile which supports https doesn't exist use an http cdn api host
         if (infraRequestUtils::getProtocol() == infraRequestUtils::PROTOCOL_HTTPS && DeliveryProfilePeer::getRemoteDeliveryByStorageId(DeliveryProfileDynamicAttributes::init($fileSync->getDc(), $asset->getEntryId(), PlaybackProtocol::HTTP, "https"))) {
             $url = requestUtils::getApiCdnHost();
         } else {
             $url = infraRequestUtils::PROTOCOL_HTTP . "://" . kConf::get("cdn_api_host");
         }
         $url .= $asset->getPlayManifestUrl($playManifestClientTag, $storageId);
     } else {
         $urlManager = DeliveryProfilePeer::getRemoteDeliveryByStorageId(DeliveryProfileDynamicAttributes::init($fileSync->getDc(), $asset->getEntryId()));
         if ($urlManager) {
             $dynamicAttrs = new DeliveryProfileDynamicAttributes();
             $dynamicAttrs->setFileExtension($asset->getFileExt());
             $dynamicAttrs->setStorageId($fileSync->getDc());
             $urlManager->setDynamicAttributes($dynamicAttrs);
             $url = ltrim($urlManager->getFileSyncUrl($fileSync), '/');
             if (strpos($url, "://") === false) {
                 $url = rtrim($urlManager->getUrl(), "/") . "/" . $url;
             }
         } else {
             KalturaLog::debug("Couldn't determine delivery profile for storage id");
             $url = null;
         }
     }
     return $url;
 }
Example #21
0
<?php

require_once __DIR__ . '/../bootstrap.php';
if ($argc == 3) {
    $partner_id = $argv[1];
    $path_format = $argv[2];
} else {
    die('usage: php ' . $_SERVER['SCRIPT_NAME'] . " [partner id] [date format]" . PHP_EOL);
}
$storages = StorageProfilePeer::retrieveExternalByPartnerId($partner_id);
if (!$storages) {
    die('no such partner.' . PHP_EOL);
}
foreach ($storages as $storage) {
    $storage->setPathFormat($path_format);
    $storage->save();
}
echo "Done.";
 /**
  * @action export
  * Action for manually exporting an entry
  * @param string $entryId
  * @param int $storageProfileId
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  * @throws KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND
  * @return KalturaBaseEntry The exported entry
  */
 public function exportAction($entryId, $storageProfileId)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $dbStorageProfile = StorageProfilePeer::retrieveByPK($storageProfileId);
     if (!$dbStorageProfile) {
         throw new KalturaAPIException(KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND, $storageProfileId);
     }
     kStorageExporter::exportEntry($dbEntry, $dbStorageProfile);
     //TODO: implement export errors
     $entry = KalturaEntryFactory::getInstanceByType($dbEntry->getType());
     $entry->fromObject($dbEntry);
     return $entry;
 }
 public function initStorageProfile()
 {
     if (!$this->deliveryAttributes->getStorageId()) {
         return;
     }
     $storageProfile = StorageProfilePeer::retrieveByPK($this->deliveryAttributes->getStorageId());
     if (!$storageProfile) {
         KExternalErrors::dieGracefully();
     }
     // TODO use a dieError
     // storage doesn't belong to the partner
     if ($storageProfile->getPartnerId() != $this->entry->getPartnerId()) {
         KExternalErrors::dieGracefully();
     }
     // TODO use a dieError
 }
Example #24
0
 /**
  * (non-PHPdoc)
  * @see asset::setStatusLocalReady()
  */
 public function setStatusLocalReady()
 {
     $newStatus = asset::ASSET_STATUS_READY;
     $externalStorages = StorageProfilePeer::retrieveExternalByPartnerId($this->getPartnerId());
     foreach ($externalStorages as $externalStorage) {
         if ($this->requiredToExportFlavor($externalStorage)) {
             KalturaLog::info('Asset id [' . $this->getId() . '] is required to export to profile [' . $externalStorage->getId() . '] - setting status to [EXPORTING]');
             $newStatus = asset::ASSET_STATUS_EXPORTING;
             break;
         }
     }
     KalturaLog::info('Setting status to [' . $newStatus . ']');
     $this->setStatus($newStatus);
 }
Example #25
0
 /**
  * Prepare storage profiles array for sorting
  *
  * @param int $partnerId
  */
 protected static function prepareStorageProfilesForSort($partnerId)
 {
     if (!is_null(self::$storageProfilesOrder)) {
         return;
     }
     $criteria = new Criteria();
     $criteria->add(StorageProfilePeer::PARTNER_ID, $partnerId);
     $criteria->add(StorageProfilePeer::DELIVERY_STATUS, StorageProfileDeliveryStatus::BLOCKED, Criteria::NOT_EQUAL);
     $criteria->addAscendingOrderByColumn(StorageProfilePeer::DELIVERY_PRIORITY);
     // Using doSelect instead of doSelectStmt for the ID column so that we can take adavntage of the query cache
     self::$storageProfilesOrder = array();
     $results = StorageProfilePeer::doSelect($criteria);
     foreach ($results as $result) {
         self::$storageProfilesOrder[] = $result->getId();
     }
 }
 public function getFieldNameFromPeer($field_name)
 {
     $res = StorageProfilePeer::translateFieldName($field_name, $this->field_name_translation_type, BasePeer::TYPE_COLNAME);
     return $res;
 }
 /**
  * @param AttachmentAsset $attachmentAsset
  * @param IRemoteStorageResource $contentResource
  * @throws KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND
  */
 protected function attachRemoteStorageResource(AttachmentAsset $attachmentAsset, IRemoteStorageResource $contentResource)
 {
     $resources = $contentResource->getResources();
     $attachmentAsset->setFileExt($contentResource->getFileExt());
     $attachmentAsset->incrementVersion();
     $attachmentAsset->setStatus(AttachmentAsset::ASSET_STATUS_READY);
     $attachmentAsset->save();
     $syncKey = $attachmentAsset->getSyncKey(AttachmentAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
     foreach ($resources as $currentResource) {
         $storageProfile = StorageProfilePeer::retrieveByPK($currentResource->getStorageProfileId());
         $fileSync = kFileSyncUtils::createReadyExternalSyncFileForKey($syncKey, $currentResource->getUrl(), $storageProfile);
     }
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(StorageProfilePeer::DATABASE_NAME);
         $criteria->add(StorageProfilePeer::ID, $pks, Criteria::IN);
         $objs = StorageProfilePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Example #29
0
 public function getExternalUrl($storageId, $fileName = null)
 {
     $key = $this->getSyncKey(self::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key, $storageId);
     if (!$fileSync || $fileSync->getStatus() != FileSync::FILE_SYNC_STATUS_READY) {
         return null;
     }
     $storage = StorageProfilePeer::retrieveByPK($fileSync->getDc());
     if (!$storage) {
         return null;
     }
     $urlManager = DeliveryProfilePeer::getRemoteDeliveryByStorageId(DeliveryProfileDynamicAttributes::init($fileSync->getDc(), $this->getEntryId()), $fileSync, $this);
     if (is_null($urlManager)) {
         return null;
     }
     $url = ltrim($urlManager->getFileSyncUrl($fileSync), "/");
     if (strpos($url, "://") === false) {
         $url = rtrim($urlManager->getUrl(), "/") . "/" . $url;
     }
     $url = $this->finalizeDownloadUrl($fileSync, $url, $fileName, true);
     return $url;
 }
 private function getExternalStorageUrl(Partner $partner, flavorAsset $flavorAsset, FileSyncKey $key)
 {
     if (!$partner->getStorageServePriority() || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) {
         return null;
     }
     if ($partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST) {
         if (kFileSyncUtils::getReadyInternalFileSyncForKey($key)) {
             // check if having file sync on kaltura dcs
             return null;
         }
     }
     $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key);
     if (!$fileSync) {
         return null;
     }
     $storage = StorageProfilePeer::retrieveByPK($fileSync->getDc());
     if (!$storage) {
         return null;
     }
     if ($this->syndicationFeedDb->getServePlayManifest()) {
         $deliveryProfile = DeliveryProfilePeer::getRemoteDeliveryByStorageId(DeliveryProfileDynamicAttributes::init($storage->getId(), $flavorAsset->getEntryId(), PlaybackProtocol::HTTP, "https"));
         $clientTag = 'feed:' . $this->syndicationFeedDb->getId();
         if (is_null($deliveryProfile)) {
             $url = infraRequestUtils::PROTOCOL_HTTP . "://" . kConf::get("cdn_api_host");
         } else {
             $url = requestUtils::getApiCdnHost();
         }
         $url .= $flavorAsset->getPlayManifestUrl($clientTag, $storage->getId());
     } else {
         $dpda = new DeliveryProfileDynamicAttributes();
         $urlManager = DeliveryProfilePeer::getRemoteDeliveryByStorageId(DeliveryProfileDynamicAttributes::init($fileSync->getDc(), $flavorAsset->getEntryId()), null, $flavorAsset);
         $url = ltrim($urlManager->getFileSyncUrl($fileSync), '/');
         if (strpos($url, "://") === false) {
             $url = rtrim($urlManager->getUrl(), "/") . "/" . $url;
         }
     }
     return $url;
 }