public function myServiceConfig($file_name, $service_name = null, $useDefualt = true) { $path = $this->getPath(); KalturaLog::debug("Path [{$path}] File [{$file_name}] Service [{$service_name}]"); $config_table_list = array(); if ($file_name == $this->getDefaultName()) { } else { if ($file_name) { $config_table_list[] = $path . $file_name; } } if (self::$secondary_config_tables) { // add the secondary before the end $config_table_list = array_merge($config_table_list, self::$secondary_config_tables); } // always append the defualt to the end if ($useDefualt) { $config_table_list[] = $path . $this->getDefaultName(); } // don't use the common path feature - add it to each config file separatly $this->config_chain = new kConfigTableChain($config_table_list, null); $tables = $this->config_chain->getTables(); self::$default_config_table = end($tables); $this->all_config_tables = $tables; if ($service_name) { $this->setServiceName($service_name); } }
/** * @param BaseObject $object * @return bool true if should continue to the next consumer */ public function objectAdded(BaseObject $object) { if (!$object instanceof FileSync || $object->getStatus() != FileSync::FILE_SYNC_STATUS_PENDING || $object->getFileType() != FileSync::FILE_SYNC_FILE_TYPE_FILE || $object->getDc() == kDataCenterMgr::getCurrentDcId()) { return true; } $c = new Criteria(); $c->addAnd(FileSyncPeer::OBJECT_ID, $object->getObjectId()); $c->addAnd(FileSyncPeer::VERSION, $object->getVersion()); $c->addAnd(FileSyncPeer::OBJECT_TYPE, $object->getObjectType()); $c->addAnd(FileSyncPeer::OBJECT_SUB_TYPE, $object->getObjectSubType()); $c->addAnd(FileSyncPeer::ORIGINAL, '1'); $original_filesync = FileSyncPeer::doSelectOne($c); if (!$original_filesync) { KalturaLog::err('Original filesync not found for object_id[' . $object->getObjectId() . '] version[' . $object->getVersion() . '] type[' . $object->getObjectType() . '] subtype[' . $object->getObjectSubType() . ']'); return true; } $sourceFileUrl = $original_filesync->getExternalUrl(); if (!$sourceFileUrl) { KalturaLog::err('External URL not found for filesync id [' . $object->getId() . ']'); return true; } $job = kMultiCentersManager::addFileSyncImportJob($this->getEntryId($object), $object->getPartnerId(), $object->getId(), $sourceFileUrl); $job->setDc($object->getDc()); $job->save(); return true; }
public function validateForSubmission(EntryDistribution $entryDistribution, $action) { $validationErrors = parent::validateForSubmission($entryDistribution, $action); //validation of flavor format $flavorAsset = null; $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds())); // if we have specific flavor assets for this distribution, grab the first one if (count($flavorAssets)) { $flavorAsset = reset($flavorAssets); $fileExt = $flavorAsset->getFileExt(); $allowedExts = explode(',', self::FLAVOR_VALID_FORMATS); if (!in_array($fileExt, $allowedExts)) { KalturaLog::debug('flavor asset id [' . $flavorAsset->getId() . '] does not have a valid extension [' . $fileExt . ']'); $errorMsg = 'Flavor format must be one of [' . self::FLAVOR_VALID_FORMATS . ']'; $validationError = $this->createValidationError($action, DistributionErrorType::INVALID_DATA); $validationError->setValidationErrorType(DistributionValidationErrorType::CUSTOM_ERROR); $validationError->setValidationErrorParam($errorMsg); $validationError->setDescription($errorMsg); $validationErrors[] = $validationError; } } $inListOrNullFields = array(IdeticDistributionField::GENRE => explode(',', self::GENRE_VALID_VALUES)); $allFieldValues = $this->getAllFieldValues($entryDistribution); if (!$allFieldValues || !is_array($allFieldValues)) { KalturaLog::err('Error getting field values from entry distribution id [' . $entryDistribution->getId() . '] profile id [' . $this->getId() . ']'); return $validationErrors; } $validationErrors = array_merge($validationErrors, $this->validateInListOrNull($inListOrNullFields, $allFieldValues, $action)); //validating Slot is a whole number $validationErrors = array_merge($validationErrors, $this->validateIsWholeNumber(IdeticDistributionField::SLOT, $allFieldValues, $action)); return $validationErrors; }
public function run($jobs = null) { if (KBatchBase::$taskConfig->isInitOnly()) { return $this->init(); } if (is_null($jobs)) { $jobs = KBatchBase::$kClient->batch->getExclusiveAlmostDone($this->getExclusiveLockKey(), KBatchBase::$taskConfig->maximumExecutionTime, $this->getMaxJobsEachRun(), $this->getFilter(), static::getType()); } KalturaLog::info(count($jobs) . " jobs to close"); if (!count($jobs) > 0) { KalturaLog::info("Queue size: 0 sent to scheduler"); $this->saveSchedulerQueue(static::getType()); return null; } foreach ($jobs as &$job) { try { self::setCurrentJob($job); $job = $this->exec($job); } catch (KalturaException $kex) { KBatchBase::unimpersonate(); $job = $this->closeJob($job, KalturaBatchJobErrorTypes::KALTURA_API, $kex->getCode(), "Error: " . $kex->getMessage(), KalturaBatchJobStatus::FAILED); } catch (KalturaClientException $kcex) { KBatchBase::unimpersonate(); $job = $this->closeJob($job, KalturaBatchJobErrorTypes::KALTURA_CLIENT, $kcex->getCode(), "Error: " . $kcex->getMessage(), KalturaBatchJobStatus::RETRY); } catch (Exception $ex) { KBatchBase::unimpersonate(); $job = $this->closeJob($job, KalturaBatchJobErrorTypes::RUNTIME, $ex->getCode(), "Error: " . $ex->getMessage(), KalturaBatchJobStatus::FAILED); } self::unsetCurrentJob(); } return $jobs; }
private function writeFilterForType(KalturaTypeReflector $type) { $map = KAutoloader::getClassMap(); if (!isset($map[$type->getType()])) { return; } $filterClassName = $type->getType() . "Filter"; $filterBaseClassName = $type->getType() . "BaseFilter"; $filterPath = dirname($map[$type->getType()]) . "/filters/{$filterClassName}.php"; if (file_exists($filterPath)) { KalturaLog::notice("Filter already exists [{$filterPath}]"); return; } $this->_txt = ""; $parentType = $type; while (1) { $parentType = $parentType->getParentTypeReflector(); if ($parentType === null || $parentType->isFilterable()) { break; } } $partnetClassName = $parentType ? $parentType->getType() . "Filter" : "KalturaFilter"; $subpackage = ($type->getPackage() == 'api' ? '' : 'api.') . 'filters'; $this->appendLine("<?php"); $this->appendLine("/**"); $this->appendLine(" * @package " . $type->getPackage()); $this->appendLine(" * @subpackage {$subpackage}"); $this->appendLine(" */"); $this->appendLine("class {$filterClassName} extends {$filterBaseClassName}"); $this->appendLine("{"); $this->appendLine("}"); $this->writeToFile($filterPath, $this->_txt); }
protected function doConnect($http_server, &$http_port) { // try connecting to server if (!$http_port || $http_port == 0) { $http_port = 80; } $http_server .= $http_server . ':' . $http_port; try { $url_parts = parse_url($http_server); if (isset($url_parts["scheme"])) { if ($url_parts["scheme"] != "http" && $url_parts["scheme"] != "https") { KalturaLog::err("URL [{$http_server}] is not http"); return false; } } else { $http_server = 'http://' . $http_server; } } catch (Exception $exception) { $http_server = 'http://' . $http_server; } $this->server = $http_server; $this->ch = curl_init(); curl_setopt($this->ch, CURLOPT_USERAGENT, $this->userAgent); curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($this->ch, CURLOPT_NOSIGNAL, true); curl_setopt($this->ch, CURLOPT_FORBID_REUSE, true); curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($this->ch, CURLOPT_HEADER, false); curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false); return $this->ch; }
public static function getIdByStrId($strId) { // try to get strId to id mapping form cache $cacheKey = 'UserRolePeer_role_str_id_' . $strId; if (kConf::get('enable_cache') && function_exists('apc_fetch') && function_exists('apc_store')) { $id = apc_fetch($cacheKey); // try to fetch from cache if ($id) { KalturaLog::debug("UserRole str_id [{$strId}] mapped to id [{$id}] - fetched from cache"); return $id; } } // not found in cache - get from database $c = new Criteria(); $c->addSelectColumn(UserRolePeer::ID); $c->addAnd(UserRolePeer::STR_ID, $strId, Criteria::EQUAL); $c->setLimit(1); $stmt = UserRolePeer::doSelectStmt($c); $id = $stmt->fetch(PDO::FETCH_COLUMN); if ($id) { // store the found id in cache for later use if (kConf::get('enable_cache') && function_exists('apc_fetch') && function_exists('apc_store')) { $success = apc_store($cacheKey, $id, kConf::get('apc_cache_ttl')); if ($success) { KalturaLog::debug("UserRole str_id [{$strId}] mapped to id [{$id}] - stored in cache"); } } } if (!$id) { KalturaLog::log("UserRole with str_id [{$strId}] not found in DB!"); } return $id; }
protected function parseCreatedFiles() { $xmlPath = $this->outDir . DIRECTORY_SEPARATOR . $this->destFileName . '.ism'; KalturaLog::info("Parse created files from ism[{$xmlPath}]"); // in case of wma if (!file_exists($xmlPath)) { KalturaLog::info("ism file[{$xmlPath}] doesn't exist"); $wmaPath = $this->outDir . DIRECTORY_SEPARATOR . $this->destFileName . '.wma'; if (file_exists($wmaPath)) { KalturaLog::info("wma file[{$wmaPath}] found"); $this->outFilesPath[0] = $wmaPath; } return; } $xml = file_get_contents($xmlPath); $xml = mb_convert_encoding($xml, 'ASCII', 'UTF-16'); KalturaLog::debug("ism content:\n{$xml}"); $arr = null; if (preg_match('/(<smil[\\s\\w\\W]+<\\/smil>)/', $xml, $arr)) { $xml = $arr[1]; } file_put_contents($xmlPath, $xml); //echo $xml; $doc = new DOMDocument(); $doc->loadXML($xml); $videoEntities = $doc->getElementsByTagName('video'); foreach ($videoEntities as $videoEntity) { $src = $this->outDir . DIRECTORY_SEPARATOR . $videoEntity->getAttribute("src"); $bitrate = $videoEntity->getAttribute("systemBitrate") / 1000; KalturaLog::info("Media found in ism bitrate[{$bitrate}] source[{$src}]"); $this->outFilesPath[$bitrate] = $src; } }
public function checkIsLive($url) { KalturaLog::info('url to check:' . $url); $parts = parse_url($url); parse_str($parts['query'], $query); $token = $query[$this->getParamName()]; $data = $this->urlExists($url, array($this->getHdsManifestContentType())); if (!$data) { KalturaLog::Info("URL [{$url}] returned no valid data. Exiting."); return false; } KalturaLog::info('Velocix HDS manifest data:' . $data); $dom = new KDOMDocument(); $dom->loadXML($data); $element = $dom->getElementsByTagName('baseURL')->item(0); if (!$element) { KalturaLog::Info("No base url was given"); return false; } $baseUrl = $element->nodeValue; foreach ($dom->getElementsByTagName('media') as $media) { $href = $media->getAttribute('href'); $streamUrl = $baseUrl . $href; $streamUrl .= $token ? '?' . $this->getParamName() . "={$token}" : ''; if ($this->urlExists($streamUrl, array(), '0-0') !== false) { KalturaLog::info('is live:' . $streamUrl); return true; } } return false; }
public function doFromObject($dbObject, KalturaDetachedResponseProfile $responseProfile = null) { /* @var $dbObject kHttpNotificationDataText */ parent::doFromObject($dbObject, $responseProfile); if ($this->shouldGet('content', $responseProfile)) { $contentType = get_class($dbObject->getContent()); KalturaLog::debug("Loading KalturaStringValue from type [{$contentType}]"); switch ($contentType) { case 'kStringValue': $this->content = new KalturaStringValue(); break; case 'kEvalStringField': $this->content = new KalturaEvalStringField(); break; default: $this->content = KalturaPluginManager::loadObject('KalturaStringValue', $contentType); break; } if ($this->content) { $this->content->fromObject($dbObject->getContent()); } } if ($this->shouldGet('data', $responseProfile)) { $this->data = $dbObject->getData(); } }
/** * Allows you to add an cue point object associated with an entry * * @action add * @param KalturaCuePoint $cuePoint * @return KalturaCuePoint */ function addAction(KalturaCuePoint $cuePoint) { $dbCuePoint = $cuePoint->toInsertableObject(); if ($cuePoint->systemName) { $existingCuePoint = CuePointPeer::retrieveBySystemName($cuePoint->entryId, $cuePoint->systemName); if ($existingCuePoint) { throw new KalturaAPIException(KalturaCuePointErrors::CUE_POINT_SYSTEM_NAME_EXISTS, $cuePoint->systemName, $existingCuePoint->getId()); } } /* @var $dbCuePoint CuePoint */ $dbCuePoint->setPartnerId($this->getPartnerId()); $dbCuePoint->setPuserId(is_null($cuePoint->userId) ? $this->getKuser()->getPuserId() : $cuePoint->userId); $dbCuePoint->setStatus(CuePointStatus::READY); if ($this->getCuePointType()) { $dbCuePoint->setType($this->getCuePointType()); } $created = $dbCuePoint->save(); if (!$created) { KalturaLog::err("Cue point not created"); return null; } $cuePoint = KalturaCuePoint::getInstance($dbCuePoint->getType()); if (!$cuePoint) { KalturaLog::err("API Cue point not instantiated"); return null; } $cuePoint->fromObject($dbCuePoint, $this->getResponseProfile()); return $cuePoint; }
protected function applyFilterFields(baseObjectFilter $filter) { /* @var $filter cuePointFilter */ // Reduce the cache expiry when fetching live stream cuepoints $entryId = $filter->get('_in_entry_id'); if ($entryId && strpos($entryId, ',') === false) { $entry = entryPeer::retrieveByPK($entryId); if ($entry && $entry->getType() == entryType::LIVE_STREAM) { kApiCache::setExpiry(self::LIVE_ENTRY_CUE_POINT_CACHE_EXPIRY_SECONDS); } } if ($filter->get('_free_text')) { $this->sphinxSkipped = false; $freeTexts = $filter->get('_free_text'); KalturaLog::debug("Attach free text [{$freeTexts}]"); $this->addFreeTextToMatchClauseByMatchFields($freeTexts, CuePointFilter::FREE_TEXT_FIELDS); } $filter->unsetByName('_free_text'); if ($filter->get('_eq_is_public')) { $this->sphinxSkipped = false; $isPublic = $filter->get('_eq_is_public'); $this->addCondition('is_public' . " = " . $isPublic); } $filter->unsetByName('_eq_is_public'); return parent::applyFilterFields($filter); }
/** * @return array */ protected function getSecureHdUrl() { $params = array(); if ($this->getSupportClipping()) { $seekStart = $this->params->getSeekFromTime(); $seekEnd = $this->params->getClipTo(); if ($seekStart != -1) { $params['start'] = floor($this->params->getSeekFromTime() / 1000); $this->params->setSeekFromTime(-1); } else { if ($seekEnd) { $params['start'] = 0; } } if ($seekEnd) { $params['end'] = ceil($this->params->getClipTo() / 1000); $this->params->setClipTo(null); } } $flavors = $this->buildHttpFlavorsArray(); $flavors = $this->sortFlavors($flavors); $flavor = AkamaiDeliveryUtils::getHDN2ManifestUrl($flavors, $this->params->getMediaProtocol(), $this->getUrl(), '/master.m3u8', '/i', $params); if (!$flavor) { KalturaLog::info(get_class() . ' failed to find flavor'); return null; } return $flavor; }
/** * Tests EntryDistributionService->addAction() * @param KalturaEntryDistribution $entryDistribution * @return int * @dataProvider provideData */ public function testAdd(KalturaEntryDistribution $entryDistribution) { try { $resultEntryDistribution = $this->client->entryDistribution->add($entryDistribution); $this->assertType('KalturaEntryDistribution', $resultEntryDistribution); $this->assertNotNull($resultEntryDistribution->id); KalturaLog::debug("Returns Entry Distribution ID [{$resultEntryDistribution->id}]"); return $resultEntryDistribution->id; } catch (KalturaException $e) { KalturaLog::err("Add EntryDistribution Exception code [" . $e->getCode() . "] message [" . $e->getMessage() . "]"); if ($e->getCode() != 'ENTRY_DISTRIBUTION_ALREADY_EXISTS') { throw $e; } } $entryDistributionFilter = new KalturaEntryDistributionFilter(); $entryDistributionFilter->entryIdIn = $entryDistribution->entryId; $entryDistributionFilter->distributionProfileIdEqual = $entryDistribution->distributionProfileId; $entryDistributionList = $this->client->entryDistribution->listAction($entryDistributionFilter); $this->assertType('KalturaEntryDistributionListResponse', $entryDistributionList); $this->assertNotEquals($entryDistributionList->totalCount, 0); $this->assertEquals($entryDistributionList->totalCount, count($entryDistributionList->objects)); $resultEntryDistribution = reset($entryDistributionList->objects); $this->assertType('KalturaEntryDistribution', $resultEntryDistribution); $this->assertNotNull($resultEntryDistribution->id); KalturaLog::debug("Returns Entry Distribution ID [{$resultEntryDistribution->id}]"); return $resultEntryDistribution->id; }
/** * Get the total VOD offset for a given time. Total = the sum of all VOD delta times throughout the segments. * @return int|null The offset that should be subtracted from the given time, or * null to indicate that this time signature is in the gap between the end * of a VOD segment and the end of the live segment (marked with x's below). * <pre> * Live Start VOD End Live End * ^ ^ ^ * | |xxxxxxxxxxx| * +------------------+-----------+ * </pre> */ public function getTotalVodTimeOffset($time) { $numSegments = count($this->segments); $totalVodOffset = 0; // Initially zero because there's no time drift in the first segment. $i = 0; $dbgPrevSegment = null; while ($i < $numSegments) { $segment = $this->segments[$i]; $liveStart = $segment[self::LIVE_START]; $vodAdjustedEndTime = $this->getVodAdjustedEndTime($segment); if ($time <= $vodAdjustedEndTime) { if ($time >= $liveStart) { return $totalVodOffset; } else { KalturaLog::debug("Time [{$time}] <= {$vodAdjustedEndTime} but not >= {$liveStart}. Segment data: {$this->segmentAsString($dbgPrevSegment)}"); return null; } } else { // Add up this segment's offset and move on to the next segment $totalVodOffset += $segment[self::VOD_TO_LIVE_DELTA_TIME]; $dbgPrevSegment = $segment; $i++; } } // The time signature is greater than the total VOD duration KalturaLog::debug("Couldn't get offset for time [{$time}]. Segment data: {$this->segmentAsString($segment)}"); return null; }
/** * Will return a JS library for integrating the KSR (similar to HTML5 in concept) * uiconfId specifies from which uiconf to fetch different settings that should be replaced in the JS */ public function execute() { // make sure output is not parsed as HTML header("Content-type: application/x-javascript"); $uiconfId = $this->getRequestParameter("uiconfId"); // replace all $_GET with $this->getRequestParameter() // load uiconf from DB. $this->uiconfObj = uiConfPeer::retrieveByPK($uiconfId); if (!$this->uiconfObj) { KExternalErrors::dieError(KExternalErrors::UI_CONF_NOT_FOUND); } $ui_conf_swf_url = $this->uiconfObj->getSwfUrl(); if (!$ui_conf_swf_url) { KExternalErrors::dieError(KExternalErrors::ILLEGAL_UI_CONF, "SWF URL not found in UI conf"); } @libxml_use_internal_errors(true); try { $this->uiconfXmlObj = new SimpleXMLElement(trim($this->uiconfObj->getConfFile())); } catch (Exception $e) { KalturaLog::debug("malformed uiconf XML - base64 encoded: [" . base64_encode(trim($this->uiconfObj->getConfFile())) . "]"); } if (!$this->uiconfXmlObj instanceof SimpleXMLElement) { // no xml or invalid XML, so throw exception throw new Exception('uiconf XML is invalid'); } // unsupress the xml errors @libxml_use_internal_errors(false); $this->_initReplacementTokens(); $this->_prepareLibJs(); $this->_prepareJs(); echo $this->jsResult; die; }
/** * * Starts the bulk upload * @param KalturaBatchJob $job */ private function startBulkUpload(KalturaBatchJob $job) { KalturaLog::info("Start bulk upload ({$job->id})"); //Gets the right Engine instance $engine = KBulkUploadEngine::getEngine($job->jobSubType, $job); if (is_null($engine)) { throw new KalturaException("Unable to find bulk upload engine", KalturaBatchJobAppErrors::ENGINE_NOT_FOUND); } $job = $this->updateJob($job, 'Parsing file [' . $engine->getName() . ']', KalturaBatchJobStatus::QUEUED, $engine->getData()); $engine->setJob($job); $engine->setData($job->data); $engine->handleBulkUpload(); $job = $engine->getJob(); $data = $engine->getData(); $countObjects = $this->countCreatedObjects($job->id, $job->data->bulkUploadObjectType); $countHandledObjects = $countObjects[0]; $countErrorObjects = $countObjects[1]; if (!$countHandledObjects && !$engine->shouldRetry() && $countErrorObjects) { throw new KalturaBatchException("None of the uploaded items were processed succsessfuly", KalturaBatchJobAppErrors::BULK_NO_ENTRIES_HANDLED, $engine->getData()); } if ($engine->shouldRetry()) { self::$kClient->batch->resetJobExecutionAttempts($job->id, $this->getExclusiveLockKey(), $job->jobType); return $this->closeJob($job, null, null, "Retrying: " . $countHandledObjects . " " . $engine->getObjectTypeTitle() . " objects were handled untill now", KalturaBatchJobStatus::RETRY); } return $this->closeJob($job, null, null, 'Waiting for objects closure', KalturaBatchJobStatus::ALMOST_DONE, $data); }
private function call($method, $args = array()) { KalturaLog::debug("Call [{$method}] args [" . print_r($args, true) . "]"); $result = $this->api->call($method, $args); KalturaLog::debug("Result [" . print_r($result, true) . "]"); return $result; }
/** * @param entry $object * @return bool true if should continue to the next consumer */ public function entryCreated(entry $object) { $mediaType = null; if ($object->getType() == entryType::AUTOMATIC) { KalturaLog::debug("entry id [" . $object->getId() . "] type [" . $object->getType() . "] source link [" . $object->getSourceLink() . "]"); $mediaType = $object->getMediaType(); if (isset(self::$fileExtensions[$mediaType])) { $object->setType(entryType::DOCUMENT); } elseif (is_null($mediaType) || $mediaType == entry::ENTRY_MEDIA_TYPE_ANY || $mediaType == entry::ENTRY_MEDIA_TYPE_AUTOMATIC) { $this->setDocumentType($object); } } if ($object->getType() != entryType::DOCUMENT) { KalturaLog::debug("entry id [" . $object->getId() . "] type [" . $object->getType() . "]"); return true; } if (is_null($mediaType) || $mediaType == entry::ENTRY_MEDIA_TYPE_ANY || $mediaType == entry::ENTRY_MEDIA_TYPE_AUTOMATIC) { $this->setDocumentType($object); } if ($object instanceof DocumentEntry) { KalturaLog::debug("entry id [" . $object->getId() . "] already handled"); return true; } KalturaLog::debug("Handling object [" . get_class($object) . "] type [" . $object->getType() . "] id [" . $object->getId() . "] status [" . $object->getStatus() . "]"); if ($object->getConversionProfileId()) { $object->setStatus(entryStatus::PRECONVERT); $object->save(); } return true; }
/** * @param KalturaBaseEntry $object */ function processObject($object) { /** @var KalturaConvertEntryFlavorsObjectTask $objectTask */ $objectTask = $this->getObjectTask(); $entryId = $object->id; $reconvert = $objectTask->reconvert; $client = $this->getClient(); $flavorParamsIds = explode(',', $objectTask->flavorParamsIds); foreach ($flavorParamsIds as $flavorParamsId) { try { $this->impersonate($object->partnerId); $flavorAssetFilter = new KalturaFlavorAssetFilter(); $flavorAssetFilter->entryIdEqual = $entryId; $flavorAssetFilter->flavorParamsIdEqual = $flavorParamsId; $flavorAssetFilter->statusEqual = KalturaFlavorAssetStatus::READY; $flavorAssetResponse = $client->flavorAsset->listAction($flavorAssetFilter); if (!count($flavorAssetResponse->objects) || $reconvert) { $client->flavorAsset->convert($entryId, $flavorParamsId); } $this->unimpersonate(); } catch (Exception $ex) { KalturaLog::err(sprintf('Failed to convert entry id %s with flavor params id %s', $entryId, $flavorParamsId)); KalturaLog::err($ex); } } }
public function apply(KalturaRelatedFilter $filter, KalturaObject $parentObject) { $filterProperty = $this->filterProperty; $parentProperty = $this->parentProperty; KalturaLog::debug("Mapping XPath {$parentProperty} to " . get_class($filter) . "::{$filterProperty}"); if (!$parentObject instanceof KalturaMetadata) { throw new KalturaAPIException(KalturaErrors::INVALID_OBJECT_TYPE, get_class($parentObject)); } if (!property_exists($filter, $filterProperty)) { throw new KalturaAPIException(KalturaErrors::PROPERTY_IS_NOT_DEFINED, $filterProperty, get_class($filter)); } $xml = $parentObject->xml; $doc = new KDOMDocument(); $doc->loadXML($xml); $xpath = new DOMXPath($doc); $metadataElements = $xpath->query($parentProperty); if ($metadataElements->length == 1) { $filter->{$filterProperty} = $metadataElements->item(0)->nodeValue; } elseif ($metadataElements->length > 1) { $values = array(); foreach ($metadataElements as $element) { $values[] = $element->nodeValue; } $filter->{$filterProperty} = implode(',', $values); } elseif (!$this->allowNull) { return false; } return true; }
private function recalculate(KalturaBatchJob $job, KalturaRecalculateCacheJobData $data) { KalturaLog::debug("Recalculate job id [{$job->id}]"); $engine = KRecalculateCacheEngine::getInstance($job->jobSubType); $recalculatedObjects = $engine->recalculate($data); return $this->closeJob($job, null, null, "Recalculated {$recalculatedObjects} cache objects", KalturaBatchJobStatus::FINISHED); }
public function execute() { $ksStr = $this->getP("ks"); if ($ksStr) { $ksObj = null; try { $ksObj = ks::fromSecureString($ksStr); } catch (Exception $e) { } if ($ksObj) { $partner = PartnerPeer::retrieveByPK($ksObj->partner_id); if (!$partner) { KExternalErrors::dieError(KExternalErrors::PARTNER_NOT_FOUND); } if (!$partner->validateApiAccessControl()) { KExternalErrors::dieError(KExternalErrors::SERVICE_ACCESS_CONTROL_RESTRICTED); } $ksObj->kill(); } KalturaLog::info("Killing session with ks - [{$ksStr}], decoded - [" . base64_decode($ksStr) . "]"); } else { KalturaLog::err('logoutAction called with no KS'); } setcookie('pid', "", 0, "/"); setcookie('subpid', "", 0, "/"); setcookie('kmcks', "", 0, "/"); return sfView::NONE; //redirection to kmc/kmc is done from java script }
/** * * @param int $offset * @param int $itemCountPerPage */ protected function callService($offset, $itemCountPerPage) { $client = Infra_ClientHelper::getClient(); if ($this->impersonatedPartnerId) { Infra_ClientHelper::impersonate($this->impersonatedPartnerId); } $pager = new Kaltura_Client_Type_FilterPager(); $pager->pageIndex = (int) ($offset / $itemCountPerPage) + 1; $pager->pageSize = $itemCountPerPage; $action = $this->action; $params = $this->args; $params[] = $pager; try { $response = call_user_func_array(array($this->service, $action), $params); } catch (Kaltura_Client_Exception $e) { KalturaLog::err($e->getMessage()); return array(); } $this->totalCount = $response->totalCount; $this->total = $response->total; if (!$response->objects) { return array(); } return $response->objects; }
public function createQuestionPdf() { $dbEntry = entryPeer::retrieveByPK($this->entryId); $title = "Here are the questions from [" . $dbEntry->getName() . "]"; KalturaLog::debug("Questions from [" . $dbEntry->getName() . "]"); $this->pdf->addTitle($title, $this->titleStyle); $questionType = QuizPlugin::getCuePointTypeCoreValue(QuizCuePointType::QUIZ_QUESTION); $questions = CuePointPeer::retrieveByEntryId($this->entryId, array($questionType)); //arange the array so that the questions will be the key for the array $questArray = array(); foreach ($questions as $question) { $questArray[$question->getName()] = $question; } //sort the array alphabetically according to its key; i.e. the question ksort($questArray, SORT_LOCALE_STRING); $questNum = 0; foreach ($questArray as $question) { $questNum += 1; $this->pdf->addList($questNum, $question->getName(), $this->listWithAddLineBeforeStyle); $this->pdf->addHeadline(6, "Optional Answers:", $this->heading6Style); $ansNum = 0; foreach ($question->getOptionalAnswers() as $optionalAnswer) { $ansNum += 1; $this->pdf->addList($ansNum, $optionalAnswer->getText(), $this->indentListStyle); } } }
public function __construct($message, $code = null, $data = null) { $this->message = $message; $this->code = $code; $this->data = $data; KalturaLog::err($this); }
/** * @param string $str */ private function __construct($str) { if (empty($str)) { $this->data = array(); } try { $this->data = @unserialize($str); if ($this->data == null) { $this->data = array(); } else { foreach ($this->data as $name => $value) { if (strpos($name, ':') > 0) { list($namespace, $subName) = explode(':', $name, 2); unset($this->data[$name]); if (!isset($this->data[$namespace])) { $this->data[$namespace] = array(); } $this->data[$namespace][$subName] = $value; } } } } catch (Exception $ex) { // cannot initialize from $str KalturaLog::log(__METHOD__ . ", cannot init from string [{$str}]"); $this->data = array(); } }
public function run($jobs = null) { $filter = new KalturaLiveStreamEntryFilter(); $filter->isLive = KalturaNullableBoolean::TRUE_VALUE; $filter->orderBy = KalturaLiveStreamEntryOrderBy::CREATED_AT_ASC; $filter->moderationStatusIn = KalturaEntryModerationStatus::PENDING_MODERATION . ',' . KalturaEntryModerationStatus::APPROVED . ',' . KalturaEntryModerationStatus::REJECTED . ',' . KalturaEntryModerationStatus::FLAGGED_FOR_REVIEW . ',' . KalturaEntryModerationStatus::AUTO_APPROVED; $pager = new KalturaFilterPager(); $pager->pageSize = 500; $pager->pageIndex = 1; $entries = self::$kClient->liveStream->listAction($filter, $pager); while (count($entries->objects)) { foreach ($entries->objects as $entry) { try { /* @var $entry KalturaLiveEntry */ self::impersonate($entry->partnerId); self::$kClient->liveStream->validateRegisteredMediaServers($entry->id); self::unimpersonate(); $filter->createdAtGreaterThanOrEqual = $entry->createdAt; } catch (KalturaException $e) { self::unimpersonate(); KalturaLog::err("Caught exception with message [" . $e->getMessage() . "]"); } } $pager->pageIndex++; $entries = self::$kClient->liveStream->listAction($filter, $pager); } }
public static function prepareNotificationData($url, $signature_key, KalturaBatchJob $job, KalturaNotificationJobData $data, $prefix = null) { KalturaLog::debug("sendSingleNotification({$url}, {$signature_key}, {$job->id}, data, {$prefix})"); $params = array("notification_id" => $job->id, "notification_type" => $data->typeAsString, "puser_id" => $data->userId, "partner_id" => $job->partnerId); switch ($data->objType) { case KalturaNotificationObjectType::USER: $params["user_id"] = $data->objectId; break; case KalturaNotificationObjectType::ENTRY: $params["entry_id"] = $data->objectId; break; case KalturaNotificationObjectType::KSHOW: $params["kshow_id"] = $data->objectId; break; case KalturaNotificationObjectType::BATCH_JOB: $params["job_id"] = $data->objectId; break; default: // VERY STARANGE - either objType not set properly or some error ! } $object_data_params = self::getDataAsArray($data->data); if ($object_data_params) { $params = array_merge($params, $object_data_params); } $params = self::fixParams($params, $prefix); $params['signed_fields'] = ''; foreach ($params as $key => $value) { $params['signed_fields'] .= $key . ','; } return self::signParams($signature_key, $params); }
protected function deleteFilesPHP($searchPath, $minutesOld, $simulateOnly) { $secondsOld = $minutesOld * 60; $files = glob($searchPath); KalturaLog::info("Found [" . count($files) . "] to scan"); $now = time(); KalturaLog::info("Deleting files that are " . $secondsOld . " seconds old (modified before " . date('c', $now - $secondsOld) . ")"); $deletedCount = 0; foreach ($files as $file) { $filemtime = filemtime($file); if ($filemtime > $now - $secondsOld) { continue; } if ($simulateOnly) { KalturaLog::info("Simulating: Deleting file [{$file}], it's last modification time was " . date('c', $filemtime)); continue; } KalturaLog::info("Deleting file [{$file}], it's last modification time was " . date('c', $filemtime)); $res = @unlink($file); if (!$res) { KalturaLog::err("Error: problem while deleting [{$file}]"); continue; } $deletedCount++; } }