Exemplo n.º 1
0
 /**
  * Add new Entry Distribution
  * 
  * @action add
  * @param KalturaEntryDistribution $entryDistribution
  * @return KalturaEntryDistribution
  * @throws ContentDistributionErrors::DISTRIBUTION_PROFILE_NOT_FOUND
  * @throws ContentDistributionErrors::ENTRY_DISTRIBUTION_ALREADY_EXISTS
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  */
 function addAction(KalturaEntryDistribution $entryDistribution)
 {
     $entryDistribution->validateForInsert();
     $dbDistributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->distributionProfileId);
     if (!$dbDistributionProfile) {
         throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_NOT_FOUND, $entryDistribution->distributionProfileId);
     }
     if ($dbDistributionProfile->getStatus() == DistributionProfileStatus::DISABLED) {
         throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_DISABLED, $entryDistribution->distributionProfileId);
     }
     $dbEntry = entryPeer::retrieveByPK($entryDistribution->entryId);
     if (!$dbEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryDistribution->entryId);
     }
     $dbEntryDistribution = EntryDistributionPeer::retrieveByEntryAndProfileId($entryDistribution->entryId, $entryDistribution->distributionProfileId);
     if ($dbEntryDistribution) {
         throw new KalturaAPIException(ContentDistributionErrors::ENTRY_DISTRIBUTION_ALREADY_EXISTS, $entryDistribution->entryId, $entryDistribution->distributionProfileId);
     }
     $dbEntryDistribution = kContentDistributionManager::addEntryDistribution($dbEntry, $dbDistributionProfile);
     $entryDistribution->toInsertableObject($dbEntryDistribution);
     $dbEntryDistribution->setPartnerId($this->getPartnerId());
     $dbEntryDistribution->save();
     $entryDistribution = new KalturaEntryDistribution();
     $entryDistribution->fromObject($dbEntryDistribution, $this->getResponseProfile());
     return $entryDistribution;
 }