diff --git a/plugins/content_distribution/providers/tvinci/lib/feed/TvinciDistributionFeedHelper.php b/plugins/content_distribution/providers/tvinci/lib/feed/TvinciDistributionFeedHelper.php
index 0def3df919b..86a611de3b5 100644
--- a/plugins/content_distribution/providers/tvinci/lib/feed/TvinciDistributionFeedHelper.php
+++ b/plugins/content_distribution/providers/tvinci/lib/feed/TvinciDistributionFeedHelper.php
@@ -117,6 +117,11 @@ private function createArgumentsForXSLT()
$tagsDoc->appendChild($tagsConfiguration);
$arguments['tagsparam'] = $tagsDoc->saveXML();
+ $partner = $this->entry->getPartner();
+ if ($partner && $partner->getPluginEnabled(DrmPlugin::PLUGIN_NAME))
+ {
+ $arguments['keyManagementPolicy'] = (string)DrmPlugin::getDrmKeyManagementPolicy($this->entry);
+ }
return $arguments;
}
@@ -288,4 +293,4 @@ private function createAppendXml($tag, $tagsDoc, $xmlNodeName, $propertyName)
return $nameNode;
}
-}
\ No newline at end of file
+}
diff --git a/plugins/content_distribution/providers/tvinci/lib/xml/tvinci_default.xslt b/plugins/content_distribution/providers/tvinci/lib/xml/tvinci_default.xslt
index d633305b35e..bba8427d996 100644
--- a/plugins/content_distribution/providers/tvinci/lib/xml/tvinci_default.xslt
+++ b/plugins/content_distribution/providers/tvinci/lib/xml/tvinci_default.xslt
@@ -102,6 +102,8 @@
+
+
@@ -244,6 +246,11 @@
+
+
+
+
+
diff --git a/plugins/drm/DrmBulkUploadXmlPlugin.php b/plugins/drm/DrmBulkUploadXmlPlugin.php
new file mode 100644
index 00000000000..0e304b3c969
--- /dev/null
+++ b/plugins/drm/DrmBulkUploadXmlPlugin.php
@@ -0,0 +1,181 @@
+
+
+
+
+
+
+
+ The DRM key management policy to apply to this entry.
+ Values correspond to the DrmKeyManagementPolicy enum:
+ 0 = UNKNOWN
+ 1 = CLEAR
+ 2 = SHARED_KEY
+ 3 = ALL_VIDEO
+ 4 = SD_HD
+ 5 = SD_HD_UHD
+ 6 = SD_HD_UHD1_UHD2
+ 7 = SD_HD1_HD2_UHD1_UHD2
+ 8 = SD_HD1_HD2_UHD
+ 9 = SDHD1_HD2_UHD
+ 10 = SDHD1_HD2_UHD1_UHD2
+ If omitted, the entry inherits the partner-level DRM key management policy.
+ If no partner-level policy is set either, the policy defaults to UNKNOWN (0).
+
+
+
+
+
+
+
+
+ DRM key management policy configuration for this entry
+
+
+
+ 3
+
+
+
+
+
+ ';
+
+ 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();
+ if (isset($item->drmConfiguration->keyManagementPolicy))
+ {
+ $policy->keyManagementPolicy = (int)$item->drmConfiguration->keyManagementPolicy;
+ }
+ else
+ {
+ KalturaLog::warning('No keyManagementPolicy specified for entry [' . $entryId . '], will use partner/default fallback.');
+ $policy->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;
+ }
+ }
+}
diff --git a/plugins/drm/lib/api/exceptions/DrmErrors.php b/plugins/drm/lib/api/exceptions/DrmErrors.php
index 8b1c2e2bad1..d1ad26097ed 100644
--- a/plugins/drm/lib/api/exceptions/DrmErrors.php
+++ b/plugins/drm/lib/api/exceptions/DrmErrors.php
@@ -7,4 +7,5 @@ class DrmErrors
{
const ACTIVE_PROVIDER_PROFILE_ALREADY_EXIST = "ACTIVE_PROVIDER_PROFILE_ALREADY_EXIST;PROVIDER;Active profile for provider [@PROVIDER@] already exists.";
const DRM_POLICY_DUPLICATE_SYSTEM_NAME = "DRM_POLICY_DUPLICATE_SYSTEM_NAME;SYSTEM_NAME;Drm policy with system name [@SYSTEM_NAME@] already exists.";
+ const ENTRY_DRM_KEY_MANAGEMENT_POLICY_ALREADY_SET = "ENTRY_DRM_KEY_MANAGEMENT_POLICY_ALREADY_SET;ENTRY_ID;DRM key management policy is already set for entry [@ENTRY_ID@] and cannot be changed.";
}
diff --git a/plugins/drm/services/DrmKeyManagementPolicyService.php b/plugins/drm/services/DrmKeyManagementPolicyService.php
index 691a9ee9936..f8f7a07560d 100644
--- a/plugins/drm/services/DrmKeyManagementPolicyService.php
+++ b/plugins/drm/services/DrmKeyManagementPolicyService.php
@@ -92,21 +92,22 @@ 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
+ * @throws KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL
* @ksIgnored
*/
public function updateAction($objectType, $objectId, KalturaKeyManagementPolicy $keyManagementPolicy)
{
- $keyManagementPolicy->validatePropertyNotNull('keyManagementPolicy');
$this->validateObjectType($objectType);
$result = new KalturaKeyManagementPolicy();
if ($objectType == KeyManagementPolicyObjectType::PARTNER)
{
+ $keyManagementPolicy->validatePropertyNotNull('keyManagementPolicy');
$partner = $this->getValidatedPartner($objectId);
$partner->setDrmKeyManagementPolicy($keyManagementPolicy->keyManagementPolicy);
$partner->save();
@@ -115,10 +116,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 = !is_null($partner) ? $partner->getDrmKeyManagementPolicy() : null;
+
+ if(!is_null($keyManagementPolicy->keyManagementPolicy))
+ {
+ $entry->setDrmKeyManagementPolicy($keyManagementPolicy->keyManagementPolicy);
+ }
+ elseif(!is_null($partnerDrmKeyManagementPolicy))
+ {
+ $entry->setDrmKeyManagementPolicy($partnerDrmKeyManagementPolicy);
+ }
+ else
+ {
+ $entry->setDrmKeyManagementPolicy(DrmKeyManagementPolicy::UNKNOWN);
+ }
+ }
}