/** * 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; }
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}"; }
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); } }
/** * 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 fromObject($source_object) { $reflector = KalturaTypeReflectorCacher::get(get_class($this)); $properties = $reflector->getProperties(); if ($reflector->requiresReadPermission() && !kPermissionManager::getReadPermitted(get_class($this), kApiParameterPermissionItem::ALL_VALUES_IDENTIFIER)) { return false; // current user has no permission for accessing this object class } foreach ($this->getMapBetweenObjects() as $this_prop => $object_prop) { if (is_numeric($this_prop)) { $this_prop = $object_prop; } if (!isset($properties[$this_prop]) || $properties[$this_prop]->isWriteOnly()) { continue; } // ignore property if it requires a read permission which the current user does not have if ($properties[$this_prop]->requiresReadPermission() && !kPermissionManager::getReadPermitted($this->getDeclaringClassName($this_prop), $this_prop)) { continue; } $getter_callback = array($source_object, "get{$object_prop}"); if (is_callable($getter_callback)) { $value = call_user_func($getter_callback); if ($properties[$this_prop]->isDynamicEnum()) { $propertyType = $properties[$this_prop]->getType(); $enumType = call_user_func(array($propertyType, 'getEnumClass')); $value = kPluginableEnumsManager::coreToApi($enumType, $value); } $this->{$this_prop} = $value; } else { KalturaLog::alert("getter for property [{$object_prop}] was not found on object class [" . get_class($source_object) . "]"); } if (in_array($this_prop, array("createdAt", "updatedAt"))) { $this->{$this_prop} = call_user_func_array($getter_callback, array(null)); // when passing null to getCreatedAt, timestamp will be returned } } }
/** * 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; }
public function setType() { $this->type = kPluginableEnumsManager::coreToApi("KalturaBulkUploadType", BulkUploadXmlPlugin::getApiValue(BulkUploadXmlType::XML)); }
/** * @param int $subType * @return string */ public function fromSubType($subType) { return kPluginableEnumsManager::coreToApi('DistributionProviderType', $subType); }
/** * @param int $subType * @return string */ public function fromSubType($subType) { return kPluginableEnumsManager::coreToApi('EventNotificationTemplateType', $subType); }
public function toData(BatchJob $dbBatchJob) { $dbData = null; if (is_null($this->jobType)) { $this->jobType = kPluginableEnumsManager::coreToApi('BatchJobType', $dbBatchJob->getJobType()); } switch ($dbBatchJob->getJobType()) { case KalturaBatchJobType::BULKUPLOAD: $dbData = new kBulkUploadJobData(); if (is_null($this->data)) { $this->data = new KalturaBulkUploadJobData(); } break; case KalturaBatchJobType::CONVERT: $dbData = new kConvertJobData(); if (is_null($this->data)) { $this->data = new KalturaConvertJobData(); } break; case KalturaBatchJobType::CONVERT_PROFILE: $dbData = new kConvertProfileJobData(); if (is_null($this->data)) { $this->data = new KalturaConvertProfileJobData(); } break; case KalturaBatchJobType::EXTRACT_MEDIA: $dbData = new kExtractMediaJobData(); if (is_null($this->data)) { $this->data = new KalturaExtractMediaJobData(); } break; case KalturaBatchJobType::IMPORT: $dbData = new kImportJobData(); if (is_null($this->data)) { $this->data = new KalturaImportJobData(); } break; case KalturaBatchJobType::POSTCONVERT: $dbData = new kPostConvertJobData(); if (is_null($this->data)) { $this->data = new KalturaPostConvertJobData(); } break; case KalturaBatchJobType::MAIL: $dbData = new kMailJobData(); if (is_null($this->data)) { $this->data = new KalturaMailJobData(); } break; case KalturaBatchJobType::NOTIFICATION: $dbData = new kNotificationJobData(); if (is_null($this->data)) { $this->data = new KalturaNotificationJobData(); } break; case KalturaBatchJobType::BULKDOWNLOAD: $dbData = new kBulkDownloadJobData(); if (is_null($this->data)) { $this->data = new KalturaBulkDownloadJobData(); } break; case KalturaBatchJobType::FLATTEN: $dbData = new kFlattenJobData(); if (is_null($this->data)) { $this->data = new KalturaFlattenJobData(); } break; case KalturaBatchJobType::PROVISION_PROVIDE: case KalturaBatchJobType::PROVISION_DELETE: $jobSubType = $dbBatchJob->getJobSubType(); $dbData = kAkamaiProvisionJobData::getInstance($jobSubType); if (is_null($this->data)) { $this->data = KalturaProvisionJobData::getJobDataInstance($jobSubType); } break; case KalturaBatchJobType::CONVERT_COLLECTION: $dbData = new kConvertCollectionJobData(); if (is_null($this->data)) { $this->data = new KalturaConvertCollectionJobData(); } break; case KalturaBatchJobType::STORAGE_EXPORT: $dbData = new kStorageExportJobData(); if (is_null($this->data)) { $this->data = new KalturaStorageExportJobData(); } break; case KalturaBatchJobType::MOVE_CATEGORY_ENTRIES: $dbData = new kMoveCategoryEntriesJobData(); if (is_null($this->data)) { $this->data = new KalturaMoveCategoryEntriesJobData(); } break; case KalturaBatchJobType::STORAGE_DELETE: $dbData = new kStorageDeleteJobData(); if (is_null($this->data)) { $this->data = new KalturaStorageDeleteJobData(); } break; case KalturaBatchJobType::CAPTURE_THUMB: $dbData = new kCaptureThumbJobData(); if (is_null($this->data)) { $this->data = new KalturaCaptureThumbJobData(); } break; case KalturaBatchJobType::INDEX: $dbData = new kIndexJobData(); if (is_null($this->data)) { $this->data = new KalturaIndexJobData(); } break; case KalturaBatchJobType::COPY: $dbData = new kCopyJobData(); if (is_null($this->data)) { $this->data = new KalturaCopyJobData(); } break; case KalturaBatchJobType::DELETE: $dbData = new kDeleteJobData(); if (is_null($this->data)) { $this->data = new KalturaDeleteJobData(); } break; case KalturaBatchJobType::DELETE_FILE: $dbData = new kDeleteFileJobData(); if (is_null($this->data)) { $this->data = new KalturaDeleteFileJobData(); } break; case KalturaBatchJobType::CONVERT_LIVE_SEGMENT: $dbData = new kConvertLiveSegmentJobData(); if (is_null($this->data)) { $this->data = new KalturaConvertLiveSegmentJobData(); } break; case KalturaBatchJobType::CONCAT: $dbData = new kConcatJobData(); if (is_null($this->data)) { $this->data = new KalturaConcatJobData(); } break; case KalturaBatchJobType::COPY_PARTNER: $dbData = new kCopyPartnerJobData(); if (is_null($this->data)) { $this->data = new KalturaCopyPartnerJobData(); } break; case KalturaBatchJobType::RECALCULATE_CACHE: switch ($dbBatchJob->getJobSubType()) { case RecalculateCacheType::RESPONSE_PROFILE: $dbData = new kRecalculateResponseProfileCacheJobData(); if (is_null($this->data)) { $this->data = new KalturaRecalculateResponseProfileCacheJobData(); } break; } break; default: $dbData = KalturaPluginManager::loadObject('kJobData', $dbBatchJob->getJobType()); if (is_null($this->data)) { $this->data = KalturaPluginManager::loadObject('KalturaJobData', $this->jobType); } } if (is_null($dbBatchJob->getData())) { $dbBatchJob->setData($dbData); } if ($this->data instanceof KalturaJobData) { $dbData = $this->data->toObject($dbBatchJob->getData()); $dbBatchJob->setData($dbData); } return $dbData; }
public function fromObject($entry) { parent::fromObject($entry); $this->mediaDate = $entry->getMediaDate(null); $reflect = KalturaTypeReflectorCacher::get('KalturaSourceType'); $constants = $reflect->getConstantsValues(); $sourceApi = kPluginableEnumsManager::coreToApi('EntrySourceType', $entry->getSource()); if (!in_array($sourceApi, $constants) || $sourceApi == EntrySourceType::SEARCH_PROVIDER) { $this->sourceType = KalturaSourceType::SEARCH_PROVIDER; $this->searchProviderType = $sourceApi; } else { $this->sourceType = $sourceApi; $this->searchProviderType = null; } }
protected function toSourceType(entry $entry) { if (!$this->sourceType) { $partner = PartnerPeer::retrieveByPK(kCurrentContext::getCurrentPartnerId()); if ($partner) { $this->sourceType = kPluginableEnumsManager::coreToApi('EntrySourceType', $partner->getDefaultLiveStreamEntrySourceType()); } } return parent::toSourceType($entry); }
public function setType() { $this->type = kPluginableEnumsManager::coreToApi("KalturaBulkUploadType", BulkUploadFilterPlugin::getApiValue(BulkUploadFilterType::FILTER)); }
public function fromObject($object) { parent::fromObject($object); foreach (self::$actions as $action) { $actionAttribute = "{$action}Action"; if (!$this->{$actionAttribute}) { $this->{$actionAttribute} = new KalturaGenericDistributionProfileAction(); } $reflector = KalturaTypeReflectorCacher::get(get_class($this->{$actionAttribute})); $properties = $reflector->getProperties(); foreach ($this->{$actionAttribute}->getMapBetweenObjects() as $this_prop => $object_prop) { if (is_numeric($this_prop)) { $this_prop = $object_prop; } if (!isset($properties[$this_prop]) || $properties[$this_prop]->isWriteOnly()) { continue; } $getter_callback = array($object, "get{$object_prop}"); if (is_callable($getter_callback)) { $value = call_user_func($getter_callback, $action); if ($properties[$this_prop]->isDynamicEnum()) { $propertyType = $properties[$this_prop]->getType(); $enumType = call_user_func(array($propertyType, 'getEnumClass')); $value = kPluginableEnumsManager::coreToApi($enumType, $value); } $this->{$actionAttribute}->{$this_prop} = $value; } else { KalturaLog::alert("getter for property [{$object_prop}] was not found on object class [" . get_class($object) . "]"); } } } $this->updateRequiredEntryFields = implode(',', $object->getUpdateRequiredEntryFields()); $this->updateRequiredMetadataXPaths = implode(',', $object->getUpdateRequiredMetadataXPaths()); }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaAttUverseDistributionProfile) { return; } /* @var $distributionProfileDb AttUverseDistributionProfile */ $distributionProfileDb = DistributionProfilePeer::retrieveByPK($distributionJobData->distributionProfileId); $distributedFlavorIds = null; $distributedThumbIds = null; $this->filesForDistribution = new KalturaAttUverseDistributionFileArray(); $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId); //Flavor Assets $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); if (count($flavorAssets)) { $assetLocalIds = array(); foreach ($flavorAssets as $flavorAsset) { $file = new KalturaAttUverseDistributionFile(); $file->assetType = KalturaAssetType::FLAVOR; /* @var $flavorAsset flavorAsset */ $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $assetLocalIds[] = $flavorAsset->getId(); $file->assetId = $flavorAsset->getId(); $file->localFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $defaultFilename = pathinfo($file->localFilePath, PATHINFO_BASENAME); $file->remoteFilename = $distributionProfileDb->getFlavorAssetFilename($entryDistributionDb, $defaultFilename, $flavorAsset->getId()); $this->filesForDistribution[] = $file; } } $distributedFlavorIds = implode(',', $assetLocalIds); } //Thumbnail $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); if (count($thumbAssets)) { $thumbLocalIds = array(); foreach ($thumbAssets as $thumbAsset) { $file = new KalturaAttUverseDistributionFile(); $file->assetType = KalturaAssetType::THUMBNAIL; $syncKey = $thumbAsset->getSyncKey(thumbAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $thumbLocalIds[] = $thumbAsset->getId(); $file->assetId = $thumbAsset->getId(); $file->localFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $defaultFilename = pathinfo($file->localFilePath, PATHINFO_BASENAME); $file->remoteFilename = $distributionProfileDb->getThumbnailAssetFilename($entryDistributionDb, $defaultFilename, $thumbAsset->getId()); $this->filesForDistribution[] = $file; } } $distributedThumbIds = implode(',', $thumbLocalIds); } //additional assets $additionalAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->assetIds)); if (count($additionalAssets)) { $captionLocalIds = array(); foreach ($additionalAssets as $additionalAsset) { $file = new KalturaAttUverseDistributionFile(); $file->assetType = kPluginableEnumsManager::coreToApi(KalturaAssetType::getEnumClass(), $additionalAsset->getType()); $syncKey = $additionalAsset->getSyncKey(CaptionAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); $id = $additionalAsset->getId(); if (kFileSyncUtils::fileSync_exists($syncKey)) { if ($file->assetType == CaptionPlugin::getApiValue(CaptionAssetType::CAPTION) || $file->assetType == AttachmentPlugin::getApiValue(AttachmentAssetType::ATTACHMENT)) { $captionLocalIds[] = $additionalAsset->getId(); $file->assetId = $additionalAsset->getId(); $file->localFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $defaultFilename = pathinfo($file->localFilePath, PATHINFO_BASENAME); $file->remoteFilename = $distributionProfileDb->getAssetFilename($entryDistributionDb, $defaultFilename, $additionalAsset->getId()); $this->filesForDistribution[] = $file; } } } $distributedCaptionIds = implode(',', $captionLocalIds); } //putting distributed flavors ids and distributed thumbnail ids in entry distribution custom data if ($entryDistributionDb) { $entryDistributionDb->putInCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_FLAVOR_IDS, $distributedFlavorIds); $entryDistributionDb->putInCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_THUMBNAIL_IDS, $distributedThumbIds); $entryDistributionDb->putInCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_CAPTION_IDS, $distributedCaptionIds); $entryDistributionDb->save(); } else { KalturaLog::err('Entry distribution [' . $distributionJobData->entryDistributionId . '] not found'); } }
<?php error_reporting(E_ALL); require_once dirname(__FILE__) . '/../../scripts/bootstrap.php'; KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "plugins", "limelight", "*")); //KAutoloader::setClassMapFilePath(KALTURA_ROOT_PATH.'/cache/scripts/limelight/classMap.cache'); KAutoloader::setClassMapFilePath(KALTURA_ROOT_PATH . '/cache/scripts/' . basename(__FILE__) . '.cache'); KAutoloader::register(); $partnerId = 101; $partner = PartnerPeer::retrieveByPK($partnerId); if (!$partner) { die("No such partner with id [{$partnerId}]"); } //$limeLightLiveParams = LimeLightPlugin::getLimeLightLiveParams($partner); //$defaultLiveSourceType = $partner->getDefaultLiveStreamEntrySourceType(); //$liveStreamEnabled = $partner->getLiveStreamEnabled(); //$customData = unserialize($partner->getCustomData()); //$customData = $partner->getCustomDataObj(); $ST = $partner->getDefaultLiveStreamEntrySourceType(); $apiVal = kPluginableEnumsManager::coreToApi('EntrySourceType', $ST); //$entryId = '0_y3sxhrol'; //$entry = entryPeer::retrieveByPK($entryId); //$purl = $entry->getPrimaryBroadcastingUrl(); //$surl = $entry->getSecondaryBroadcastingUrl(); //$primary = $limeLightLiveParams->getLimeLightLivePrimaryBroadcastingURL(); var_dump($ST);
/** * @param int $subType * @return string */ public function fromSubType($subType) { switch ($subType) { case KalturaSourceType::AKAMAI_LIVE: case KalturaSourceType::AKAMAI_UNIVERSAL_LIVE: return $subType; break; default: return kPluginableEnumsManager::coreToApi('EntrySourceType', $subType); break; } }
/** * @param int $subType * @return string */ public function fromSubType($subType) { return kPluginableEnumsManager::coreToApi('VirusScanEngineType', $subType); }
/** * @param int $subType * @return string */ public function fromSubType($subType) { return kPluginableEnumsManager::coreToApi('IndexObjectType', $subType); }
public function fromObject($source_object) { $reflector = KalturaTypeReflectorCacher::get(get_class($this)); foreach ($this->getMapBetweenObjects() as $this_prop => $object_prop) { if (is_numeric($this_prop)) { $this_prop = $object_prop; } if (array_key_exists($object_prop, $source_object->fields)) { $value = $source_object->get($object_prop); $property = $reflector->getProperty($this_prop); if ($property->isDynamicEnum()) { $propertyType = $property->getType(); $enumType = call_user_func(array($propertyType, 'getEnumClass')); $value = kPluginableEnumsManager::coreToApi($enumType, $value); } elseif ($property->getDynamicType()) { $propertyType = $property->getDynamicType(); $enumType = call_user_func(array($propertyType, 'getEnumClass')); $values = explode(',', $value); $finalValues = array(); foreach ($values as $val) { $finalValues[] = kPluginableEnumsManager::coreToApi($enumType, $val); } $value = implode(',', $finalValues); } $this->{$this_prop} = $value; } else { KalturaLog::alert("field [{$object_prop}] was not found on filter object class [" . get_class($source_object) . "]"); } } $newOrderBy = ""; $orderByMap = $this->getOrderByMap(); if ($orderByMap) { $orderProps = explode(",", $this->orderBy); foreach ($orderProps as $prop) { $key = array_search($prop, $orderByMap); if ($key !== false) { $newOrderBy .= $key . ","; } } } if (strpos($newOrderBy, ",") === strlen($newOrderBy) - 1) { $newOrderBy = substr($newOrderBy, 0, strlen($newOrderBy) - 1); } $this->orderBy = $newOrderBy; $advancedSearch = $source_object->getAdvancedSearch(); if (is_object($advancedSearch) && $advancedSearch instanceof AdvancedSearchFilterItem) { $apiClass = $advancedSearch->getKalturaClass(); if (!class_exists($apiClass)) { KalturaLog::err("Class [{$apiClass}] not found"); } else { $this->advancedSearch = new $apiClass(); $this->advancedSearch->fromObject($advancedSearch); } } else { KalturaLog::debug("Advanced search not defined"); } }
/** * will return $max_count of objects using the peer. * The criteria will be used to filter the basic parameter, the function will encapsulate the inner logic of the BatchJob * and the exclusiveness. * * @param Criteria $c */ private static function getExclusive(Criteria $c, kExclusiveLockKey $lockKey, $max_execution_time, $number_of_objects, $jobType, $maxOffset = null) { $schd = BatchJobLockPeer::SCHEDULER_ID; $work = BatchJobLockPeer::WORKER_ID; $btch = BatchJobLockPeer::BATCH_INDEX; $stat = BatchJobLockPeer::STATUS; $atmp = BatchJobLockPeer::EXECUTION_ATTEMPTS; $expr = BatchJobLockPeer::EXPIRATION; $recheck = BatchJobLockPeer::START_AT; $partnerLoadQuota = PartnerLoadPeer::QUOTA; $schd_id = $lockKey->getSchedulerId(); $work_id = $lockKey->getWorkerId(); $btch_id = $lockKey->getBatchIndex(); $now = time(); $now_str = date('Y-m-d H:i:s', $now); $delayedJobTypes = kConf::get('delayed_job_types'); $apiJobType = kPluginableEnumsManager::coreToApi('BatchJobType', $jobType); // added to support nfs delay if (in_array($apiJobType, $delayedJobTypes)) { $interval = kConf::hasParam('nfs_safety_margin_sec') ? kConf::get('nfs_safety_margin_sec') : 5; $c->add(BatchJobLockPeer::CREATED_AT, time() - $interval, Criteria::LESS_THAN); } $c->add(BatchJobLockPeer::JOB_TYPE, $jobType); $c->add(BatchJobLockPeer::DC, kDataCenterMgr::getCurrentDcId()); $c->add(BatchJobLockPeer::BATCH_VERSION, BatchJobLockPeer::getBatchVersion($jobType), Criteria::LESS_EQUAL); $prioritizers_ratio = BatchJobLockPeer::getPrioritizersRatio($jobType); $shouldUseJoin = BatchJobLockPeer::getMaxJobsForPartner($jobType) != self::UNLIMITED_QUOTA; self::addPrioritizersCondition($c, $prioritizers_ratio, $shouldUseJoin); // Query Parts $unClosedStatuses = implode(',', BatchJobPeer::getUnClosedStatusList()); $statusCondition = "{$stat} IN ({$unClosedStatuses})"; $lockExpiredCondition = "{$expr} <= '{$now_str}'"; $pendingJobsCondition = "( {$stat} = " . BatchJob::BATCHJOB_STATUS_PENDING . " OR ( {$stat} = " . BatchJob::BATCHJOB_STATUS_RETRY . " AND {$recheck} <= '{$now_str}' ))"; $unhandledJobCondition = "{$schd} IS NULL AND {$work} IS NULL AND {$btch} IS NULL "; $newJobsCond = "({$pendingJobsCondition} AND ({$unhandledJobCondition}))"; if ($shouldUseJoin) { $partnerLoadCondition = "(({$partnerLoadQuota} > 0) OR ({$partnerLoadQuota} is null))"; $newJobsCond .= " AND {$partnerLoadCondition}"; } $jobAlreadyHandledByWorker = "{$schd} = {$schd_id} AND {$work} = {$work_id} AND {$btch} = {$btch_id}"; $max_exe_attempts = BatchJobLockPeer::getMaxExecutionAttempts($jobType); $jobWasntExecutedTooMany = "{$atmp} <= {$max_exe_attempts} OR {$atmp} IS NULL"; // Generate query $query = "\t{$statusCondition}\n\t\t\t\t\tAND\t(\n\t\t\t\t\t\t{$lockExpiredCondition}\n\t\t\t\t\t\tOR\t({$newJobsCond})\n\t\t\t\t\t\tOR ({$jobAlreadyHandledByWorker})\n\t\t\t\t\t)\n\t\t\t\t\tAND ({$jobWasntExecutedTooMany})"; $c->add($stat, $query, Criteria::CUSTOM); // In case maxOffset isn't null, we want to take the chunk out of a random offset in between. // That's usefull for load handling if ($maxOffset) { $c->setOffset(rand(0, $maxOffset)); } $c->setLimit($number_of_objects); $objects = BatchJobLockPeer::doSelect($c, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2)); return self::lockObjects($lockKey, $objects, $max_execution_time); }
/** * Get the [object_type] column value. * * @return int */ public function getObjectType() { $objectType = parent::getObjectType(); return kPluginableEnumsManager::coreToApi('BatchJobObjectType', $objectType); }
/** * @param int $subType from enum mediaParserType * @return string from enum KalturaMediaParserType */ public function fromSubType($subType) { return kPluginableEnumsManager::coreToApi('mediaParserType', $subType); }
/** * @param int $subType * @return string */ public function fromSubType($subType) { if (is_null($subType)) { return null; } return kPluginableEnumsManager::coreToApi('BulkUploadType', $subType); }
/** * @param int $subType * @return string */ public function fromSubType($subType) { return kPluginableEnumsManager::coreToApi('RecalculateCacheType', $subType); }
public function toData(BatchJob $dbBatchJob) { $dbData = null; if (is_null($this->jobType)) { $this->jobType = kPluginableEnumsManager::coreToApi('BatchJobType', $dbBatchJob->getJobType()); } switch ($dbBatchJob->getJobType()) { case KalturaBatchJobType::BULKUPLOAD: $dbData = new kBulkUploadJobData(); if (is_null($this->data)) { $this->data = new KalturaBulkUploadJobData(); } break; case KalturaBatchJobType::CONVERT: $dbData = new kConvertJobData(); if (is_null($this->data)) { $this->data = new KalturaConvertJobData(); } break; case KalturaBatchJobType::CONVERT_PROFILE: $dbData = new kConvertProfileJobData(); if (is_null($this->data)) { $this->data = new KalturaConvertProfileJobData(); } break; case KalturaBatchJobType::EXTRACT_MEDIA: $dbData = new kExtractMediaJobData(); if (is_null($this->data)) { $this->data = new KalturaExtractMediaJobData(); } break; case KalturaBatchJobType::IMPORT: $dbData = new kImportJobData(); if (is_null($this->data)) { $this->data = new KalturaImportJobData(); } break; case KalturaBatchJobType::POSTCONVERT: $dbData = new kPostConvertJobData(); if (is_null($this->data)) { $this->data = new KalturaPostConvertJobData(); } break; case KalturaBatchJobType::PULL: $dbData = new kPullJobData(); if (is_null($this->data)) { $this->data = new KalturaPullJobData(); } break; case KalturaBatchJobType::REMOTE_CONVERT: $dbData = new kRemoteConvertJobData(); if (is_null($this->data)) { $this->data = new KalturaRemoteConvertJobData(); } break; case KalturaBatchJobType::MAIL: $dbData = new kMailJobData(); if (is_null($this->data)) { $this->data = new KalturaMailJobData(); } break; case KalturaBatchJobType::NOTIFICATION: $dbData = new kNotificationJobData(); if (is_null($this->data)) { $this->data = new KalturaNotificationJobData(); } break; case KalturaBatchJobType::BULKDOWNLOAD: $dbData = new kBulkDownloadJobData(); if (is_null($this->data)) { $this->data = new KalturaBulkDownloadJobData(); } break; case KalturaBatchJobType::FLATTEN: $dbData = new kFlattenJobData(); if (is_null($this->data)) { $this->data = new KalturaFlattenJobData(); } break; case KalturaBatchJobType::PROVISION_PROVIDE: case KalturaBatchJobType::PROVISION_DELETE: $dbData = new kProvisionJobData(); if (is_null($this->data)) { $this->data = new KalturaProvisionJobData(); } break; case KalturaBatchJobType::CONVERT_COLLECTION: $dbData = new kConvertCollectionJobData(); if (is_null($this->data)) { $this->data = new KalturaConvertCollectionJobData(); } break; case KalturaBatchJobType::STORAGE_EXPORT: $dbData = new kStorageExportJobData(); if (is_null($this->data)) { $this->data = new KalturaStorageExportJobData(); } break; case KalturaBatchJobType::STORAGE_DELETE: $dbData = new kStorageDeleteJobData(); if (is_null($this->data)) { $this->data = new KalturaStorageDeleteJobData(); } break; case KalturaBatchJobType::CAPTURE_THUMB: $dbData = new kCaptureThumbJobData(); if (is_null($this->data)) { $this->data = new KalturaCaptureThumbJobData(); } break; default: $dbData = KalturaPluginManager::loadObject('kJobData', $dbBatchJob->getJobType()); if (is_null($this->data)) { $this->data = KalturaPluginManager::loadObject('KalturaJobData', $this->jobType); } } if (is_null($dbBatchJob->getData())) { $dbBatchJob->setData($dbData); } if ($this->data instanceof KalturaJobData) { $dbData = $this->data->toObject($dbBatchJob->getData()); $dbBatchJob->setData($dbData); } return $dbData; }