Exemplo n.º 1
0
 /**
  * Add new Syndication Feed
  * 
  * @action add
  * @param KalturaBaseSyndicationFeed $syndicationFeed
  * @return KalturaBaseSyndicationFeed 
  */
 public function addAction(KalturaBaseSyndicationFeed $syndicationFeed)
 {
     $syndicationFeed->validatePlaylistId();
     $syndicationFeed->validateStorageId($this->getPartnerId());
     if ($syndicationFeed instanceof KalturaGenericXsltSyndicationFeed) {
         $syndicationFeed->validatePropertyNotNull('xslt');
         $syndicationFeedDB = new genericSyndicationFeed();
         $syndicationFeedDB->incrementVersion();
     } else {
         $syndicationFeedDB = new syndicationFeed();
     }
     $syndicationFeed->toInsertableObject($syndicationFeedDB);
     $syndicationFeedDB->setPartnerId($this->getPartnerId());
     $syndicationFeedDB->setStatus(KalturaSyndicationFeedStatus::ACTIVE);
     $syndicationFeedDB->save();
     if ($syndicationFeed->addToDefaultConversionProfile) {
         $partner = PartnerPeer::retrieveByPK($this->getPartnerId());
         $c = new Criteria();
         $c->addAnd(flavorParamsConversionProfilePeer::CONVERSION_PROFILE_ID, $partner->getDefaultConversionProfileId());
         $c->addAnd(flavorParamsConversionProfilePeer::FLAVOR_PARAMS_ID, $syndicationFeed->flavorParamId);
         $is_exist = flavorParamsConversionProfilePeer::doCount($c);
         if (!$is_exist || $is_exist === 0) {
             $assetParams = assetParamsPeer::retrieveByPK($syndicationFeed->flavorParamId);
             $fpc = new flavorParamsConversionProfile();
             $fpc->setConversionProfileId($partner->getDefaultConversionProfileId());
             $fpc->setFlavorParamsId($syndicationFeed->flavorParamId);
             if ($assetParams) {
                 $fpc->setReadyBehavior($assetParams->getReadyBehavior());
                 $fpc->setSystemName($assetParams->getSystemName());
                 if ($assetParams->hasTag(assetParams::TAG_SOURCE) || $assetParams->hasTag(assetParams::TAG_INGEST)) {
                     $fpc->setOrigin(assetParamsOrigin::INGEST);
                 } else {
                     $fpc->setOrigin(assetParamsOrigin::CONVERT);
                 }
             }
             $fpc->save();
         }
     }
     if ($syndicationFeed instanceof KalturaGenericXsltSyndicationFeed) {
         $key = $syndicationFeedDB->getSyncKey(genericSyndicationFeed::FILE_SYNC_SYNDICATION_FEED_XSLT);
         kFileSyncUtils::file_put_contents($key, $syndicationFeed->xslt);
     }
     $syndicationFeed->fromObject($syndicationFeedDB, $this->getResponseProfile());
     return $syndicationFeed;
 }
Exemplo n.º 2
0
 /**
  * Adds the relation of flavorParams <> conversionProfile2
  * 
  * @param conversionProfile2 $conversionProfileDb
  * @param $flavorParamsIds
  * 
  * @throws KalturaErrors::ASSET_PARAMS_INVALID_TYPE
  */
 protected function addFlavorParamsRelation(conversionProfile2 $conversionProfileDb, $flavorParamsIds)
 {
     $existingIds = flavorParamsConversionProfilePeer::getFlavorIdsByProfileId($conversionProfileDb->getId());
     $assetParamsObjects = assetParamsPeer::retrieveByPKs($flavorParamsIds);
     foreach ($assetParamsObjects as $assetParams) {
         /* @var $assetParams assetParams */
         if (in_array($assetParams->getId(), $existingIds)) {
             continue;
         }
         if ($conversionProfileDb->getType() == ConversionProfileType::LIVE_STREAM && $assetParams->getType() != assetType::LIVE) {
             throw new KalturaAPIException(KalturaErrors::ASSET_PARAMS_INVALID_TYPE, $assetParams->getId(), $assetParams->getType());
         }
         $fpc = new flavorParamsConversionProfile();
         $fpc->setConversionProfileId($conversionProfileDb->getId());
         $fpc->setFlavorParamsId($assetParams->getId());
         $fpc->setReadyBehavior($assetParams->getReadyBehavior());
         $fpc->setSystemName($assetParams->getSystemName());
         $fpc->setForceNoneComplied(false);
         if ($assetParams->hasTag(assetParams::TAG_SOURCE) || $assetParams->hasTag(assetParams::TAG_INGEST)) {
             $fpc->setOrigin(assetParamsOrigin::INGEST);
         } else {
             $fpc->setOrigin(assetParamsOrigin::CONVERT);
         }
         $fpc->save();
     }
 }
 /**
  * Adds the relation of flavorParams <> conversionProfile2
  * 
  * @param conversionProfile2 $conversionProfileDb
  * @param $flavorParamsIds
  */
 protected function addFlavorParamsRelation(conversionProfile2 $conversionProfileDb, $flavorParamsIds)
 {
     $existingIds = flavorParamsConversionProfilePeer::getFlavorIdsByProfileId($conversionProfileDb->getId());
     $assetParamsObjects = assetParamsPeer::retrieveByPKs($flavorParamsIds);
     foreach ($assetParamsObjects as $assetParams) {
         /* @var $assetParams assetParams */
         if (in_array($assetParams->getId(), $existingIds)) {
             continue;
         }
         $fpc = new flavorParamsConversionProfile();
         $fpc->setConversionProfileId($conversionProfileDb->getId());
         $fpc->setFlavorParamsId($assetParams->getId());
         $fpc->setReadyBehavior($assetParams->getReadyBehavior());
         $fpc->setSystemName($assetParams->getSystemName());
         $fpc->setForceNoneComplied(false);
         if ($assetParams->hasTag(assetParams::TAG_SOURCE)) {
             $fpc->setOrigin(assetParamsOrigin::INGEST);
         } else {
             $fpc->setOrigin(assetParamsOrigin::CONVERT);
         }
         $fpc->save();
     }
 }
$partners = PartnerPeer::doSelect($partnerCriteria);
foreach ($partners as $partner) {
    /* @var $partner Partner */
    $profileCriteria = new Criteria();
    $profileCriteria->add(conversionProfile2Peer::PARTNER_ID, $partner->getId());
    $profileCriteria->add(conversionProfile2Peer::TYPE, $conversionProfileType);
    $profileCriteria->add(conversionProfile2Peer::STATUS, ConversionProfileStatus::DELETED, Criteria::NOT_EQUAL);
    $profiles = conversionProfile2Peer::doSelect($profileCriteria);
    foreach ($profiles as $profile) {
        /* @var $profile conversionProfile2 */
        $flavorParamsConversionProfileIds = flavorParamsConversionProfilePeer::getFlavorIdsByProfileId($profile->getId());
        foreach ($additioalFlavorParamsObjects as $additioalFlavorParamsId => $additioalFlavorParamsObject) {
            if (in_array($additioalFlavorParamsId, $flavorParamsConversionProfileIds)) {
                continue;
            }
            $flavorParamsConversionProfile = new flavorParamsConversionProfile();
            $flavorParamsConversionProfile->setConversionProfileId($profile->getId());
            $flavorParamsConversionProfile->setFlavorParamsId($additioalFlavorParamsId);
            $flavorParamsConversionProfile->setReadyBehavior($additioalFlavorParamsObject->getReadyBehavior());
            $flavorParamsConversionProfile->setSystemName($additioalFlavorParamsObject->getSystemName());
            $flavorParamsConversionProfile->setForceNoneComplied(false);
            if ($additioalFlavorParamsObject->hasTag(assetParams::TAG_SOURCE) || $additioalFlavorParamsObject->hasTag(assetParams::TAG_INGEST)) {
                $flavorParamsConversionProfile->setOrigin(assetParamsOrigin::INGEST);
            } else {
                $flavorParamsConversionProfile->setOrigin(assetParamsOrigin::CONVERT);
            }
            $flavorParamsConversionProfile->save();
        }
    }
}
exit(0);