Ejemplo n.º 1
0
function getExcludeFileSyncMap()
{
    $result = array();
    $dcConfig = kConf::getMap("dc_config");
    if (isset($dcConfig['sync_exclude_types'])) {
        foreach ($dcConfig['sync_exclude_types'] as $syncExcludeType) {
            $configObjectType = $syncExcludeType;
            $configObjectSubType = null;
            if (strpos($syncExcludeType, ':') > 0) {
                list($configObjectType, $configObjectSubType) = explode(':', $syncExcludeType, 2);
            }
            // translate api dynamic enum, such as contentDistribution.EntryDistribution - {plugin name}.{object name}
            if (!is_numeric($configObjectType)) {
                $configObjectType = kPluginableEnumsManager::apiToCore('FileSyncObjectType', $configObjectType);
            }
            // translate api dynamic enum, including the enum type, such as conversionEngineType.mp4box.Mp4box - {enum class name}.{plugin name}.{object name}
            if (!is_null($configObjectSubType) && !is_numeric($configObjectSubType)) {
                list($enumType, $configObjectSubType) = explode('.', $configObjectSubType);
                $configObjectSubType = kPluginableEnumsManager::apiToCore($enumType, $configObjectSubType);
            }
            if (!isset($result[$configObjectType])) {
                $result[$configObjectType] = array();
            }
            if (!is_null($configObjectSubType)) {
                $result[$configObjectType][] = $configObjectSubType;
            }
        }
    }
    return $result;
}
 public function getData(kHttpNotificationDispatchJobData $jobData = null)
 {
     $coreObject = unserialize($this->coreObject);
     $apiObject = new $this->apiObjectType();
     /* @var $apiObject KalturaObject */
     $apiObject->fromObject($coreObject);
     $httpNotificationTemplate = EventNotificationTemplatePeer::retrieveByPK($jobData->getTemplateId());
     $notification = new KalturaHttpNotification();
     $notification->object = $apiObject;
     $notification->eventObjectType = kPluginableEnumsManager::coreToApi('EventNotificationEventObjectType', $httpNotificationTemplate->getObjectType());
     $notification->eventNotificationJobId = $jobData->getJobId();
     $notification->templateId = $httpNotificationTemplate->getId();
     $notification->templateName = $httpNotificationTemplate->getName();
     $notification->templateSystemName = $httpNotificationTemplate->getSystemName();
     $notification->eventType = $httpNotificationTemplate->getEventType();
     $data = '';
     switch ($this->format) {
         case KalturaResponseType::RESPONSE_TYPE_XML:
             $serializer = new KalturaXmlSerializer($this->ignoreNull);
             $data = '<notification>' . $serializer->serialize($notification) . '</notification>';
             break;
         case KalturaResponseType::RESPONSE_TYPE_PHP:
             $serializer = new KalturaPhpSerializer($this->ignoreNull);
             $data = $serializer->serialize($notification);
             break;
         case KalturaResponseType::RESPONSE_TYPE_JSON:
             $serializer = new KalturaJsonSerializer($this->ignoreNull);
             $data = $serializer->serialize($notification);
             break;
     }
     return "data={$data}";
 }
 /**
  * Allows you to clone exiting event notification template object and create a new one with similar configuration
  * 
  * @action clone
  * @param int $id source template to clone
  * @param KalturaEventNotificationTemplate $eventNotificationTemplate overwrite configuration object
  * @throws KalturaEventNotificationErrors::EVENT_NOTIFICATION_TEMPLATE_NOT_FOUND
  * @throws KalturaEventNotificationErrors::EVENT_NOTIFICATION_WRONG_TYPE
  * @throws KalturaEventNotificationErrors::EVENT_NOTIFICATION_TEMPLATE_DUPLICATE_SYSTEM_NAME
  * @return KalturaEventNotificationTemplate
  */
 public function cloneAction($id, KalturaEventNotificationTemplate $eventNotificationTemplate = null)
 {
     // get the source object
     $dbEventNotificationTemplate = EventNotificationTemplatePeer::retrieveByPK($id);
     if (!$dbEventNotificationTemplate) {
         throw new KalturaAPIException(KalturaEventNotificationErrors::EVENT_NOTIFICATION_TEMPLATE_NOT_FOUND, $id);
     }
     // copy into new db object
     $newDbEventNotificationTemplate = $dbEventNotificationTemplate->copy();
     // init new Kaltura object
     $newEventNotificationTemplate = KalturaEventNotificationTemplate::getInstanceByType($newDbEventNotificationTemplate->getType());
     $templateClass = get_class($newEventNotificationTemplate);
     if ($eventNotificationTemplate && get_class($eventNotificationTemplate) != $templateClass && !is_subclass_of($eventNotificationTemplate, $templateClass)) {
         throw new KalturaAPIException(KalturaEventNotificationErrors::EVENT_NOTIFICATION_WRONG_TYPE, $id, kPluginableEnumsManager::coreToApi('EventNotificationTemplateType', $dbEventNotificationTemplate->getType()));
     }
     if ($eventNotificationTemplate) {
         // update new db object with the overwrite configuration
         $newDbEventNotificationTemplate = $eventNotificationTemplate->toUpdatableObject($newDbEventNotificationTemplate);
     }
     //Check uniqueness of new object's system name
     $systemNameTemplates = EventNotificationTemplatePeer::retrieveBySystemName($newDbEventNotificationTemplate->getSystemName());
     if (count($systemNameTemplates)) {
         throw new KalturaAPIException(KalturaEventNotificationErrors::EVENT_NOTIFICATION_TEMPLATE_DUPLICATE_SYSTEM_NAME, $newDbEventNotificationTemplate->getSystemName());
     }
     // save the new db object
     $newDbEventNotificationTemplate->setPartnerId($this->getPartnerId());
     $newDbEventNotificationTemplate->save();
     // return the saved object
     $newEventNotificationTemplate = KalturaEventNotificationTemplate::getInstanceByType($newDbEventNotificationTemplate->getType());
     $newEventNotificationTemplate->fromObject($newDbEventNotificationTemplate, $this->getResponseProfile());
     return $newEventNotificationTemplate;
 }
Ejemplo n.º 4
0
 protected function getExclusiveJobs(KalturaExclusiveLockKey $lockKey, $maxExecutionTime, $numberOfJobs, KalturaBatchJobFilter $filter = null, $jobType, $maxOffset = null)
 {
     $dbJobType = kPluginableEnumsManager::apiToCore('BatchJobType', $jobType);
     if (!is_null($filter)) {
         $jobsFilter = $filter->toFilter($dbJobType);
     }
     return kBatchExclusiveLock::getExclusiveJobs($lockKey->toObject(), $maxExecutionTime, $numberOfJobs, $dbJobType, $jobsFilter, $maxOffset);
 }
Ejemplo n.º 5
0
 /**
  * Dispatch integration task
  * 
  * @action dispatch
  * @param KalturaIntegrationJobData $data
  * @param KalturaBatchJobObjectType $objectType
  * @param string $objectId
  * @throws KalturaIntegrationErrors::INTEGRATION_DISPATCH_FAILED
  * @return int
  */
 public function dispatchAction(KalturaIntegrationJobData $data, $objectType, $objectId)
 {
     $jobData = $data->toObject();
     $coreObjectType = kPluginableEnumsManager::apiToCore('BatchJobObjectType', $objectType);
     $job = kIntegrationFlowManager::addintegrationJob($coreObjectType, $objectId, $jobData);
     if (!$job) {
         throw new KalturaAPIException(KalturaIntegrationErrors::INTEGRATION_DISPATCH_FAILED, $objectType);
     }
     return $job->getId();
 }
Ejemplo n.º 6
0
 public static function getRetryInterval($job_type = null)
 {
     $job_type = kPluginableEnumsManager::coreToApi('BatchJobType', $job_type);
     $job_type = str_replace('.', '_', $job_type);
     // in Zend_Ini . is used to create hierarchy
     $jobCheckAgainTimeouts = kConf::get('job_retry_intervals');
     if (isset($jobCheckAgainTimeouts[$job_type])) {
         return $jobCheckAgainTimeouts[$job_type];
     }
     return kConf::get('default_job_retry_interval');
 }
 /**
  * @param int $subType
  * @return string
  */
 public function fromSubType($subType)
 {
     switch ($subType) {
         case DropFolderType::FTP:
         case DropFolderType::SFTP:
         case DropFolderType::SCP:
         case DropFolderType::S3:
             return $subType;
         default:
             return kPluginableEnumsManager::coreToApi('DropFolderType', $subType);
     }
 }
 /**
  * @param int $subType
  * @return string
  */
 public function fromSubType($subType)
 {
     switch ($subType) {
         case StorageProfileProtocol::SFTP:
         case StorageProfileProtocol::FTP:
         case StorageProfileProtocol::SCP:
         case StorageProfileProtocol::S3:
         case StorageProfileProtocol::KALTURA_DC:
             return $subType;
         default:
             return kPluginableEnumsManager::coreToApi('StorageProfileProtocol', $subType);
     }
 }
Ejemplo n.º 9
0
 public function toObject($object_to_fill = null, $props_to_skip = array())
 {
     $dbFilter = parent::toObject($object_to_fill, $props_to_skip);
     $jobTypeAndSubTypeIn = $this->jobTypeAndSubTypeIn;
     if (is_null($this->jobTypeAndSubTypeIn)) {
         return $dbFilter;
     }
     $finalTypesAndSubTypes = array();
     $arr = explode(BatchJobFilter::JOB_TYPE_AND_SUB_TYPE_MAIN_DELIMITER, $this->jobTypeAndSubTypeIn);
     foreach ($arr as $jobTypeIn) {
         list($jobType, $jobSubTypes) = explode(BatchJobFilter::JOB_TYPE_AND_SUB_TYPE_TYPE_DELIMITER, $jobTypeIn);
         $jobType = kPluginableEnumsManager::apiToCore('BatchJobType', $jobType);
         $finalTypesAndSubTypes[] = $jobType . BatchJobFilter::JOB_TYPE_AND_SUB_TYPE_TYPE_DELIMITER . $jobSubTypes;
     }
     $jobTypeAndSubTypeIn = implode(BatchJobFilter::JOB_TYPE_AND_SUB_TYPE_MAIN_DELIMITER, $finalTypesAndSubTypes);
     $dbFilter->set('_in_job_type_and_sub_type', $jobTypeAndSubTypeIn);
     return $dbFilter;
 }
Ejemplo n.º 10
0
 private static function purgeAssetFromEdgeCast(asset $asset)
 {
     // get partner
     $partnerId = $asset->getPartnerId();
     $partner = PartnerPeer::retrieveByPK($partnerId);
     if (!$partner) {
         KalturaLog::err('Cannot find partner with id [' . $partnerId . ']');
         return false;
     }
     $mediaType = $asset instanceof thumbAsset ? self::EDGE_SERVICE_HTTP_SMALL_OBJECT_MEDIA_TYPE : self::EDGE_SERVICE_HTTP_LARGE_OBJECT_MEDIA_TYPE;
     $mediaTypePathList = array();
     try {
         $mediaTypePathList[] = array('MediaType' => $mediaType, 'MediaPath' => $asset->getDownloadUrl());
         // asset download url
     } catch (Exception $e) {
         KalturaLog::err('Cannot get asset URL for asset id [' . $asset->getId() . '] - ' . $e->getMessage());
     }
     if ($asset instanceof flavorAsset) {
         // get a list of all URLs leading to the asset for purging
         $subPartnerId = $asset->getentry()->getSubpId();
         $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subPartnerId);
         $assetId = $asset->getId();
         $serveFlavorUrl = "{$partnerPath}/serveFlavor/entryId/" . $asset->getEntryId() . "/flavorId/{$assetId}" . '*';
         // * wildcard should delete all serveFlavor urls
         $types = array(kPluginableEnumsManager::apiToCore(EdgeCastDeliveryProfileType::EDGE_CAST_HTTP), kPluginableEnumsManager::apiToCore(EdgeCastDeliveryProfileType::EDGE_CAST_RTMP));
         $deliveryProfile = $partner->getDeliveryProfileIds();
         $deliveryProfileIds = array();
         foreach ($deliveryProfile as $key => $value) {
             $deliveryProfileIds = array_merge($deliveryProfileIds, $value);
         }
         $c = new Criteria();
         $c->add(DeliveryProfilePeer::PARTNER_ID, $partnerId);
         $c->add(DeliveryProfilePeer::ID, $deliveryProfileIds, Criteria::IN);
         $c->addSelectColumn(DeliveryProfilePeer::HOST_NAME);
         $stmt = PermissionPeer::doSelectStmt($c);
         $hosts = $stmt->fetchAll(PDO::FETCH_COLUMN);
         foreach ($hosts as $host) {
             if (!empty($host)) {
                 $mediaTypePathList[] = array('MediaType' => $mediaType, 'MediaPath' => $host . $serveFlavorUrl);
             }
         }
     }
     return self::purgeFromEdgeCast($mediaTypePathList, $partner);
 }
 public function shouldConsumeJobStatusEvent(BatchJob $dbBatchJob)
 {
     $jobTypes = array(ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE));
     if (!in_array($dbBatchJob->getJobType(), $jobTypes)) {
         // wrong job type
         return false;
     }
     $data = $dbBatchJob->getData();
     if (!$data instanceof kDistributionJobData) {
         KalturaLog::err('Wrong job data type');
         return false;
     }
     $crossKalturaCoreValueType = kPluginableEnumsManager::apiToCore('DistributionProviderType', CrossKalturaDistributionPlugin::getApiValue(CrossKalturaDistributionProviderType::CROSS_KALTURA));
     if ($data->getProviderType() == $crossKalturaCoreValueType) {
         return true;
     }
     // not the right provider
     return false;
 }
 /**
  * Adds new live stream entry.
  * The entry will be queued for provision.
  * 
  * @action add
  * @param KalturaLiveStreamAdminEntry $liveStreamEntry Live stream entry metadata  
  * @param KalturaSourceType $sourceType  Live stream source type
  * @return KalturaLiveStreamAdminEntry The new live stream entry
  * 
  * @throws KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL
  */
 function addAction(KalturaLiveStreamAdminEntry $liveStreamEntry, $sourceType = null)
 {
     //TODO: allow sourceType that belongs to LIVE entries only - same for mediaType
     if ($sourceType) {
         $liveStreamEntry->sourceType = $sourceType;
     } else {
         // default sourceType is AKAMAI_LIVE
         $liveStreamEntry->sourceType = kPluginableEnumsManager::coreToApi('EntrySourceType', $this->getPartner()->getDefaultLiveStreamEntrySourceType());
     }
     // if the given password is empty, generate a random 8-character string as the new password
     if ($liveStreamEntry->streamPassword == null || strlen(trim($liveStreamEntry->streamPassword)) <= 0) {
         $tempPassword = sha1(md5(uniqid(rand(), true)));
         $liveStreamEntry->streamPassword = substr($tempPassword, rand(0, strlen($tempPassword) - 8), 8);
     }
     // if no bitrate given, add default
     if (is_null($liveStreamEntry->bitrates) || !$liveStreamEntry->bitrates->count) {
         $liveStreamBitrate = new KalturaLiveStreamBitrate();
         $liveStreamBitrate->bitrate = self::DEFAULT_BITRATE;
         $liveStreamBitrate->width = self::DEFAULT_WIDTH;
         $liveStreamBitrate->height = self::DEFAULT_HEIGHT;
         $liveStreamEntry->bitrates = new KalturaLiveStreamBitrateArray();
         $liveStreamEntry->bitrates[] = $liveStreamBitrate;
     } else {
         $bitrates = new KalturaLiveStreamBitrateArray();
         foreach ($liveStreamEntry->bitrates as $bitrate) {
             if (is_null($bitrate->bitrate)) {
                 $bitrate->bitrate = self::DEFAULT_BITRATE;
             }
             if (is_null($bitrate->width)) {
                 $bitrate->bitrate = self::DEFAULT_WIDTH;
             }
             if (is_null($bitrate->height)) {
                 $bitrate->bitrate = self::DEFAULT_HEIGHT;
             }
             $bitrates[] = $bitrate;
         }
         $liveStreamEntry->bitrates = $bitrates;
     }
     $dbEntry = $this->insertLiveStreamEntry($liveStreamEntry);
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry, $this->getPartnerId(), null, null, null, $dbEntry->getId());
     $liveStreamEntry->fromObject($dbEntry);
     return $liveStreamEntry;
 }
 public function updatedJob(BatchJob $dbBatchJob, BatchJob $twinJob = null)
 {
     $data = $dbBatchJob->getData();
     if (!$data instanceof kDistributionJobData) {
         return true;
     }
     $attUverseCoreValueType = kPluginableEnumsManager::apiToCore('DistributionProviderType', AttUverseDistributionPlugin::getApiValue(AttUverseDistributionProviderType::ATT_UVERSE));
     if ($data->getProviderType() != $attUverseCoreValueType) {
         return true;
     }
     $jobTypesToFinish = array(ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE));
     if (in_array($dbBatchJob->getJobType(), $jobTypesToFinish) && $dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED) {
         return self::onDistributionJobFinished($dbBatchJob, $data, $twinJob);
     }
     if ($dbBatchJob->getJobType() == ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE) && $dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_PENDING) {
         kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_FINISHED);
     }
     return true;
 }
 /**
  * Add new Distribution Profile
  * 
  * @action add
  * @param KalturaDistributionProfile $distributionProfile
  * @return KalturaDistributionProfile
  * @throws ContentDistributionErrors::DISTRIBUTION_PROVIDER_NOT_FOUND
  */
 function addAction(KalturaDistributionProfile $distributionProfile)
 {
     $distributionProfile->validatePropertyMinLength("name", 1);
     $distributionProfile->validatePropertyNotNull("providerType");
     if (is_null($distributionProfile->status)) {
         $distributionProfile->status = KalturaDistributionProfileStatus::DISABLED;
     }
     $providerType = kPluginableEnumsManager::apiToCore('DistributionProviderType', $distributionProfile->providerType);
     $dbDistributionProfile = DistributionProfilePeer::createDistributionProfile($providerType);
     if (!$dbDistributionProfile) {
         throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROVIDER_NOT_FOUND, $distributionProfile->providerType);
     }
     $distributionProfile->toInsertableObject($dbDistributionProfile);
     $dbDistributionProfile->setPartnerId($this->impersonatedPartnerId);
     $dbDistributionProfile->save();
     $distributionProfile = KalturaDistributionProfileFactory::createKalturaDistributionProfile($dbDistributionProfile->getProviderType());
     $distributionProfile->fromObject($dbDistributionProfile);
     return $distributionProfile;
 }
Ejemplo n.º 15
0
 public function updatedJob(BatchJob $dbBatchJob)
 {
     $data = $dbBatchJob->getData();
     if (!$data instanceof kDistributionJobData) {
         return true;
     }
     $doubleClickCoreValueType = kPluginableEnumsManager::apiToCore('DistributionProviderType', DoubleClickDistributionPlugin::getApiValue(DoubleClickDistributionProviderType::DOUBLECLICK));
     if ($data->getProviderType() != $doubleClickCoreValueType) {
         return true;
     }
     if ($dbBatchJob->getStatus() != BatchJob::BATCHJOB_STATUS_PENDING) {
         return true;
     }
     $jobTypesToFinish = array(ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_FETCH_REPORT), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_ENABLE), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DISABLE));
     if (in_array($dbBatchJob->getJobType(), $jobTypesToFinish)) {
         kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_FINISHED);
     }
     return true;
 }
 public function toObject($coreFilter = null, $skip = array())
 {
     /* @var $coreFilter entryFilter */
     if ($this->externalSourceTypeEqual) {
         $coreFilter->fields['_like_plugins_data'] = ExternalMediaPlugin::getExternalSourceSearchData($this->externalSourceTypeEqual);
         $this->externalSourceTypeEqual = null;
     }
     if ($this->externalSourceTypeIn) {
         $coreExternalSourceTypes = array();
         $apiExternalSourceTypes = explode(',', $this->externalSourceTypeIn);
         foreach ($apiExternalSourceTypes as $apiExternalSourceType) {
             $coreExternalSourceType = kPluginableEnumsManager::apiToCore('ExternalMediaSourceType', $apiExternalSourceType);
             $coreExternalSourceTypes[] = ExternalMediaPlugin::getExternalSourceSearchData($coreExternalSourceType);
         }
         $externalSourceTypeIn = implode(',', $coreExternalSourceTypes);
         $coreFilter->fields['_mlikeor_plugins_data'] = $externalSourceTypeIn;
         $this->externalSourceTypeIn = null;
     }
     return parent::toObject($coreFilter, $skip);
 }
Ejemplo n.º 17
0
 protected static function loadApiMap($useCache = true)
 {
     $apiCachePath = kConf::get('cache_root_path') . '/ApiPluginableEnums.cache';
     if ($useCache && file_exists($apiCachePath)) {
         self::$apiMap = unserialize(file_get_contents($apiCachePath));
         return;
     }
     self::$apiMap = array();
     $dynamicEnums = DynamicEnumPeer::doSelect(new Criteria());
     foreach ($dynamicEnums as $dynamicEnum) {
         $dynamicEnumId = $dynamicEnum->getId();
         $dynamicEnumType = $dynamicEnum->getEnumName();
         $dynamicEnumApiName = $dynamicEnum->getPluginName() . IKalturaEnumerator::PLUGIN_VALUE_DELIMITER . $dynamicEnum->getValueName();
         if (!isset(self::$apiMap[$dynamicEnumType])) {
             self::$apiMap[$dynamicEnumType] = array();
         }
         self::$apiMap[$dynamicEnumType][$dynamicEnumApiName] = $dynamicEnumId;
     }
     file_put_contents($apiCachePath, serialize(self::$apiMap));
 }
 public static function loadObject($baseClass, $enumValue, array $constructorArgs = null)
 {
     if (class_exists('Kaltura_Client_Client')) {
         return null;
     }
     if (class_exists('KalturaClient')) {
         if ($baseClass == 'KObjectTaskEntryEngineBase' && $enumValue == KalturaObjectTaskType::DISTRIBUTE) {
             return new KObjectTaskDistributeEngine();
         }
     } else {
         $apiValue = self::getApiValue(DistributeObjectTaskType::DISTRIBUTE);
         $distributeObjectTaskCoreValue = kPluginableEnumsManager::apiToCore('ObjectTaskType', $apiValue);
         if ($baseClass == 'KalturaObjectTask' && $enumValue == $distributeObjectTaskCoreValue) {
             return new KalturaDistributeObjectTask();
         }
         if ($baseClass == 'KObjectTaskEntryEngineBase' && $enumValue == $apiValue) {
             return new KObjectTaskDistributeEngine();
         }
     }
     return null;
 }
Ejemplo n.º 19
0
 public static function loadObject($baseClass, $enumValue, array $constructorArgs = null)
 {
     if (class_exists('Kaltura_Client_Client')) {
         return null;
     }
     if (class_exists('KalturaClient')) {
         if ($baseClass == 'KObjectTaskEntryEngineBase' && $enumValue == KalturaObjectTaskType::EXECUTE_METADATA_XSLT) {
             return new KObjectTaskExecuteMetadataXsltEngine();
         }
     } else {
         $apiValue = self::getApiValue(ExecuteMetadataXsltObjectTaskType::EXECUTE_METADATA_XSLT);
         $executeMetadataXsltObjectTaskCoreValue = kPluginableEnumsManager::apiToCore('ObjectTaskType', $apiValue);
         if ($baseClass == 'KalturaObjectTask' && $enumValue == $executeMetadataXsltObjectTaskCoreValue) {
             return new KalturaExecuteMetadataXsltObjectTask();
         }
         if ($baseClass == 'KObjectTaskEntryEngineBase' && $enumValue == $apiValue) {
             return new KObjectTaskExecuteMetadataXsltEngine();
         }
     }
     return null;
 }
Ejemplo n.º 20
0
 /**
  * Check if specific file sync that belong to object type and sub type should be synced
  *
  * @param int $objectType
  * @param int $objectSubType
  * @return bool
  */
 public static function shouldSyncFileObjectType($fileSync)
 {
     if (is_null(self::$excludedSyncFileObjectTypes)) {
         self::$excludedSyncFileObjectTypes = array();
         $dcConfig = kConf::getMap("dc_config");
         if (isset($dcConfig['sync_exclude_types'])) {
             foreach ($dcConfig['sync_exclude_types'] as $syncExcludeType) {
                 $configObjectType = $syncExcludeType;
                 $configObjectSubType = null;
                 if (strpos($syncExcludeType, ':') > 0) {
                     list($configObjectType, $configObjectSubType) = explode(':', $syncExcludeType, 2);
                 }
                 // translate api dynamic enum, such as contentDistribution.EntryDistribution - {plugin name}.{object name}
                 if (!is_numeric($configObjectType)) {
                     $configObjectType = kPluginableEnumsManager::apiToCore('FileSyncObjectType', $configObjectType);
                 }
                 // translate api dynamic enum, including the enum type, such as conversionEngineType.mp4box.Mp4box - {enum class name}.{plugin name}.{object name}
                 if (!is_null($configObjectSubType) && !is_numeric($configObjectSubType)) {
                     list($enumType, $configObjectSubType) = explode('.', $configObjectSubType);
                     $configObjectSubType = kPluginableEnumsManager::apiToCore($enumType, $configObjectSubType);
                 }
                 if (!isset(self::$excludedSyncFileObjectTypes[$configObjectType])) {
                     self::$excludedSyncFileObjectTypes[$configObjectType] = array();
                 }
                 if (!is_null($configObjectSubType)) {
                     self::$excludedSyncFileObjectTypes[$configObjectType][] = $configObjectSubType;
                 }
             }
         }
     }
     if (!isset(self::$excludedSyncFileObjectTypes[$fileSync->getObjectType()])) {
         return true;
     }
     if (count(self::$excludedSyncFileObjectTypes[$fileSync->getObjectType()]) && !in_array($fileSync->getObjectSubType(), self::$excludedSyncFileObjectTypes[$fileSync->getObjectType()])) {
         return true;
     }
     return false;
 }
Ejemplo n.º 21
0
 /**
  * Add new bulk upload batch job
  * Conversion profile id can be specified in the API or in the CSV file, the one in the CSV file will be stronger.
  * If no conversion profile was specified, partner's default will be used
  * 
  * @action add
  * @param int $conversionProfileId Convertion profile id to use for converting the current bulk (-1 to use partner's default)
  * @param file $csvFileData bulk upload file
  * @param KalturaBulkUploadType $bulkUploadType
  * @param string $uploadedBy
  * @param string $fileName Friendly name of the file, used to be recognized later in the logs.
  * @return KalturaBulkUpload
  */
 public function addAction($conversionProfileId, $csvFileData, $bulkUploadType = null, $uploadedBy = null, $fileName = null)
 {
     if ($conversionProfileId == self::PARTNER_DEFAULT_CONVERSION_PROFILE_ID) {
         $conversionProfileId = $this->getPartner()->getDefaultConversionProfileId();
     }
     $conversionProfile = conversionProfile2Peer::retrieveByPK($conversionProfileId);
     if (!$conversionProfile) {
         throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $conversionProfileId);
     }
     $coreBulkUploadType = kPluginableEnumsManager::apiToCore('BulkUploadType', $bulkUploadType);
     if (is_null($uploadedBy)) {
         $uploadedBy = $this->getKuser()->getPuserId();
     }
     if (!$fileName) {
         $fileName = $csvFileData["name"];
     }
     $data = $this->constructJobData($csvFileData["tmp_name"], $fileName, $this->getPartner(), $this->getKuser()->getPuserId(), $uploadedBy, $conversionProfileId, $coreBulkUploadType);
     $dbJob = kJobsManager::addBulkUploadJob($this->getPartner(), $data, $coreBulkUploadType);
     $dbJobLog = BatchJobLogPeer::retrieveByBatchJobId($dbJob->getId());
     $bulkUpload = new KalturaBulkUpload();
     $bulkUpload->fromObject($dbJobLog, $this->getResponseProfile());
     return $bulkUpload;
 }
 public function toObject($objectToFill = null, $propsToSkip = array())
 {
     if (is_null($objectToFill)) {
         $objectToFill = new kEventNotificationScope();
     }
     /** @var kEventNotificationScope $objectToFill */
     $objectToFill = parent::toObject($objectToFill);
     $objectClassName = KalturaPluginManager::getObjectClass('EventNotificationEventObjectType', kPluginableEnumsManager::apiToCore('EventNotificationEventObjectType', $this->scopeObjectType));
     $peerClass = $objectClassName . 'Peer';
     $objectId = $this->objectId;
     if (class_exists($peerClass)) {
         $objectToFill->setObject($peerClass::retrieveByPk($objectId));
     } else {
         $b = new $objectClassName();
         $peer = $b->getPeer();
         $object = $peer::retrieveByPK($objectId);
         $objectToFill->setObject($object);
     }
     if (is_null($objectToFill->getObject())) {
         throw new KalturaAPIException(KalturaErrors::INVALID_OBJECT_ID, $this->objectId);
     }
     return $objectToFill;
 }
Ejemplo n.º 23
0
 /**
  * Adds new live stream entry.
  * The entry will be queued for provision.
  * 
  * @action add
  * @param KalturaLiveStreamEntry $liveStreamEntry Live stream entry metadata  
  * @param KalturaSourceType $sourceType  Live stream source type
  * @return KalturaLiveStreamEntry The new live stream entry
  * 
  * @throws KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL
  */
 function addAction(KalturaLiveStreamEntry $liveStreamEntry, $sourceType = null)
 {
     if ($sourceType) {
         $liveStreamEntry->sourceType = $sourceType;
     } elseif (is_null($liveStreamEntry->sourceType)) {
         // default sourceType is AKAMAI_LIVE
         $liveStreamEntry->sourceType = kPluginableEnumsManager::coreToApi('EntrySourceType', $this->getPartner()->getDefaultLiveStreamEntrySourceType());
     }
     $dbEntry = $this->prepareEntryForInsert($liveStreamEntry);
     $dbEntry->save();
     $te = new TrackEntry();
     $te->setEntryId($dbEntry->getId());
     $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY);
     $te->setDescription(__METHOD__ . ":" . __LINE__ . "::" . $dbEntry->getSource());
     TrackEntry::addTrackEntry($te);
     //If a jobData can be created for entry sourceType, add provision job. Otherwise, just save the entry.
     $jobData = kProvisionJobData::getInstance($dbEntry->getSource());
     if ($jobData) {
         /* @var $data kProvisionJobData */
         $jobData->populateFromPartner($dbEntry->getPartner());
         $jobData->populateFromEntry($dbEntry);
         kJobsManager::addProvisionProvideJob(null, $dbEntry, $jobData);
     } else {
         $dbEntry->setStatus(entryStatus::READY);
         $dbEntry->save();
         $liveAssets = assetPeer::retrieveByEntryId($dbEntry->getId(), array(assetType::LIVE));
         foreach ($liveAssets as $liveAsset) {
             /* @var $liveAsset liveAsset */
             $liveAsset->setStatus(asset::ASSET_STATUS_READY);
             $liveAsset->save();
         }
     }
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry, $this->getPartnerId(), null, null, null, $dbEntry->getId());
     $liveStreamEntry->fromObject($dbEntry, $this->getResponseProfile());
     return $liveStreamEntry;
 }
Ejemplo n.º 24
0
 public static function isSearchProviderSource($source)
 {
     $refClass = new ReflectionClass('EntrySourceType');
     $coreConstants = $refClass->getConstants();
     if (in_array($source, array_values($coreConstants))) {
         return false;
     }
     $typeMap = kPluginableEnumsManager::getCoreMap('EntrySourceType');
     if (isset($typeMap[$source])) {
         return false;
     }
     return true;
 }
Ejemplo n.º 25
0
 public static function getCuePointTypeCoreValue($valueName)
 {
     $value = self::getPluginName() . IKalturaEnumerator::PLUGIN_VALUE_DELIMITER . $valueName;
     return kPluginableEnumsManager::apiToCore('CuePointType', $value);
 }
 /**
  * @param int $subType
  * @return string
  */
 public function fromSubType($subType)
 {
     return kPluginableEnumsManager::coreToApi('RecalculateCacheType', $subType);
 }
Ejemplo n.º 27
0
 /**
  * @return int id of dynamic enum in the DB.
  */
 public static function getIntegrationProviderCoreValue($valueName)
 {
     $class = get_called_class();
     $value = $class::getPluginName() . IKalturaEnumerator::PLUGIN_VALUE_DELIMITER . $valueName;
     return kPluginableEnumsManager::apiToCore('IntegrationProviderType', $value);
 }
Ejemplo n.º 28
0
    public static function contributeToSchema($type)
    {
        $coreType = kPluginableEnumsManager::apiToCore('SchemaType', $type);
        if ($coreType != SchemaType::SYNDICATION) {
            return null;
        }
        $xsd = '
		
	<!-- ' . self::getPluginName() . ' -->
	
	<xs:complexType name="T_distribution">
		<xs:sequence>
			<xs:element name="remoteId" minOccurs="0" maxOccurs="1" type="xs:string">
				<xs:annotation>
					<xs:documentation>Unique id in the remote site</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="sunrise" minOccurs="0" maxOccurs="1" type="xs:int">
				<xs:annotation>
					<xs:documentation>Time that the entry will become available in the remote site</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="sunset" minOccurs="0" maxOccurs="1" type="xs:int">
				<xs:annotation>
					<xs:documentation>Time that the entry will become unavailable in the remote site</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="flavorAssetIds" minOccurs="0" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>Ids of flavor assets to be submitted to the remote site</xs:documentation>
				</xs:annotation>
				<xs:complexType>
					<xs:sequence>
						<xs:element name="flavorAssetId" minOccurs="0" maxOccurs="unbounded" type="xs:string" />
					</xs:sequence>
				</xs:complexType>
			</xs:element>
			<xs:element name="thumbAssetIds" minOccurs="0" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>Ids of thumbnail assets to be submitted to the remote site</xs:documentation>
				</xs:annotation>
				<xs:complexType>
					<xs:sequence>
						<xs:element name="thumbAssetId" minOccurs="0" maxOccurs="unbounded" type="xs:string" />
					</xs:sequence>
				</xs:complexType>
			</xs:element>
			<xs:element name="assetIds" minOccurs="0" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>Ids of assets to be submitted to the remote site</xs:documentation>
				</xs:annotation>
				<xs:complexType>
					<xs:sequence>
						<xs:element name="assetId" minOccurs="0" maxOccurs="unbounded" type="xs:string" />
					</xs:sequence>
				</xs:complexType>
			</xs:element>
			<xs:element name="errorDescription" minOccurs="0" maxOccurs="1" type="xs:string">
				<xs:annotation>
					<xs:documentation>Submission error description</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="createdAt" minOccurs="1" maxOccurs="1" type="xs:dateTime">
				<xs:annotation>
					<xs:documentation>Entry distribution creation date</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="updatedAt" minOccurs="1" maxOccurs="1" type="xs:dateTime">
				<xs:annotation>
					<xs:documentation>Entry distribution last update date</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="submittedAt" minOccurs="0" maxOccurs="1" type="xs:dateTime">
				<xs:annotation>
					<xs:documentation>Entry distribution submission date</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="lastReport" minOccurs="0" maxOccurs="1" type="xs:dateTime">
				<xs:annotation>
					<xs:documentation>Entry distribution last report date</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="dirtyStatus" minOccurs="0" maxOccurs="1" type="KalturaEntryDistributionFlag">
				<xs:annotation>
					<xs:documentation>Indicates that there are future action to be submitted</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="status" minOccurs="1" maxOccurs="1" type="KalturaEntryDistributionStatus">
				<xs:annotation>
					<xs:documentation>Entry distribution status</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="sunStatus" minOccurs="1" maxOccurs="1" type="KalturaEntryDistributionSunStatus">
				<xs:annotation>
					<xs:documentation>Entry distribution availability status</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="plays" minOccurs="0" maxOccurs="1" type="xs:int">
				<xs:annotation>
					<xs:documentation>Entry plays count in the remote site</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="views" minOccurs="0" maxOccurs="1" type="xs:int">
				<xs:annotation>
					<xs:documentation>Entry views count in the remote site</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="errorNumber" minOccurs="0" maxOccurs="1" type="xs:int">
				<xs:annotation>
					<xs:documentation>Submission error number</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="errorType" minOccurs="0" maxOccurs="1" type="KalturaBatchJobErrorTypes">
				<xs:annotation>
					<xs:documentation>Submission error type</xs:documentation>
				</xs:annotation>
			</xs:element>
		
			<xs:element ref="distribution-extension" minOccurs="0" maxOccurs="unbounded" />
			
		</xs:sequence>
		
		<xs:attribute name="entryDistributionId" use="required" type="xs:int">
			<xs:annotation>
				<xs:documentation>Entry distribution unique id</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="provider" use="optional" type="xs:string">
			<xs:annotation>
				<xs:documentation>Entry distribution provider</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="distributionProviderId" use="optional" type="xs:int">
			<xs:annotation>
				<xs:documentation>Entry distribution provider id<br/>relevant to generic providers</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="feedId" use="optional" type="xs:string">
			<xs:annotation>
				<xs:documentation>Entry distribution feed id<br/>relevant to syndicated providers</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="distributionProfileId" use="required" type="xs:int">
			<xs:annotation>
				<xs:documentation>Entry distribution profile id</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="distributionProfile" use="optional" type="xs:string">
			<xs:annotation>
				<xs:documentation>Entry distribution profile system name</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="distributionProfileName" use="optional" type="xs:string">
			<xs:annotation>
				<xs:documentation>Entry distribution profile name</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		
	</xs:complexType>
	
	<xs:element name="distribution" type="T_distribution" substitutionGroup="item-extension">
		<xs:annotation>
			<xs:documentation>Entry distribution element</xs:documentation>
			<xs:appinfo>
				<example>
					<distribution	entryDistributionId="{entry distribution id}" 
									distributionProfileId="{distribution profile id}" 
									distributionProfileName="My Profile"
					>
						<remoteId>{remote site id}</remoteId>
						<sunrise>1305636600</sunrise>
						<sunset>1305640200</sunset>
						<flavorAssetIds>
							<flavorAssetId>0_bp1qzu1d</flavorAssetId>
							<flavorAssetId>0_bp1qzfsd</flavorAssetId>
						</flavorAssetIds>
						<thumbAssetIds>
							<thumbAssetId>0_di94zu1d</thumbAssetId>
							<thumbAssetId>0_di940sde</thumbAssetId>
						</thumbAssetIds>
						<errorDescription>Error: No metadata objects found</errorDescription>
						<createdAt>2011-05-17T07:46:20</createdAt>
						<updatedAt>2011-06-09T09:23:46</updatedAt>
						<submittedAt>2011-05-17T08:03:00</submittedAt>
						<dirtyStatus>3</dirtyStatus>
						<status>8</status>
						<sunStatus>3</sunStatus>
						<errorType>1</errorType>
					</distribution>
				</example>
			</xs:appinfo>
		</xs:annotation>
	</xs:element>
	<xs:element name="distribution-extension" />
		';
        return $xsd;
    }
Ejemplo n.º 29
0
 /**
  * batch getOrCreateWorker returns a worker by name, create it if doesnt exist
  * 
  * @param Scheduler $scheduler The scheduler object
  * @param int $workerConfigId The worker configured id
  * @param KalturaBatchJobType $workerType The type of the remote worker
  * @param string $workerName The name of the remote worker
  * @return Worker
  */
 private function getOrCreateWorker(Scheduler $scheduler, $workerConfigId, $workerType = null, $workerName = null)
 {
     if (!is_null($workerType) && !is_numeric($workerType)) {
         $workerType = kPluginableEnumsManager::apiToCore('BatchJobType', $workerType);
     }
     $c = new Criteria();
     $c->add(SchedulerWorkerPeer::SCHEDULER_CONFIGURED_ID, $scheduler->getConfiguredId());
     $c->add(SchedulerWorkerPeer::CONFIGURED_ID, $workerConfigId);
     $workerDb = SchedulerWorkerPeer::doSelectOne($c, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2));
     if ($workerDb) {
         $shouldSave = false;
         if (!is_null($workerName) && $workerDb->getName() != $workerName) {
             $workerDb->setName($workerName);
             $shouldSave = true;
         }
         if (!is_null($workerType) && $workerDb->getType() != $workerType) {
             $workerDb->setType($workerType);
             $shouldSave = true;
         }
         if ($shouldSave) {
             $workerDb->save();
         }
         return $workerDb;
     }
     $workerDb = new SchedulerWorker();
     $workerDb->setLastStatus(time());
     $workerDb->setCreatedBy("Scheduler: " . $scheduler->getName());
     $workerDb->setUpdatedBy("Scheduler: " . $scheduler->getName());
     $workerDb->setSchedulerId($scheduler->getId());
     $workerDb->setSchedulerConfiguredId($scheduler->getConfiguredId());
     $workerDb->setConfiguredId($workerConfigId);
     $workerDb->setDescription('');
     if (!is_null($workerType)) {
         $workerDb->setType($workerType);
     }
     if (!is_null($workerName)) {
         $workerDb->setName($workerName);
     }
     $workerDb->save();
     return $workerDb;
 }
Ejemplo n.º 30
0
 /**
  * @param int $subType from enum mediaParserType
  * @return string from enum KalturaMediaParserType
  */
 public function fromSubType($subType)
 {
     return kPluginableEnumsManager::coreToApi('mediaParserType', $subType);
 }