public function fromObject($sourceObject)
 {
     parent::fromObject($sourceObject);
     $this->mediaFiles = KalturaDistributionRemoteMediaFileArray::fromDbArray($sourceObject->getMediaFiles());
     if (!$this->distributionProfileId) {
         return;
     }
     if (!$this->entryDistributionId) {
         return;
     }
     $distributionProfile = DistributionProfilePeer::retrieveByPK($this->distributionProfileId);
     if (!$distributionProfile || $distributionProfile->getStatus() != DistributionProfileStatus::ENABLED) {
         return;
     }
     $this->distributionProfile = KalturaDistributionProfileFactory::createKalturaDistributionProfile($distributionProfile->getProviderType());
     $this->distributionProfile->fromObject($distributionProfile);
     $entryDistribution = EntryDistributionPeer::retrieveByPK($this->entryDistributionId);
     if ($entryDistribution) {
         $this->entryDistribution = new KalturaEntryDistribution();
         $this->entryDistribution->fromObject($entryDistribution);
     }
     $providerType = $sourceObject->getProviderType();
     if ($providerType) {
         if ($providerType == KalturaDistributionProviderType::GENERIC) {
             $this->providerData = new KalturaGenericDistributionJobProviderData($this);
         } else {
             $this->providerData = KalturaPluginManager::loadObject('KalturaDistributionJobProviderData', $providerType, array($this));
         }
         $providerData = $sourceObject->getProviderData();
         if ($this->providerData && $providerData && $providerData instanceof kDistributionJobProviderData) {
             $this->providerData->fromObject($providerData);
         }
     }
 }
 /**
  * Retrieve EntryDistribution objects by entry id according to specified statuses list
  *
  * @param      string $entryId
  * @param      array $statuses
  * @param      PropelPDO $con the connection to use
  * @return     EntryDistribution
  */
 public static function retrieveByEntryAndStatuses($entryId, array $statuses, PropelPDO $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(EntryDistributionPeer::ENTRY_ID, $entryId);
     $criteria->add(EntryDistributionPeer::STATUS, $statuses, Criteria::IN);
     return EntryDistributionPeer::doSelect($criteria, $con);
 }
 /**
  * @param entry $entry
  * @param SimpleXMLElement $mrss
  * @return SimpleXMLElement
  */
 public function contribute(entry $entry, SimpleXMLElement $mrss)
 {
     $entryDistributions = EntryDistributionPeer::retrieveByEntryId($entry->getId());
     foreach ($entryDistributions as $entryDistribution) {
         $this->contributeDistribution($entryDistribution, $mrss);
     }
 }
 public function __construct(KalturaDistributionJobData $distributionJobData = null)
 {
     parent::__construct($distributionJobData);
     $this->notificationBaseUrl = 'http://' . kConf::get('cdn_api_host');
     if (!$distributionJobData) {
         return;
     }
     if (!$distributionJobData->distributionProfile instanceof KalturaUnicornDistributionProfile) {
         return;
     }
     $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId);
     $distributionProfileDb = DistributionProfilePeer::retrieveByPK($distributionJobData->distributionProfileId);
     /* @var $distributionProfileDb UnicornDistributionProfile */
     $flavorAssetIds = explode(',', $entryDistributionDb->getFlavorAssetIds());
     $flavorAssetId = reset($flavorAssetIds);
     $flavorAsset = assetPeer::retrieveById($flavorAssetId);
     $flavorAssetOldVersion = $entryDistributionDb->getFromCustomData(kUnicornDistributionJobProviderData::CUSTOM_DATA_FLAVOR_ASSET_OLD_VERSION);
     $flavorAssetNewVersion = null;
     if ($flavorAsset) {
         $flavorAssetNewVersion = $flavorAsset->getVersion();
     }
     $values = $distributionProfileDb->getAllFieldValues($entryDistributionDb);
     $this->catalogGuid = $values[UnicornDistributionField::CATALOG_GUID];
     $this->title = $values[UnicornDistributionField::TITLE];
     $this->flavorAssetVersion = $flavorAssetNewVersion;
     $this->mediaChanged = $flavorAssetOldVersion != $flavorAssetNewVersion;
 }
 public function __construct(KalturaDistributionJobData $distributionJobData = null)
 {
     parent::__construct($distributionJobData);
     if (!$distributionJobData) {
         return;
     }
     if (!$distributionJobData->distributionProfile instanceof KalturaUverseDistributionProfile) {
         return;
     }
     $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds));
     if (count($flavorAssets)) {
         // if we have specific flavor assets for this distribution, grab the first one
         $flavorAsset = reset($flavorAssets);
     } else {
         // take the source asset
         $flavorAsset = assetPeer::retrieveOriginalReadyByEntryId($distributionJobData->entryDistribution->entryId);
     }
     if ($flavorAsset) {
         $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         if (kFileSyncUtils::fileSync_exists($syncKey)) {
             $this->localAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false);
         }
     }
     $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId);
     if ($entryDistributionDb) {
         $this->remoteAssetUrl = $entryDistributionDb->getFromCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_URL);
         $this->remoteAssetFileName = $entryDistributionDb->getFromCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_FILE_NAME);
     } else {
         KalturaLog::err('Entry distribution [' . $distributionJobData->entryDistributionId . '] not found');
     }
 }
Exemplo n.º 6
0
 /**
  * Retrieve single EntryDistribution object by entry id and profile id.
  *
  * @param      string $entryId
  * @param      int $distributionProfileId
  * @param      PropelPDO $con the connection to use
  * @return     EntryDistribution
  */
 public static function retrieveByEntryAndProfileId($entryId, $distributionProfileId, PropelPDO $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(EntryDistributionPeer::ENTRY_ID, $entryId);
     $criteria->add(EntryDistributionPeer::DISTRIBUTION_PROFILE_ID, $distributionProfileId);
     return EntryDistributionPeer::doSelectOne($criteria, $con);
 }
 public function __construct(KalturaDistributionJobData $distributionJobData = null)
 {
     if (!$distributionJobData) {
         return;
     }
     if (!$distributionJobData->distributionProfile instanceof KalturaYoutubeApiDistributionProfile) {
         return;
     }
     $flavorAssets = flavorAssetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds));
     if (count($flavorAssets)) {
         // if we have specific flavor assets for this distribution, grab the first one
         $flavorAsset = reset($flavorAssets);
     } else {
         // take the source asset
         $flavorAsset = flavorAssetPeer::retrieveOriginalReadyByEntryId($distributionJobData->entryDistribution->entryId);
     }
     if ($flavorAsset) {
         $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         $this->videoAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, true);
     }
     $thumbAssets = thumbAssetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds));
     if (count($thumbAssets)) {
         $syncKey = reset($thumbAssets)->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         $this->thumbAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, true);
     }
     $this->loadPlaylistsFromMetadata($distributionJobData->entryDistribution->entryId, $distributionJobData->distributionProfile);
     $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId);
     //		if ($entryDistributionDb)
     //			$this->currentPlaylists = $entryDistributionDb->getFromCustomData('currentPlaylists');
     //		else
     //			KalturaLog::err('Entry distribution ['.$distributionJobData->entryDistributionId.'] not found');
 }
 /**
  * @action getFeed
  * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY
  * @param int $distributionProfileId
  * @param string $hash
  * @return file
  */
 public function getFeedAction($distributionProfileId, $hash)
 {
     if (!$this->getPartnerId() || !$this->getPartner()) {
         throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $this->getPartnerId());
     }
     $profile = DistributionProfilePeer::retrieveByPK($distributionProfileId);
     if (!$profile || !$profile instanceof UverseDistributionProfile) {
         throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_NOT_FOUND, $distributionProfileId);
     }
     if ($profile->getStatus() != KalturaDistributionProfileStatus::ENABLED) {
         throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_DISABLED, $distributionProfileId);
     }
     if ($profile->getUniqueHashForFeedUrl() != $hash) {
         throw new KalturaAPIException(UverseDistributionErrors::INVALID_FEED_URL);
     }
     // "Creates advanced filter on distribution profile
     $distributionAdvancedSearch = new ContentDistributionSearchFilter();
     $distributionAdvancedSearch->setDistributionProfileId($profile->getId());
     $distributionAdvancedSearch->setDistributionSunStatus(EntryDistributionSunStatus::AFTER_SUNRISE);
     $distributionAdvancedSearch->setEntryDistributionStatus(EntryDistributionStatus::READY);
     $distributionAdvancedSearch->setHasEntryDistributionValidationErrors(false);
     //Creates entry filter with advanced filter
     $entryFilter = new entryFilter();
     $entryFilter->setStatusEquel(entryStatus::READY);
     $entryFilter->setModerationStatusNot(entry::ENTRY_MODERATION_STATUS_REJECTED);
     $entryFilter->setPartnerSearchScope($this->getPartnerId());
     $entryFilter->setAdvancedSearch($distributionAdvancedSearch);
     $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS);
     $baseCriteria->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL);
     $entryFilter->attachToCriteria($baseCriteria);
     $entries = entryPeer::doSelect($baseCriteria);
     $feed = new UverseFeed('uverse_template.xml');
     $feed->setDistributionProfile($profile);
     $feed->setChannelFields();
     $lastBuildDate = $profile->getUpdatedAt(null);
     foreach ($entries as $entry) {
         /* @var $entry entry */
         $entryDistribution = EntryDistributionPeer::retrieveByEntryAndProfileId($entry->getId(), $profile->getId());
         if (!$entryDistribution) {
             KalturaLog::err('Entry distribution was not found for entry [' . $entry->getId() . '] and profile [' . $profile->getId() . ']');
             continue;
         }
         $fields = $profile->getAllFieldValues($entryDistribution);
         $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds()));
         $flavorAsset = reset($flavorAssets);
         $flavorAssetRemoteUrl = $entryDistribution->getFromCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_URL);
         $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getThumbAssetIds()));
         $feed->addItem($fields, $flavorAsset, $flavorAssetRemoteUrl, $thumbAssets);
         // we want to find the newest update time between all entries
         if ($entry->getUpdatedAt(null) > $lastBuildDate) {
             $lastBuildDate = $entry->getUpdatedAt(null);
         }
     }
     $feed->setChannelLastBuildDate($lastBuildDate);
     header('Content-Type: text/xml');
     echo $feed->getXml();
     die;
 }
 /**
  * @action getFeed
  * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY
  * @param int $distributionProfileId
  * @param string $hash
  * @return file
  */
 public function getFeedAction($distributionProfileId, $hash)
 {
     if (!$this->getPartnerId() || !$this->getPartner()) {
         throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $this->getPartnerId());
     }
     $profile = DistributionProfilePeer::retrieveByPK($distributionProfileId);
     if (!$profile || !$profile instanceof SynacorHboDistributionProfile) {
         throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_NOT_FOUND, $distributionProfileId);
     }
     if ($profile->getStatus() != KalturaDistributionProfileStatus::ENABLED) {
         throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_DISABLED, $distributionProfileId);
     }
     if ($profile->getUniqueHashForFeedUrl() != $hash) {
         throw new KalturaAPIException(SynacorHboDistributionErrors::INVALID_FEED_URL);
     }
     // "Creates advanced filter on distribution profile
     $distributionAdvancedSearch = new ContentDistributionSearchFilter();
     $distributionAdvancedSearch->setDistributionProfileId($profile->getId());
     $distributionAdvancedSearch->setDistributionSunStatus(EntryDistributionSunStatus::AFTER_SUNRISE);
     $distributionAdvancedSearch->setEntryDistributionStatus(EntryDistributionStatus::READY);
     $distributionAdvancedSearch->setEntryDistributionFlag(EntryDistributionDirtyStatus::NONE);
     $distributionAdvancedSearch->setHasEntryDistributionValidationErrors(false);
     //Creates entry filter with advanced filter
     $entryFilter = new entryFilter();
     $entryFilter->setStatusEquel(entryStatus::READY);
     $entryFilter->setModerationStatusNot(entry::ENTRY_MODERATION_STATUS_REJECTED);
     $entryFilter->setPartnerSearchScope($this->getPartnerId());
     $entryFilter->setAdvancedSearch($distributionAdvancedSearch);
     $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS);
     $baseCriteria->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL);
     $entryFilter->attachToCriteria($baseCriteria);
     $entries = entryPeer::doSelect($baseCriteria);
     $feed = new SynacorHboFeed('synacor_hbo_feed_template.xml');
     $feed->setDistributionProfile($profile);
     $counter = 0;
     foreach ($entries as $entry) {
         /* @var $entry entry */
         $entryDistribution = EntryDistributionPeer::retrieveByEntryAndProfileId($entry->getId(), $profile->getId());
         if (!$entryDistribution) {
             KalturaLog::err('Entry distribution was not found for entry [' . $entry->getId() . '] and profile [' . $profile->getId() . ']');
             continue;
         }
         $fields = $profile->getAllFieldValues($entryDistribution);
         $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds()));
         $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getThumbAssetIds()));
         $additionalAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getAssetIds()));
         $feed->addItem($fields, $entry, $flavorAssets, $thumbAssets, $additionalAssets);
         $counter++;
         //to avoid the cache exceeding the memory size
         if ($counter >= 100) {
             kMemoryManager::clearMemory();
             $counter = 0;
         }
     }
     header('Content-Type: text/xml');
     echo $feed->getXml();
     die;
 }
 public function contribute(BaseObject $object, SimpleXMLElement $mrss, kMrssParameters $mrssParams = null)
 {
     if (!$object instanceof entry) {
         return;
     }
     $entryDistributions = EntryDistributionPeer::retrieveByEntryId($object->getId());
     foreach ($entryDistributions as $entryDistribution) {
         $this->contributeDistribution($entryDistribution, $mrss);
     }
 }
 public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null)
 {
     $c = new Criteria();
     $entryDistributionFilter = $this->toObject();
     $entryDistributionFilter->attachToCriteria($c);
     $count = EntryDistributionPeer::doCount($c);
     $pager->attachToCriteria($c);
     $list = EntryDistributionPeer::doSelect($c);
     $response = new KalturaEntryDistributionListResponse();
     $response->objects = KalturaEntryDistributionArray::fromDbArray($list, $responseProfile);
     $response->totalCount = $count;
     return $response;
 }
 /**
  * @param BatchJob $dbBatchJob
  * @param kDistributionJobData $data
  * @return BatchJob
  */
 public static function onDistributionJobFinished(BatchJob $dbBatchJob, kDistributionJobData $data)
 {
     $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId());
     if (!$entryDistribution) {
         KalturaLog::err("Entry distribution [" . $data->getEntryDistributionId() . "] not found");
         return $dbBatchJob;
     }
     $providerData = $data->getProviderData();
     if ($providerData instanceof kUverseDistributionJobProviderData) {
         $entryDistribution->putInCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_URL, $providerData->getRemoteAssetUrl());
         $entryDistribution->putInCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_FILE_NAME, $providerData->getRemoteAssetFileName());
         $entryDistribution->save();
     }
     return $dbBatchJob;
 }
 /**
  * @param BatchJob $dbBatchJob
  * @param kDistributionJobData $data
  * @return BatchJob
  */
 public static function onDistributionJobFinished(BatchJob $dbBatchJob, kDistributionJobData $data)
 {
     $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId());
     if (!$entryDistribution) {
         KalturaLog::err("Entry distribution [" . $data->getEntryDistributionId() . "] not found");
         return $dbBatchJob;
     }
     $distributionProfileId = $data->getDistributionProfileId();
     $distributionProfile = DistributionProfilePeer::retrieveByPK($distributionProfileId);
     // only feed spec v2 (rights feed) is setting the playlists on submit close action
     if ($distributionProfile && $distributionProfile instanceof YouTubeDistributionProfile && $distributionProfile->getFeedSpecVersion() == YouTubeDistributionFeedSpecVersion::VERSION_2) {
         self::saveCurrentPlaylistsToCustomData($data, $entryDistribution);
     }
     return $dbBatchJob;
 }
 /**
  * @param BatchJob $dbBatchJob
  * @param kDistributionJobData $data
  * @param BatchJob $twinJob
  * @return BatchJob
  */
 public static function onDistributionJobFinished(BatchJob $dbBatchJob, kDistributionJobData $data, BatchJob $twinJob = null)
 {
     $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId());
     if (!$entryDistribution) {
         KalturaLog::err("Entry distribution [" . $data->getEntryDistributionId() . "] not found");
         return $dbBatchJob;
     }
     $providerData = $data->getProviderData();
     if ($providerData instanceof kAttUverseDistributionJobProviderData) {
         KalturaLog::debug('Updating AttUverse job provider data in entry distribution custom data');
         $entryDistribution->putInCustomData(AttUverseEntryDistributionCustomDataField::REMOTE_ASSET_FILE_URLS, $providerData->getRemoteAssetFileUrls());
         $entryDistribution->putInCustomData(AttUverseEntryDistributionCustomDataField::REMOTE_THUMBNAIL_FILE_URLS, $providerData->getRemoteThumbnailFileUrls());
         $entryDistribution->save();
     }
     return $dbBatchJob;
 }
 /**
  * @param BatchJob $dbBatchJob
  * @param kDistributionJobData $data
  * @param BatchJob $twinJob
  * @return BatchJob
  */
 public static function onDistributionJobUpdatedAlmostDone(BatchJob $dbBatchJob, kDistributionJobData $data, BatchJob $twinJob = null)
 {
     $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId());
     if (!$entryDistribution) {
         KalturaLog::err("Entry distribution [" . $data->getEntryDistributionId() . "] not found");
         return $dbBatchJob;
     }
     $providerData = $data->getProviderData();
     KalturaLog::crit('provider data type' . get_class($providerData));
     if ($providerData instanceof kYouTubeDistributionJobProviderData) {
         KalturaLog::debug('setting currentPlaylists to entryDistribution custom data');
         $entryDistribution->putInCustomData('currentPlaylists', $providerData->getCurrentPlaylists());
         $entryDistribution->save();
     }
     return $dbBatchJob;
 }
 protected function executeSphinx($index, $wheres, $orderBy, $limit, $maxMatches, $setLimit)
 {
     $sql = "SELECT entry_distribution_id FROM {$index} {$wheres} {$orderBy} LIMIT {$limit} OPTION max_matches={$maxMatches}";
     //debug query
     //echo $sql."\n"; die;
     $pdo = DbManager::getSphinxConnection();
     $stmt = $pdo->query($sql);
     if (!$stmt) {
         KalturaLog::err("Invalid sphinx query [{$sql}]");
         return;
     }
     $ids = $stmt->fetchAll(PDO::FETCH_COLUMN, 2);
     KalturaLog::debug("Found " . count($ids) . " ids");
     foreach ($this->keyToRemove as $key) {
         KalturaLog::debug("Removing key [{$key}] from criteria");
         $this->remove($key);
     }
     $this->addAnd(EntryDistributionPeer::ID, $ids, Criteria::IN);
     $this->recordsCount = 0;
     if (!$this->doCount) {
         return;
     }
     if ($setLimit) {
         $this->setOffset(0);
         $sql = "show meta";
         $stmt = $pdo->query($sql);
         $meta = $stmt->fetchAll(PDO::FETCH_NAMED);
         if (count($meta)) {
             foreach ($meta as $metaItem) {
                 KalturaLog::debug("Sphinx query " . $metaItem['Variable_name'] . ': ' . $metaItem['Value']);
                 if ($metaItem['Variable_name'] == 'total_found') {
                     $this->recordsCount = (int) $metaItem['Value'];
                 }
             }
         }
     } else {
         $c = clone $this;
         $c->setLimit(null);
         $c->setOffset(null);
         $this->recordsCount = EntryDistributionPeer::doCount($c);
     }
 }
Exemplo n.º 17
0
 /**
  * @action notify
  * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY
  * @param int $id distribution job id
  */
 public function notifyAction($id)
 {
     $submitCoreType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT);
     $updateCoreType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE);
     $deleteCoreType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE);
     $validJobTypes = array($submitCoreType, $updateCoreType, $deleteCoreType);
     $batchJob = BatchJobPeer::retrieveByPK($id);
     $invalid = false;
     if (!$batchJob) {
         $invalid = true;
         KalturaLog::err("Job [{$id}] not found");
     } elseif (!in_array($batchJob->getJobType(), $validJobTypes)) {
         $invalid = true;
         KalturaLog::err("Job [{$id}] wrong type [" . $batchJob->getJobType() . "] expected [" . implode(', ', $validJobTypes) . "]");
     } elseif ($batchJob->getJobSubType() != UnicornDistributionProvider::get()->getType()) {
         $invalid = true;
         KalturaLog::err("Job [{$id}] wrong sub-type [" . $batchJob->getJobSubType() . "] expected [" . UnicornDistributionProvider::get()->getType() . "]");
     } elseif ($batchJob->getStatus() != KalturaBatchJobStatus::ALMOST_DONE) {
         $invalid = true;
         KalturaLog::err("Job [{$id}] wrong status [" . $batchJob->getStatus() . "] expected [" . KalturaBatchJobStatus::ALMOST_DONE . "]");
     }
     if ($invalid) {
         throw new KalturaAPIException(KalturaErrors::INVALID_BATCHJOB_ID, $id);
     }
     kJobsManager::updateBatchJob($batchJob, KalturaBatchJobStatus::FINISHED);
     $data = $batchJob->getData();
     /* @var $data kDistributionJobData */
     $providerData = $data->getProviderData();
     /* @var $providerData kUnicornDistributionJobProviderData */
     $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId());
     if ($entryDistribution) {
         $entryDistribution->putInCustomData(kUnicornDistributionJobProviderData::CUSTOM_DATA_FLAVOR_ASSET_OLD_VERSION, $providerData->getFlavorAssetVersion());
         $entryDistribution->save();
     }
     if ($batchJob->getJobType() == $submitCoreType) {
         $this->attachRemoteAssetResource($batchJob->getEntry(), $batchJob->getData());
     }
     if ($batchJob->getJobType() == $deleteCoreType) {
         $this->detachRemoteAssetResource($batchJob->getEntry(), $batchJob->getData());
     }
 }
 public function __construct(KalturaDistributionJobData $distributionJobData = null)
 {
     parent::__construct($distributionJobData);
     if (!$distributionJobData) {
         return;
     }
     if (!$distributionJobData->distributionProfile instanceof KalturaCrossKalturaDistributionProfile) {
         return;
     }
     // load previously distributed data from entry distribution
     $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId);
     if (!$entryDistributionDb) {
         KalturaLog::err('Entry distribution [' . $distributionJobData->entryDistributionId . '] not found');
         return;
     }
     $this->distributedFlavorAssets = $entryDistributionDb->getFromCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_FLAVOR_ASSETS);
     $this->distributedThumbAssets = $entryDistributionDb->getFromCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_THUMB_ASSETS);
     $this->distributedMetadata = $entryDistributionDb->getFromCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_METADATA);
     $this->distributedCaptionAssets = $entryDistributionDb->getFromCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_CAPTION_ASSETS);
     $this->distributedCuePoints = $entryDistributionDb->getFromCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_CUE_POINTS);
 }
 /**
  * @param BatchJob $dbBatchJob
  * @return BatchJob
  */
 public static function onDistributionJobFinished(BatchJob $dbBatchJob)
 {
     $data = $dbBatchJob->getData();
     $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId());
     if (!$entryDistribution) {
         KalturaLog::err('Entry distribution [' . $data->getEntryDistributionId() . '] not found');
         return $dbBatchJob;
     }
     $providerData = $data->getProviderData();
     if (!$providerData instanceof kCrossKalturaDistributionJobProviderData) {
         KalturaLog::err('Wrong provider data class [' . get_class($providerData) . ']');
         return $dbBatchJob;
     }
     $entryDistribution->putInCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_FLAVOR_ASSETS, $providerData->getDistributedFlavorAssets());
     $entryDistribution->putInCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_THUMB_ASSETS, $providerData->getDistributedThumbAssets());
     $entryDistribution->putInCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_METADATA, $providerData->getDistributedMetadata());
     $entryDistribution->putInCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_CAPTION_ASSETS, $providerData->getDistributedCaptionAssets());
     $entryDistribution->putInCustomData(CrossKalturaDistributionCustomDataField::DISTRIBUTED_CUE_POINTS, $providerData->getDistributedCuePoints());
     $entryDistribution->save();
     return $dbBatchJob;
 }
 /**
  * Called on the server side and enables you to populate the object with any data from the DB
  * 
  * @param KalturaDistributionJobData $distributionJobData
  */
 public function __construct(KalturaDistributionJobData $distributionJobData = null)
 {
     parent::__construct($distributionJobData);
     if (!$distributionJobData) {
         return;
     }
     if (!$distributionJobData->distributionProfile instanceof KalturaFtpDistributionProfile) {
         return;
     }
     $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId);
     $distributionProfileDb = DistributionProfilePeer::retrieveByPK($distributionJobData->distributionProfileId);
     if (is_null($entryDistributionDb)) {
         return KalturaLog::err('Entry distribution #' . $distributionJobData->entryDistributionId . ' not found');
     }
     if (is_null($distributionProfileDb)) {
         return KalturaLog::err('Distribution profile #' . $distributionJobData->distributionProfileId . ' not found');
     }
     if (!$distributionProfileDb instanceof FtpDistributionProfile) {
         return KalturaLog::err('Distribution profile #' . $distributionJobData->distributionProfileId . ' is not instance of FtpDistributionProfile');
     }
     $this->filesForDistribution = $this->getDistributionFiles($distributionProfileDb, $entryDistributionDb);
     KalturaLog::log("Files for distribution: " . print_r($this->filesForDistribution, true));
 }
 /**
  * @param BatchJob $dbBatchJob
  * @param kDistributionFetchReportJobData $data
  * @param BatchJob $twinJob
  * @return BatchJob
  */
 public static function onDistributionFetchReportJobFinished(BatchJob $dbBatchJob, kDistributionFetchReportJobData $data, BatchJob $twinJob = null)
 {
     $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId());
     if (!$entryDistribution) {
         KalturaLog::err("Entry distribution [" . $data->getEntryDistributionId() . "] not found");
         return $dbBatchJob;
     }
     $providerData = $data->getProviderData();
     /*		if($providerData instanceof kIdeticDistributionJobProviderData)
     		{
     			$entryDistribution->putInCustomData('emailed', $providerData->getEmailed());
     			$entryDistribution->putInCustomData('rated', $providerData->getRated());
     			$entryDistribution->putInCustomData('blogged', $providerData->getBlogged());
     			$entryDistribution->putInCustomData('reviewed', $providerData->getReviewed());
     			$entryDistribution->putInCustomData('bookmarked', $providerData->getBookmarked());
     			$entryDistribution->putInCustomData('playbackFailed', $providerData->getPlaybackFailed());
     			$entryDistribution->putInCustomData('timeSpent', $providerData->getTimeSpent());
     			$entryDistribution->putInCustomData('recommended', $providerData->getRecommended());
     			
     			$entryDistribution->save();
     		}
     	*/
     return $dbBatchJob;
 }
Exemplo n.º 22
0
 public function getFieldNameFromPeer($field_name)
 {
     $res = EntryDistributionPeer::translateFieldName($field_name, $this->field_name_translation_type, BasePeer::TYPE_COLNAME);
     return $res;
 }
 /**
  * creates all required jobs according to entry distribution dirty flags 
  * 
  * @action createRequiredJobs
  */
 function createRequiredJobsAction()
 {
     // serach all records that their next report time arrived
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::NEXT_REPORT, time(), Criteria::LESS_EQUAL);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
         if ($distributionProfile) {
             kContentDistributionManager::submitFetchEntryDistributionReport($entryDistribution, $distributionProfile);
         } else {
             KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]");
         }
     }
     // serach all records that arrived their sunrise time and requires submittion
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::DIRTY_STATUS, EntryDistributionDirtyStatus::SUBMIT_REQUIRED);
     $criteria->add(EntryDistributionPeer::SUNRISE, time(), Criteria::LESS_EQUAL);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
         if ($distributionProfile) {
             kContentDistributionManager::submitAddEntryDistribution($entryDistribution, $distributionProfile);
         } else {
             KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]");
         }
     }
     // serach all records that arrived their sunrise time and requires enable
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::DIRTY_STATUS, EntryDistributionDirtyStatus::ENABLE_REQUIRED);
     $criteria->add(EntryDistributionPeer::SUNRISE, time(), Criteria::LESS_EQUAL);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
         if ($distributionProfile) {
             kContentDistributionManager::submitEnableEntryDistribution($entryDistribution, $distributionProfile);
         } else {
             KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]");
         }
     }
     // serach all records that arrived their sunset time and requires deletion
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::DIRTY_STATUS, EntryDistributionDirtyStatus::DELETE_REQUIRED);
     $criteria->add(EntryDistributionPeer::SUNSET, time(), Criteria::LESS_EQUAL);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
         if ($distributionProfile) {
             kContentDistributionManager::submitDeleteEntryDistribution($entryDistribution, $distributionProfile);
         } else {
             KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]");
         }
     }
     // serach all records that arrived their sunset time and requires disable
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::DIRTY_STATUS, EntryDistributionDirtyStatus::DISABLE_REQUIRED);
     $criteria->add(EntryDistributionPeer::SUNSET, time(), Criteria::LESS_EQUAL);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
         if ($distributionProfile) {
             kContentDistributionManager::submitDisableEntryDistribution($entryDistribution, $distributionProfile);
         } else {
             KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]");
         }
     }
 }
Exemplo n.º 24
0
		$fileTransferMgr->login('ftp-int.vzw.real.com', 'vp_foxsports', 'X4ul3ap');
		print_r($fileTransferMgr->listDir("/pub/in"));
//		$fileTransferMgr->putFile($destFile, $srcFile, true);

		return;*/
$entry = entryPeer::retrieveByPKNoFilter($entryId);
$mrss = kMrssManager::getEntryMrss($entry);
file_put_contents('mrss.xml', $mrss);
KalturaLog::debug("MRSS [{$mrss}]");
$distributionJobData = new KalturaDistributionSubmitJobData();
$dbDistributionProfile = DistributionProfilePeer::retrieveByPK(3);
$distributionProfile = new KalturaDailymotionDistributionProfile();
$distributionProfile->fromObject($dbDistributionProfile);
$distributionJobData->distributionProfileId = $distributionProfile->id;
$distributionJobData->distributionProfile = $distributionProfile;
$dbEntryDistribution = EntryDistributionPeer::retrieveByPK(24);
$entryDistribution = new KalturaEntryDistribution();
$entryDistribution->fromObject($dbEntryDistribution);
$distributionJobData->entryDistributionId = $entryDistribution->id;
$distributionJobData->entryDistribution = $entryDistribution;
$myp = new DailymotionDistributionProfile();
print_r($myp->validateForSubmission($dbEntryDistribution, "submit"));
$providerData = new KalturaDailymotionDistributionJobProviderData($distributionJobData);
$distributionJobData->providerData = $providerData;
//file_put_contents('out.xml', $providerData->xml);
//KalturaLog::debug("XML [$providerData->xml]");
//return;
$engine = new DailymotionDistributionEngine();
$engine->submit($distributionJobData);
//$xml = new KDOMDocument();
//if(!$xml->loadXML($mrss))
Exemplo n.º 25
0
 public static function loadObject($baseClass, $enumValue, array $constructorArgs = null)
 {
     if ($baseClass == 'ISyncableFile' && isset($constructorArgs['objectId'])) {
         $objectId = $constructorArgs['objectId'];
         if ($enumValue == self::getContentDistributionFileSyncObjectTypeCoreValue(ContentDistributionFileSyncObjectType::GENERIC_DISTRIBUTION_ACTION)) {
             GenericDistributionProviderActionPeer::setUseCriteriaFilter(false);
             $object = GenericDistributionProviderActionPeer::retrieveByPK($objectId);
             GenericDistributionProviderActionPeer::setUseCriteriaFilter(true);
             return $object;
         }
         if ($enumValue == self::getContentDistributionFileSyncObjectTypeCoreValue(ContentDistributionFileSyncObjectType::ENTRY_DISTRIBUTION)) {
             EntryDistributionPeer::setUseCriteriaFilter(false);
             $object = EntryDistributionPeer::retrieveByPK($objectId);
             EntryDistributionPeer::setUseCriteriaFilter(true);
             return $object;
         }
         if ($enumValue == self::getContentDistributionFileSyncObjectTypeCoreValue(ContentDistributionFileSyncObjectType::DISTRIBUTION_PROFILE)) {
             DistributionProfilePeer::setUseCriteriaFilter(false);
             $object = DistributionProfilePeer::retrieveByPK($objectId);
             DistributionProfilePeer::setUseCriteriaFilter(true);
             return $object;
         }
     }
     if ($baseClass == 'kJobData') {
         if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT)) {
             return new kDistributionSubmitJobData();
         }
         if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE)) {
             return new kDistributionUpdateJobData();
         }
         if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE)) {
             return new kDistributionDeleteJobData();
         }
         if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_FETCH_REPORT)) {
             return new kDistributionFetchReportJobData();
         }
         if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_ENABLE)) {
             return new kDistributionEnableJobData();
         }
         if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DISABLE)) {
             return new kDistributionDisableJobData();
         }
     }
     if ($baseClass == 'KalturaJobData') {
         if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT)) {
             return new KalturaDistributionSubmitJobData();
         }
         if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE)) {
             return new KalturaDistributionUpdateJobData();
         }
         if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE)) {
             return new KalturaDistributionDeleteJobData();
         }
         if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_FETCH_REPORT) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_FETCH_REPORT)) {
             return new KalturaDistributionFetchReportJobData();
         }
         if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_ENABLE) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_ENABLE)) {
             return new KalturaDistributionEnableJobData();
         }
         if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_DISABLE) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DISABLE)) {
             return new KalturaDistributionDisableJobData();
         }
     }
     return null;
 }
 public function __construct(KalturaDistributionJobData $distributionJobData = null)
 {
     parent::__construct($distributionJobData);
     if (!$distributionJobData) {
         return;
     }
     if (!$distributionJobData->distributionProfile instanceof KalturaAttUverseDistributionProfile) {
         return;
     }
     /* @var $distributionProfileDb AttUverseDistributionProfile */
     $distributionProfileDb = DistributionProfilePeer::retrieveByPK($distributionJobData->distributionProfileId);
     $distributedFlavorIds = null;
     $distributedThumbIds = null;
     $this->filesForDistribution = new KalturaAttUverseDistributionFileArray();
     $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId);
     //Flavor Assets
     $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds));
     if (count($flavorAssets)) {
         $assetLocalIds = array();
         foreach ($flavorAssets as $flavorAsset) {
             $file = new KalturaAttUverseDistributionFile();
             $file->assetType = KalturaAssetType::FLAVOR;
             /* @var $flavorAsset flavorAsset */
             $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
             if (kFileSyncUtils::fileSync_exists($syncKey)) {
                 $assetLocalIds[] = $flavorAsset->getId();
                 $file->assetId = $flavorAsset->getId();
                 $file->localFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false);
                 $defaultFilename = pathinfo($file->localFilePath, PATHINFO_BASENAME);
                 $file->remoteFilename = $distributionProfileDb->getFlavorAssetFilename($entryDistributionDb, $defaultFilename, $flavorAsset->getId());
                 $this->filesForDistribution[] = $file;
             }
         }
         $distributedFlavorIds = implode(',', $assetLocalIds);
     }
     //Thumbnail
     $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds));
     if (count($thumbAssets)) {
         $thumbLocalIds = array();
         foreach ($thumbAssets as $thumbAsset) {
             $file = new KalturaAttUverseDistributionFile();
             $file->assetType = KalturaAssetType::THUMBNAIL;
             $syncKey = $thumbAsset->getSyncKey(thumbAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
             if (kFileSyncUtils::fileSync_exists($syncKey)) {
                 $thumbLocalIds[] = $thumbAsset->getId();
                 $file->assetId = $thumbAsset->getId();
                 $file->localFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false);
                 $defaultFilename = pathinfo($file->localFilePath, PATHINFO_BASENAME);
                 $file->remoteFilename = $distributionProfileDb->getThumbnailAssetFilename($entryDistributionDb, $defaultFilename, $thumbAsset->getId());
                 $this->filesForDistribution[] = $file;
             }
         }
         $distributedThumbIds = implode(',', $thumbLocalIds);
     }
     //additional assets
     $additionalAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->assetIds));
     if (count($additionalAssets)) {
         $captionLocalIds = array();
         foreach ($additionalAssets as $additionalAsset) {
             $file = new KalturaAttUverseDistributionFile();
             $file->assetType = kPluginableEnumsManager::coreToApi(KalturaAssetType::getEnumClass(), $additionalAsset->getType());
             $syncKey = $additionalAsset->getSyncKey(CaptionAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
             $id = $additionalAsset->getId();
             if (kFileSyncUtils::fileSync_exists($syncKey)) {
                 if ($file->assetType == CaptionPlugin::getApiValue(CaptionAssetType::CAPTION) || $file->assetType == AttachmentPlugin::getApiValue(AttachmentAssetType::ATTACHMENT)) {
                     $captionLocalIds[] = $additionalAsset->getId();
                     $file->assetId = $additionalAsset->getId();
                     $file->localFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false);
                     $defaultFilename = pathinfo($file->localFilePath, PATHINFO_BASENAME);
                     $file->remoteFilename = $distributionProfileDb->getAssetFilename($entryDistributionDb, $defaultFilename, $additionalAsset->getId());
                     $this->filesForDistribution[] = $file;
                 }
             }
         }
         $distributedCaptionIds = implode(',', $captionLocalIds);
     }
     //putting distributed flavors ids and distributed thumbnail ids in entry distribution custom data
     if ($entryDistributionDb) {
         $entryDistributionDb->putInCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_FLAVOR_IDS, $distributedFlavorIds);
         $entryDistributionDb->putInCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_THUMBNAIL_IDS, $distributedThumbIds);
         $entryDistributionDb->putInCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_CAPTION_IDS, $distributedCaptionIds);
         $entryDistributionDb->save();
     } else {
         KalturaLog::err('Entry distribution [' . $distributionJobData->entryDistributionId . '] not found');
     }
 }
 public static function getEntrySearchValues(entry $entry)
 {
     if (!ContentDistributionPlugin::isAllowedPartner($entry->getPartnerId())) {
         return null;
     }
     $entryDistributions = EntryDistributionPeer::retrieveByEntryId($entry->getId());
     if (!count($entryDistributions)) {
         return self::getSearchStringNoDistributionProfiles();
     }
     $searchValues = array();
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfileId = $entryDistribution->getDistributionProfileId();
         $searchValues[] = self::getSearchStringDistributionProfile($distributionProfileId);
         $searchValues[] = self::getSearchStringDistributionStatus($entryDistribution->getStatus(), $distributionProfileId);
         $searchValues[] = self::getSearchStringDistributionFlag($entryDistribution->getDirtyStatus(), $distributionProfileId);
         $searchValues[] = self::getSearchStringDistributionSunStatus($entryDistribution->getSunStatus(), $distributionProfileId);
         $validationErrors = $entryDistribution->getValidationErrors();
         if (count($validationErrors)) {
             $searchValues[] = self::getSearchStringDistributionHasValidationError($distributionProfileId);
         }
         foreach ($validationErrors as $validationError) {
             $searchValues[] = self::getSearchStringDistributionValidationError($validationError->getErrorType(), $distributionProfileId);
         }
     }
     return implode(' ', $searchValues);
 }
 protected function handleEntries($context, $feed, array $entries)
 {
     $protocol = infraRequestUtils::getProtocol();
     $cachePrefix = "dist_" . $this->profile->getId() . "/{$protocol}/entry_";
     $profileUpdatedAt = $this->profile->getUpdatedAt(null);
     $extendItems = $this->profile->getItemXpathsToExtend();
     $enableCache = empty($extendItems);
     $cacheStore = null;
     if ($enableCache) {
         $cacheStore = kCacheManager::getSingleLayerCache(kCacheManager::CACHE_TYPE_FEED_ENTRY);
         if (is_null($cacheStore)) {
             $enableCache = false;
         }
     }
     $counter = 0;
     foreach ($entries as $entry) {
         $xml = null;
         $cacheKey = $cachePrefix . str_replace("_", "-", $entry->getId());
         // replace _ with - so cache folders will be created with random entry id and not 0_/1_
         if ($enableCache) {
             $cacheTime = $cacheStore->get($cacheKey . self::CACHE_CREATION_TIME_SUFFIX);
             $updatedAt = max($profileUpdatedAt, $entry->getUpdatedAt(null));
             if ($updatedAt + self::CACHE_CREATION_MARGIN < $cacheTime) {
                 $xml = $cacheStore->get($cacheKey);
             }
         }
         if (!$xml) {
             $entryDistribution = EntryDistributionPeer::retrieveByEntryAndProfileId($entry->getId(), $this->profile->getId());
             if (!$entryDistribution) {
                 KalturaLog::err('Entry distribution was not found for entry [' . $entry->getId() . '] and profile [' . $this->profile->getId() . ']');
                 continue;
             }
             $xml = $this->handleEntry($context, $feed, $entry, $entryDistribution);
             if (!is_null($xml) && $enableCache) {
                 $cacheStore->set($cacheKey . self::CACHE_CREATION_TIME_SUFFIX, time());
                 $cacheStore->set($cacheKey, $xml);
             }
         }
         $feed->addItemXml($xml);
         $counter++;
         //to avoid the cache exceeding the memory size
         if ($counter % self::CACHE_SIZE == 0) {
             kMemoryManager::clearMemory();
         }
     }
 }
 /**
  * @param asset $asset
  */
 public static function onAssetReadyOrDeleted(asset $asset)
 {
     if (!ContentDistributionPlugin::isAllowedPartner($asset->getPartnerId())) {
         KalturaLog::log("Partner [" . $asset->getPartnerId() . "] is not allowed");
         return true;
     }
     $entry = $asset->getentry();
     if (!$entry) {
         KalturaLog::log("Entry [" . $asset->getEntryId() . "] not found");
         return true;
     }
     $entryDistributions = EntryDistributionPeer::retrieveByEntryId($asset->getEntryId());
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfileId = $entryDistribution->getDistributionProfileId();
         $distributionProfile = DistributionProfilePeer::retrieveByPK($distributionProfileId);
         if (!$distributionProfile) {
             KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] profile [{$distributionProfileId}] not found");
             continue;
         }
         if ($entryDistribution->getStatus() == EntryDistributionStatus::QUEUED || $entryDistribution->getStatus() == EntryDistributionStatus::PENDING) {
             $listChanged = kContentDistributionManager::assignFlavorAssets($entryDistribution, $entry, $distributionProfile);
             $listChanged = $listChanged | kContentDistributionManager::assignThumbAssets($entryDistribution, $entry, $distributionProfile);
             $listChanged = $listChanged | kContentDistributionManager::assignAssets($entryDistribution, $entry, $distributionProfile);
             if (!$listChanged) {
                 KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] asset lists didn't change");
                 continue;
             }
             $validationErrors = $distributionProfile->validateForSubmission($entryDistribution, DistributionAction::SUBMIT);
             $entryDistribution->setValidationErrorsArray($validationErrors);
             $entryDistribution->save();
             if ($entryDistribution->getStatus() == EntryDistributionStatus::QUEUED) {
                 if ($entryDistribution->getDirtyStatus() != EntryDistributionDirtyStatus::SUBMIT_REQUIRED) {
                     self::submitAddEntryDistribution($entryDistribution, $distributionProfile);
                 }
             }
         }
         // submit
         if ($entryDistribution->getStatus() == EntryDistributionStatus::READY || $entryDistribution->getStatus() == EntryDistributionStatus::ERROR_UPDATING) {
             $distributionProvider = $distributionProfile->getProvider();
             if (!$distributionProvider) {
                 KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] provider not found");
                 continue;
             }
             if (!$distributionProvider->isUpdateEnabled() || !$distributionProvider->isMediaUpdateEnabled()) {
                 KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] provider [" . $distributionProvider->getName() . "] does not support update");
                 continue;
             }
             $listChanged = kContentDistributionManager::assignFlavorAssets($entryDistribution, $entry, $distributionProfile);
             $listChanged = $listChanged | kContentDistributionManager::assignThumbAssets($entryDistribution, $entry, $distributionProfile);
             $listChanged = $listChanged | kContentDistributionManager::assignAssets($entryDistribution, $entry, $distributionProfile);
             if (!$listChanged) {
                 KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] asset lists didn't change");
                 continue;
             }
             $validationErrors = $distributionProfile->validateForSubmission($entryDistribution, DistributionAction::UPDATE);
             $entryDistribution->setValidationErrorsArray($validationErrors);
             $entryDistribution->save();
             if (!count($validationErrors) && $distributionProfile->getUpdateEnabled() == DistributionProfileActionStatus::AUTOMATIC) {
                 self::submitUpdateEntryDistribution($entryDistribution, $distributionProfile);
             } else {
                 KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] should not be updated automatically");
                 $entryDistribution->setDirtyStatus(EntryDistributionDirtyStatus::UPDATE_REQUIRED);
                 $entryDistribution->save();
                 continue;
             }
         }
         // update
     }
     return true;
 }
 /**
  * @action getFeed
  * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY
  * @param int $distributionProfileId
  * @param string $hash
  * @return file
  */
 public function getFeedAction($distributionProfileId, $hash)
 {
     if (!$this->getPartnerId() || !$this->getPartner()) {
         throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $this->getPartnerId());
     }
     $profile = DistributionProfilePeer::retrieveByPK($distributionProfileId);
     if (!$profile || !$profile instanceof AttUverseDistributionProfile) {
         throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_NOT_FOUND, $distributionProfileId);
     }
     if ($profile->getStatus() != KalturaDistributionProfileStatus::ENABLED) {
         throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_DISABLED, $distributionProfileId);
     }
     if ($profile->getUniqueHashForFeedUrl() != $hash) {
         throw new KalturaAPIException(AttUverseDistributionErrors::INVALID_FEED_URL);
     }
     // "Creates advanced filter on distribution profile
     $distributionAdvancedSearch = new ContentDistributionSearchFilter();
     $distributionAdvancedSearch->setDistributionProfileId($profile->getId());
     $distributionAdvancedSearch->setDistributionSunStatus(EntryDistributionSunStatus::AFTER_SUNRISE);
     $distributionAdvancedSearch->setEntryDistributionStatus(EntryDistributionStatus::READY);
     $distributionAdvancedSearch->setEntryDistributionFlag(EntryDistributionDirtyStatus::NONE);
     $distributionAdvancedSearch->setHasEntryDistributionValidationErrors(false);
     //Creates entry filter with advanced filter
     $entryFilter = new entryFilter();
     $entryFilter->setStatusEquel(entryStatus::READY);
     $entryFilter->setModerationStatusNot(entry::ENTRY_MODERATION_STATUS_REJECTED);
     $entryFilter->setPartnerSearchScope($this->getPartnerId());
     $entryFilter->setAdvancedSearch($distributionAdvancedSearch);
     $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS);
     $baseCriteria->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL);
     $entryFilter->attachToCriteria($baseCriteria);
     $entries = entryPeer::doSelect($baseCriteria);
     $feed = new AttUverseDistributionFeedHelper('feed_template.xml', $profile);
     $channelTitle = $profile->getChannelTitle();
     $counter = 0;
     foreach ($entries as $entry) {
         /* @var $entry entry */
         /* @var $entryDistribution Entrydistribution */
         $entryDistribution = EntryDistributionPeer::retrieveByEntryAndProfileId($entry->getId(), $profile->getId());
         if (!$entryDistribution) {
             KalturaLog::err('Entry distribution was not found for entry [' . $entry->getId() . '] and profile [' . $profile->getId() . ']');
             continue;
         }
         $fields = $profile->getAllFieldValues($entryDistribution);
         //flavors assets and remote flavor asset file urls
         $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_FLAVOR_IDS)));
         $remoteAssetFileUrls = unserialize($entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::REMOTE_ASSET_FILE_URLS));
         //thumb assets and remote thumb asset file urls
         $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_THUMBNAIL_IDS)));
         $remoteThumbailFileUrls = unserialize($entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::REMOTE_THUMBNAIL_FILE_URLS));
         //thumb assets and remote thumb asset file urls
         $captionAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_CAPTION_IDS)));
         $feed->addItem($fields, $flavorAssets, $remoteAssetFileUrls, $thumbAssets, $remoteThumbailFileUrls, $captionAssets);
         $counter++;
         //to avoid the cache exceeding the memory size
         if ($counter >= 100) {
             kMemoryManager::clearMemory();
             $counter = 0;
         }
     }
     //set channel title
     if (isset($fields)) {
         $channelTitle = $fields[AttUverseDistributionField::CHANNEL_TITLE];
     }
     $feed->setChannelTitle($channelTitle);
     header('Content-Type: text/xml');
     echo str_replace('&', '&amp;', html_entity_decode($feed->getXml(), ENT_QUOTES, 'UTF-8'));
     die;
 }