本文整理汇总了PHP中kFileSyncUtils::getLocalFileSyncForKey方法的典型用法代码示例。如果您正苦于以下问题:PHP kFileSyncUtils::getLocalFileSyncForKey方法的具体用法?PHP kFileSyncUtils::getLocalFileSyncForKey怎么用?PHP kFileSyncUtils::getLocalFileSyncForKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kFileSyncUtils
的用法示例。
在下文中一共展示了kFileSyncUtils::getLocalFileSyncForKey方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFileSize
public function getFileSize()
{
return 0;
// temp fix
$dataFileKey = $this->getSyncKey(self::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
$fileSync = kFileSyncUtils::getLocalFileSyncForKey($dataFileKey);
if ($fileSync && $fileSync->getStatus() == FileSync::FILE_SYNC_STATUS_READY) {
return $fileSync->getFileSize();
}
return "";
}
示例2: getAppStudioTemplatePath
private function getAppStudioTemplatePath()
{
$template_partner_id = isset($this->templatePartnerId) ? $this->templatePartnerId : self::SYSTEM_DEFAULT_PARTNER;
if (!$template_partner_id) {
return false;
}
$c = new Criteria();
$c->addAnd(uiConfPeer::PARTNER_ID, $template_partner_id);
$c->addAnd(uiConfPeer::STATUS, uiConf::UI_CONF_STATUS_READY);
$c->addAnd(uiConfPeer::OBJ_TYPE, uiConf::UI_CONF_TYPE_KMC_APP_STUDIO);
$c->addAnd(uiConfPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK);
$uiConf = uiConfPeer::doSelectOne($c);
if ($uiConf) {
$sync_key = $uiConf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_DATA);
if ($sync_key) {
$file_sync = kFileSyncUtils::getLocalFileSyncForKey($sync_key, true);
if ($file_sync) {
return "/" . $file_sync->getFilePath();
}
}
}
return false;
}
示例3: die
uiConfPeer::setUseCriteriaFilter(false);
FileSyncPeer::setUseCriteriaFilter(false);
$uiConf = uiConfPeer::retrieveByPK($uiConfId);
if (!$uiConf) {
die("UI-Conf ID [{$uiConfId}] not found");
}
$fileSyncs = array();
$fileSync = kFileSyncUtils::getLocalFileSyncForKey($uiConf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_DATA), false);
if ($fileSync) {
$fileSyncs[] = $fileSync;
}
$fileSync = kFileSyncUtils::getLocalFileSyncForKey($uiConf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_CONFIG), false);
if ($fileSync) {
$fileSyncs[] = $fileSync;
}
$fileSync = kFileSyncUtils::getLocalFileSyncForKey($uiConf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_FEATURES), false);
if ($fileSync) {
$fileSyncs[] = $fileSync;
}
if (empty($fileSyncs)) {
die("No file_sync found for UI-Conf ID [" . $uiConfId . "]");
}
uiConfPeer::setUseCriteriaFilter(true);
FileSyncPeer::setUseCriteriaFilter(true);
foreach ($fileSyncs as $fileSync) {
if (!file_exists($fileSync->getFullPath())) {
die("UI-Conf file ID [" . $fileSync->getId() . "] file not found");
}
}
foreach ($fileSyncs as $fileSync) {
if (method_exists($fileSync, 'setDeletedId')) {
示例4: addConvertIsmCollectionJob
/**
* addConvertIsmCollectionJob creates a convert collection job
*
* @param string $tag
* @param FileSyncKey $srcSyncKey
* @param entry $entry
* @param BatchJob $parentJob
* @param array<flavorParamsOutput> $flavorParamsOutputs
* @return BatchJob
*/
public static function addConvertIsmCollectionJob($tag, FileSyncKey $srcSyncKey, entry $entry, BatchJob $parentJob = null, array $flavorParamsOutputs, $sameRoot = null)
{
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, true, false);
$srcFileSyncDescriptor = new kSourceFileSyncDescriptor();
if ($fileSync) {
if ($fileSync->getFileType() != FileSync::FILE_SYNC_FILE_TYPE_URL) {
$srcFileSyncDescriptor->setFileSyncLocalPath($fileSync->getFullPath());
}
$srcFileSyncDescriptor->setFileSyncRemoteUrl($fileSync->getExternalUrl($entry->getId()));
$srcFileSyncDescriptor->setAssetId($fileSync->getObjectId());
$srcFileSyncDescriptor->setFileSyncObjectSubType($srcSyncKey->getObjectSubType());
}
// increment entry version
$ismVersion = $entry->incrementIsmVersion();
$entry->save();
$fileName = $entry->generateFileName(0, $ismVersion);
// creates convert data
$convertCollectionData = new kConvertCollectionJobData();
$convertCollectionData->setSrcFileSyncs(array($srcFileSyncDescriptor));
$convertCollectionData->setDestFileName($fileName);
$clipOffset = null;
$clipDuration = null;
// look for clipping params
foreach ($flavorParamsOutputs as $flavorParamsOutput) {
$clipOffset = $flavorParamsOutput->getClipOffset();
$clipDuration = $flavorParamsOutput->getClipDuration();
if (isset($clipOffset) || isset($clipDuration)) {
KalturaLog::log("Found clipping params: clipOffset({$clipOffset}),clipDuration({$clipDuration})");
break;
}
}
// check bitrates duplications & update clipping params
foreach ($flavorParamsOutputs as $flavorParamsOutputIndex => $flavorParamsOutput) {
// if one of clip params exsits - update the object and db
if (isset($clipOffset)) {
$flavorParamsOutputs[$flavorParamsOutputIndex]->setClipOffset($clipOffset);
}
if (isset($clipDuration)) {
$flavorParamsOutputs[$flavorParamsOutputIndex]->setClipDuration($clipDuration);
}
if (isset($clipOffset) || isset($clipDuration)) {
$flavorParamsOutputs[$flavorParamsOutputIndex]->save();
}
}
/*
* Put together all separted flavor XML's into a single Smooth Streaming preset file
*/
KalturaLog::log("Calling CDLProceessFlavorsForCollection with [" . count($flavorParamsOutputs) . "] flavor params");
$presetXml = KDLWrap::CDLProceessFlavorsForCollection($flavorParamsOutputs);
$presetXml = str_replace(KDLCmdlinePlaceholders::OutFileName, $fileName, $presetXml);
foreach ($flavorParamsOutputs as $flavorParamsOutput) {
/*
* Save in case that videoBitrate was changed by the FlavorsForCollection (see above)
*/
$flavorParamsOutput->save();
$convertCollectionFlavorData = new kConvertCollectionFlavorData();
$convertCollectionFlavorData->setFlavorAssetId($flavorParamsOutput->getFlavorAssetId());
$convertCollectionFlavorData->setFlavorParamsOutputId($flavorParamsOutput->getId());
$convertCollectionFlavorData->setReadyBehavior($flavorParamsOutput->getReadyBehavior());
$convertCollectionFlavorData->setVideoBitrate($flavorParamsOutput->getVideoBitrate());
$convertCollectionFlavorData->setAudioBitrate($flavorParamsOutput->getAudioBitrate());
$convertCollectionFlavorData->setAudioBitrate($flavorParamsOutput->getAudioBitrate());
$convertCollectionData->addFlavor($convertCollectionFlavorData);
}
$currentConversionEngine = conversionEngineType::EXPRESSION_ENCODER3;
KalturaLog::log("Using conversion engine [{$currentConversionEngine}]");
if ($sameRoot == null) {
// creats a child convert job
if ($parentJob) {
$dbConvertCollectionJob = $parentJob->createChild(BatchJobType::CONVERT_COLLECTION, $currentConversionEngine);
KalturaLog::log("Created from parent convert job with entry id [" . $dbConvertCollectionJob->getEntryId() . "]");
} else {
$dbConvertCollectionJob = new BatchJob();
$dbConvertCollectionJob->setEntryId($entry->getId());
$dbConvertCollectionJob->setPartnerId($entry->getPartnerId());
$dbConvertCollectionJob->setJobType(BatchJobType::CONVERT_COLLECTION);
$dbConvertCollectionJob->setJobSubType($currentConversionEngine);
}
} else {
$dbConvertCollectionJob = $parentJob->createChild(BatchJobType::CONVERT_COLLECTION, $currentConversionEngine, false);
}
$dbConvertCollectionJob->setObjectId($entry->getId());
$dbConvertCollectionJob->setObjectType(BatchJobObjectType::ENTRY);
$dbConvertCollectionJob->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS);
$dbConvertCollectionJob = kJobsManager::addJob($dbConvertCollectionJob, $convertCollectionData, BatchJobType::CONVERT_COLLECTION, $currentConversionEngine);
$syncKey = $dbConvertCollectionJob->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_CONFIG);
kFileSyncUtils::file_put_contents($syncKey, $presetXml);
$fileSync = kFileSyncUtils::getLocalFileSyncForKey($syncKey);
$remoteUrl = $fileSync->getExternalUrl($entry->getId());
$localPath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
//.........这里部分代码省略.........
示例5: decideSourceFlavorConvert
private static function decideSourceFlavorConvert($entryId, assetParams $sourceFlavor = null, flavorAsset $originalFlavorAsset, $conversionProfileId, $flavors, mediaInfo $mediaInfo = null, BatchJob $parentJob, BatchJob $convertProfileJob)
{
if ($sourceFlavor && ($sourceFlavor->getOperators() || $sourceFlavor->getConversionEngines()) && $originalFlavorAsset->getInterFlowCount() == null) {
KalturaLog::log("Source flavor asset requires conversion");
self::adjustAssetParams($entryId, array($sourceFlavor));
$srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$errDescription = null;
$sourceFlavorOutput = self::validateFlavorAndMediaInfo($sourceFlavor, $mediaInfo, $errDescription);
if (!$sourceFlavorOutput) {
if (!$errDescription) {
$errDescription = "Failed to create flavor params output from source flavor";
}
$originalFlavorAsset->setDescription($originalFlavorAsset->getDescription() . "\n{$errDescription}");
$originalFlavorAsset->setStatus(flavorAsset::ASSET_STATUS_ERROR);
$originalFlavorAsset->save();
kBatchManager::updateEntry($entryId, entryStatus::ERROR_CONVERTING);
kJobsManager::updateBatchJob($convertProfileJob, BatchJob::BATCHJOB_STATUS_FAILED);
return false;
}
} elseif ($mediaInfo) {
/*
* Check whether there is a need for an intermediate source pre-processing
*/
$sourceFlavorOutput = KDLWrap::GenerateIntermediateSource($mediaInfo, $flavors);
if (!$sourceFlavorOutput) {
return true;
}
$srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$errDescription = null;
/*
* Save the original source asset in another asset, in order
* to prevent its liquidated by the inter-source asset.
* But, do it only if the conversion profile contains source flavor
*/
if ($sourceFlavor) {
$sourceAsset = assetPeer::retrieveById($mediaInfo->getFlavorAssetId());
$copyFlavorParams = assetParamsPeer::retrieveBySystemName(self::SAVE_ORIGINAL_SOURCE_FLAVOR_PARAM_SYS_NAME);
if (!$copyFlavorParams) {
throw new APIException(APIErrors::OBJECT_NOT_FOUND);
}
$asset = $sourceAsset->copy();
$asset->setFlavorParamsId($copyFlavorParams->getId());
$asset->setFromAssetParams($copyFlavorParams);
$asset->setStatus(flavorAsset::ASSET_STATUS_READY);
$asset->setIsOriginal(0);
$asset->setTags($copyFlavorParams->getTags());
$asset->incrementVersion();
$asset->save();
kFileSyncUtils::createSyncFileLinkForKey($asset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET), $sourceAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET));
$origFileSync = kFileSyncUtils::getLocalFileSyncForKey($sourceAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET));
$asset->setSize(intval($origFileSync->getFileSize() / 1000));
$asset->save();
}
}
/*
* '_passthrough' controls whether the source is to be 'passthrough' although there
* is a source flavor that contains transcoder settings.
* Looks for a '_passthrough' flag on the source's flavor params output.
*/
if (!$sourceFlavorOutput || $sourceFlavorOutput->_passthrough == true) {
return true;
}
// save flavor params
$sourceFlavorOutput->setPartnerId($sourceFlavorOutput->getPartnerId());
$sourceFlavorOutput->setEntryId($entryId);
$sourceFlavorOutput->setFlavorAssetId($originalFlavorAsset->getId());
$sourceFlavorOutput->setFlavorAssetVersion($originalFlavorAsset->getVersion());
$sourceFlavorOutput->save();
if ($errDescription) {
$originalFlavorAsset->setDescription($originalFlavorAsset->getDescription() . "\n{$errDescription}");
}
$errDescription = kBusinessConvertDL::parseFlavorDescription($sourceFlavorOutput);
if ($errDescription) {
$originalFlavorAsset->setDescription($originalFlavorAsset->getDescription() . "\n{$errDescription}");
}
// decided by the business logic layer
if ($sourceFlavorOutput->_create_anyway) {
KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] selected to be created anyway");
} else {
if (!$sourceFlavorOutput->IsValid()) {
KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is invalid");
$originalFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
$originalFlavorAsset->save();
$errDescription = "Source flavor could not be converted";
self::setError($errDescription, $convertProfileJob, BatchJobType::CONVERT_PROFILE, $convertProfileJob->getEntryId());
return false;
}
if ($sourceFlavorOutput->_force) {
KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is forced");
} elseif ($sourceFlavorOutput->_isNonComply) {
KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is none-comply");
} else {
KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is valid");
}
}
$originalFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_CONVERTING);
if (isset($sourceFlavor)) {
$originalFlavorAsset->addTags($sourceFlavor->getTagsArray());
$originalFlavorAsset->setFileExt($sourceFlavorOutput->getFileExt());
$originalFlavorAsset->save();
//.........这里部分代码省略.........
示例6: createEnclosureXml
/**
* @param asset $asset
* @param string $class
* @param string $encodingProfile
* @param string $duration
* @param string $url
*/
protected function createEnclosureXml(asset $asset, $class, $encodingProfile, $duration)
{
/**
*
* In QuickPlay's XML example, the namespace "http://www.quickplaymedia.com" is added to the "enclosure"
* element regardless to the fact that it was registerted with the prefix "qpm" on the root element.
* We cannot set a namespace that was already defined with a prefix because DOMDocument will add the element
* as "qpm:enclosure" and won't set the namespace explicitly.
*
* The hack is to create a new KDOMDocument with default namespace "http://www.quickplaymedia.com" and then
* add it to the xml manually (see getXml() method)
*
*/
$syncKey = $asset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$fileSync = kFileSyncUtils::getLocalFileSyncForKey($syncKey);
$contentNode = $this->_enclosureNode->cloneNode(true);
kXml::setNodeValue($this->_xpath, '@encodingProfile', $encodingProfile, $contentNode);
$url = $this->getAssetUrl($asset);
$mimeType = $this->getContentTypeFromUrl($url);
$enclosureDoc = new KDOMDocument();
$enclosureElement = $enclosureDoc->createElementNS('http://www.quickplaymedia.com', 'enclosure');
$xmlElement = $enclosureDoc->createElement('xml');
$enclosureDoc->appendChild($xmlElement);
$enclosureNode = $enclosureDoc->importNode($contentNode, true);
$enclosureNode->setAttribute('class', $class);
$link = $enclosureNode->getElementsByTagName('link')->item(0);
$link->setAttribute('type', $mimeType);
$link->setAttribute('length', $fileSync->getFileSize());
$link->setAttribute('duration', $duration);
$link->setAttribute('url', pathinfo($fileSync->getFilePath(), PATHINFO_BASENAME));
$xmlElement->appendChild($enclosureNode);
return $enclosureDoc->saveXML($enclosureNode);
}
示例7: saveOriginalSource
private static function saveOriginalSource($mediaInfo)
{
$sourceAsset = assetPeer::retrieveById($mediaInfo->getFlavorAssetId());
$copyFlavorParams = assetParamsPeer::retrieveBySystemName(self::SAVE_ORIGINAL_SOURCE_FLAVOR_PARAM_SYS_NAME);
if (!$copyFlavorParams) {
throw new APIException(APIErrors::OBJECT_NOT_FOUND);
}
$asset = $sourceAsset->copy();
$asset->setFlavorParamsId($copyFlavorParams->getId());
$asset->setFromAssetParams($copyFlavorParams);
$asset->setStatus(flavorAsset::ASSET_STATUS_READY);
$asset->setIsOriginal(0);
$asset->setTags($copyFlavorParams->getTags());
$asset->incrementVersion();
$asset->save();
kFileSyncUtils::createSyncFileLinkForKey($asset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET), $sourceAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET));
$origFileSync = kFileSyncUtils::getLocalFileSyncForKey($sourceAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET));
$asset->setSize(intval($origFileSync->getFileSize() / 1000));
$asset->save();
}
示例8: attachFileSync
/**
* @param flavorAsset $flavorAsset
* @param FileSyncKey $srcSyncKey
*/
protected function attachFileSync(flavorAsset $flavorAsset, FileSyncKey $srcSyncKey)
{
$flavorAsset->incrementVersion();
$flavorAsset->save();
$newSyncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
kFileSyncUtils::createSyncFileLinkForKey($newSyncKey, $srcSyncKey);
$fileSync = kFileSyncUtils::getLocalFileSyncForKey($newSyncKey, false);
$fileSync = kFileSyncUtils::resolve($fileSync);
if (!$flavorAsset->isLocalReadyStatus()) {
$flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_QUEUED);
}
$flavorAsset->setSize($fileSync->getFileSize());
$flavorAsset->save();
}
示例9: addConvertIsmCollectionJob
//.........这里部分代码省略.........
$remoteUrl = $fileSync->getExternalUrl($entry->getId());
}
// increment entry version
$ismVersion = $entry->incrementIsmVersion();
$entry->save();
$fileName = $entry->generateFileName(0, $ismVersion);
// creates convert data
$convertCollectionData = new kConvertCollectionJobData();
$convertCollectionData->setSrcFileSyncLocalPath($localPath);
$convertCollectionData->setSrcFileSyncRemoteUrl($remoteUrl);
$convertCollectionData->setDestFileName($fileName);
$clipOffset = null;
$clipDuration = null;
// look for clipping params
foreach ($flavorParamsOutputs as $flavorParamsOutput) {
$clipOffset = $flavorParamsOutput->getClipOffset();
$clipDuration = $flavorParamsOutput->getClipDuration();
if (isset($clipOffset) || isset($clipDuration)) {
KalturaLog::log("Found clipping params: clipOffset({$clipOffset}),clipDuration({$clipDuration})");
break;
}
}
$bitrates = array();
$finalFlavorParamsOutputs = array();
// check bitrates duplications & update clipping params
foreach ($flavorParamsOutputs as $flavorParamsOutputIndex => $flavorParamsOutput) {
if (!isset($bitrates[$flavorParamsOutput->getVideoBitrate()])) {
$bitrates[$flavorParamsOutput->getVideoBitrate()] = array();
}
// if one of clip params exsits - update the object and db
if (isset($clipOffset)) {
$flavorParamsOutputs[$flavorParamsOutputIndex]->setClipOffset($clipOffset);
}
if (isset($clipDuration)) {
$flavorParamsOutputs[$flavorParamsOutputIndex]->setClipDuration($clipDuration);
}
if (isset($clipOffset) || isset($clipDuration)) {
$flavorParamsOutputs[$flavorParamsOutputIndex]->save();
}
$bitrates[$flavorParamsOutput->getVideoBitrate()][] = $flavorParamsOutput->getId();
$finalFlavorParamsOutputs[$flavorParamsOutput->getId()] = $flavorParamsOutput;
}
foreach ($bitrates as $bitrate => $flavorParamsOutputIds) {
if (count($flavorParamsOutputIds) == 1) {
// no bitrate dupliaction
continue;
}
$tempFlavorParamsOutputs = array();
foreach ($flavorParamsOutputIds as $index => $flavorParamsOutputId) {
$tempFlavorParamsOutputs[] = $finalFlavorParamsOutputs[$flavorParamsOutputId];
}
// sort the flavors by height
usort($tempFlavorParamsOutputs, array('kBusinessConvertDL', 'compareFlavorsByHeight'));
// increment the bitrate so it will be a bit different for each flavor
$index = 0;
foreach ($tempFlavorParamsOutputs as $flavorParamsOutput) {
$finalFlavorParamsOutputs[$flavorParamsOutput->getId()]->setVideoBitrate($bitrate + $index++);
}
}
foreach ($finalFlavorParamsOutputs as $flavorParamsOutput) {
$convertCollectionFlavorData = new kConvertCollectionFlavorData();
$convertCollectionFlavorData->setFlavorAssetId($flavorParamsOutput->getFlavorAssetId());
$convertCollectionFlavorData->setFlavorParamsOutputId($flavorParamsOutput->getId());
$convertCollectionFlavorData->setReadyBehavior($flavorParamsOutput->getReadyBehavior());
$convertCollectionFlavorData->setVideoBitrate($flavorParamsOutput->getVideoBitrate());
$convertCollectionFlavorData->setAudioBitrate($flavorParamsOutput->getAudioBitrate());
$convertCollectionFlavorData->setAudioBitrate($flavorParamsOutput->getAudioBitrate());
$convertCollectionData->addFlavor($convertCollectionFlavorData);
}
$currentConversionEngine = conversionEngineType::EXPRESSION_ENCODER3;
KalturaLog::log("Using conversion engine [{$currentConversionEngine}]");
if (!$dbConvertCollectionJob) {
// creats a child convert job
if ($parentJob) {
$dbConvertCollectionJob = $parentJob->createChild();
KalturaLog::log("Created from parent convert job with entry id [" . $dbConvertCollectionJob->getEntryId() . "]");
} else {
$dbConvertCollectionJob = new BatchJob();
$dbConvertCollectionJob->setEntryId($entry->getId());
$dbConvertCollectionJob->setPartnerId($entry->getPartnerId());
$dbConvertCollectionJob->save();
KalturaLog::log("Created from convert collection job with entry id [" . $dbConvertCollectionJob->getEntryId() . "]");
}
}
KalturaLog::log("Calling CDLProceessFlavorsForCollection with [" . count($finalFlavorParamsOutputs) . "] flavor params");
$xml = KDLWrap::CDLProceessFlavorsForCollection($finalFlavorParamsOutputs);
$xml = str_replace(KDLCmdlinePlaceholders::OutFileName, $fileName, $xml);
$syncKey = $dbConvertCollectionJob->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_CONFIG);
kFileSyncUtils::file_put_contents($syncKey, $xml);
$fileSync = kFileSyncUtils::getLocalFileSyncForKey($syncKey);
$remoteUrl = $fileSync->getExternalUrl($entry->getId());
$localPath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
$commandLines = array(conversionEngineType::EXPRESSION_ENCODER3 => KDLCmdlinePlaceholders::InFileName . ' ' . KDLCmdlinePlaceholders::ConfigFileName);
$commandLinesStr = flavorParamsOutput::buildCommandLinesStr($commandLines);
$convertCollectionData->setInputXmlLocalPath($localPath);
$convertCollectionData->setInputXmlRemoteUrl($remoteUrl);
$convertCollectionData->setCommandLinesStr($commandLinesStr);
$dbConvertCollectionJob->setFileSize(kFile::fileSize($convertCollectionData->getSrcFileSyncLocalPath()));
return kJobsManager::addJob($dbConvertCollectionJob, $convertCollectionData, BatchJobType::CONVERT_COLLECTION, $currentConversionEngine);
}
示例10: objectChanged
public function objectChanged(BaseObject $object, array $modifiedColumns)
{
if ($object instanceof entry && in_array(entryPeer::STATUS, $modifiedColumns) && ($object->getStatus() == entryStatus::READY || $object->getStatus() == entryStatus::ERROR_CONVERTING) && $object->getReplacedEntryId()) {
kFlowHelper::handleEntryReplacement($object);
return true;
}
if ($object instanceof UploadToken && in_array(UploadTokenPeer::STATUS, $modifiedColumns) && $object->getStatus() == UploadToken::UPLOAD_TOKEN_FULL_UPLOAD) {
kFlowHelper::handleUploadFinished($object);
return true;
}
if ($object instanceof BatchJob && $object->getJobType() == BatchJobType::BULKUPLOAD && $object->getStatus() == BatchJob::BATCHJOB_STATUS_ABORTED && in_array(BatchJobPeer::STATUS, $modifiedColumns) && in_array($object->getColumnsOldValue(BatchJobPeer::STATUS), BatchJobPeer::getClosedStatusList())) {
$partner = $object->getPartner();
if ($partner->getEnableBulkUploadNotificationsEmails()) {
kFlowHelper::sendBulkUploadNotificationEmail($object, MailType::MAIL_TYPE_BULKUPLOAD_ABORTED, array($partner->getAdminName(), $object->getId(), kFlowHelper::createBulkUploadLogUrl($object)));
}
return true;
}
if ($object instanceof UserRole && in_array(UserRolePeer::PERMISSION_NAMES, $modifiedColumns)) {
$filter = new kuserFilter();
$filter->set('_eq_role_ids', $object->getId());
kJobsManager::addIndexJob($object->getPartnerId(), IndexObjectType::USER, $filter, false);
return true;
}
if ($object instanceof FileSync) {
$c = new Criteria();
$c->add(BatchJobLockPeer::OBJECT_ID, $object->getId());
$c->add(BatchJobLockPeer::OBJECT_TYPE, BatchJobObjectType::FILE_SYNC);
$c->add(BatchJobLockPeer::JOB_TYPE, BatchJobType::FILESYNC_IMPORT);
$c->add(BatchJobLockPeer::STATUS, array(BatchJob::BATCHJOB_STATUS_RETRY, BatchJob::BATCHJOB_STATUS_PENDING), Criteria::IN);
$fileSyncImportJobs = BatchJobLockPeer::doSelect($c);
foreach ($fileSyncImportJobs as $fileSyncImportJob) {
kJobsManager::abortDbBatchJob(BatchJobPeer::retrieveByPK($fileSyncImportJob->getId()));
}
return true;
}
if (!$object instanceof flavorAsset || !in_array(assetPeer::STATUS, $modifiedColumns)) {
return true;
}
$entry = entryPeer::retrieveByPKNoFilter($object->getEntryId());
KalturaLog::info("Asset id [" . $object->getId() . "] isOriginal [" . $object->getIsOriginal() . "] status [" . $object->getStatus() . "]");
if ($object->getIsOriginal()) {
return true;
}
if ($object->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_VALIDATING) {
$postConvertAssetType = BatchJob::POSTCONVERT_ASSET_TYPE_FLAVOR;
$offset = $entry->getThumbOffset();
// entry getThumbOffset now takes the partner DefThumbOffset into consideration
$syncKey = $object->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$fileSync = kFileSyncUtils::getLocalFileSyncForKey($syncKey, false);
if (!$fileSync) {
return true;
}
$srcFileSyncLocalPath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
if ($srcFileSyncLocalPath) {
kJobsManager::addPostConvertJob(null, $postConvertAssetType, $srcFileSyncLocalPath, $object->getId(), null, $entry->getCreateThumb(), $offset);
}
} elseif ($object->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_READY) {
// If we get a ready flavor and the entry is in no content
if ($entry->getStatus() == entryStatus::NO_CONTENT) {
$entry->setStatus(entryStatus::PENDING);
// we change the entry to pending
$entry->save();
}
}
return true;
}
示例11: attachFileSync
/**
* @param FileAsset $dbFileAsset
* @param FileSyncKey $srcSyncKey
*/
protected function attachFileSync(FileAsset $dbFileAsset, FileSyncKey $srcSyncKey)
{
$dbFileAsset->incrementVersion();
$dbFileAsset->save();
$newSyncKey = $dbFileAsset->getSyncKey(FileAsset::FILE_SYNC_ASSET);
kFileSyncUtils::createSyncFileLinkForKey($newSyncKey, $srcSyncKey);
$fileSync = kFileSyncUtils::getLocalFileSyncForKey($newSyncKey, false);
$fileSync = kFileSyncUtils::resolve($fileSync);
$dbFileAsset->setStatus(FileAssetStatus::READY);
$dbFileAsset->setSize($fileSync->getFileSize());
$dbFileAsset->save();
}
示例12: addStorageDeleteJob
public static function addStorageDeleteJob(BatchJob $parentJob, Partner $partner, FileSyncKey $syncKey)
{
$srcFileSyncLocalPath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false);
$fileSync = kFileSyncUtils::getLocalFileSyncForKey($syncKey, false);
$netStorageDeleteData = new kStorageDeleteJobData();
$netStorageDeleteData->setServerUrl($partner->getStorageAddress());
$netStorageDeleteData->setServerUsername($partner->getStorageUsername());
$netStorageDeleteData->setServerPassword($partner->getStoragePassword());
$netStorageDeleteData->setFtpPassiveMode($partner->getStorageFtpPassive());
$netStorageDeleteData->setSrcFileSyncLocalPath($srcFileSyncLocalPath);
$netStorageDeleteData->setSrcFileSyncId($fileSync->getId());
$batchJob = $parentJob->createChild(false);
KalturaLog::log("Creating Net-Storage Delete job, with source file: " . $netStorageDeleteData->getSrcFileSyncLocalPath());
return self::addJob($batchJob, $netStorageDeleteData, BatchJobType::STORAGE_DELETE, $partner->getStorageProtocol());
}