本文整理汇总了PHP中kDataCenterMgr::getRemoteDcExternalUrlByDcId方法的典型用法代码示例。如果您正苦于以下问题:PHP kDataCenterMgr::getRemoteDcExternalUrlByDcId方法的具体用法?PHP kDataCenterMgr::getRemoteDcExternalUrlByDcId怎么用?PHP kDataCenterMgr::getRemoteDcExternalUrlByDcId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kDataCenterMgr
的用法示例。
在下文中一共展示了kDataCenterMgr::getRemoteDcExternalUrlByDcId方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateEntry
public function validateEntry(entry $dbEntry)
{
parent::validateEntry($dbEntry);
$this->validatePropertyNotNull('resources');
$dc = null;
foreach ($this->resources as $resource) {
$resource->validateEntry($dbEntry);
if (!$resource instanceof KalturaDataCenterContentResource) {
continue;
}
$theDc = $resource->getDc();
if (is_null($theDc)) {
continue;
}
if (is_null($dc)) {
$dc = $theDc;
} elseif ($dc != $theDc) {
throw new KalturaAPIException(KalturaErrors::RESOURCES_MULTIPLE_DATA_CENTERS);
}
}
if (!is_null($dc) && $dc != kDataCenterMgr::getCurrentDcId()) {
$remoteHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId($dc);
kFileUtils::dumpApiRequest($remoteHost);
}
}
示例2: createPeriodicSyncPoints
/**
* Creates perioding metadata sync-point events on a live stream
*
* @action createPeriodicSyncPoints
* @actionAlias liveStream.createPeriodicSyncPoints
* @param string $entryId Kaltura live-stream entry id
* @param int $interval Events interval in seconds
* @param int $duration Duration in seconds
*
* @throws KalturaErrors::ENTRY_ID_NOT_FOUND
* @throws KalturaErrors::NO_MEDIA_SERVER_FOUND
* @throws KalturaErrors::MEDIA_SERVER_SERVICE_NOT_FOUND
*/
function createPeriodicSyncPoints($entryId, $interval, $duration)
{
$entryDc = substr($entryId, 0, 1);
if ($entryDc != kDataCenterMgr::getCurrentDcId()) {
$remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId($entryDc);
kFileUtils::dumpApiRequest($remoteDCHost, true);
}
$dbEntry = entryPeer::retrieveByPK($entryId);
if (!$dbEntry || $dbEntry->getType() != KalturaEntryType::LIVE_STREAM || !in_array($dbEntry->getSource(), array(KalturaSourceType::LIVE_STREAM, KalturaSourceType::LIVE_STREAM_ONTEXTDATA_CAPTIONS))) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
/* @var $dbEntry LiveStreamEntry */
$mediaServers = $dbEntry->getMediaServers();
if (!count($mediaServers)) {
throw new KalturaAPIException(KalturaErrors::NO_MEDIA_SERVER_FOUND, $entryId);
}
foreach ($mediaServers as $key => $kMediaServer) {
if ($kMediaServer && $kMediaServer instanceof kLiveMediaServer) {
$mediaServer = $kMediaServer->getMediaServer();
$mediaServerCuePointsService = $mediaServer->getWebService(MediaServer::WEB_SERVICE_CUE_POINTS);
KalturaLog::debug("Sending sync points for DC [" . $mediaServer->getDc() . "] ");
if ($mediaServerCuePointsService && $mediaServerCuePointsService instanceof KalturaMediaServerCuePointsService) {
KalturaLog::debug("Call createTimeCuePoints on DC [" . $mediaServer->getDc() . "] ");
$mediaServerCuePointsService->createTimeCuePoints($entryId, $interval, $duration);
} else {
KalturaLog::debug("Media server service not found on DC: [" . $mediaServer->getDc() . "] ");
}
}
}
}
示例3: dumpApiRequest
function dumpApiRequest($entryId, $onlyIfAvailable = true)
{
$entryDc = substr($entryId, 0, 1);
if ($entryDc != kDataCenterMgr::getCurrentDcId()) {
$remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId($entryDc);
kFileUtils::dumpApiRequest($remoteDCHost, $onlyIfAvailable);
}
}
示例4: validateEntry
public function validateEntry(entry $dbEntry)
{
parent::validateEntry($dbEntry);
$dc = $this->getDc();
if ($dc == kDataCenterMgr::getCurrentDcId()) {
return;
}
$remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId($dc);
if ($remoteDCHost) {
kFile::dumpApiRequest($remoteDCHost);
}
throw new KalturaAPIException(KalturaErrors::REMOTE_DC_NOT_FOUND, $dc);
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:13,代码来源:KalturaDataCenterContentResource.php
示例5: validateForUsage
public function validateForUsage($sourceObject, $propertiesToSkip = array())
{
parent::validateForUsage($sourceObject, $propertiesToSkip);
$dc = $this->getDc();
if ($dc == kDataCenterMgr::getCurrentDcId()) {
return;
}
$remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId($dc);
if ($remoteDCHost) {
kFileUtils::dumpApiRequest($remoteDCHost);
}
throw new KalturaAPIException(KalturaErrors::REMOTE_DC_NOT_FOUND, $dc);
}
示例6: getLocalThumbFilePath
/**
* will create thumbnail according to the entry type
* @return the thumbnail path.
*/
public function getLocalThumbFilePath($version, $width, $height, $type, $bgcolor = "ffffff", $crop_provider = null, $quality = 0, $src_x = 0, $src_y = 0, $src_w = 0, $src_h = 0, $vid_sec = -1, $vid_slice = 0, $vid_slices = -1, $density = 0, $stripProfiles = false, $flavorId = null, $fileName = null)
{
$contentPath = myContentStorage::getFSContentRootPath();
// if entry type is audio - serve generic thumb:
if ($this->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO) {
if ($this->getStatus() == entryStatus::DELETED || $this->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK) {
KalturaLog::log("rejected audio entry - not serving thumbnail");
KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED);
}
$audioEntryExist = false;
$audioThumbEntry = null;
$audioThumbEntryId = null;
$partner = $this->getPartner();
if ($partner) {
$audioThumbEntryId = $partner->getAudioThumbEntryId();
}
if ($audioThumbEntryId) {
$audioThumbEntry = entryPeer::retrieveByPK($audioThumbEntryId);
}
if ($audioThumbEntry && $audioThumbEntry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$fileSyncVersion = $partner->getAudioThumbEntryVersion();
$audioEntryKey = $audioThumbEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $fileSyncVersion);
$contentPath = kFileSyncUtils::getLocalFilePathForKey($audioEntryKey);
if ($contentPath) {
$msgPath = $contentPath;
$audioEntryExist = true;
} else {
KalturaLog::err('no local file sync for entry id');
}
}
if (!$audioEntryExist) {
$msgPath = $contentPath . "content/templates/entry/thumbnail/audio_thumb.jpg";
}
return myEntryUtils::resizeEntryImage($this, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $msgPath, $density, $stripProfiles);
} elseif ($this->getMediaType() == entry::ENTRY_MEDIA_TYPE_SHOW) {
// roughcut without any thumbnail, probably just created
$msgPath = $contentPath . "content/templates/entry/thumbnail/auto_edit.jpg";
return myEntryUtils::resizeEntryImage($this, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $msgPath, $density, $stripProfiles);
} elseif ($this->getType() == entryType::MEDIA_CLIP) {
try {
return myEntryUtils::resizeEntryImage($this, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices);
} catch (Exception $ex) {
if ($ex->getCode() == kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC) {
// get original flavor asset
$origFlavorAsset = assetPeer::retrieveOriginalByEntryId($this->getId());
if ($origFlavorAsset) {
$syncKey = $origFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
list($readyFileSync, $isLocal) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, TRUE, FALSE);
if ($readyFileSync) {
if ($isLocal) {
KalturaLog::err('Trying to redirect to myself - stop here.');
KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
}
//Ready fileSync is on the other DC - dumping
kFileUtils::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()));
}
KalturaLog::err('No ready fileSync found on any DC.');
KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
}
}
}
}
}
示例7: serveReportAction
/**
*
* Will serve a requested report
* @action serveReport
*
*
* @param string $id - the requested id
* @return string
*/
public function serveReportAction($id)
{
$fileNameRegex = "/^(?<dc>[01]+)_(?<fileName>\\d+_Export_[a-zA-Z0-9]+_[\\w\\-]+.csv)\$/";
// KS verification - we accept either admin session or download privilege of the file
$ks = $this->getKs();
if (!$ks || !($ks->isAdmin() || $ks->verifyPrivileges(ks::PRIVILEGE_DOWNLOAD, $id))) {
KExternalErrors::dieError(KExternalErrors::ACCESS_CONTROL_RESTRICTED);
}
if (!preg_match($fileNameRegex, $id, $matches)) {
KalturaLog::err("Report Id Format doesn't match the file name format");
throw new KalturaAPIException(KalturaErrors::REPORT_NOT_FOUND, $id);
}
// Check if the request should be handled by the other DC
$curerntDc = kDataCenterMgr::getCurrentDcId();
if ($matches['dc'] == 1 - $curerntDc) {
kFileUtils::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - $curerntDc));
}
// Serve report
$filePath = $this->getReportDirectory($this->getPartnerId()) . DIRECTORY_SEPARATOR . $matches['fileName'];
return $this->dumpFile($filePath, 'text/csv');
}
示例8: execute
//.........这里部分代码省略.........
if (!preg_match('/^[0-9a-fA-F]{1,6}$/', $bgcolor)) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'bgcolor must be six hexadecimal characters');
}
if ($upload_token_id) {
$upload_token = UploadTokenPeer::retrieveByPK($upload_token_id);
if ($upload_token) {
$partnerId = $upload_token->getPartnerId();
$partner = PartnerPeer::retrieveByPK($partnerId);
if ($density == 0) {
$density = $partner->getDefThumbDensity();
}
if (is_null($stripProfiles)) {
$stripProfiles = $partner->getStripThumbProfile();
}
$thumb_full_path = myContentStorage::getFSCacheRootPath() . myContentStorage::getGeneralEntityPath("uploadtokenthumb", $upload_token->getIntId(), $upload_token->getId(), $upload_token->getId() . ".jpg");
kFile::fullMkdir($thumb_full_path);
if (file_exists($upload_token->getUploadTempPath())) {
$src_full_path = $upload_token->getUploadTempPath();
$valid_image_types = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP);
$image_type = exif_imagetype($src_full_path);
if (!in_array($image_type, $valid_image_types)) {
// capture full frame
myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 3);
if (!file_exists($thumb_full_path)) {
myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 0);
}
$src_full_path = $thumb_full_path;
}
// and resize it
myFileConverter::convertImage($src_full_path, $thumb_full_path, $width, $height, $type, $bgcolor, true, $quality, $src_x, $src_y, $src_w, $src_h, $density, $stripProfiles);
kFile::dumpFile($thumb_full_path);
} else {
KalturaLog::debug("token_id [{$upload_token_id}] not found in DC [" . kDataCenterMgr::getCurrentDcId() . "]. dump url to romote DC");
$remoteUrl = kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()) . $_SERVER['REQUEST_URI'];
kFile::dumpUrl($remoteUrl);
}
}
}
if ($entry_id) {
$entry = entryPeer::retrieveByPKNoFilter($entry_id);
if (!$entry) {
// problem could be due to replication lag
kFile::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()));
}
} else {
// get the widget
$widget = widgetPeer::retrieveByPK($widget_id);
if (!$widget) {
KExternalErrors::dieError(KExternalErrors::ENTRY_AND_WIDGET_NOT_FOUND);
}
// get the kshow
$kshow_id = $widget->getKshowId();
$kshow = kshowPeer::retrieveByPK($kshow_id);
if ($kshow) {
$entry_id = $kshow->getShowEntryId();
} else {
$entry_id = $widget->getEntryId();
}
$entry = entryPeer::retrieveByPKNoFilter($entry_id);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
$partner = $entry->getPartner();
if ($density == 0) {
$density = $partner->getDefThumbDensity();
示例9: updateAction
/**
* Update media entry. Only the properties that were set will be updated.
*
* @action update
* @param string $entryId Media entry id to update
* @param KalturaMediaEntry $mediaEntry Media entry metadata to update
* @return KalturaMediaEntry The updated media entry
* @throws KalturaErrors::ENTRY_ID_NOT_FOUND
* @validateUser entry entryId edit
*/
function updateAction($entryId, KalturaMediaEntry $mediaEntry)
{
$dbEntry = entryPeer::retrieveByPK($entryId);
if (!$dbEntry) {
$dcIndex = kDataCenterMgr::getDCByObjectId($entryId, true);
if ($dcIndex != kDataCenterMgr::getCurrentDcId()) {
KalturaLog::debug("EntryID [{$entryId}] wasn't found on current DC. dumping the request to DC id [{$dcIndex}]");
kFileUtils::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrlByDcId($dcIndex));
}
}
if (!$dbEntry || $dbEntry->getType() != KalturaEntryType::MEDIA_CLIP) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$mediaEntry = $this->updateEntry($entryId, $mediaEntry, KalturaEntryType::MEDIA_CLIP);
return $mediaEntry;
}
示例10: getRemoteHostForUploadToken
/**
* get DC host for remote upload token
*
* @param $uploadTokenId
* @param $localDcId
* @return string
*/
public static function getRemoteHostForUploadToken($uploadTokenId, $localDcId = null)
{
$uploadToken = UploadTokenPeer::retrieveByPK($uploadTokenId);
if (!$uploadToken) {
return FALSE;
}
if ($localDcId !== null && $localDcId == $uploadToken->getDc()) {
// return FALSE if token's DC is not remote, but the same as $localDcId
return FALSE;
}
return kDataCenterMgr::getRemoteDcExternalUrlByDcId($uploadToken->getDc());
}
示例11: addFromUploadedFileAction
/**
* Generic add entry using an uploaded file, should be used when the uploaded entry type is not known.
*
* @action addFromUploadedFile
* @param KalturaBaseEntry $entry
* @param string $uploadTokenId
* @param KalturaEntryType $type
* @return KalturaBaseEntry
*/
function addFromUploadedFileAction(KalturaBaseEntry $entry, $uploadTokenId, $type = -1)
{
try {
// check that the uploaded file exists
$entryFullPath = kUploadTokenMgr::getFullPathByUploadTokenId($uploadTokenId);
} catch (kCoreException $ex) {
if ($ex->getCode() == kUploadTokenException::UPLOAD_TOKEN_INVALID_STATUS) {
}
throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_INVALID_STATUS_FOR_ADD_ENTRY);
throw $ex;
}
if (!file_exists($entryFullPath)) {
// Backward compatability - support case in which the required file exist in the other DC
kFileUtils::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()));
/*
$remoteDCHost = kUploadTokenMgr::getRemoteHostForUploadToken($uploadTokenId, kDataCenterMgr::getCurrentDcId());
if($remoteDCHost)
{
kFileUtils::dumpApiRequest($remoteDCHost);
}
else
{
throw new KalturaAPIException(KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN);
}
*/
}
// validate the input object
//$entry->validatePropertyMinLength("name", 1);
if (!$entry->name) {
$entry->name = $this->getPartnerId() . '_' . time();
}
// first copy all the properties to the db entry, then we'll check for security stuff
$dbEntry = $entry->toInsertableObject(new entry());
$dbEntry->setType($type);
$dbEntry->setMediaType(entry::ENTRY_MEDIA_TYPE_AUTOMATIC);
$this->checkAndSetValidUserInsert($entry, $dbEntry);
$this->checkAdminOnlyInsertProperties($entry);
$this->validateAccessControlId($entry);
$this->validateEntryScheduleDates($entry, $dbEntry);
$dbEntry->setPartnerId($this->getPartnerId());
$dbEntry->setSubpId($this->getPartnerId() * 100);
$dbEntry->setSourceId($uploadTokenId);
$dbEntry->setSourceLink($entryFullPath);
myEntryUtils::setEntryTypeAndMediaTypeFromFile($dbEntry, $entryFullPath);
$dbEntry->setDefaultModerationStatus();
// hack due to KCW of version from KMC
if (!is_null(parent::getConversionQualityFromRequest())) {
$dbEntry->setConversionQuality(parent::getConversionQualityFromRequest());
}
$dbEntry->save();
$kshow = $this->createDummyKShow();
$kshowId = $kshow->getId();
// setup the needed params for my insert entry helper
$paramsArray = array("entry_media_source" => KalturaSourceType::FILE, "entry_media_type" => $dbEntry->getMediaType(), "entry_full_path" => $entryFullPath, "entry_license" => $dbEntry->getLicenseType(), "entry_credit" => $dbEntry->getCredit(), "entry_source_link" => $dbEntry->getSourceLink(), "entry_tags" => $dbEntry->getTags());
$token = $this->getKsUniqueString();
$insert_entry_helper = new myInsertEntryHelper(null, $dbEntry->getKuserId(), $kshowId, $paramsArray);
$insert_entry_helper->setPartnerId($this->getPartnerId(), $this->getPartnerId() * 100);
$insert_entry_helper->insertEntry($token, $dbEntry->getType(), $dbEntry->getId(), $dbEntry->getName(), $dbEntry->getTags(), $dbEntry);
$dbEntry = $insert_entry_helper->getEntry();
kUploadTokenMgr::closeUploadTokenById($uploadTokenId);
myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry);
$entry->fromObject($dbEntry, $this->getResponseProfile());
return $entry;
}
示例12: execute
//.........这里部分代码省略.........
$partnerId = $upload_token->getPartnerId();
$partner = PartnerPeer::retrieveByPK($partnerId);
if ($partner) {
KalturaMonitorClient::initApiMonitor(false, 'extwidget.thumbnail', $partner->getId());
if ($quality == 0) {
$quality = $partner->getDefThumbQuality();
}
if ($density == 0) {
$density = $partner->getDefThumbDensity();
}
if (is_null($stripProfiles)) {
$stripProfiles = $partner->getStripThumbProfile();
}
}
$thumb_full_path = myContentStorage::getFSCacheRootPath() . myContentStorage::getGeneralEntityPath("uploadtokenthumb", $upload_token->getIntId(), $upload_token->getId(), $upload_token->getId() . ".jpg");
kFile::fullMkdir($thumb_full_path);
if (file_exists($upload_token->getUploadTempPath())) {
$src_full_path = $upload_token->getUploadTempPath();
$valid_image_types = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP);
$image_type = exif_imagetype($src_full_path);
if (!in_array($image_type, $valid_image_types)) {
// capture full frame
myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 3);
if (!file_exists($thumb_full_path)) {
myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 0);
}
$src_full_path = $thumb_full_path;
}
// and resize it
myFileConverter::convertImage($src_full_path, $thumb_full_path, $width, $height, $type, $bgcolor, true, $quality, $src_x, $src_y, $src_w, $src_h, $density, $stripProfiles, null, $format);
kFileUtils::dumpFile($thumb_full_path);
} else {
KalturaLog::info("token_id [{$upload_token_id}] not found in DC [" . kDataCenterMgr::getCurrentDcId() . "]. dump url to romote DC");
$remoteUrl = kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()) . $_SERVER['REQUEST_URI'];
kFileUtils::dumpUrl($remoteUrl);
}
}
}
if ($entry_id) {
$entry = entryPeer::retrieveByPKNoFilter($entry_id);
if (!$entry) {
// problem could be due to replication lag
kFileUtils::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()));
}
} else {
// get the widget
$widget = widgetPeer::retrieveByPK($widget_id);
if (!$widget) {
KExternalErrors::dieError(KExternalErrors::ENTRY_AND_WIDGET_NOT_FOUND);
}
// get the kshow
$kshow_id = $widget->getKshowId();
$kshow = kshowPeer::retrieveByPK($kshow_id);
if ($kshow) {
$entry_id = $kshow->getShowEntryId();
} else {
$entry_id = $widget->getEntryId();
}
$entry = entryPeer::retrieveByPKNoFilter($entry_id);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
KalturaMonitorClient::initApiMonitor(false, 'extwidget.thumbnail', $entry->getPartnerId());
if ($nearest_aspect_ratio) {
// Get the entry's default thumbnail path (if any)
示例13: executeImpl
/**
Will allow creation of multiple entries
ASSUME - the prefix of the entries is entryX_ where X is the index starting at 1
*/
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
{
// $logger = sfLogger::getInstance();
self::$escape_text = true;
/* if ( !$puser_kuser )
{
$this->addError( "No such user ..." );
return;
}
*/
// TODO - validate if the user can add entries to this kshow
$kshow_id = $this->getP("kshow_id");
$show_entry_id = $this->getP("show_entry_id");
$conversion_quality = $this->getP("conversionquality");
// must be all lower case
// for now - by default use quick_edit
$partner = PartnerPeer::retrieveByPK($partner_id);
for ($i = 0; $i <= $partner->getAddEntryMaxFiles(); ++$i) {
if ($i == 0) {
$prefix = $this->getObjectPrefix() . "_";
} else {
$prefix = $this->getObjectPrefix() . "{$i}" . "_";
}
$source = $this->getP($prefix . "source");
$filename = $this->getP($prefix . "filename");
if ($source != entry::ENTRY_MEDIA_SOURCE_WEBCAM || !$filename) {
continue;
}
$content = myContentStorage::getFSContentRootPath();
$entryFullPath = "{$content}/content/webcam/{$filename}.flv";
if (!file_exists($entryFullPath)) {
$remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId());
if ($remoteDCHost) {
kFileUtils::dumpApiRequest($remoteDCHost);
}
$this->addError(APIErrors::INVALID_FILE_NAME, $filename);
return;
}
}
if (strpos($kshow_id, 'entry-') !== false && !$show_entry_id) {
$show_entry_id = substr($kshow_id, 6);
}
$screen_name = $this->getP("screen_name");
$site_url = $this->getP("site_url");
$null_kshow = true;
if ($show_entry_id) {
// in this case we have the show_entry_id (of the relevant roughcut) - it suppresses the kshow_id
$show_entry = entryPeer::retrieveByPK($show_entry_id);
if ($show_entry) {
$kshow_id = $show_entry->getKshowId();
} else {
$kshow_id = null;
}
}
if ($kshow_id === kshow::SANDBOX_ID) {
$this->addError(APIErrors::SANDBOX_ALERT);
return;
}
$default_kshow_name = $this->getP("entry_name", null);
if (!$default_kshow_name) {
$default_kshow_name = $this->getP("entry1_name", null);
}
if ($kshow_id == kshow::KSHOW_ID_USE_DEFAULT) {
// see if the partner has some default kshow to add to
$kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser, null, false, $default_kshow_name);
$null_kshow = false;
if ($kshow) {
$kshow_id = $kshow->getId();
}
} elseif ($kshow_id == kshow::KSHOW_ID_CREATE_NEW) {
// if the partner allows - create a new kshow
$kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser, null, true, $default_kshow_name);
$null_kshow = false;
if ($kshow) {
$kshow_id = $kshow->getId();
}
} else {
$kshow = kshowPeer::retrieveByPK($kshow_id);
}
if (!$kshow) {
// the partner is attempting to add an entry to some invalid or non-existing kwho
$this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
return;
}
// find permissions from kshow
$permissions = $kshow->getPermissions();
$kuser_id = $puser_kuser->getKuserId();
// TODO - once the CW
$quick_edit = myPolicyMgr::getPolicyFor("allowQuickEdit", $kshow, $partner);
// let the user override the quick_edit propery
if ($this->getP("quick_edit") == '0' || $this->getP("quick_edit") == "false") {
$quick_edit = false;
}
if ($quick_edit == '0' || $quick_edit === "false" || !$quick_edit || $quick_edit == false) {
KalturaLog::err('$quick_edit: [' . $quick_edit . ']');
//.........这里部分代码省略.........
示例14: toObject
public function toObject($object_to_fill = null, $props_to_skip = array())
{
$this->validateForUsage($object_to_fill, $props_to_skip);
$srcEntry = entryPeer::retrieveByPK($this->entryId);
if (!$srcEntry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $this->entryId);
}
if ($srcEntry->getType() == entryType::LIVE_STREAM) {
/* @var $srcEntry LiveEntry */
if (!in_array($srcEntry->getSource(), array(EntrySourceType::LIVE_STREAM, EntrySourceType::LIVE_STREAM_ONTEXTDATA_CAPTIONS))) {
throw new KalturaAPIException(KalturaErrors::RESOURCE_TYPE_NOT_SUPPORTED, get_class($this));
}
$mediaServer = $srcEntry->getMediaServer();
if ($mediaServer && !is_null($mediaServer->getDc()) && $mediaServer->getDc() != kDataCenterMgr::getCurrentDcId()) {
$remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId($mediaServer->getDc());
if ($remoteDCHost) {
kFileUtils::dumpApiRequest($remoteDCHost);
} else {
throw new KalturaAPIException(KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN);
}
}
if ($object_to_fill && !$object_to_fill instanceof kLiveEntryResource) {
throw new KalturaAPIException(KalturaErrors::RESOURCE_TYPE_NOT_SUPPORTED, get_class($object_to_fill));
}
$object_to_fill = new kLiveEntryResource();
$object_to_fill->setEntry($srcEntry);
return $object_to_fill;
}
if (!$object_to_fill) {
$object_to_fill = new kFileSyncResource();
}
if ($srcEntry->getMediaType() == KalturaMediaType::IMAGE) {
$object_to_fill->setFileSyncObjectType(FileSyncObjectType::ENTRY);
$object_to_fill->setObjectSubType(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
$object_to_fill->setObjectId($srcEntry->getId());
return $object_to_fill;
}
$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_PARAMS_ID_NOT_FOUND, $this->flavorParamsId);
}
}
$object_to_fill->setFileSyncObjectType(FileSyncObjectType::FLAVOR_ASSET);
$object_to_fill->setObjectSubType(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$object_to_fill->setObjectId($srcFlavorAsset->getId());
$object_to_fill->setOriginEntryId($this->entryId);
return $object_to_fill;
}