From add071bc33964c3235e01d70093a0dbb20969b85 Mon Sep 17 00:00:00 2001 From: yossipapi Date: Mon, 23 Jun 2014 18:04:55 +0300 Subject: [PATCH] change filesync subtype of the manifest flavor to ASSET instead ISM --- .../actions/playManifestAction.class.php | 10 +++++++++- .../extwidget/actions/serveIsmAction.class.php | 3 ++- .../model/DeliveryProfileAkamaiSilverLight.php | 15 ++++++++++++--- alpha/lib/model/asset.php | 4 +++- .../ismIndex/lib/KOperationEngineIsmManifest.php | 2 +- .../ismIndex/lib/kIsmIndexEventsConsumer.php | 4 ++-- 6 files changed, 29 insertions(+), 9 deletions(-) diff --git a/alpha/apps/kaltura/modules/extwidget/actions/playManifestAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/playManifestAction.class.php index d090f6b0cdf..36343d6e72f 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/playManifestAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/playManifestAction.class.php @@ -358,12 +358,20 @@ protected function getFlavorKeyByTag($flavorAssets, $tag, $syncKeyType) { protected function initSilverLightManifest($flavorAssets) { - $key = $this->getFlavorKeyByTag($flavorAssets, assetParams::TAG_ISM_MANIFEST, flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISM); + $key = $this->getFlavorKeyByTag($flavorAssets, assetParams::TAG_ISM_MANIFEST, flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); if(!$key) $key = $this->entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM); $localFileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($key); + + //To Remove - Until the migration process from asset sub type 3 to asset sub type 1 will be completed we need to support both formats + if(!$localFileSync) + { + $key = $this->getFlavorKeyByTag($flavorAssets, assetParams::TAG_ISM_MANIFEST, flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISM); + $localFileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($key); + } + $remoteFileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key); if ($this->shouldUseLocalFlavors($localFileSync, $remoteFileSync)) { diff --git a/alpha/apps/kaltura/modules/extwidget/actions/serveIsmAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/serveIsmAction.class.php index fa73f01c4e9..221466291fe 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/serveIsmAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/serveIsmAction.class.php @@ -80,7 +80,8 @@ private function getFileSyncKey($objectId, $type) switch ($type) { case 'ism': - if($subType == flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISM) + //To Remove - Until the migration process from asset sub type 3 to asset sub type 1 will be completed we need to support both formats + if($subType == flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET || $subType == flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISM) $isAsset = true; else $subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM; diff --git a/alpha/lib/model/DeliveryProfileAkamaiSilverLight.php b/alpha/lib/model/DeliveryProfileAkamaiSilverLight.php index 8eac2c6aa9a..47989f68fba 100644 --- a/alpha/lib/model/DeliveryProfileAkamaiSilverLight.php +++ b/alpha/lib/model/DeliveryProfileAkamaiSilverLight.php @@ -11,13 +11,22 @@ protected function doGetFileSyncUrl(FileSync $fileSync) return parent::doGetFileSyncUrl($fileSync); $partnerPath = myPartnerUtils::getUrlForPartner($fileSync->getPartnerId(), $fileSync->getPartnerId() * 100); + $objectSubType = $fileSync->getObjectSubType(); - if($fileSync->getObjectType() == FileSyncObjectType::ENTRY && $fileSync->getObjectSubType() == entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM) + if($fileSync->getObjectType() == FileSyncObjectType::ENTRY && $objectSubType == entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM) return $this->doGetServeIsmUrl($fileSync, $partnerPath, $storage); - - if($fileSync->getObjectType() == FileSyncObjectType::FLAVOR_ASSET && $fileSync->getObjectSubType() == flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISM) + + //To Remove - Until the migration process from asset sub type 3 to asset sub type 1 will be completed we need to support both formats + if($fileSync->getObjectType() == FileSyncObjectType::FLAVOR_ASSET && $objectSubType == flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISM) return $this->doGetServeIsmUrl($fileSync, $partnerPath, $storage); + if($fileSync->getObjectType() == FileSyncObjectType::FLAVOR_ASSET && $objectSubType == flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET) + { + $asset = assetPeer::retrieveById($fileSync->getObjectId()); + if($asset->hasTag(assetParams::TAG_ISM_MANIFEST)) + return $this->doGetServeIsmUrl($fileSync, $partnerPath, $storage); + } + return parent::doGetFileSyncUrl($fileSync); } diff --git a/alpha/lib/model/asset.php b/alpha/lib/model/asset.php index 73d879fe416..e8cdf46d418 100644 --- a/alpha/lib/model/asset.php +++ b/alpha/lib/model/asset.php @@ -368,7 +368,9 @@ public function generateFileName( $sub_type, $version = null) { case self::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET: $ext = ''; - if($this->getFileExt()) + if($this->hasTag(assetParams::TAG_ISM_MANIFEST)) + $ext = ".ism"; + else if($this->getFileExt()) $ext = '.' . $this->getFileExt(); return $fileName . $ext; diff --git a/plugins/transcoding/ismIndex/lib/KOperationEngineIsmManifest.php b/plugins/transcoding/ismIndex/lib/KOperationEngineIsmManifest.php index 575578305df..3589af6384e 100644 --- a/plugins/transcoding/ismIndex/lib/KOperationEngineIsmManifest.php +++ b/plugins/transcoding/ismIndex/lib/KOperationEngineIsmManifest.php @@ -37,7 +37,7 @@ protected function doOperation() $destFileSyncDescArr = array(); $fileSyncDesc = new KalturaDestFileSyncDescriptor(); $fileSyncDesc->fileSyncLocalPath = $ismFilePath; - $fileSyncDesc->fileSyncObjectSubType = 3; //".ism"; + $fileSyncDesc->fileSyncObjectSubType = 1; //".ism"; $destFileSyncDescArr[] = $fileSyncDesc; $fileSyncDesc = new KalturaDestFileSyncDescriptor(); diff --git a/plugins/transcoding/ismIndex/lib/kIsmIndexEventsConsumer.php b/plugins/transcoding/ismIndex/lib/kIsmIndexEventsConsumer.php index ebad8f930da..9a4124bb1ef 100644 --- a/plugins/transcoding/ismIndex/lib/kIsmIndexEventsConsumer.php +++ b/plugins/transcoding/ismIndex/lib/kIsmIndexEventsConsumer.php @@ -25,7 +25,7 @@ public function shouldConsumeChangedEvent(BaseObject $object, array $modifiedCol public function objectChanged(BaseObject $object, array $modifiedColumns) { // replacing the ismc file name in the ism file - $ismPrevVersionFileSyncKey = $object->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISM); + $ismPrevVersionFileSyncKey = $object->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); $ismContents = kFileSyncUtils::file_get_contents($ismPrevVersionFileSyncKey); $ismcPrevVersionFileSyncKey = $object->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISMC); @@ -47,7 +47,7 @@ public function objectChanged(BaseObject $object, array $modifiedColumns) $tmpPath = kFileSyncUtils::getLocalFilePathForKey($ismPrevVersionFileSyncKey).'.tmp'; file_put_contents($tmpPath, $ismXml->asXML()); - kFileSyncUtils::moveFromFile($tmpPath, $object->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISM)); + kFileSyncUtils::moveFromFile($tmpPath, $object->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET)); return true; }