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; }
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); }
/** * 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(); }
/** * @param string $subType * @return int */ public function toSubType($subType) { switch ($subType) { case KalturaDropFolderType::FTP: case KalturaDropFolderType::SFTP: case KalturaDropFolderType::SCP: case KalturaDropFolderType::S3: return $subType; default: return kPluginableEnumsManager::apiToCore('KalturaDropFolderType', $subType); } }
/** * @param string $subType * @return int */ public function toSubType($subType) { switch ($subType) { case KalturaStorageProfileProtocol::SFTP: case KalturaStorageProfileProtocol::FTP: case KalturaStorageProfileProtocol::SCP: case KalturaStorageProfileProtocol::S3: case KalturaStorageProfileProtocol::KALTURA_DC: return $subType; default: return kPluginableEnumsManager::apiToCore('KalturaStorageProfileProtocol', $subType); } }
public function toObject($object = null, $skip = array()) { if (is_null($object)) { $object = new GenericDistributionProfile(); } $object = parent::toObject($object, $skip); foreach (self::$actions as $action) { $actionAttribute = "{$action}Action"; if (!$this->{$actionAttribute}) { continue; } $typeReflector = KalturaTypeReflectorCacher::get(get_class($this->{$actionAttribute})); foreach ($this->{$actionAttribute}->getMapBetweenObjects() as $this_prop => $object_prop) { if (is_numeric($this_prop)) { $this_prop = $object_prop; } if (in_array($this_prop, $skip)) { continue; } $value = $this->{$actionAttribute}->{$this_prop}; if ($value !== null) { $propertyInfo = $typeReflector->getProperty($this_prop); if (!$propertyInfo) { KalturaLog::alert("property [{$this_prop}] was not found on object class [" . get_class($object) . "]"); } else { if ($propertyInfo->isDynamicEnum()) { $propertyType = $propertyInfo->getType(); $enumType = call_user_func(array($propertyType, 'getEnumClass')); $value = kPluginableEnumsManager::apiToCore($enumType, $value); } } if ($value !== null) { $setter_callback = array($object, "set{$object_prop}"); if (is_callable($setter_callback)) { call_user_func_array($setter_callback, array($value, $action)); } else { KalturaLog::alert("setter for property [{$object_prop}] was not found on object class [" . get_class($object) . "]"); } } } } } $object->setUpdateRequiredEntryFields(explode(',', $this->updateRequiredEntryFields)); $object->setUpdateRequiredMetadataXpaths(explode(',', $this->updateRequiredMetadataXPaths)); return $object; }
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; }
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); }
/** * 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; }
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; }
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 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; }
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); }
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; }
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; }
/** * 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; }
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; }
/** * 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 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; }
/** * 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; }
/** * @param string $subType from enum KalturaMediaParserType * @return int from enum mediaParserType */ public function toSubType($subType) { return kPluginableEnumsManager::apiToCore('mediaParserType', $subType); }
/** * @param KalturaBaseEntry $entry * @param entry $dbEntry * @return entry */ protected function prepareEntryForInsert(KalturaBaseEntry $entry, entry $dbEntry = null) { // create a default name if none was given if (!$entry->name) { $entry->name = $this->getPartnerId() . '_' . time(); } if ($entry->licenseType === null) { $entry->licenseType = KalturaLicenseType::UNKNOWN; } // first copy all the properties to the db entry, then we'll check for security stuff if (!$dbEntry) { $entryType = kPluginableEnumsManager::apiToCore('entryType', $entry->type); $class = entryPeer::getEntryClassByType($entryType); KalturaLog::debug("Creating new entry of API type [{$entry->type}] core type [{$entryType}] class [{$class}]"); $dbEntry = new $class(); } $dbEntry = $entry->toInsertableObject($dbEntry); $this->checkAndSetValidUserInsert($entry, $dbEntry); $this->checkAdminOnlyInsertProperties($entry); $this->validateAccessControlId($entry); $this->validateEntryScheduleDates($entry, $dbEntry); $dbEntry->setPartnerId($this->getPartnerId()); $dbEntry->setSubpId($this->getPartnerId() * 100); $dbEntry->setDefaultModerationStatus(); return $dbEntry; }
public static function contributeToSchema($type) { $coreType = kPluginableEnumsManager::apiToCore('SchemaType', $type); if ($coreType != BulkUploadXmlPlugin::getSchemaTypeCoreValue(XmlSchemaType::BULK_UPLOAD_XML) && $coreType != BulkUploadXmlPlugin::getSchemaTypeCoreValue(XmlSchemaType::BULK_UPLOAD_RESULT_XML)) { return null; } $xsd = ' <!-- ' . self::getPluginName() . ' --> <xs:complexType name="T_subTitles"> <xs:sequence> <xs:element name="action" minOccurs="0" maxOccurs="1"> <xs:annotation> <xs:documentation> The action to apply:<br/> Update - Update existing subtitles<br/> </xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="update" /> </xs:restriction> </xs:simpleType> </xs:element> <xs:element ref="subTitle" maxOccurs="unbounded" minOccurs="0"> <xs:annotation> <xs:documentation>All subTitles elements</xs:documentation> </xs:annotation> </xs:element> </xs:sequence> </xs:complexType> <xs:complexType name="T_subTitle"> <xs:sequence> <xs:element name="tags" minOccurs="1" maxOccurs="1" type="T_tags"> <xs:annotation> <xs:documentation>Specifies specific tags you want to set for the flavor asset</xs:documentation> </xs:annotation> </xs:element> <xs:choice minOccurs="1" maxOccurs="1"> <xs:element ref="serverFileContentResource" minOccurs="1" maxOccurs="1"> <xs:annotation> <xs:documentation>Specifies that content ingestion location is on a Kaltura hosted server</xs:documentation> </xs:annotation> </xs:element> <xs:element ref="urlContentResource" minOccurs="1" maxOccurs="1"> <xs:annotation> <xs:documentation>Specifies that content file location is a URL (http,ftp)</xs:documentation> </xs:annotation> </xs:element> <xs:element ref="remoteStorageContentResource" minOccurs="1" maxOccurs="1"> <xs:annotation> <xs:documentation>Specifies that content file location is a path within a Kaltura defined remote storage</xs:documentation> </xs:annotation> </xs:element> <xs:element ref="remoteStorageContentResources" minOccurs="1" maxOccurs="1"> <xs:annotation> <xs:documentation>Set of content files within several Kaltura defined remote storages</xs:documentation> </xs:annotation> </xs:element> <xs:element ref="entryContentResource" minOccurs="1" maxOccurs="1"> <xs:annotation> <xs:documentation>Specifies that content is a Kaltura entry</xs:documentation> </xs:annotation> </xs:element> <xs:element ref="assetContentResource" minOccurs="1" maxOccurs="1"> <xs:annotation> <xs:documentation>Specifies that content is a Kaltura asset</xs:documentation> </xs:annotation> </xs:element> <xs:element ref="contentResource-extension" minOccurs="1" maxOccurs="1" /> </xs:choice> <xs:element ref="subtitle-extension" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> <xs:attribute name="captionParamsId" type="xs:int" use="optional"> <xs:annotation> <xs:documentation>The asset id to be updated with this resource used only for update</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name="captionParams" type="xs:string" use="optional"> <xs:annotation> <xs:documentation>System name of caption params to be associated with the caption asset</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name="captionAssetId" type="xs:string" use="optional"> <xs:annotation> <xs:documentation>ID of caption params to be associated with the caption asset</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name="isDefault" type="xs:boolean" use="optional"> <xs:annotation> <xs:documentation>Specifies if this asset is the default caption asset</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name="format" type="KalturaCaptionType" use="optional"> <xs:annotation> <xs:documentation>Caption asset file format</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name="lang" type="KalturaLanguage" use="optional"> <xs:annotation> <xs:documentation>Caption asset file language</xs:documentation> </xs:annotation> </xs:attribute> </xs:complexType> <xs:element name="subtitle-extension" /> <xs:element name="subTitles" type="T_subTitles" substitutionGroup="item-extension"> <xs:annotation> <xs:documentation>All subTitles elements</xs:documentation> <xs:appinfo> <example> <subTitles> <action>update</action> <subTitle>...</subTitle> <subTitle>...</subTitle> <subTitle>...</subTitle> </subTitles> </example> </xs:appinfo> </xs:annotation> </xs:element> <xs:element name="subTitle" type="T_subTitle"> <xs:annotation> <xs:documentation>A single caption asset element</xs:documentation> <xs:appinfo> <example> <subTitle isDefault="true" format="2" lang="Hebrew"> <tags> <tag>tag1</tag> <tag>tag2</tag> </tags> <urlContentResource url="http://my.domain/path/caption.srt"/> </subTitle> </example> </xs:appinfo> </xs:annotation> </xs:element> '; return $xsd; }
/** * @param string $subType is the provider type * @return int */ public function toSubType($subType) { return kPluginableEnumsManager::apiToCore('EventNotificationTemplateType', $subType); }
/** * @return int id of dynamic enum in the DB. */ public static function getBaseEntryCloneOptionsCoreValue($valueName) { $value = self::getPluginName() . IKalturaEnumerator::PLUGIN_VALUE_DELIMITER . $valueName; return kPluginableEnumsManager::apiToCore('BaseEntryCloneOptions', $value); }
/** * @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); }
/** * @param string $subType * @return int */ public function toSubType($subType) { return kPluginableEnumsManager::apiToCore('RecalculateCacheType', $subType); }
/** * Adds a metadata object associated with Kaltura object * * @param int $metadataProfileId * @param KalturaMetadataObjectType $objectType * @param string $objectId * @return Metadata * @throws MetadataErrors::METADATA_ALREADY_EXISTS * @throws MetadataErrors::INVALID_METADATA_PROFILE * @throws MetadataErrors::INVALID_METADATA_PROFILE_TYPE * @throws MetadataErrors::INVALID_METADATA_OBJECT */ protected function addMetadata($metadataProfileId, $objectType, $objectId) { $objectType = kPluginableEnumsManager::apiToCore('MetadataObjectType', $objectType); $check = MetadataPeer::retrieveByObject($metadataProfileId, $objectType, $objectId); if ($check) { throw new KalturaAPIException(MetadataErrors::METADATA_ALREADY_EXISTS, $check->getId()); } $dbMetadataProfile = MetadataProfilePeer::retrieveByPK($metadataProfileId); if (!$dbMetadataProfile) { throw new KalturaAPIException(MetadataErrors::INVALID_METADATA_PROFILE, $metadataProfileId); } if ($dbMetadataProfile->getObjectType() != $objectType) { throw new KalturaAPIException(MetadataErrors::INVALID_METADATA_PROFILE_TYPE, $dbMetadataProfile->getObjectType()); } $dbMetadata = new Metadata(); $dbMetadata->setPartnerId($this->getPartnerId()); $dbMetadata->setMetadataProfileId($metadataProfileId); $dbMetadata->setMetadataProfileVersion($dbMetadataProfile->getVersion()); $dbMetadata->setObjectType($objectType); $dbMetadata->setObjectId($objectId); $dbMetadata->setStatus(KalturaMetadataStatus::VALID); $dbMetadata->setLikeNew(true); // dynamic objects are metadata only, skip validating object id if ($objectType != KalturaMetadataObjectType::DYNAMIC_OBJECT) { // validate object exists $object = kMetadataManager::getObjectFromPeer($dbMetadata); if (!$object) { throw new KalturaAPIException(MetadataErrors::INVALID_METADATA_OBJECT, $objectId); } } $dbMetadata->save(); $this->deleteOldVersions($dbMetadata); return $dbMetadata; }
public static function getCuePointTypeCoreValue($valueName) { $value = self::getPluginName() . IKalturaEnumerator::PLUGIN_VALUE_DELIMITER . $valueName; return kPluginableEnumsManager::apiToCore('CuePointType', $value); }
/** * batch retryJobAction aborts and returns the status of task * * @action retryJob * @param int $jobId the id of the job * @param KalturaBatchJobType $jobType the type of the job * @return KalturaBatchJobResponse */ function retryJobAction($jobId, $jobType) { $dbJobType = kPluginableEnumsManager::apiToCore('BatchJobType', $jobType); kJobsManager::retryJob($jobId, $dbJobType); return $this->getStatusAction($jobId, $jobType); }