-
Notifications
You must be signed in to change notification settings - Fork 184
PLAT-26004: drm key management policy set from drop folder xml upload… #14089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| <?php | ||
| /** | ||
| * Enable DRM key management policy ingestion from XML bulk upload | ||
| * @package plugins.drm | ||
| */ | ||
| class DrmBulkUploadXmlPlugin extends KalturaPlugin implements IKalturaPending, IKalturaSchemaContributor, IKalturaBulkUploadXmlHandler | ||
| { | ||
| const PLUGIN_NAME = 'drmBulkUploadXml'; | ||
| const BULK_UPLOAD_XML_PLUGIN_NAME = 'bulkUploadXml'; | ||
|
|
||
| /* (non-PHPdoc) | ||
| * @see IKalturaPlugin::getPluginName() | ||
| */ | ||
| public static function getPluginName() | ||
| { | ||
| return self::PLUGIN_NAME; | ||
| } | ||
|
|
||
| /* (non-PHPdoc) | ||
| * @see IKalturaPending::dependsOn() | ||
| */ | ||
| public static function dependsOn() | ||
| { | ||
| $bulkUploadXmlDependency = new KalturaDependency(self::BULK_UPLOAD_XML_PLUGIN_NAME); | ||
| $drmDependency = new KalturaDependency(DrmPlugin::getPluginName()); | ||
|
|
||
| return array($bulkUploadXmlDependency, $drmDependency); | ||
| } | ||
|
|
||
| /* (non-PHPdoc) | ||
| * @see IKalturaSchemaContributor::contributeToSchema() | ||
| */ | ||
| 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_drmConfiguration"> | ||
| <xs:sequence> | ||
| <xs:element name="keyManagementPolicy" minOccurs="0" maxOccurs="1" type="xs:int"> | ||
| <xs:annotation> | ||
| <xs:documentation> | ||
| The DRM key management policy to apply to this entry.<br/> | ||
| Values correspond to the DrmKeyManagementPolicy enum:<br/> | ||
| 0 = UNKNOWN<br/> | ||
| 1 = CLEAR<br/> | ||
| 2 = SHARED_KEY<br/> | ||
| 3 = ALL_VIDEO<br/> | ||
| 4 = SD_HD<br/> | ||
| 5 = SD_HD_UHD<br/> | ||
| 6 = SD_HD_UHD1_UHD2<br/> | ||
| 7 = SD_HD1_HD2_UHD1_UHD2<br/> | ||
| 8 = SD_HD1_HD2_UHD<br/> | ||
| 9 = SDHD1_HD2_UHD<br/> | ||
| 10 = SDHD1_HD2_UHD1_UHD2<br/> | ||
| </xs:documentation> | ||
| </xs:annotation> | ||
| </xs:element> | ||
| </xs:sequence> | ||
| </xs:complexType> | ||
|
|
||
| <xs:element name="drmConfiguration" type="T_drmConfiguration" substitutionGroup="item-extension"> | ||
| <xs:annotation> | ||
| <xs:documentation>DRM key management policy configuration for this entry</xs:documentation> | ||
| <xs:appinfo> | ||
| <example> | ||
| <drmConfiguration> | ||
| <keyManagementPolicy>3</keyManagementPolicy> | ||
| </drmConfiguration> | ||
| </example> | ||
| </xs:appinfo> | ||
| </xs:annotation> | ||
| </xs:element> | ||
| '; | ||
|
|
||
| return $xsd; | ||
| } | ||
|
|
||
| /* (non-PHPdoc) | ||
| * @see IKalturaBulkUploadXmlHandler::configureBulkUploadXmlHandler() | ||
| */ | ||
| public function configureBulkUploadXmlHandler(BulkUploadEngineXml $xmlBulkUploadEngine) | ||
| { | ||
|
|
||
| } | ||
|
|
||
| /* (non-PHPdoc) | ||
| * @see IKalturaBulkUploadXmlHandler::handleItemAdded() | ||
| */ | ||
| public function handleItemAdded(KalturaObjectBase $object, SimpleXMLElement $item) | ||
| { | ||
| if(!($object instanceof KalturaBaseEntry)) | ||
| return; | ||
|
|
||
| if(!isset($item->drmConfiguration)) | ||
| return; | ||
|
|
||
| $this->handleDrmConfiguration($object->id, $item); | ||
| } | ||
|
|
||
| /* (non-PHPdoc) | ||
| * @see IKalturaBulkUploadXmlHandler::handleItemUpdated() | ||
| */ | ||
| public function handleItemUpdated(KalturaObjectBase $object, SimpleXMLElement $item) | ||
| { | ||
| if(!($object instanceof KalturaBaseEntry)) | ||
| return; | ||
|
|
||
| if(!isset($item->drmConfiguration)) | ||
| return; | ||
|
|
||
| $this->handleDrmConfiguration($object->id, $item); | ||
| } | ||
|
|
||
| /* (non-PHPdoc) | ||
| * @see IKalturaBulkUploadXmlHandler::handleItemDeleted() | ||
| */ | ||
| public function handleItemDeleted(KalturaObjectBase $object, SimpleXMLElement $item) | ||
| { | ||
| // No handling required | ||
| } | ||
|
|
||
| /* (non-PHPdoc) | ||
| * @see IKalturaBulkUploadXmlHandler::getContainerName() | ||
| */ | ||
| public function getContainerName() | ||
| { | ||
| return 'drmConfiguration'; | ||
| } | ||
|
|
||
| /** | ||
| * Set the DRM key management policy on the entry via the keyManagementPolicy service. | ||
| * | ||
| * @param string $entryId | ||
| * @param SimpleXMLElement $item | ||
| */ | ||
| private function handleDrmConfiguration($entryId, SimpleXMLElement $item) | ||
| { | ||
| KalturaLog::debug("Handling DRM key management policy for entry: " . $entryId); | ||
|
|
||
| $policy = new KalturaKeyManagementPolicy(); | ||
| $policy->keyManagementPolicy = isset($item->drmConfiguration->keyManagementPolicy) | ||
| ? (int)$item->drmConfiguration->keyManagementPolicy | ||
| : null; | ||
| try | ||
| { | ||
| KBatchBase::$kClient->keyManagementPolicy->update( | ||
| KalturaKeyManagementPolicyObjectType::ENTRY, | ||
| $entryId, | ||
| $policy | ||
| ); | ||
| } | ||
| catch (Exception $e) | ||
| { | ||
| if ($e->getCode() == 'ENTRY_DRM_KEY_MANAGEMENT_POLICY_ALREADY_SET') | ||
| { | ||
| KalturaLog::info('DRM key management policy already set for entry [' . $entryId . '], skipping.'); | ||
| return; | ||
| } | ||
| KalturaLog::err('drmConfiguration handling failed for entry [' . $entryId . ']: ' . $e->getMessage()); | ||
| throw $e; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,16 +92,15 @@ public function getAction($objectType, $objectId) | |
| * @param string $objectId | ||
| * @param KalturaKeyManagementPolicy $keyManagementPolicy | ||
| * @return KalturaKeyManagementPolicy | ||
| * @throws KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL | ||
| * @throws KalturaErrors::INVALID_ENUM_VALUE | ||
| * @throws KalturaErrors::INVALID_PARTNER_ID | ||
| * @throws KalturaErrors::INVALID_OBJECT_ID | ||
| * @throws KalturaErrors::PLUGIN_NOT_AVAILABLE_FOR_PARTNER | ||
| * @throws DrmErrors::ENTRY_DRM_KEY_MANAGEMENT_POLICY_ALREADY_SET | ||
| * @ksIgnored | ||
| */ | ||
| public function updateAction($objectType, $objectId, KalturaKeyManagementPolicy $keyManagementPolicy) | ||
| { | ||
| $keyManagementPolicy->validatePropertyNotNull('keyManagementPolicy'); | ||
| $this->validateObjectType($objectType); | ||
|
|
||
| $result = new KalturaKeyManagementPolicy(); | ||
|
|
@@ -115,10 +114,36 @@ public function updateAction($objectType, $objectId, KalturaKeyManagementPolicy | |
| else | ||
| { | ||
| $entry = $this->getValidatedEntry($objectId); | ||
| $entry->setDrmKeyManagementPolicy($keyManagementPolicy->keyManagementPolicy); | ||
|
|
||
| $existingStatus = $entry->getDrmKeyManagementPolicy(); | ||
| if(!is_null($existingStatus)) | ||
| { | ||
| throw new KalturaAPIException(DrmErrors::ENTRY_DRM_KEY_MANAGEMENT_POLICY_ALREADY_SET, $entry->getId()); | ||
| } | ||
|
|
||
| $this->setDrmKeyManagementPolicyForEntry($entry, $keyManagementPolicy); | ||
| $entry->save(); | ||
| $result->keyManagementPolicy = DrmPlugin::getDrmKeyManagementPolicy($entry); | ||
| } | ||
| return $result; | ||
| } | ||
|
|
||
| protected function setDrmKeyManagementPolicyForEntry(entry $entry, KalturaKeyManagementPolicy $keyManagementPolicy) | ||
| { | ||
| $partner = $entry->getPartner(); | ||
| $partnerDrmKeyManagementPolicy = $partner->getDrmKeyManagementPolicy(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add null check before refferencing the partner |
||
|
|
||
| if(!is_null($keyManagementPolicy->keyManagementPolicy)) | ||
| { | ||
| $entry->setDrmKeyManagementPolicy($keyManagementPolicy->keyManagementPolicy); | ||
| } | ||
| elseif(!is_null($partnerDrmKeyManagementPolicy)) | ||
| { | ||
| $entry->setDrmKeyManagementPolicy($partnerDrmKeyManagementPolicy); | ||
| } | ||
| else | ||
| { | ||
| $entry->setDrmKeyManagementPolicy(DrmKeyManagementPolicy::UNKNOWN); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 3?