本文整理匯總了PHP中FileSyncPeer::getCriteriaForFileSyncKey方法的典型用法代碼示例。如果您正苦於以下問題:PHP FileSyncPeer::getCriteriaForFileSyncKey方法的具體用法?PHP FileSyncPeer::getCriteriaForFileSyncKey怎麽用?PHP FileSyncPeer::getCriteriaForFileSyncKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FileSyncPeer
的用法示例。
在下文中一共展示了FileSyncPeer::getCriteriaForFileSyncKey方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: validateEntry
public function validateEntry(entry $dbEntry)
{
parent::validateEntry($dbEntry);
$this->validatePropertyNotNull('entryId');
$srcEntry = entryPeer::retrieveByPK($this->entryId);
if (!$srcEntry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $this->entryId);
}
if ($srcEntry->getMediaType() == KalturaMediaType::IMAGE) {
return parent::validateEntry($dbEntry);
}
$srcFlavorAsset = null;
if (is_null($this->flavorParamsId)) {
$srcFlavorAsset = assetPeer::retrieveOriginalByEntryId($this->entryId);
if (!$srcFlavorAsset) {
throw new KalturaAPIException(KalturaErrors::ORIGINAL_FLAVOR_ASSET_IS_MISSING);
}
} else {
$srcFlavorAsset = assetPeer::retrieveByEntryIdAndParams($this->entryId, $this->flavorParamsId);
if (!$srcFlavorAsset) {
throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $this->assetId);
}
}
$key = $srcFlavorAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
$c = FileSyncPeer::getCriteriaForFileSyncKey($key);
$c->addAnd(FileSyncPeer::FILE_TYPE, array(FileSync::FILE_SYNC_FILE_TYPE_FILE, FileSync::FILE_SYNC_FILE_TYPE_LINK), Criteria::IN);
$fileSyncs = FileSyncPeer::doSelect($c);
foreach ($fileSyncs as $fileSync) {
$fileSync = kFileSyncUtils::resolve($fileSync);
if ($fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_FILE) {
return;
}
}
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
}
示例2: resumeEvents
private function resumeEvents($flavorAsset)
{
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$c = FileSyncPeer::getCriteriaForFileSyncKey($syncKey);
$fileSyncList = FileSyncPeer::doSelect($c);
foreach ($fileSyncList as $fileSync) {
// resume file sync added event
kEventsManager::continueEvent(new kObjectAddedEvent($fileSync), 'kVirusScanFlowManager');
}
// resume flavor asset added event consumption
kEventsManager::continueEvent(new kObjectAddedEvent($flavorAsset), 'kVirusScanFlowManager');
}
示例3: getAllReadyInternalFileSyncsForKey
function getAllReadyInternalFileSyncsForKey(FileSyncKey $key)
{
$c = new Criteria();
$c = FileSyncPeer::getCriteriaForFileSyncKey($key);
$c->addAnd(FileSyncPeer::FILE_TYPE, FileSync::FILE_SYNC_FILE_TYPE_FILE);
$c->addAnd(FileSyncPeer::STATUS, FileSync::FILE_SYNC_STATUS_READY);
$results = FileSyncPeer::doSelect($c);
$assocResults = array();
foreach ($results as $curResult) {
$assocResults[$curResult->getDc()] = $curResult;
}
return $assocResults;
}
示例4: validateForUsage
public function validateForUsage($sourceObject, $propertiesToSkip = array())
{
parent::validateForUsage($sourceObject, $propertiesToSkip);
$this->validatePropertyNotNull('assetId');
$srcFlavorAsset = assetPeer::retrieveById($this->assetId);
if (!$srcFlavorAsset) {
throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $resource->assetId);
}
$key = $srcFlavorAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
$c = FileSyncPeer::getCriteriaForFileSyncKey($key);
$c->addAnd(FileSyncPeer::FILE_TYPE, array(FileSync::FILE_SYNC_FILE_TYPE_FILE, FileSync::FILE_SYNC_FILE_TYPE_LINK), Criteria::IN);
$fileSyncs = FileSyncPeer::doSelect($c);
foreach ($fileSyncs as $fileSync) {
$fileSync = kFileSyncUtils::resolve($fileSync);
if ($fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_FILE) {
return;
}
}
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
}
示例5: deleteSyncFileForKey
/**
* mark file as deleted, return deleted version
* @param FileSyncKey $key
* @param bool $strict
* @param bool $fromKalturaDcsOnly
* @return string
*/
public static function deleteSyncFileForKey(FileSyncKey $key, $strict = false, $fromKalturaDcsOnly = false)
{
if (!$key) {
if ($strict) {
throw new Exception("Empty key");
}
return null;
}
//Retrieve all file sync for key
$c = new Criteria();
$c = FileSyncPeer::getCriteriaForFileSyncKey($key);
if ($fromKalturaDcsOnly) {
$c->add(FileSyncPeer::FILE_TYPE, FileSync::FILE_SYNC_FILE_TYPE_URL, Criteria::NOT_EQUAL);
}
$file_sync_list = FileSyncPeer::doSelect($c);
foreach ($file_sync_list as $file_sync) {
/* @var $fileSync FileSync */
if ($file_sync->getLinkedId()) {
$newStatus = FileSync::FILE_SYNC_STATUS_PURGED;
self::decrementLinkCountForFileSync(FileSyncPeer::retrieveByPK($file_sync->getLinkedId()));
} else {
if ($file_sync->getLinkCount() == 0) {
$newStatus = FileSync::FILE_SYNC_STATUS_DELETED;
} elseif ($file_sync->getLinkCount() > 100) {
KalturaLog::notice("The file sync [" . $file_sync->getId() . "] is associated with [" . $file_sync->getLinkCount() . "] links and won't be deleted");
return null;
} else {
$newStatus = FileSync::FILE_SYNC_STATUS_PURGED;
self::convertLinksToFiles($file_sync);
}
}
$file_sync->setStatus($newStatus);
$file_sync->save();
}
}
示例6: isPendingExport
public function isPendingExport(FileSyncKey $key)
{
$c = FileSyncPeer::getCriteriaForFileSyncKey($key);
$c->addAnd(FileSyncPeer::DC, $this->getId(), Criteria::EQUAL);
$fileSync = FileSyncPeer::doSelectOne($c);
if (!$fileSync) {
return false;
}
return $fileSync->getStatus() == FileSync::FILE_SYNC_STATUS_PENDING;
}
示例7: isPendingExport
public function isPendingExport(asset $asset)
{
$key = $asset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$c = FileSyncPeer::getCriteriaForFileSyncKey($key);
$c->addAnd(FileSyncPeer::DC, $this->getId(), Criteria::EQUAL);
$fileSync = FileSyncPeer::doSelectOne($c);
if (!$fileSync) {
return false;
}
return $fileSync->getStatus() == FileSync::FILE_SYNC_STATUS_PENDING;
}
示例8: initFlavorAssetArray
protected function initFlavorAssetArray()
{
if (!$this->shouldInitFlavorAssetsArray()) {
return;
}
$oneOnly = false;
if ($this->deliveryAttributes->getFormat() == PlaybackProtocol::HTTP || $this->deliveryAttributes->getFormat() == "url" || $this->deliveryAttributes->getFormat() == "rtsp") {
$oneOnly = true;
}
// get initial flavor list by input
$flavorAssets = array();
if ($this->flavorIds) {
$flavorAssets = assetPeer::retrieveReadyByEntryId($this->entryId, $this->flavorIds);
$flavorAssets = $this->removeNotAllowedFlavors($flavorAssets);
$flavorAssets = $this->removeMaxBitrateFlavors($flavorAssets);
}
if (!$flavorAssets || !count($flavorAssets)) {
$flavorAssets = assetPeer::retrieveReadyFlavorsByEntryId($this->entryId);
$flavorAssets = $this->deliveryAttributes->filterFlavorsByTags($flavorAssets);
$flavorAssets = $this->removeNotAllowedFlavors($flavorAssets);
$flavorAssets = $this->removeMaxBitrateFlavors($flavorAssets);
}
if ($this->deliveryAttributes->getFormat() == PlaybackProtocol::SILVER_LIGHT) {
$this->initSilverLightManifest($flavorAssets);
return;
}
if ($this->deliveryAttributes->getFormat() == PlaybackProtocol::HDS || $this->deliveryAttributes->getFormat() == PlaybackProtocol::APPLE_HTTP) {
// try to look for a smil manifest, if it was found, we will use it for hds and hls
if ($this->initSmilManifest($flavorAssets)) {
return;
}
}
// get flavors availability
$servePriority = $this->entry->getPartner()->getStorageServePriority();
$localFlavors = array();
$remoteFlavorsByDc = array();
$remoteFileSyncs = array();
foreach ($flavorAssets as $flavorAsset) {
$flavorId = $flavorAsset->getId();
$key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$c = new Criteria();
$c = FileSyncPeer::getCriteriaForFileSyncKey($key);
$c->addAnd(FileSyncPeer::STATUS, FileSync::FILE_SYNC_STATUS_READY);
switch ($servePriority) {
case StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY:
$c->addAnd(FileSyncPeer::FILE_TYPE, FileSync::FILE_SYNC_FILE_TYPE_URL, Criteria::NOT_EQUAL);
break;
case StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_ONLY:
$c->add(FileSyncPeer::FILE_TYPE, FileSync::FILE_SYNC_FILE_TYPE_URL);
break;
}
if ($this->deliveryAttributes->getStorageId()) {
$c->addAnd(FileSyncPeer::DC, $this->deliveryAttributes->getStorageId());
}
$fileSyncs = FileSyncPeer::doSelect($c);
foreach ($fileSyncs as $fileSync) {
if ($fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL) {
$dc = $fileSync->getDc();
$remoteFlavorsByDc[$dc][$flavorId] = $flavorAsset;
$remoteFileSyncs[$dc][$flavorId] = $fileSync;
} else {
$localFlavors[$flavorId] = $flavorAsset;
}
}
}
// filter out any invalid / disabled storage profiles
if ($remoteFileSyncs) {
$storageProfileIds = array_keys($remoteFileSyncs);
$storageProfiles = StorageProfilePeer::retrieveExternalByPartnerId($this->entry->getPartnerId(), $storageProfileIds);
$activeStorageProfileIds = array();
foreach ($storageProfiles as $storageProfile) {
$activeStorageProfileIds[] = $storageProfile->getId();
}
foreach ($storageProfileIds as $storageProfileId) {
if (in_array($storageProfileId, $activeStorageProfileIds)) {
continue;
}
unset($remoteFlavorsByDc[$storageProfileId]);
unset($remoteFileSyncs[$storageProfileId]);
}
}
// choose the storage profile with the highest number of flavors
$maxDc = null;
$maxDcFlavorCount = 0;
$remoteFlavors = array();
foreach ($remoteFlavorsByDc as $dc => $curDcFlavors) {
$curDcFlavorCount = count($curDcFlavors);
if ($curDcFlavorCount <= $maxDcFlavorCount) {
continue;
}
$maxDc = $dc;
$maxDcFlavorCount = $curDcFlavorCount;
$remoteFlavors = $curDcFlavors;
}
// choose the flavor set according to the serve priority
if ($this->shouldUseLocalFlavors($localFlavors, $remoteFlavors)) {
$this->deliveryAttributes->setStorageId(null);
$this->deliveryAttributes->setFlavorAssets($localFlavors);
} else {
if ($maxDc) {
//.........這裏部分代碼省略.........
示例9: convertLinksToFiles
/**
* 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
*/
public static function convertLinksToFiles(FileSyncKey $key)
{
// fetch sources from all DCs
$c = new Criteria();
$c = FileSyncPeer::getCriteriaForFileSyncKey($key);
$fileSyncList = FileSyncPeer::doSelect($c);
foreach ($fileSyncList as $fileSync) {
/* @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, FileSync::FILE_SYNC_FILE_TYPE_LINK);
$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);
while (count($links)) {
// 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->setWamsAssetId($fileSync->getWamsAssetId());
$firstLink->setWamsUrl($fileSync->getWamsUrl());
$firstLink->setFileType(FileSync::FILE_SYNC_FILE_TYPE_FILE);
$firstLink->setLinkedId(0);
// keep it zero instead of null, that's the only way to know it used to be a link.
$firstLink->setLinkCount(count($links));
$firstLink->save();
}
// change all the rest of the links to point on the new file sync
foreach ($links as $link) {
/* @var $link FileSync */
$link->setStatus($fileSync->getStatus());
$link->setLinkedId($firstLink->getId());
$link->save();
}
FileSyncPeer::clearInstancePool();
$links = FileSyncPeer::doSelect($c);
}
}
}
示例10: convertLinksToFiles
/**
* 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
*/
public static function convertLinksToFiles(FileSyncKey $key)
{
// fetch sources from all DCs
$c = new Criteria();
$c = FileSyncPeer::getCriteriaForFileSyncKey($key);
$fileSyncList = FileSyncPeer::doSelect($c);
foreach ($fileSyncList as $fileSync) {
// for each source, find its links and fix them
$c = new Criteria();
$c->add(FileSyncPeer::LINKED_ID, $fileSync->getId());
$c->addAnd(FileSyncPeer::FILE_TYPE, FileSync::FILE_SYNC_FILE_TYPE_LINK);
$c->addAnd(FileSyncPeer::DC, $fileSync->getDc());
$c->addAnd(FileSyncPeer::STATUS, FileSync::FILE_SYNC_STATUS_READY);
$links = FileSyncPeer::doSelect($c);
foreach ($links as $link) {
$link->setStatus($fileSync->getStatus());
$link->setFileRoot($fileSync->getFileRoot());
$link->setFilePath($fileSync->getFilePath());
$link->setFileType(FileSync::FILE_SYNC_FILE_TYPE_FILE);
$link->save();
}
}
}