本文整理汇总了PHP中kFile::dumpApiRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP kFile::dumpApiRequest方法的具体用法?PHP kFile::dumpApiRequest怎么用?PHP kFile::dumpApiRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kFile
的用法示例。
在下文中一共展示了kFile::dumpApiRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
kFile::dumpApiRequest($remoteHost);
}
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:25,代码来源:KalturaAssetsParamsResourceContainers.php
示例2: toObject
public function toObject($object_to_fill = null, $props_to_skip = array())
{
$dbUploadToken = UploadTokenPeer::retrieveByPK($this->token);
if (is_null($dbUploadToken)) {
throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_NOT_FOUND);
}
if (!$object_to_fill) {
$object_to_fill = new kUploadedFileTokenResource();
}
$object_to_fill->setToken($this->token);
if ($dbUploadToken->getStatus() != UploadToken::UPLOAD_TOKEN_FULL_UPLOAD) {
$object_to_fill->setIsReady(false);
return $object_to_fill;
}
try {
$entryFullPath = kUploadTokenMgr::getFullPathByUploadTokenId($this->token);
} 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)) {
$remoteDCHost = kUploadTokenMgr::getRemoteHostForUploadToken($this->token, kDataCenterMgr::getCurrentDcId());
if ($remoteDCHost) {
kFile::dumpApiRequest($remoteDCHost);
} else {
throw new KalturaAPIException(KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN);
}
}
$object_to_fill->setLocalFilePath($entryFullPath);
return $object_to_fill;
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:33,代码来源:KalturaUploadedFileTokenResource.php
示例3: 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)) {
$remoteDCHost = kUploadTokenMgr::getRemoteHostForUploadToken($uploadTokenId, kDataCenterMgr::getCurrentDcId());
if ($remoteDCHost) {
kFile::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->checkAndSetValidUser($entry, $dbEntry);
$this->checkAdminOnlyInsertProperties($entry);
$this->validateAccessControlId($entry);
$this->validateEntryScheduleDates($entry);
$dbEntry->setPartnerId($this->getPartnerId());
$dbEntry->setSubpId($this->getPartnerId() * 100);
$dbEntry->setSourceId($uploadTokenId);
$dbEntry->setSourceLink($entryFullPath);
$dbEntry->setDefaultModerationStatus();
$dbEntry->save();
$kshow = $this->createDummyKShow();
$kshowId = $kshow->getId();
myEntryUtils::setEntryTypeAndMediaTypeFromFile($dbEntry, $entryFullPath);
// 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);
return $entry;
}
示例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: addFromUploadedFileAction
/**
* Add new document entry after the specific document file was uploaded and the upload token id exists
*
* @action addFromUploadedFile
* @param KalturaDocumentEntry $documentEntry Document entry metadata
* @param string $uploadTokenId Upload token id
* @return KalturaDocumentEntry The new document entry
*
* @throws KalturaErrors::PROPERTY_VALIDATION_MIN_LENGTH
* @throws KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL
* @throws KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN
*/
function addFromUploadedFileAction(KalturaDocumentEntry $documentEntry, $uploadTokenId)
{
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)) {
$remoteDCHost = kUploadTokenMgr::getRemoteHostForUploadToken($uploadTokenId, kDataCenterMgr::getCurrentDcId());
if ($remoteDCHost) {
kFile::dumpApiRequest($remoteDCHost);
} else {
throw new KalturaAPIException(KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN);
}
}
$dbEntry = $this->prepareEntryForInsert($documentEntry);
$dbEntry->setSource(KalturaSourceType::FILE);
$dbEntry->setSourceLink("file:{$entryFullPath}");
$dbEntry->save();
$te = new TrackEntry();
$te->setEntryId($dbEntry->getId());
$te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY);
$te->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA_SOURCE_FILE");
TrackEntry::addTrackEntry($te);
$msg = null;
$flavorAsset = kFlowHelper::createOriginalFlavorAsset($this->getPartnerId(), $dbEntry->getId(), $msg);
if (!$flavorAsset) {
KalturaLog::err("Flavor asset not created for entry [" . $dbEntry->getId() . "] reason [{$msg}]");
$dbEntry->setStatus(entryStatus::ERROR_CONVERTING);
$dbEntry->save();
} else {
$ext = pathinfo($entryFullPath, PATHINFO_EXTENSION);
KalturaLog::info("Uploaded file extension: {$ext}");
$flavorAsset->setFileExt($ext);
$flavorAsset->save();
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
kFileSyncUtils::moveFromFile($entryFullPath, $syncKey);
kEventsManager::raiseEvent(new kObjectAddedEvent($flavorAsset));
}
kUploadTokenMgr::closeUploadTokenById($uploadTokenId);
myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry);
$documentEntry->fromObject($dbEntry);
return $documentEntry;
}
示例6: uploadAction
/**
* Upload a file using the upload token id, returns an error on failure (an exception will be thrown when using one of the Kaltura clients)
*
* @action upload
* @param string $uploadTokenId
* @param file $fileData
* @param bool $resume
* @param bool $finalChunk
* @param float $resumeAt
* @return KalturaUploadToken
*/
function uploadAction($uploadTokenId, $fileData, $resume = false, $finalChunk = true, $resumeAt = -1)
{
$this->restrictPeerToCurrentUser();
$uploadTokenDb = UploadTokenPeer::retrieveByPK($uploadTokenId);
if (is_null($uploadTokenDb)) {
throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_NOT_FOUND);
}
// if the token was generated on another datacenter, proxy the upload action there
$remoteDCHost = kUploadTokenMgr::getRemoteHostForUploadToken($uploadTokenId, kDataCenterMgr::getCurrentDcId());
if ($remoteDCHost) {
kFile::dumpApiRequest($remoteDCHost);
}
$uploadTokenMgr = new kUploadTokenMgr($uploadTokenDb);
try {
$uploadTokenMgr->uploadFileToToken($fileData, $resume, $finalChunk, $resumeAt);
} catch (kUploadTokenException $ex) {
switch ($ex->getCode()) {
case kUploadTokenException::UPLOAD_TOKEN_INVALID_STATUS:
throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_INVALID_STATUS_FOR_UPLOAD);
case kUploadTokenException::UPLOAD_TOKEN_FILE_NAME_IS_MISSING_FOR_UPLOADED_FILE:
case kUploadTokenException::UPLOAD_TOKEN_UPLOAD_ERROR_OCCURRED:
case kUploadTokenException::UPLOAD_TOKEN_FILE_IS_NOT_VALID:
throw new KalturaAPIException(KalturaErrors::UPLOAD_ERROR);
case kUploadTokenException::UPLOAD_TOKEN_FILE_NOT_FOUND_FOR_RESUME:
throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_CANNOT_RESUME);
case kUploadTokenException::UPLOAD_TOKEN_RESUMING_NOT_ALLOWED:
throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_RESUMING_NOT_ALLOWED);
case kUploadTokenException::UPLOAD_TOKEN_RESUMING_INVALID_POSITION:
throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_RESUMING_INVALID_POSITION);
default:
throw $ex;
}
}
$uploadToken = new KalturaUploadToken();
$uploadToken->fromObject($uploadTokenDb);
return $uploadToken;
}
示例7: convert
/**
* Convert entry
*
* @param string $entryId Media entry id
* @param int $conversionProfileId
* @param KalturaConversionAttributeArray $dynamicConversionAttributes
* @return int job id
* @throws KalturaErrors::ENTRY_ID_NOT_FOUND
* @throws KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND
* @throws KalturaErrors::FLAVOR_PARAMS_NOT_FOUND
*/
protected function convert($entryId, $conversionProfileId = null, KalturaConversionAttributeArray $dynamicConversionAttributes = null)
{
$entry = entryPeer::retrieveByPK($entryId);
if (!$entry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$srcFlavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
if (!$srcFlavorAsset) {
throw new KalturaAPIException(KalturaErrors::ORIGINAL_FLAVOR_ASSET_IS_MISSING);
}
if (is_null($conversionProfileId) || $conversionProfileId <= 0) {
$conversionProfile = myPartnerUtils::getConversionProfile2ForEntry($entryId);
if (!$conversionProfile) {
throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $conversionProfileId);
}
$conversionProfileId = $conversionProfile->getId();
} else {
//The search is with the entry's partnerId. so if conversion profile wasn't found it means that the
//conversionId is not exist or the conversion profileId does'nt belong to this partner.
$conversionProfile = conversionProfile2Peer::retrieveByPK($conversionProfileId);
if (is_null($conversionProfile)) {
throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $conversionProfileId);
}
}
$srcSyncKey = $srcFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
// if the file sync isn't local (wasn't synced yet) proxy request to other datacenter
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, true, false);
if (!$fileSync) {
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
} else {
if (!$local) {
kFile::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrl($fileSync));
}
}
// even if it null
$entry->setConversionQuality($conversionProfileId);
$entry->save();
if ($dynamicConversionAttributes) {
$flavors = assetParamsPeer::retrieveByProfile($conversionProfileId);
if (!count($flavors)) {
throw new KalturaAPIException(KalturaErrors::FLAVOR_PARAMS_NOT_FOUND);
}
$srcFlavorParamsId = null;
$flavorParams = $entry->getDynamicFlavorAttributes();
foreach ($flavors as $flavor) {
if ($flavor->hasTag(flavorParams::TAG_SOURCE)) {
$srcFlavorParamsId = $flavor->getId();
}
$flavorParams[$flavor->getId()] = $flavor;
}
$dynamicAttributes = array();
foreach ($dynamicConversionAttributes as $dynamicConversionAttribute) {
if (is_null($dynamicConversionAttribute->flavorParamsId)) {
$dynamicConversionAttribute->flavorParamsId = $srcFlavorParamsId;
}
if (is_null($dynamicConversionAttribute->flavorParamsId)) {
continue;
}
$dynamicAttributes[$dynamicConversionAttribute->flavorParamsId][trim($dynamicConversionAttribute->name)] = trim($dynamicConversionAttribute->value);
}
if (count($dynamicAttributes)) {
$entry->setDynamicFlavorAttributes($dynamicAttributes);
$entry->save();
}
}
$srcFilePath = kFileSyncUtils::getLocalFilePathForKey($srcSyncKey);
$wamsAssetId = kFileSyncUtils::getWamsAssetIdForKey($srcSyncKey);
$job = kJobsManager::addConvertProfileJob(null, $entry, $srcFlavorAsset->getId(), $srcFilePath, $wamsAssetId);
if (!$job) {
return null;
}
return $job->getId();
}
示例8: generateAction
/**
* @action generate
* @param string $entryId
* @param KalturaThumbParams $thumbParams
* @param string $sourceAssetId id of the source asset (flavor or thumbnail) to be used as source for the thumbnail generation
* @return KalturaThumbAsset
*
* @throws KalturaErrors::ENTRY_ID_NOT_FOUND
* @throws KalturaErrors::ENTRY_TYPE_NOT_SUPPORTED
* @throws KalturaErrors::ENTRY_MEDIA_TYPE_NOT_SUPPORTED
* @throws KalturaErrors::THUMB_ASSET_PARAMS_ID_NOT_FOUND
* @throws KalturaErrors::INVALID_ENTRY_STATUS
* @throws KalturaErrors::THUMB_ASSET_IS_NOT_READY
* @validateUser entry entryId edit
*/
public function generateAction($entryId, KalturaThumbParams $thumbParams, $sourceAssetId = null)
{
$entry = entryPeer::retrieveByPK($entryId);
if (!$entry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
if (!in_array($entry->getType(), $this->mediaTypes)) {
throw new KalturaAPIException(KalturaErrors::ENTRY_TYPE_NOT_SUPPORTED, $entry->getType());
}
if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_VIDEO) {
throw new KalturaAPIException(KalturaErrors::ENTRY_MEDIA_TYPE_NOT_SUPPORTED, $entry->getMediaType());
}
$validStatuses = array(entryStatus::ERROR_CONVERTING, entryStatus::PRECONVERT, entryStatus::READY);
if (!in_array($entry->getStatus(), $validStatuses)) {
throw new KalturaAPIException(KalturaErrors::INVALID_ENTRY_STATUS);
}
$destThumbParams = new thumbParams();
$thumbParams->toUpdatableObject($destThumbParams);
$srcAsset = kBusinessPreConvertDL::getSourceAssetForGenerateThumbnail($sourceAssetId, $destThumbParams->getSourceParamsId(), $entryId);
if (is_null($srcAsset)) {
throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_IS_NOT_READY);
}
$sourceFileSyncKey = $srcAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($sourceFileSyncKey, true);
/* @var $fileSync FileSync */
if (is_null($fileSync)) {
throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_IS_NOT_READY);
}
if ($fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL) {
throw new KalturaAPIException(KalturaErrors::SOURCE_FILE_REMOTE);
}
if (!$local) {
kFile::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrl($fileSync));
}
$runSync = is_null($fileSync->getWamsAssetId());
$dbThumbAsset = kBusinessPreConvertDL::decideThumbGenerate($entry, $destThumbParams, null, $sourceAssetId, $runSync, $srcAsset);
if (!$dbThumbAsset) {
return null;
}
$thumbAsset = new KalturaThumbAsset();
$thumbAsset->fromObject($dbThumbAsset);
return $thumbAsset;
}
示例9: serveFile
/**
* @param ISyncableFile $syncable
* @param int $fileSubType
* @param string $fileName
* @param bool $forceProxy
* @throws KalturaErrors::FILE_DOESNT_EXIST
*/
protected function serveFile(ISyncableFile $syncable, $fileSubType, $fileName, $entryId = null, $forceProxy = false)
{
/* @var $fileSync FileSync */
$syncKey = $syncable->getSyncKey($fileSubType);
if (!kFileSyncUtils::fileSync_exists($syncKey)) {
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
}
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
if ($local) {
$filePath = $fileSync->getFullPath();
$wamsAssetId = $fileSync->getWamsAssetId();
if (empty($wamsAssetId)) {
$mimeType = kFile::mimeType($filePath);
kFile::dumpFile($filePath, $mimeType);
} else {
kWAMS::getInstance($fileSync->getPartnerId())->dumpFile($wamsAssetId, pathinfo($filePath, PATHINFO_EXTENSION));
}
} else {
if (in_array($fileSync->getDc(), kDataCenterMgr::getDcIds())) {
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
KalturaLog::info("Redirecting to [{$remoteUrl}]");
if ($forceProxy) {
kFile::dumpApiRequest($remoteUrl);
} else {
//TODO find or build function which redurects the API request with all its parameters without using curl.
// or redirect if no proxy
header("Location: {$remoteUrl}");
die;
}
} else {
$remoteUrl = $fileSync->getExternalUrl($entryId);
header("Location: {$remoteUrl}");
die;
}
}
}
示例10: convertPptToSwf
/**
* This will queue a batch job for converting the document file to swf
* Returns the URL where the new swf will be available
*
* @action convertPptToSwf
* @param string $entryId
* @return string
*/
function convertPptToSwf($entryId)
{
$dbEntry = entryPeer::retrieveByPK($entryId);
if (!$dbEntry || $dbEntry->getType() != KalturaEntryType::DOCUMENT) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$flavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
if (is_null($flavorAsset) || !$flavorAsset->isLocalReadyStatus()) {
throw new KalturaAPIException(KalturaErrors::ORIGINAL_FLAVOR_ASSET_IS_MISSING);
}
$sync_key = null;
$sync_key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if (!kFileSyncUtils::file_exists($sync_key)) {
// if not found local file - perhaps wasn't created here and wasn't synced yet
// try to see if remote exists - and proxy the request if it is.
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($sync_key, true, true);
if (!$local) {
$remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrl($fileSync);
kFile::dumpApiRequest($remoteDCHost);
}
KalturaLog::log("convertPptToSwf sync key doesn't exists");
return;
}
$flavorParams = myConversionProfileUtils::getFlavorParamsFromFileFormat($dbEntry->getPartnerId(), flavorParams::CONTAINER_FORMAT_SWF);
$flavorParamsId = $flavorParams->getId();
$puserId = $this->getKuser()->getPuserId();
$err = "";
kBusinessPreConvertDL::decideAddEntryFlavor(null, $dbEntry->getId(), $flavorParamsId, $err);
$downloadPath = $dbEntry->getDownloadUrl();
//TODO: once api_v3 will support parameters with '/' instead of '?', we can change this to war with api_v3
return $downloadPath . '/direct_serve/true/type/download/forceproxy/true/format/swf';
}
示例11: 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) {
kFile::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 . ']');
//.........这里部分代码省略.........
示例12: getLocalThumbFilePath
/**
* will create thumbnail according to the entry type
* @return the thumbnail path.
*/
public function getLocalThumbFilePath(entry $entry, $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);
}
$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->getType() == entryType::LIVE_STREAM) {
if ($this->getStatus() == entryStatus::DELETED || $this->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK) {
KalturaLog::log("rejected live stream entry - not serving thumbnail");
KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED);
}
$msgPath = $contentPath . "content/templates/entry/thumbnail/live_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
kFile::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()));
}
KalturaLog::err('No ready fileSync found on any DC.');
KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
}
}
}
}
}
示例13: convertAction
/**
* Add and convert new Flavor Asset for Entry with specific Flavor Params
*
* @action convert
* @param string $entryId
* @param int $flavorParamsId
* @validateUser entry entryId edit
*/
public function convertAction($entryId, $flavorParamsId)
{
$dbEntry = entryPeer::retrieveByPK($entryId);
if (!$dbEntry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$flavorParamsDb = assetParamsPeer::retrieveByPK($flavorParamsId);
assetParamsPeer::setUseCriteriaFilter(false);
if (!$flavorParamsDb) {
throw new KalturaAPIException(KalturaErrors::FLAVOR_PARAMS_ID_NOT_FOUND, $flavorParamsId);
}
$validStatuses = array(entryStatus::ERROR_CONVERTING, entryStatus::PRECONVERT, entryStatus::READY);
if (!in_array($dbEntry->getStatus(), $validStatuses)) {
throw new KalturaAPIException(KalturaErrors::INVALID_ENTRY_STATUS);
}
$conversionProfile = $dbEntry->getconversionProfile2();
if (!$conversionProfile) {
throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $dbEntry->getConversionProfileId());
}
$originalFlavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
if (is_null($originalFlavorAsset) || !$originalFlavorAsset->isLocalReadyStatus()) {
throw new KalturaAPIException(KalturaErrors::ORIGINAL_FLAVOR_ASSET_IS_MISSING);
}
$srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
// if the file sync isn't local (wasn't synced yet) proxy request to other datacenter
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, true, false);
/* @var $fileSync FileSync */
if (!$fileSync) {
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
}
if (!$local && $fileSync->getFileType() != FileSync::FILE_SYNC_FILE_TYPE_URL) {
kFile::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrl($fileSync));
}
$err = "";
$dynamicFlavorAttributes = $dbEntry->getDynamicFlavorAttributesForAssetParams($flavorParamsDb->getId());
kBusinessPreConvertDL::decideAddEntryFlavor(null, $dbEntry->getId(), $flavorParamsId, $err, null, $dynamicFlavorAttributes);
}
示例14: 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}]");
kFile::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;
}
示例15: addFromUploadedFileAction
/**
* Add new entry after the specific media file was uploaded and the upload token id exists
*
* @action addFromUploadedFile
* @param KalturaMediaEntry $mediaEntry Media entry metadata
* @param string $uploadTokenId Upload token id
* @return KalturaMediaEntry The new media entry
*
* @throws KalturaErrors::PROPERTY_VALIDATION_MIN_LENGTH
* @throws KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL
* @throws KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN
*/
function addFromUploadedFileAction(KalturaMediaEntry $mediaEntry, $uploadTokenId)
{
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)) {
$remoteDCHost = kUploadTokenMgr::getRemoteHostForUploadToken($uploadTokenId, kDataCenterMgr::getCurrentDcId());
if ($remoteDCHost) {
kFile::dumpApiRequest($remoteDCHost);
} else {
throw new KalturaAPIException(KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN);
}
}
$dbEntry = $this->prepareEntryForInsert($mediaEntry);
$kshowId = $dbEntry->getKshowId();
// 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);
$ret = new KalturaMediaEntry();
if ($dbEntry) {
myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry, $dbEntry->getPartnerId(), null, null, null, $dbEntry->getId());
$ret->fromObject($dbEntry);
}
return $ret;
}