本文整理汇总了PHP中kFileSyncUtils::softCopy方法的典型用法代码示例。如果您正苦于以下问题:PHP kFileSyncUtils::softCopy方法的具体用法?PHP kFileSyncUtils::softCopy怎么用?PHP kFileSyncUtils::softCopy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kFileSyncUtils
的用法示例。
在下文中一共展示了kFileSyncUtils::softCopy方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uiConfCopied
/**
* @param uiConf $fromObject
* @param uiConf $toObject
*/
protected function uiConfCopied(uiConf $fromObject, uiConf $toObject)
{
$fileAssets = FileAssetPeer::retrieveByObject(FileAssetObjectType::UI_CONF, $fromObject->getId());
foreach ($fileAssets as $fileAsset) {
/* @var $fileAsset FileAsset */
$newFileAssets = $fileAsset->copy();
$newFileAssets->setObjectId($toObject->getId());
$newFileAssets->incrementVersion();
$newFileAssets->save();
$syncKey = $fileAsset->getSyncKey(FileAsset::FILE_SYNC_ASSET);
$newSyncKey = $newFileAssets->getSyncKey(FileAsset::FILE_SYNC_ASSET);
if (kFileSyncUtils::fileSync_exists($syncKey)) {
kFileSyncUtils::softCopy($syncKey, $newSyncKey);
}
}
}
示例2: copyToEntry
public function copyToEntry($entryId = null, $partnerId = null)
{
$newFlavorAsset = $this->copy();
if ($partnerId) {
$newFlavorAsset->setPartnerId($partnerId);
}
if ($entryId) {
$newFlavorAsset->setEntryId($entryId);
}
$newFlavorAsset->save();
$flavorParamsOutput = flavorParamsOutputPeer::retrieveByFlavorAssetId($this->getId());
if ($flavorParamsOutput) {
$newFlavorParamsOutput = $flavorParamsOutput->copy();
$newFlavorParamsOutput->setPartnerId($newFlavorAsset->getPartnerId());
$newFlavorParamsOutput->setEntryId($newFlavorAsset->getEntryId());
$newFlavorParamsOutput->setFlavorAssetId($newFlavorAsset->getId());
$newFlavorParamsOutput->save();
}
$mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($this->getId());
if ($mediaInfo) {
$newMediaInfo = $mediaInfo->copy();
$newMediaInfo->setFlavorAssetId($newFlavorAsset->getId());
$newMediaInfo->save();
}
$assetSyncKey = $this->getSyncKey(self::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$convertLogSyncKey = $this->getSyncKey(self::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_CONVERT_LOG);
$newAssetSyncKey = $newFlavorAsset->getSyncKey(self::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$newConvertLogSyncKey = $newFlavorAsset->getSyncKey(self::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_CONVERT_LOG);
if (kFileSyncUtils::file_exists($assetSyncKey, true)) {
kFileSyncUtils::softCopy($assetSyncKey, $newAssetSyncKey);
}
if (kFileSyncUtils::file_exists($convertLogSyncKey, true)) {
kFileSyncUtils::softCopy($convertLogSyncKey, $newConvertLogSyncKey);
}
return $newFlavorAsset;
}
示例3: shalowClone
public static function shalowClone(kshow $source_kshow, $new_prodcuer_id)
{
$target_kshow = $source_kshow->copy();
$target_kshow->setProducerId($new_prodcuer_id);
$target_kshow->save();
self::resetKshowStats($target_kshow, true);
if (!$source_kshow->getEpisodeId()) {
$target_kshow->setEpisodeId($source_kshow->getId());
}
//$target_kshow->setHasRoughcut($source_kshow->getHasRoughcut());
$target_show_entry = $target_kshow->createEntry(entry::ENTRY_MEDIA_TYPE_SHOW, $new_prodcuer_id);
$content = myContentStorage::getFSContentRootPath();
$source_thumbnail_path = $source_kshow->getThumbnailPath();
$target_kshow->setThumbnail(null);
$target_kshow->setThumbnail($source_kshow->getThumbnail());
$target_thumbnail_path = $target_kshow->getThumbnailPath();
// myContentStorage::moveFile( $content . $source_thumbnail_path , $content . $target_thumbnail_path , false , true );
$target_kshow->save();
// copy the show_entry file content
$source_show_entry = entryPeer::retrieveByPK($source_kshow->getShowEntryId());
$source_show_entry_data_key = $source_show_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
$target_show_entry->setData(null);
$target_show_entry->setData($source_show_entry->getData());
$target_show_entry_data_key = $target_show_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
$target_show_entry->setName($source_show_entry->getName());
$target_show_entry->setLengthInMsecs($source_show_entry->getLengthInMsecs());
kFileSyncUtils::softCopy($source_show_entry_data_key, $target_show_entry_data_key);
//myContentStorage::moveFile( $content . $source_show_entry_path , $content . $target_show_entry_path , false , true );
myEntryUtils::createThumbnail($target_show_entry, $source_show_entry, true);
// $target_kshow->setHasRoughcut(true);
// $target_kshow->save();
$target_show_entry->save();
return $target_kshow;
}
示例4: handleImportFinished
/**
* @param BatchJob $dbBatchJob
* @param kImportJobData $data
* @param BatchJob $twinJob
* @return BatchJob
*/
public static function handleImportFinished(BatchJob $dbBatchJob, kImportJobData $data, BatchJob $twinJob = null)
{
KalturaLog::debug("Import finished, with file: " . $data->getDestFileLocalPath());
if ($dbBatchJob->getAbort()) {
return $dbBatchJob;
}
if (!$twinJob) {
if (!file_exists($data->getDestFileLocalPath())) {
throw new APIException(APIErrors::INVALID_FILE_NAME, $data->getDestFileLocalPath());
}
}
$msg = null;
$flavorAsset = kFlowHelper::createOriginalFlavorAsset($dbBatchJob->getPartnerId(), $dbBatchJob->getEntryId(), $msg);
if (!$flavorAsset) {
KalturaLog::err("Flavor asset not created for entry [" . $dbBatchJob->getEntryId() . "]");
kBatchManager::updateEntry($dbBatchJob, entryStatus::ERROR_CONVERTING);
$dbBatchJob->setMessage($msg);
$dbBatchJob->setDescription($dbBatchJob->getDescription() . "\n" . $msg);
return $dbBatchJob;
}
$syncKey = null;
if ($twinJob) {
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
// copy file sync
$twinData = $twinJob->getData();
if ($twinData instanceof kImportJobData) {
$twinFlavorAsset = flavorAssetPeer::retrieveById($twinData->getFlavorAssetId());
if ($twinFlavorAsset) {
$twinSyncKey = $twinFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if ($twinSyncKey && kFileSyncUtils::file_exists($twinSyncKey)) {
kFileSyncUtils::softCopy($twinSyncKey, $syncKey);
}
}
}
} else {
$ext = pathinfo($data->getDestFileLocalPath(), PATHINFO_EXTENSION);
KalturaLog::info("Imported file extension: {$ext}");
$flavorAsset->setFileExt($ext);
$flavorAsset->save();
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
kFileSyncUtils::moveFromFile($data->getDestFileLocalPath(), $syncKey);
}
// set the path in the job data
$data->setDestFileLocalPath(kFileSyncUtils::getLocalFilePathForKey($syncKey));
$data->setFlavorAssetId($flavorAsset->getId());
$dbBatchJob->setData($data);
$dbBatchJob->save();
kEventsManager::raiseEvent(new kObjectAddedEvent($flavorAsset));
return $dbBatchJob;
}
示例5: copyToEntry
public function copyToEntry($entryId = null, $partnerId = null)
{
$newFlavorAsset = $this->copy();
//this is the first version of the new asset.
$newFlavorAsset->incrementVersion();
if ($partnerId) {
$newFlavorAsset->setPartnerId($partnerId);
}
if ($entryId) {
$newFlavorAsset->setEntryId($entryId);
}
$newFlavorAsset->save();
$flavorParamsOutput = assetParamsOutputPeer::retrieveByAssetId($this->getId());
if ($flavorParamsOutput) {
$newFlavorParamsOutput = $flavorParamsOutput->copy();
$newFlavorParamsOutput->setPartnerId($newFlavorAsset->getPartnerId());
$newFlavorParamsOutput->setEntryId($newFlavorAsset->getEntryId());
$newFlavorParamsOutput->setFlavorAssetId($newFlavorAsset->getId());
$newFlavorParamsOutput->save();
}
$mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($this->getId());
if ($mediaInfo) {
$newMediaInfo = $mediaInfo->copy();
$newMediaInfo->setFlavorAssetId($newFlavorAsset->getId());
$newMediaInfo->setFlavorAssetVersion($newFlavorAsset->getVersion());
$newMediaInfo->save();
}
$assetSyncKey = $this->getSyncKey(self::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$convertLogSyncKey = $this->getSyncKey(self::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_CONVERT_LOG);
$ismSyncKey = $this->getSyncKey(self::FILE_SYNC_ASSET_SUB_TYPE_ISM);
$ismcSyncKey = $this->getSyncKey(self::FILE_SYNC_ASSET_SUB_TYPE_ISMC);
$newAssetSyncKey = $newFlavorAsset->getSyncKey(self::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$newConvertLogSyncKey = $newFlavorAsset->getSyncKey(self::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_CONVERT_LOG);
$newIsmSyncKey = $newFlavorAsset->getSyncKey(self::FILE_SYNC_ASSET_SUB_TYPE_ISM);
$newIsmcSyncKey = $newFlavorAsset->getSyncKey(self::FILE_SYNC_ASSET_SUB_TYPE_ISMC);
if (kFileSyncUtils::fileSync_exists($assetSyncKey)) {
kFileSyncUtils::softCopy($assetSyncKey, $newAssetSyncKey);
}
if (kFileSyncUtils::fileSync_exists($convertLogSyncKey)) {
kFileSyncUtils::softCopy($convertLogSyncKey, $newConvertLogSyncKey);
}
if (kFileSyncUtils::fileSync_exists($ismSyncKey)) {
kFileSyncUtils::softCopy($ismSyncKey, $newIsmSyncKey);
}
if (kFileSyncUtils::fileSync_exists($ismcSyncKey)) {
kFileSyncUtils::softCopy($ismcSyncKey, $newIsmcSyncKey);
}
kEventsManager::raiseEvent(new kObjectAddedEvent($newFlavorAsset));
return $newFlavorAsset;
}
示例6: copyEntry
public static function copyEntry(entry $entry, Partner $toPartner = null, $dontCopyUsers = false)
{
KalturaLog::log("copyEntry - Copying entry [" . $entry->getId() . "] to partner [" . $toPartner->getId() . "]");
$newEntry = $entry->copy();
$newEntry->setIntId(null);
if ($toPartner instanceof Partner) {
$newEntry->setPartnerId($toPartner->getId());
$newEntry->setSubpId($toPartner->getId() * 100);
$newEntry->setAccessControlId($toPartner->getDefaultAccessControlId());
$flavorParamsStr = $entry->getFlavorParamsIds();
$flavorParams = explode(',', $flavorParamsStr);
$newFlavorParams = array();
foreach ($flavorParams as $flavorParamsId) {
$newFlavorParamsId = kObjectCopyHandler::getMappedId('flavorParams', $flavorParamsId);
if (is_null($newFlavorParamsId)) {
$newFlavorParamsId = $flavorParamsId;
}
$newFlavorParams[] = $newFlavorParamsId;
}
$newEntry->setFlavorParamsIds(implode(',', $newFlavorParams));
}
$newKuser = null;
if (!$dontCopyUsers) {
// copy the kuser (if the same puser id exists its kuser will be used)
kuserPeer::setUseCriteriaFilter(false);
$kuser = $entry->getKuser();
$newKuser = kuserPeer::createKuserForPartner($newEntry->getPartnerId(), $kuser->getPuserId());
$newEntry->setKuserId($newKuser->getId());
kuserPeer::setUseCriteriaFilter(true);
}
// copy the kshow
kshowPeer::setUseCriteriaFilter(false);
$kshow = $entry->getKshow();
if ($kshow) {
$newKshow = $kshow->copy();
$newKshow->setIntId(null);
$newKshow->setPartnerId($toPartner->getId());
$newKshow->setSubpId($toPartner->getId() * 100);
if ($newKuser) {
$newKshow->setProducerId($newKuser->getId());
}
$newKshow->save();
$newEntry->setKshowId($newKshow->getId());
}
kshowPeer::setUseCriteriaFilter(true);
// reset the statistics
myEntryUtils::resetEntryStatistics($newEntry);
// set the new partner id into the default category criteria filter
$defaultCategoryFilter = categoryPeer::getCriteriaFilter()->getFilter();
$oldPartnerId = $defaultCategoryFilter->get(categoryPeer::PARTNER_ID);
$defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
$defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $newEntry->getPartnerId());
// save the entry
$newEntry->save();
// restore the original partner id in the default category criteria filter
$defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
$defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $oldPartnerId);
KalturaLog::log("copyEntry - New entry [" . $newEntry->getId() . "] was created");
// for any type that does not require assets:
$shouldCopyDataForNonClip = $entry->getType() != entryType::MEDIA_CLIP;
$shouldCopyDataForClip = false;
// only images get their data copied
if ($entry->getType() == entryType::MEDIA_CLIP) {
if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_VIDEO && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_AUDIO) {
$shouldCopyDataForClip = true;
}
}
if ($shouldCopyDataForNonClip || $shouldCopyDataForClip) {
// copy the data
$from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
// replaced__getDataPath
$to = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
// replaced__getDataPath
KalturaLog::log("copyEntriesByType - copying entry data [" . $from . "] to [" . $to . "]");
kFileSyncUtils::softCopy($from, $to);
}
$ismFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
if (kFileSyncUtils::fileSync_exists($ismFrom)) {
$ismTo = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
KalturaLog::log("copying entry ism [" . $ismFrom . "] to [" . $ismTo . "]");
kFileSyncUtils::softCopy($ismFrom, $ismTo);
}
$ismcFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
if (kFileSyncUtils::fileSync_exists($ismcFrom)) {
$ismcTo = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
KalturaLog::log("copying entry ism [" . $ismcFrom . "] to [" . $ismcTo . "]");
kFileSyncUtils::softCopy($ismcFrom, $ismcTo);
}
$from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
// replaced__getThumbnailPath
$considerCopyThumb = true;
// if entry is image - data is thumbnail, and it was copied
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$considerCopyThumb = false;
}
// if entry is not clip, and there is no file in both DCs - nothing to copy
if ($entry->getType() != entryType::MEDIA_CLIP && !kFileSyncUtils::file_exists($from, true)) {
$considerCopyThumb = false;
}
if ($considerCopyThumb) {
//.........这里部分代码省略.........
示例7: sentToCenversion
private function sentToCenversion($write_to_log = true)
{
try {
$debug = array("before getFileToConvert");
list($before_archiving_file_path, $file_name, $in_proc) = $this->getFileToConvert($write_to_log);
$debug[] = "after getFileToConvert [{$before_archiving_file_path}] [{$file_name}]";
if (!$before_archiving_file_path) {
return;
}
// TODO - check if this file failed too many times ...
//if ( !$this->shouldHandleFile ( $file_name ) )
$entry_id = self::getEntryIdFromFileName($file_name);
$debug[] = "entry_id [{$entry_id}]";
// we have to retrieve the path of the entry - do so by setting the data to the file path (now rather than at the end)
$entry = entryPeer::retrieveByPK($entry_id);
$conv_profile = myPartnerUtils::getConversionProfileForEntry($entry_id);
$debug[] = "conversion profile of class [" . get_class($conv_profile) . "]";
if (!$entry) {
KalturaLog::debug("entry id [{$entry_id}] not found!");
return;
}
// the conversion target should be the entry's dataPath
$flv_file_name = kConversionHelper::flvFileName($before_archiving_file_path);
$debug[] = "flv_file_name [{$flv_file_name}]";
$entry->setData(null);
$entry->setData($flv_file_name);
// we assume the output will be of type FLV
$entry->save();
$archive_file_sync = $this->archiveFile($before_archiving_file_path);
$archived_file_path = $archive_file_sync->getFullPath();
$debug[] = "archived_file_path [{$archived_file_path}]";
if ($conv_profile->getBypassFlv() && kConversionHelper::isFlv($archived_file_path)) {
$conv_cmd = $this->createConversionCommandFromConverionProfile($archived_file_path, $archived_file_path, $conv_profile, $entry);
$debug[] = "before createConversionInDb[{$entry_id}] [{$archived_file_path}]";
// first update the DB
$this->createConversionInDb($entry_id, $archived_file_path, $conv_cmd);
// TODO - check if there is a set of convParams for this FLV profile and manye some conversion should be done
// for the edit version ??
KalturaLog::debug("Bypassing conversion for entry_id [{$entry_id}] file [{$file_name}]");
$conv_res = new kConversionResult($conv_cmd);
$conv_res_info = new kConvResInfo();
$conv_res_info->target = $archived_file_path;
$start = microtime(true);
// FileSync - soft copy
$archived_sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ARCHIVE);
$data_sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
kFileSyncUtils::softCopy($archived_sync_key, $data_sync_key);
$end = microtime(true);
$conv_res_info->duration = $end - $start;
$conv_res_info->conv_str = "NO CONVERT";
$conv_res->appendResInfo($conv_res_info);
$this->updateConvertedEntry(true, $entry, $conv_res);
$this->removeInProc($in_proc);
return;
}
// FileSync - create file sync for the future place of the converted data
$data_sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
kFileSyncUtils::createSyncFileForKey($data_sync_key, false, false);
$full_target_path = kFileSyncUtils::getLocalFilePathForKey($data_sync_key, true);
if ($conv_profile->getProfileTypeSuffix() == "edit") {
// FileSync - create file sync for the future place of the converted data in edit flavor
$data_edit_sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA_EDIT);
kFileSyncUtils::createSyncFileForKey($data_edit_sync_key, false, false);
}
$debug[] = "full_target_path [{$full_target_path}]";
$conv_cmd = $this->createConversionCommandFromConverionProfile($archived_file_path, $full_target_path, $conv_profile, $entry);
$debug[] = "before createConversionInDb[{$entry_id}] [{$archived_file_path}]";
// first update the DB
$this->createConversionInDb($entry_id, $archived_file_path, $conv_cmd);
KalturaLog::debug("Setting ConversionCommand for file [{$file_name}]\n" . print_r($conv_cmd, true));
$debug[] = "before saveConversionCommand";
// then save the conversion command
$cmd_file_path = $this->saveConversionCommand();
$this->removeInProc($in_proc);
KalturaLog::debug("Set ConversionCommand for file [{$file_name}] in [{$cmd_file_path}]");
$debug[] = "end";
} catch (kConversionException $kcoe) {
$this->removeInProc($in_proc);
KalturaLog::debug("Error:\n" . $kcoe->getMessage() . "\n" . $kcoe->getTraceAsString() . "\n" . print_r($debug));
// update the entry with the error sttus and the error message to the conversion result
$conv_res = new kConversionResult($conv_cmd);
$conv_res->appendResult($kcoe->getMessage());
$this->updateConvertedEntry(false, $entry, $conv_res);
} catch (Exception $ex) {
$this->removeInProc($in_proc);
KalturaLog::debug("Error:\n" . $ex->getMessage() . "\n" . $ex->getTraceAsString() . "\n" . print_r($debug));
// if this failed for some unknown reason - set it for reconversion
$indicator = $this->setFileToReConvert($before_archiving_file_path, $file_name);
KalturaLog::debug("... will reconvert [" . print_r($indicator, true) . "]");
throw $ex;
}
}
示例8: copyEntryData
public static function copyEntryData(entry $entry, entry $targetEntry)
{
// for any type that does not require assets:
$shouldCopyDataForNonClip = true;
if ($entry->getType() == entryType::MEDIA_CLIP) {
$shouldCopyDataForNonClip = false;
}
if ($entry->getType() == entryType::PLAYLIST) {
$shouldCopyDataForNonClip = false;
}
$shouldCopyDataForClip = false;
// only images get their data copied
if ($entry->getType() == entryType::MEDIA_CLIP) {
if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_VIDEO && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_AUDIO) {
$shouldCopyDataForClip = true;
}
}
if ($shouldCopyDataForNonClip || $shouldCopyDataForClip) {
// copy the data
$from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
// replaced__getDataPath
$to = $targetEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
// replaced__getDataPath
KalturaLog::log("copyEntriesByType - copying entry data [" . $from . "] to [" . $to . "]");
kFileSyncUtils::softCopy($from, $to);
}
$ismFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
if (kFileSyncUtils::fileSync_exists($ismFrom)) {
$ismTo = $targetEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
KalturaLog::log("copying entry ism [" . $ismFrom . "] to [" . $ismTo . "]");
kFileSyncUtils::softCopy($ismFrom, $ismTo);
}
$ismcFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
if (kFileSyncUtils::fileSync_exists($ismcFrom)) {
$ismcTo = $targetEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
KalturaLog::log("copying entry ism [" . $ismcFrom . "] to [" . $ismcTo . "]");
kFileSyncUtils::softCopy($ismcFrom, $ismcTo);
}
$from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
// replaced__getThumbnailPath
$considerCopyThumb = true;
// if entry is image - data is thumbnail, and it was copied
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$considerCopyThumb = false;
}
// if entry is not clip, and there is no file in both DCs - nothing to copy
if ($entry->getType() != entryType::MEDIA_CLIP && !kFileSyncUtils::file_exists($from, true)) {
$considerCopyThumb = false;
}
if ($considerCopyThumb) {
$skipThumb = false;
// don't attempt to copy a thumbnail for images - it's the same as the data which was just created
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO) {
// check if audio entry has real thumb, if not - don't copy thumb.
$originalFileSync = kFileSyncUtils::getOriginFileSyncForKey($from, false);
if (!$originalFileSync) {
$skipThumb = true;
}
}
if (!$skipThumb) {
$to = $targetEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
// replaced__getThumbnailPath
KalturaLog::log("copyEntriesByType - copying entry thumbnail [" . $from . "] to [" . $to . "]");
kFileSyncUtils::softCopy($from, $to);
}
}
// added by Tan-Tan 12/01/2010 to support falvors copy
$sourceAssets = assetPeer::retrieveByEntryId($entry->getId());
foreach ($sourceAssets as $sourceAsset) {
$sourceAsset->copyToEntry($targetEntry->getId(), $targetEntry->getPartnerId());
}
}
示例9: copyEntry
//.........这里部分代码省略.........
}
$entryFilter->fields["_matchand_categories_ids"] = implode(",", $newCategoriesIds);
}
if (isset($entryFilter->fields["_matchor_categories_ids"])) {
$categoriesIds = explode(",", $entryFilter->fields["_matchor_categories_ids"]);
$newCategoriesIds = array();
foreach ($categoriesIds as $categoryId) {
$newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId);
}
$entryFilter->fields["_matchor_categories_ids"] = implode(",", $newCategoriesIds);
}
if (isset($entryFilter->fields["_in_category_ancestor_id"])) {
$categoriesIds = explode(",", $entryFilter->fields["_in_category_ancestor_id"]);
$newCategoriesIds = array();
foreach ($categoriesIds as $categoryId) {
$newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId);
}
$entryFilter->fields["_in_category_ancestor_id"] = implode(",", $newCategoriesIds);
}
$toEntryFilterXML = $toFiltersXml->addChild("filter");
$toEntryFilterXML = $entryFilter->toXml($toEntryFilterXML);
}
$newEntry->setDataContent($toPlaylistXml->asXML());
break;
}
}
if ($shouldCopyDataForNonClip || $shouldCopyDataForClip) {
// copy the data
$from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
// replaced__getDataPath
$to = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
// replaced__getDataPath
KalturaLog::log("copyEntriesByType - copying entry data [" . $from . "] to [" . $to . "]");
kFileSyncUtils::softCopy($from, $to);
}
$ismFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
if (kFileSyncUtils::fileSync_exists($ismFrom)) {
$ismTo = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
KalturaLog::log("copying entry ism [" . $ismFrom . "] to [" . $ismTo . "]");
kFileSyncUtils::softCopy($ismFrom, $ismTo);
}
$ismcFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
if (kFileSyncUtils::fileSync_exists($ismcFrom)) {
$ismcTo = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
KalturaLog::log("copying entry ism [" . $ismcFrom . "] to [" . $ismcTo . "]");
kFileSyncUtils::softCopy($ismcFrom, $ismcTo);
}
$from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
// replaced__getThumbnailPath
$considerCopyThumb = true;
// if entry is image - data is thumbnail, and it was copied
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$considerCopyThumb = false;
}
// if entry is not clip, and there is no file in both DCs - nothing to copy
if ($entry->getType() != entryType::MEDIA_CLIP && !kFileSyncUtils::file_exists($from, true)) {
$considerCopyThumb = false;
}
if ($considerCopyThumb) {
$skipThumb = false;
// don't attempt to copy a thumbnail for images - it's the same as the data which was just created
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO) {
// check if audio entry has real thumb, if not - don't copy thumb.
$originalFileSync = kFileSyncUtils::getOriginFileSyncForKey($from, false);
if (!$originalFileSync) {
$skipThumb = true;
示例10: handleImportFinished
/**
* @param BatchJob $dbBatchJob
* @param kImportJobData $data
* @param BatchJob $twinJob
* @return BatchJob
*/
public static function handleImportFinished(BatchJob $dbBatchJob, kImportJobData $data, BatchJob $twinJob = null)
{
KalturaLog::debug("Import finished, with file: " . $data->getDestFileLocalPath());
if ($dbBatchJob->getAbort()) {
return $dbBatchJob;
}
if (!$twinJob) {
if (!file_exists($data->getDestFileLocalPath())) {
throw new APIException(APIErrors::INVALID_FILE_NAME, $data->getDestFileLocalPath());
}
}
// get entry
$entryId = $dbBatchJob->getEntryId();
$dbEntry = entryPeer::retrieveByPKNoFilter($entryId);
// IMAGE media entries
if ($dbEntry->getType() == entryType::MEDIA_CLIP && $dbEntry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$syncKey = $dbEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
try {
kFileSyncUtils::moveFromFile($data->getDestFileLocalPath(), $syncKey, true, false, $data->getCacheOnly());
} catch (Exception $e) {
if ($dbEntry->getStatus() == entryStatus::NO_CONTENT) {
$dbEntry->setStatus(entryStatus::ERROR_CONVERTING);
$dbEntry->save();
}
throw $e;
}
$dbEntry->setStatus(entryStatus::READY);
$dbEntry->save();
return $dbBatchJob;
}
$flavorAsset = null;
if ($data->getFlavorAssetId()) {
$flavorAsset = assetPeer::retrieveById($data->getFlavorAssetId());
}
$isNewFlavor = false;
if (!$flavorAsset) {
$msg = null;
$flavorAsset = kFlowHelper::createOriginalFlavorAsset($dbBatchJob->getPartnerId(), $dbBatchJob->getEntryId(), $msg);
if (!$flavorAsset) {
KalturaLog::err("Flavor asset not created for entry [" . $dbBatchJob->getEntryId() . "]");
kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING);
$dbBatchJob->setMessage($msg);
$dbBatchJob->setDescription($dbBatchJob->getDescription() . "\n" . $msg);
return $dbBatchJob;
}
$isNewFlavor = true;
}
$isNewContent = true;
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if (kFileSyncUtils::fileSync_exists($syncKey)) {
$isNewContent = false;
}
if ($twinJob) {
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
// copy file sync
$twinData = $twinJob->getData();
if ($twinData instanceof kImportJobData) {
$twinFlavorAsset = assetPeer::retrieveById($twinData->getFlavorAssetId());
if ($twinFlavorAsset) {
$twinSyncKey = $twinFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if ($twinSyncKey && kFileSyncUtils::file_exists($twinSyncKey)) {
kFileSyncUtils::softCopy($twinSyncKey, $syncKey);
}
}
}
} else {
$ext = pathinfo($data->getDestFileLocalPath(), PATHINFO_EXTENSION);
KalturaLog::info("Imported file extension: {$ext}");
if (!$flavorAsset->getVersion()) {
$flavorAsset->incrementVersion();
}
$flavorAsset->setFileExt($ext);
$flavorAsset->save();
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
kFileSyncUtils::moveFromFile($data->getDestFileLocalPath(), $syncKey, true, false, $data->getCacheOnly());
}
// set the path in the job data
$localFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
$data->setDestFileLocalPath($localFilePath);
$data->setFlavorAssetId($flavorAsset->getId());
$dbBatchJob->setData($data);
$dbBatchJob->save();
if ($isNewContent || $dbEntry->getStatus() == entryStatus::IMPORT) {
// check if status == import for importing file of type url (filesync exists, and we want to raise event for conversion profile to start)
kEventsManager::raiseEvent(new kObjectAddedEvent($flavorAsset, $dbBatchJob));
}
if (!$isNewFlavor && $flavorAsset->getIsOriginal()) {
$entryFlavors = assetPeer::retrieveFlavorsByEntryId($flavorAsset->getEntryId());
foreach ($entryFlavors as $entryFlavor) {
/* @var $entryFlavor flavorAsset */
if ($entryFlavor->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_WAIT_FOR_CONVERT && $entryFlavor->getFlavorParamsId()) {
kBusinessPreConvertDL::decideAddEntryFlavor($dbBatchJob, $flavorAsset->getEntryId(), $entryFlavor->getFlavorParamsId());
}
}
//.........这里部分代码省略.........