Exemplo n.º 1
0
 protected function getCaptions($partnerId, $entryId)
 {
     $c = new Criteria();
     $c->add(assetPeer::PARTNER_ID, $partnerId);
     $c->add(assetPeer::ENTRY_ID, $entryId);
     $c->add(assetPeer::TYPE, CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION));
     $c->add(assetPeer::STATUS, asset::ASSET_STATUS_READY);
     return assetPeer::doSelect($c);
 }
 public function __construct(KalturaDistributionJobData $distributionJobData = null)
 {
     parent::__construct($distributionJobData);
     if (!$distributionJobData) {
         return;
     }
     if (!$distributionJobData->distributionProfile instanceof KalturaYahooDistributionProfile) {
         return;
     }
     //Flavor Assets
     $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds));
     if (count($flavorAssets)) {
         $videoAssetFilePathArray = array();
         foreach ($flavorAssets as $flavorAsset) {
             if ($flavorAsset) {
                 /* @var $flavorAsset flavorAsset */
                 $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
                 if (kFileSyncUtils::fileSync_exists($syncKey)) {
                     $id = $flavorAsset->getId();
                     //$this->videoAssetFilePath[$id] = kFileSyncUtils::getLocalFilePathForKey($syncKey, false);
                     $videoAssetFilePathArray[$id] = kFileSyncUtils::getLocalFilePathForKey($syncKey, false);
                 }
             }
         }
         $this->videoAssetFilePath = serialize($videoAssetFilePathArray);
     }
     //Thumbnails
     $c = new Criteria();
     $c->addAnd(assetPeer::ID, explode(',', $distributionJobData->entryDistribution->thumbAssetIds), Criteria::IN);
     $c->addAscendingOrderByColumn(assetPeer::ID);
     $thumbAssets = assetPeer::doSelect($c);
     //$thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds));
     if (count($thumbAssets) >= 2) {
         if ($thumbAssets[0]->getWidth() <= $thumbAssets[1]->getWidth()) {
             $smallThumbAsset = $thumbAssets[0];
             $largeThumbAsset = $thumbAssets[1];
         } else {
             $smallThumbAsset = $thumbAssets[1];
             $largeThumbAsset = $thumbAssets[0];
         }
         $syncKey = $smallThumbAsset->getSyncKey(thumbAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
         if (kFileSyncUtils::fileSync_exists($syncKey)) {
             $this->smallThumbPath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false);
         }
         $syncKey = $largeThumbAsset->getSyncKey(thumbAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
         if (kFileSyncUtils::fileSync_exists($syncKey)) {
             $this->largeThumbPath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false);
         }
     }
 }
Exemplo n.º 3
0
 protected function doGetListResponse(KalturaFilterPager $pager, array $types = null)
 {
     $this->validateEntryIdFiltered();
     myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
     // verify access to the relevant entries - either same partner as the KS or kaltura network
     if ($this->entryIdEqual) {
         $entryIds = array($this->entryIdEqual);
     } else {
         if ($this->entryIdIn) {
             $entryIds = explode(',', $this->entryIdIn);
         } else {
             throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, 'KalturaAssetFilter::entryIdEqual/KalturaAssetFilter::entryIdIn');
         }
     }
     $entryIds = array_slice($entryIds, 0, baseObjectFilter::getMaxInValues());
     $c = KalturaCriteria::create(entryPeer::OM_CLASS);
     $c->addAnd(entryPeer::ID, $entryIds, Criteria::IN);
     $criterionPartnerOrKn = $c->getNewCriterion(entryPeer::PARTNER_ID, kCurrentContext::getCurrentPartnerId());
     $criterionPartnerOrKn->addOr($c->getNewCriterion(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK));
     $c->addAnd($criterionPartnerOrKn);
     $dbEntries = entryPeer::doSelect($c);
     if (!$dbEntries) {
         return array(array(), 0);
     }
     $entryIds = array();
     foreach ($dbEntries as $dbEntry) {
         $entryIds[] = $dbEntry->getId();
     }
     $this->entryIdEqual = null;
     $this->entryIdIn = implode(',', $entryIds);
     // get the flavors
     $flavorAssetFilter = new AssetFilter();
     $this->toObject($flavorAssetFilter);
     $c = new Criteria();
     $flavorAssetFilter->attachToCriteria($c);
     if ($types) {
         $c->add(assetPeer::TYPE, $types, Criteria::IN);
     }
     $pager->attachToCriteria($c);
     $list = assetPeer::doSelect($c);
     $resultCount = count($list);
     if ($resultCount && $resultCount < $pager->pageSize) {
         $totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount;
     } else {
         KalturaFilterPager::detachFromCriteria($c);
         $totalCount = assetPeer::doCount($c);
     }
     myDbHelper::$use_alternative_con = null;
     return array($list, $totalCount);
 }
 /**
  * Validate at least one thumbnail exists
  * @param $entryDistribution
  * @param $action
  */
 private function validateThumbnailExist($entryDistribution, $action)
 {
     $validationErrors = array();
     //Validating thumbnails
     $c = new Criteria();
     $c->addAnd(assetPeer::ID, explode(',', $entryDistribution->getThumbAssetIds()), Criteria::IN);
     $c->addAscendingOrderByColumn(assetPeer::ID);
     $thumbAssets = assetPeer::doSelect($c);
     if (!count($thumbAssets)) {
         $errorMsg = 'thumbnail is required';
         $validationError = $this->createValidationError($action, DistributionErrorType::INVALID_DATA);
         $validationError->setValidationErrorType(DistributionValidationErrorType::CUSTOM_ERROR);
         $validationError->setValidationErrorParam($errorMsg);
         $validationError->setDescription($errorMsg);
         $validationErrors[] = $validationError;
     }
     return $validationErrors;
 }
Exemplo n.º 5
0
 protected function doGetListResponse(KalturaFilterPager $pager, array $types = null)
 {
     $this->validateEntryIdFiltered();
     myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
     // verify access to the relevant entries - either same partner as the KS or kaltura network
     if ($this->entryIdEqual) {
         $entryIds = array($this->entryIdEqual);
     } else {
         if ($this->entryIdIn) {
             $entryIds = explode(',', $this->entryIdIn);
         } else {
             throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, 'KalturaAssetFilter::entryIdEqual/KalturaAssetFilter::entryIdIn');
         }
     }
     $entryIds = entryPeer::filterEntriesByPartnerOrKalturaNetwork($entryIds, kCurrentContext::getCurrentPartnerId());
     if (!$entryIds) {
         return array(array(), 0);
     }
     $this->entryIdEqual = null;
     $this->entryIdIn = implode(',', $entryIds);
     // get the flavors
     $flavorAssetFilter = new AssetFilter();
     $this->toObject($flavorAssetFilter);
     $c = new Criteria();
     $flavorAssetFilter->attachToCriteria($c);
     if ($types) {
         $c->add(assetPeer::TYPE, $types, Criteria::IN);
     }
     $pager->attachToCriteria($c);
     $list = assetPeer::doSelect($c);
     $resultCount = count($list);
     if ($resultCount && $resultCount < $pager->pageSize) {
         $totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount;
     } else {
         KalturaFilterPager::detachFromCriteria($c);
         $totalCount = assetPeer::doCount($c);
     }
     myDbHelper::$use_alternative_con = null;
     return array($list, $totalCount);
 }
Exemplo n.º 6
0
 /**
  * @param entry $entry
  */
 protected function entryDeleted(entry $entry)
 {
     $this->syncableDeleted($entry->getId(), FileSyncObjectType::ENTRY);
     // delete flavor assets
     $c = new Criteria();
     $c->add(assetPeer::ENTRY_ID, $entry->getId());
     $c->add(assetPeer::STATUS, asset::FLAVOR_ASSET_STATUS_DELETED, Criteria::NOT_EQUAL);
     $c->add(assetPeer::DELETED_AT, null, Criteria::ISNULL);
     assetPeer::resetInstanceCriteriaFilter();
     $assets = assetPeer::doSelect($c);
     foreach ($assets as $asset) {
         $asset->setStatus(asset::FLAVOR_ASSET_STATUS_DELETED);
         $asset->setDeletedAt(time());
         $asset->save();
     }
     $c = new Criteria();
     $c->add(flavorParamsOutputPeer::ENTRY_ID, $entry->getId());
     $c->add(flavorParamsOutputPeer::DELETED_AT, null, Criteria::ISNULL);
     $flavorParamsOutputs = flavorParamsOutputPeer::doSelect($c);
     foreach ($flavorParamsOutputs as $flavorParamsOutput) {
         $flavorParamsOutput->setDeletedAt(time());
         $flavorParamsOutput->save();
     }
 }
Exemplo n.º 7
0
 public static function getSearchData(BaseObject $object)
 {
     if ($object instanceof entry) {
         $c = new Criteria();
         $c->add(assetPeer::ENTRY_ID, $object->getId());
         $flavorType = self::getAssetTypeCoreValue(WidevineAssetType::WIDEVINE_FLAVOR);
         $c->add(assetPeer::TYPE, $flavorType);
         $wvFlavorAssets = assetPeer::doSelect($c);
         if (count($wvFlavorAssets)) {
             $searchData = array();
             foreach ($wvFlavorAssets as $wvFlavorAsset) {
                 $searchData[] = self::getWidevineAssetIdSearchData($wvFlavorAsset->getWidevineAssetId());
             }
             return array('plugins_data' => implode(' ', $searchData));
         }
     }
     return null;
 }
Exemplo n.º 8
0
    die($argv[0] . " <Partner ID> <comma,separated,asset,Ids> <dry-run|real-run>.\n");
}
$partnerId = $argv[1];
$entryIds = $argv[2];
$entryIdsArray = explode(',', trim($entryIds));
require_once __DIR__ . '/../bootstrap.php';
KalturaStatement::setDryRun($argv[3] !== 'real-run');
if (!PartnerPeer::retrieveByPK($partnerId)) {
    die("Partner ID not found.\n");
}
$c = new Criteria();
$c->add(assetPeer::PARTNER_ID, $partnerId, Criteria::EQUAL);
$c->add(assetPeer::STATUS, entryStatus::DELETED, Criteria::EQUAL);
$c->add(assetPeer::ID, $entryIdsArray, Criteria::IN);
assetPeer::setUseCriteriaFilter(false);
$assets = assetPeer::doSelect($c);
foreach ($assets as $deletedAsset) {
    echo 'LOG: Changing status of asset ' . $deletedAsset->getId() . ' to: ' . asset::ASSET_STATUS_READY . ".\n";
    $deletedAsset->setStatus(asset::ASSET_STATUS_READY);
    $deletedAsset->save();
    assetPeer::clearInstancePool();
    FileSyncPeer::setUseCriteriaFilter(false);
    $assetSyncKey = $deletedAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
    $assetfileSyncs = FileSyncPeer::retrieveAllByFileSyncKey($assetSyncKey);
    foreach ($assetfileSyncs as $assetfileSync) {
        if ($assetfileSync->getStatus() == FileSync::FILE_SYNC_STATUS_DELETED || $assetfileSync->getStatus() == FileSync::FILE_SYNC_STATUS_PURGED) {
            $file_full_path = $assetfileSync->getFullPath();
            if (file_exists($file_full_path)) {
                echo 'LOG: Changing status of file_sync ' . $assetfileSync->getId() . ' to: ' . FileSync::FILE_SYNC_STATUS_READY . ".\n";
                $assetfileSync->setStatus(FileSync::FILE_SYNC_STATUS_READY);
                $assetfileSync->save();
Exemplo n.º 9
0
 public static function doSelect(Criteria $criteria, PropelPDO $con = null)
 {
     self::getInstance();
     return parent::doSelect($criteria, $con);
 }
Exemplo n.º 10
0
 private function getAllowedFlavorAssets(KSecureEntryHelper $secureEntryHelper, $entryId, $format = null, $isOriginal = false, $isBestPlay = false)
 {
     $flavorAsset = null;
     if ($isBestPlay) {
         $flavorAssets = assetPeer::retrieveReadyWebByEntryId($entryId);
     } else {
         $c = new Criteria();
         $c->add(assetPeer::ENTRY_ID, $entryId);
         if ($format) {
             $c->add(assetPeer::FILE_EXT, $format);
         }
         if ($isOriginal) {
             $c->add(assetPeer::IS_ORIGINAL, true);
         }
         $flavorAssets = assetPeer::doSelect($c);
     }
     foreach ($flavorAssets as $currentFlavorAsset) {
         if ($secureEntryHelper->isAssetAllowed($currentFlavorAsset)) {
             $flavorAsset = $currentFlavorAsset;
             break;
         }
     }
     return $flavorAsset;
 }
Exemplo n.º 11
0
            case assetParams::CONTAINER_FORMAT_SWF:
                $asset->setType(DocumentAssetType::get()->coreValue(DocumentAssetType::SWF));
                break;
            case thumbParams::CONTAINER_FORMAT_JPG:
                $asset->setType(assetType::THUMBNAIL);
                break;
            default:
                $asset->setType(assetType::FLAVOR);
                $asset->putInCustomData(flavorAsset::CUSTOM_DATA_FIELD_BITRATE, $asset->getBitrate());
                $asset->putInCustomData(flavorAsset::CUSTOM_DATA_FIELD_FRAME_RATE, $asset->getFrameRate());
                $asset->putInCustomData(flavorAsset::CUSTOM_DATA_FIELD_VIDEO_CODEC_ID, $asset->getVideoCodecId());
        }
        $asset->save();
    }
    assetPeer::clearInstancePool();
    $assets = assetPeer::doSelect($c, $con);
}
$c = new Criteria();
$c->add(assetParamsPeer::TYPE, 0);
$c->setLimit($entryLimitEachLoop);
$assetParams = assetParamsPeer::doSelect($c, $con);
while (count($assetParams)) {
    foreach ($assetParams as $assetParam) {
        switch ($assetParam->getFormat()) {
            case assetParams::CONTAINER_FORMAT_PDF:
                $assetParam->setType(DocumentAssetType::get()->coreValue(DocumentAssetType::PDF));
                break;
            case assetParams::CONTAINER_FORMAT_SWF:
                $assetParam->setType(DocumentAssetType::get()->coreValue(DocumentAssetType::SWF));
                break;
            case thumbParams::CONTAINER_FORMAT_JPG:
Exemplo n.º 12
0
 private function getWidevineFlavorAssetsForEntry($entryId)
 {
     $c = new Criteria();
     $c->add(assetPeer::ENTRY_ID, $entryId);
     $flavorType = WidevinePlugin::getAssetTypeCoreValue(WidevineAssetType::WIDEVINE_FLAVOR);
     $c->add(assetPeer::TYPE, $flavorType);
     return assetPeer::doSelect($c);
 }
Exemplo n.º 13
0
 protected function servePlaylist($entry)
 {
     // allow only manual playlist
     if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_TEXT) {
         KExternalErrors::dieError(KExternalErrors::INVALID_ENTRY_TYPE);
     }
     // get request parameters
     $flavorParamIds = $this->getRequestParameter("flavorParamIds");
     if ($flavorParamIds) {
         $flavorParamIds = explode(',', $flavorParamIds);
     }
     $version = $this->getRequestParameter("v");
     // execute the playlist
     if ($version) {
         $entry->setDesiredVersion($version);
     }
     list($entryIds, $durations, $referenceEntry) = myPlaylistUtils::executeStitchedPlaylist($entry);
     if (!$referenceEntry) {
         KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
     }
     // load the flavor assets
     // Note: not filtering by $flavorParamIds here, so that in case some flavor is missing
     //		we can fill in the gap using some other flavor params
     $c = new Criteria();
     $c->add(assetPeer::ENTRY_ID, $entryIds, Criteria::IN);
     $c->add(assetPeer::STATUS, flavorAsset::FLAVOR_ASSET_STATUS_READY);
     $flavorTypes = assetPeer::retrieveAllFlavorsTypes();
     $c->add(assetPeer::TYPE, $flavorTypes, Criteria::IN);
     $flavorAssets = assetPeer::doSelect($c);
     // group the flavors by entry and flavor params
     $groupedFlavors = array();
     foreach ($flavorAssets as $flavor) {
         if (!isset($groupedFlavors[$flavor->getEntryId()])) {
             $groupedFlavors[$flavor->getEntryId()] = array();
         }
         $groupedFlavors[$flavor->getEntryId()][$flavor->getFlavorParamsId()] = $flavor;
     }
     // remove entries that don't have flavors
     for ($i = count($entryIds) - 1; $i >= 0; $i--) {
         $entryId = $entryIds[$i];
         if (isset($groupedFlavors[$entryId])) {
             continue;
         }
         unset($entryIds[$i]);
         unset($durations[$i]);
     }
     // get the flavor params of the reference entry that should be returned
     $referenceEntryFlavorParamsIds = array_keys($groupedFlavors[$referenceEntry->getId()]);
     if ($flavorParamIds) {
         $flavorParamIds = array_intersect($referenceEntryFlavorParamsIds, $flavorParamIds);
     } else {
         $flavorParamIds = $referenceEntryFlavorParamsIds;
     }
     if (!$flavorParamIds) {
         KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
     }
     // build the sequences
     $storeCache = true;
     $sequences = array();
     foreach ($flavorParamIds as $flavorParamsId) {
         $referenceFlavor = $groupedFlavors[$referenceEntry->getId()][$flavorParamsId];
         // build the clips of the current sequence
         $clips = array();
         foreach ($entryIds as $entryId) {
             if (isset($groupedFlavors[$entryId][$flavorParamsId])) {
                 $flavor = $groupedFlavors[$entryId][$flavorParamsId];
             } else {
                 // don't have a flavor for this entry in the desired flavor params,
                 // choose the one with the closest bitrate
                 $flavor = null;
                 foreach ($groupedFlavors[$entryId] as $curFlavor) {
                     if (!$flavor || abs($curFlavor->getBitrate() - $referenceFlavor->getBitrate()) < abs($flavor->getBitrate() - $referenceFlavor->getBitrate())) {
                         $flavor = $curFlavor;
                     }
                 }
             }
             // get the file path of the flavor
             $syncKey = $flavor->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
             list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, false, false);
             if ($fileSync) {
                 $resolvedFileSync = kFileSyncUtils::resolve($fileSync);
                 $path = $resolvedFileSync->getFullPath();
             } else {
                 error_log('missing file sync for flavor ' . $flavor->getId() . ' version ' . $flavor->getVersion());
                 $path = '';
                 $storeCache = false;
             }
             $clips[] = array('type' => 'source', 'path' => $path);
         }
         $sequences[] = array('clips' => $clips);
     }
     // build the json
     $mediaSet = array('durations' => $durations, 'sequences' => $sequences);
     $json = json_encode($mediaSet);
     $renderer = new kRendererString($json, self::JSON_CONTENT_TYPE);
     if ($storeCache) {
         $this->storeCache($renderer, $entry->getPartnerId());
     }
     $renderer->output();
     KExternalErrors::dieGracefully();
 }
 public function validateForSubmission(EntryDistribution $entryDistribution, $action)
 {
     $validationErrors = parent::validateForSubmission($entryDistribution, $action);
     // make sure that all flavor assets marked for distribution have a flavor params id assigned to them
     $flavorAssetIds = explode(',', $entryDistribution->getFlavorAssetIds());
     if (count($flavorAssetIds)) {
         $c = new Criteria();
         $c->addAnd(assetPeer::ID, $flavorAssetIds, Criteria::IN);
         $flavorTypes = assetPeer::retrieveAllFlavorsTypes();
         $c->add(assetPeer::TYPE, $flavorTypes, Criteria::IN);
         $flavorAssets = assetPeer::doSelect($c);
         foreach ($flavorAssets as $asset) {
             /* @var $asset flavorAsset */
             if (strlen($asset->getFlavorParamsId()) <= 0) {
                 $validationErrors[] = $this->createValidationError($action, DistributionErrorType::INVALID_DATA, 'flavor asset', 'flavor asset must be assigned to a flavor params id');
             }
         }
     }
     return $validationErrors;
 }
Exemplo n.º 15
0
 /**
  * @param entry $entry
  */
 protected function entryDeleted(entry $entry)
 {
     $this->syncableDeleted($entry->getId(), FileSyncObjectType::ENTRY);
     // delete flavor assets
     $c = new Criteria();
     $c->add(assetPeer::ENTRY_ID, $entry->getId());
     $c->add(assetPeer::STATUS, asset::FLAVOR_ASSET_STATUS_DELETED, Criteria::NOT_EQUAL);
     $c->add(assetPeer::DELETED_AT, null, Criteria::ISNULL);
     $assets = assetPeer::doSelect($c);
     foreach ($assets as $asset) {
         $asset->setStatus(asset::FLAVOR_ASSET_STATUS_DELETED);
         $asset->setDeletedAt(time());
         $asset->save();
     }
     $c = new Criteria();
     $c->add(assetParamsOutputPeer::ENTRY_ID, $entry->getId());
     $c->add(assetParamsOutputPeer::DELETED_AT, null, Criteria::ISNULL);
     $flavorParamsOutputs = assetParamsOutputPeer::doSelect($c);
     foreach ($flavorParamsOutputs as $flavorParamsOutput) {
         $flavorParamsOutput->setDeletedAt(time());
         $flavorParamsOutput->save();
     }
     $filter = new categoryEntryFilter();
     $filter->setEntryIdEqual($entry->getId());
     $c = new Criteria();
     $c->add(categoryEntryPeer::ENTRY_ID, $entry->getId());
     if (!categoryEntryPeer::doSelectOne($c)) {
         return;
     }
     kJobsManager::addDeleteJob($entry->getPartnerId(), DeleteObjectType::CATEGORY_ENTRY, $filter);
 }
Exemplo n.º 16
0
 public static function getManifestEditors($config)
 {
     $contributors = array();
     switch ($config->format) {
         case PlaybackProtocol::APPLE_HTTP:
             $contributor = new WebVttCaptionsManifestEditor();
             $contributor->captions = array();
             //retrieve the current working partner's captions according to the entryId
             $c = new Criteria();
             $c->addAnd(assetPeer::ENTRY_ID, $config->entryId);
             $c->addAnd(assetPeer::TYPE, CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION));
             $captionAssets = assetPeer::doSelect($c);
             if (!count($captionAssets)) {
                 return array();
             }
             foreach ($captionAssets as $captionAsset) {
                 /* @var $captionAsset CaptionAsset */
                 $captionAssetObj = array();
                 if ($captionAsset->getContainerFormat() == CaptionType::WEBVTT) {
                     $captionAssetObj['url'] = $captionAsset->getExternalUrl($config->storageId);
                 } else {
                     if (!PermissionPeer::isValidForPartner(CaptionPermissionName::FEATURE_GENERATE_WEBVTT_CAPTIONS, $captionAsset->getPartnerId())) {
                         continue;
                     }
                     $cdnHost = myPartnerUtils::getCdnHost($captionAsset->getPartnerId());
                     $versionStr = '';
                     if ($captionAsset->getVersion() > 1) {
                         $versionStr = '/version/' . $captionAsset->getVersion();
                     }
                     $ksStr = '';
                     if ($captionAsset->isKsNeededForDownload()) {
                         $ksStr = '/ks/' . self::generateKsForCaptionServe($captionAsset);
                     }
                     $captionAssetObj['url'] = $cdnHost . '/api_v3/index.php/service/caption_captionasset/action/serveWebVTT' . '/captionAssetId/' . $captionAsset->getId() . $ksStr . $versionStr . '/a.m3u8';
                 }
                 $label = $captionAsset->getLabel();
                 if (!$label) {
                     $label = $captionAsset->getLanguage();
                 }
                 if (!$label) {
                     $label = 'Track' . (count($contributor->captions) + 1);
                 }
                 $captionAssetObj['label'] = $label;
                 $captionAssetObj['default'] = $captionAsset->getDefault() ? "YES" : "NO";
                 if (isset(self::$captionsFormatMap[$captionAsset->getLanguage()])) {
                     $captionAssetObj['language'] = self::$captionsFormatMap[$captionAsset->getLanguage()];
                 }
                 KalturaLog::info("Object passed into editor: " . print_r($captionAssetObj, true));
                 $contributor->captions[] = $captionAssetObj;
             }
             KalturaLog::debug("contributor captions :" . print_r($contributor->captions, true));
             if ($contributor->captions) {
                 $contributors[] = $contributor;
             }
             break;
     }
     return $contributors;
 }
Exemplo n.º 17
0
 public static function doSelectAscendingBitrate(Criteria $criteria, PropelPDO $con = null)
 {
     $assets = assetPeer::doSelect($criteria);
     usort($assets, array('assetPeer', 'compareBitrate'));
     return $assets;
 }
Exemplo n.º 18
0
 /**
  * Get Flavor Asset with the relevant Flavor Params (Flavor Params can exist without Flavor Asset & vice versa)
  * 
  * @action getFlavorAssetsWithParams
  * @param string $entryId
  * @return KalturaFlavorAssetWithParamsArray
  */
 public function getFlavorAssetsWithParamsAction($entryId)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     // get all the flavor params of partner 0 and the current partner (note that partner 0 is defined as partner group in service.ct)
     $c = new Criteria();
     $flavorTypes = assetParamsPeer::retrieveAllFlavorParamsTypes();
     $c->add(assetParamsPeer::TYPE, $flavorTypes, Criteria::IN);
     $partnerIds = array($dbEntry->getPartnerId(), PartnerPeer::GLOBAL_PARTNER);
     $c->add(assetParamsPeer::PARTNER_ID, array_map('strval', $partnerIds), Criteria::IN);
     $flavorParamsDb = assetParamsPeer::doSelect($c);
     // get the flavor assets for this entry
     $c = new Criteria();
     $flavorTypes = assetPeer::retrieveAllFlavorsTypes();
     $c->add(assetPeer::TYPE, $flavorTypes, Criteria::IN);
     $c->add(assetPeer::ENTRY_ID, $entryId);
     $c->add(assetPeer::STATUS, array(flavorAsset::FLAVOR_ASSET_STATUS_DELETED, flavorAsset::FLAVOR_ASSET_STATUS_TEMP), Criteria::NOT_IN);
     $flavorAssetsDb = assetPeer::doSelect($c);
     // find what flavot params are required
     $requiredFlavorParams = array();
     foreach ($flavorAssetsDb as $item) {
         $requiredFlavorParams[$item->getFlavorParamsId()] = true;
     }
     // now merge the results, first organize the flavor params in an array with the id as the key
     $flavorParamsArray = array();
     foreach ($flavorParamsDb as $item) {
         $flavorParams = $item->getId();
         $flavorParamsArray[$flavorParams] = $item;
         if (isset($requiredFlavorParams[$flavorParams])) {
             unset($requiredFlavorParams[$flavorParams]);
         }
     }
     // adding missing required flavors params to the list
     if (count($requiredFlavorParams)) {
         $flavorParamsDb = assetParamsPeer::retrieveByPKsNoFilter(array_keys($requiredFlavorParams));
         foreach ($flavorParamsDb as $item) {
             $flavorParamsArray[$item->getId()] = $item;
         }
     }
     $usedFlavorParams = array();
     // loop over the flavor assets and add them, if it has flavor params add them too
     $flavorAssetWithParamsArray = new KalturaFlavorAssetWithParamsArray();
     foreach ($flavorAssetsDb as $flavorAssetDb) {
         $flavorParamsId = $flavorAssetDb->getFlavorParamsId();
         $flavorAssetWithParams = new KalturaFlavorAssetWithParams();
         $flavorAssetWithParams->entryId = $entryId;
         $flavorAsset = KalturaFlavorAsset::getInstance($flavorAssetDb, $this->getResponseProfile());
         $flavorAssetWithParams->flavorAsset = $flavorAsset;
         if (isset($flavorParamsArray[$flavorParamsId])) {
             $flavorParamsDb = $flavorParamsArray[$flavorParamsId];
             $flavorParams = KalturaFlavorParamsFactory::getFlavorParamsInstance($flavorParamsDb->getType());
             $flavorParams->fromObject($flavorParamsDb, $this->getResponseProfile());
             $flavorAssetWithParams->flavorParams = $flavorParams;
             // we want to log which flavor params are in use, there could be more
             // than one flavor asset using same params
             $usedFlavorParams[$flavorParamsId] = $flavorParamsId;
         }
         //			else if ($flavorAssetDb->getIsOriginal())
         //			{
         //				// create a dummy flavor params
         //				$flavorParams = new KalturaFlavorParams();
         //				$flavorParams->name = "Original source";
         //				$flavorAssetWithParams->flavorParams = $flavorParams;
         //			}
         $flavorAssetWithParamsArray[] = $flavorAssetWithParams;
     }
     // copy the remaining params
     foreach ($flavorParamsArray as $flavorParamsId => $flavorParamsDb) {
         if (isset($usedFlavorParams[$flavorParamsId])) {
             // flavor params already exists for a flavor asset, not need
             // to list it one more time
             continue;
         }
         $flavorParams = KalturaFlavorParamsFactory::getFlavorParamsInstance($flavorParamsDb->getType());
         $flavorParams->fromObject($flavorParamsDb, $this->getResponseProfile());
         $flavorAssetWithParams = new KalturaFlavorAssetWithParams();
         $flavorAssetWithParams->entryId = $entryId;
         $flavorAssetWithParams->flavorParams = $flavorParams;
         $flavorAssetWithParamsArray[] = $flavorAssetWithParams;
     }
     return $flavorAssetWithParamsArray;
 }
Exemplo n.º 19
0
 public static function decideLiveProfile(LiveEntry $entry)
 {
     // find all live assets of the entry
     $c = new Criteria();
     $c->add(assetPeer::PARTNER_ID, $entry->getPartnerId());
     $c->add(assetPeer::ENTRY_ID, $entry->getId());
     $c->add(assetPeer::TYPE, assetType::LIVE);
     // include deleted assets
     assetPeer::setUseCriteriaFilter(false);
     $liveAssets = assetPeer::doSelect($c);
     assetPeer::setUseCriteriaFilter(true);
     // build array of all assets with asset params id as key
     $liveAssetsParams = array();
     foreach ($liveAssets as $liveAsset) {
         /* @var $liveAsset liveAsset */
         $flavorParamsId = is_null($liveAsset->getFlavorParamsId()) ? $liveAsset->getId() : $liveAsset->getFlavorParamsId();
         $liveAssetsParams[$flavorParamsId] = $liveAsset;
     }
     $flavorParamsConversionProfileArray = flavorParamsConversionProfilePeer::retrieveByConversionProfile($entry->getConversionProfileId());
     $liveParamIdsArray = array();
     foreach ($flavorParamsConversionProfileArray as $flavorParamsConversionProfile) {
         /* @var $flavorParamsConversionProfile flavorParamsConversionProfile */
         $liveParamIdsArray[] = $flavorParamsConversionProfile->getFlavorParamsId();
     }
     asort($liveParamIdsArray);
     $liveParamIds = implode(",", $liveParamIdsArray);
     if ($liveParamIds == $entry->getFlavorParamsIds()) {
         return;
     }
     $streamBitrates = array();
     $definedRecordingAnchor = false;
     foreach ($flavorParamsConversionProfileArray as $flavorParamsConversionProfile) {
         /* @var $flavorParamsConversionProfile flavorParamsConversionProfile */
         $liveParams = $flavorParamsConversionProfile->getassetParams();
         if ($liveParams instanceof liveParams) {
             if ($flavorParamsConversionProfile->getOrigin() == assetParamsOrigin::INGEST) {
                 $streamBitrate = array('bitrate' => $liveParams->getVideoBitrate(), 'width' => $liveParams->getWidth(), 'height' => $liveParams->getHeight(), 'tags' => $liveParams->getTags());
                 $streamBitrates[] = $streamBitrate;
             }
             // check if asset already exists
             if (isset($liveAssetsParams[$liveParams->getId()])) {
                 $liveAsset = $liveAssetsParams[$liveParams->getId()];
                 $liveAsset->setDeletedAt(null);
                 // remove the asset from the list, the left assets will be deleted later
                 unset($liveAssetsParams[$liveParams->getId()]);
             } else {
                 // create a new asset
                 $liveAsset = new liveAsset();
                 $liveAsset->setType(assetType::LIVE);
                 $liveAsset->setPartnerId($entry->getPartnerId());
                 $liveAsset->setFlavorParamsId($liveParams->getId());
                 $liveAsset->setFromAssetParams($liveParams);
                 $liveAsset->setEntryId($entry->getId());
                 if ($entry->getRecordStatus() && !$definedRecordingAnchor) {
                     // We specifically add a flag that does NOT exist on the live asset, since we can't predict which
                     // live params the conversion profile is going to contain.
                     $liveAsset->addTags(array(assetParams::TAG_RECORDING_ANCHOR));
                     $definedRecordingAnchor = true;
                 }
             }
             // set the status according to the entry status
             if ($entry->getStatus() == entryStatus::READY) {
                 $liveAsset->setStatus(asset::ASSET_STATUS_READY);
             } else {
                 $liveAsset->setStatus(asset::ASSET_STATUS_IMPORTING);
             }
             $liveAsset->save();
         }
     }
     // delete all left assets
     foreach ($liveAssetsParams as $liveAsset) {
         /* @var $liveAsset liveAsset */
         $liveAsset->setDeletedAt(time());
         $liveAsset->setStatus(asset::ASSET_STATUS_DELETED);
         $liveAsset->save();
     }
     if (!count($streamBitrates)) {
         $streamBitrate = array('bitrate' => 900, 'width' => 640, 'height' => 480);
         $streamBitrates[] = $streamBitrate;
     }
     $entry->setStreamBitrates($streamBitrates);
     $entry->save();
 }
Exemplo n.º 20
0
function convertFlavorsTags(Partner $partner, Criteria $c)
{
    assetPeer::setDefaultCriteriaFilter(false);
    $flavors = assetPeer::doSelect($c);
    foreach ($flavors as $flavor) {
        if (DEBUG) {
            KalturaLog::debug("select tags, partner_id, is_original, file_ext, id from flavor_asset where id = '{$flavor->getId()}';");
            KalturaLog::debug("update flavor_asset set tags = 'mbr,web' where id = '{$flavor->getId()}';");
        } else {
            $flavor->setTags('mbr,web');
            $flavor->save();
        }
    }
    assetPeer::setDefaultCriteriaFilter(true);
}
Exemplo n.º 21
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(assetPeer::DATABASE_NAME);
         $criteria->add(assetPeer::INT_ID, $pks, Criteria::IN);
         $objs = assetPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Exemplo n.º 22
0
 /**
  * @action getByEntryId
  * @param string $entryId
  * @return KalturaThumbAssetArray
  * 
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  * @deprecated Use thumbAsset.list instead
  */
 public function getByEntryIdAction($entryId)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     // get the thumb assets for this entry
     $c = new Criteria();
     $c->add(assetPeer::ENTRY_ID, $entryId);
     //KMC currently does not support showing thumb asset extending types
     //$thumbTypes = KalturaPluginManager::getExtendedTypes(assetPeer::OM_CLASS, assetType::THUMBNAIL);
     //$c->add(assetPeer::TYPE, $thumbTypes, Criteria::IN);
     $c->add(assetPeer::TYPE, assetType::THUMBNAIL, Criteria::EQUAL);
     $thumbAssetsDb = assetPeer::doSelect($c);
     $thumbAssets = KalturaThumbAssetArray::fromDbArray($thumbAssetsDb, $this->getResponseProfile());
     return $thumbAssets;
 }
Exemplo n.º 23
0
 /**
  * Gets an array of asset objects which contain a foreign key that references this object.
  *
  * If this collection has already been initialized with an identical Criteria, it returns the collection.
  * Otherwise if this entry has previously been saved, it will retrieve
  * related assets from storage. If this entry is new, it will return
  * an empty collection or the current collection, the criteria is ignored on a new object.
  *
  * @param      PropelPDO $con
  * @param      Criteria $criteria
  * @return     array asset[]
  * @throws     PropelException
  */
 public function getassets($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(entryPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collassets === null) {
         if ($this->isNew()) {
             $this->collassets = array();
         } else {
             $criteria->add(assetPeer::ENTRY_ID, $this->id);
             assetPeer::addSelectColumns($criteria);
             $this->collassets = assetPeer::doSelect($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return the collection.
             $criteria->add(assetPeer::ENTRY_ID, $this->id);
             assetPeer::addSelectColumns($criteria);
             if (!isset($this->lastassetCriteria) || !$this->lastassetCriteria->equals($criteria)) {
                 $this->collassets = assetPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastassetCriteria = $criteria;
     return $this->collassets;
 }
Exemplo n.º 24
0
 public function getassets($criteria = null, PropelPDO $con = null)
 {
     if ($this->isNew()) {
         return array();
     }
     if ($criteria === null) {
         $criteria = new Criteria(assetParamsPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     $criteria->add(assetPeer::FLAVOR_PARAMS_ID, $this->id);
     assetPeer::addSelectColumns($criteria);
     return assetPeer::doSelect($criteria, $con);
 }
chdir(dirname(__FILE__));
require_once dirname(__FILE__) . '/../bootstrap.php';
if (count($argv) !== 2) {
    die('pleas provide partner id as input' . PHP_EOL . 'to run script: ' . basename(__FILE__) . ' X' . PHP_EOL . 'whereas X is partner id' . PHP_EOL);
}
$partner_id = @$argv[1];
$partner = PartnerPeer::retrieveByPK($partner_id);
if (!$partner) {
    die('no such partner.' . PHP_EOL);
}
$c = new Criteria();
$c->add(assetPeer::PARTNER_ID, $partner_id);
$c->add(assetPeer::IS_ORIGINAL, true);
$c->add(assetPeer::STATUS, flavorAsset::FLAVOR_ASSET_STATUS_READY);
$con = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2);
$flavorAssets = assetPeer::doSelect($c, $con);
$changedEntriesCounter = 0;
foreach ($flavorAssets as $flavorAsset) {
    $flavorSyncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
    try {
        if (!kFileSyncUtils::file_exists($flavorSyncKey, true)) {
            echo 'changed source flavor asset to status deleted for entry: ' . $flavorAsset->getEntryId() . ' and for flavor id ' . $flavorAsset->getId() . PHP_EOL;
            // set the status of the flavor asset to deleted and set deleted time (taken from flavorAssetService)
            $entry = $flavorAsset->getEntry();
            if ($entry) {
                $entry->removeFlavorParamsId($flavorAsset->getFlavorParamsId());
                $entry->save();
            }
            $flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_DELETED);
            $flavorAsset->setDeletedAt(time());
            $flavorAsset->save();
Exemplo n.º 26
0
 protected static function deleteErrorAssets()
 {
     $criteria = new Criteria();
     $criteria->add(assetPeer::STATUS, array(asset::ASSET_STATUS_READY, asset::ASSET_STATUS_DELETED), Criteria::NOT_IN);
     $criteria->add(assetPeer::UPDATED_AT, self::$errObjectsUpdatedAt, Criteria::LESS_THAN);
     $criteria->addSelectColumn('UNIX_TIMESTAMP(MIN(' . assetPeer::UPDATED_AT . '))');
     $stmt = assetPeer::doSelectStmt($criteria);
     $mins = $stmt->fetchAll(PDO::FETCH_COLUMN);
     if (!count($mins)) {
         return;
     }
     $errObjectsUpdatedAtStart = reset($mins);
     if (is_null($errObjectsUpdatedAtStart)) {
         return;
     }
     $errObjectsUpdatedAtEnd = min(self::$errObjectsUpdatedAt, $errObjectsUpdatedAtStart + 60 * 60 * 24 * 30);
     // month
     $criteria = new Criteria();
     $criteria->add(assetPeer::STATUS, array(asset::ASSET_STATUS_READY, asset::ASSET_STATUS_DELETED), Criteria::NOT_IN);
     $criteria->add(assetPeer::UPDATED_AT, $errObjectsUpdatedAtStart, Criteria::LESS_THAN);
     $criteria->addAnd(entryPeer::UPDATED_AT, $errObjectsUpdatedAtEnd, Criteria::LESS_THAN);
     $criteria->addDescendingOrderByColumn(assetPeer::SIZE);
     $criteria->setLimit(self::$queryLimit);
     $assets = assetPeer::doSelect($criteria);
     foreach ($assets as $asset) {
         /* @var $asset asset */
         KalturaLog::info("Deleting asset [" . $asset->getId() . "]");
         $asset->setStatus(asset::ASSET_STATUS_DELETED);
         try {
             $asset->save();
         } catch (Exception $e) {
             KalturaLog::err($e);
         }
     }
     self::incrementSummary('asset', count($assets));
     kMemoryManager::clearMemory();
 }
 /**
  * List attachment Assets by filter and pager
  * 
  * @action list
  * @param KalturaAssetFilter $filter
  * @param KalturaFilterPager $pager
  * @return KalturaAttachmentAssetListResponse
  */
 function listAction(KalturaAssetFilter $filter = null, KalturaFilterPager $pager = null)
 {
     if (!$filter) {
         $filter = new KalturaAssetFilter();
     }
     if (!$pager) {
         $pager = new KalturaFilterPager();
     }
     $attachmentAssetFilter = new AssetFilter();
     $filter->toObject($attachmentAssetFilter);
     $c = new Criteria();
     $attachmentAssetFilter->attachToCriteria($c);
     $types = KalturaPluginManager::getExtendedTypes(assetPeer::OM_CLASS, AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT));
     $c->add(assetPeer::TYPE, $types, Criteria::IN);
     $totalCount = assetPeer::doCount($c);
     $pager->attachToCriteria($c);
     $dbList = assetPeer::doSelect($c);
     $list = KalturaAttachmentAssetArray::fromDbArray($dbList);
     $response = new KalturaAttachmentAssetListResponse();
     $response->objects = $list;
     $response->totalCount = $totalCount;
     return $response;
 }
Exemplo n.º 28
0
 echo 'changing status of entry ' . $deletedEntry->getId();
 $deletedEntry->setStatusReady();
 $deletedEntry->save();
 entryPeer::clearInstancePool();
 $entryFileSyncKey = $deletedEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
 $entryFileSyncs = FileSyncPeer::retrieveAllByFileSyncKey($entryFileSyncKey);
 foreach ($entryFileSyncs as $entryFileSync) {
     $entryFileSync->setStatus(FileSync::FILE_SYNC_STATUS_READY);
     $entryFileSync->save();
 }
 //Restore assets
 $assetCrit = new Criteria();
 $assetCrit->add(assetPeer::ENTRY_ID, $deletedEntry->getId(), Criteria::EQUAL);
 $assetCrit->add(assetPeer::STATUS, asset::ASSET_STATUS_DELETED, Criteria::EQUAL);
 assetPeer::setUseCriteriaFilter(false);
 $deletedAssets = assetPeer::doSelect($assetCrit);
 foreach ($deletedAssets as $deletedAsset) {
     /* @var $deletedAsset asset */
     echo 'changing status of asset ' . $deletedAsset->getId();
     $deletedAsset->setStatus(asset::ASSET_STATUS_READY);
     $deletedAsset->save();
     assetPeer::clearInstancePool();
     $assetSyncKey = $deletedAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
     $assetfileSyncs = FileSyncPeer::retrieveAllByFileSyncKey($assetSyncKey);
     foreach ($assetfileSyncs as $assetfileSync) {
         if ($assetfileSync->getStatus() == FileSync::FILE_SYNC_STATUS_DELETED) {
             $file_full_path = $assetfileSync->getFullPath();
             if (file_exists($file_full_path)) {
                 echo 'LOG: Changing status of file_sync ' . $assetfileSync->getId() . ' to: ' . FileSync::FILE_SYNC_STATUS_READY . ".\n";
                 $assetfileSync->setStatus(FileSync::FILE_SYNC_STATUS_READY);
                 $assetfileSync->save();
Exemplo n.º 29
0
 /**
  * Validate thumbnails dimensions
  * @param $entryDistribution
  * @param $action
  */
 private function validateThumbnailsDimensions($entryDistribution, $action)
 {
     $validationErrors = array();
     //Validating thumbnails
     $c = new Criteria();
     $c->addAnd(assetPeer::ID, explode(',', $entryDistribution->getThumbAssetIds()), Criteria::IN);
     $c->addAscendingOrderByColumn(assetPeer::ID);
     $thumbAssets = assetPeer::doSelect($c);
     $smallThumbFound = false;
     $largeThumbFound = false;
     if (count($thumbAssets)) {
         //if the thumbnails dimensions were not found
         if (!$smallThumbFound || !$largeThumbFound) {
             foreach ($thumbAssets as $thumbAsset) {
                 /* @var $thumbAsset KalturaThumbAsset */
                 if (empty($thumbAsset)) {
                     continue;
                 }
                 $width = $thumbAsset->width;
                 $height = $thumbAsset->height;
                 if ($width == self::SMALL_THUMB_WIDTH && $height == self::SMALL_THUMB_HEIGHT) {
                     $smallThumbFound = true;
                 }
                 if ($width == self::LARGE_THUMB_WIDTH && $height == self::LARGE_THUMB_HEIGHT) {
                     $largeThumbFound = true;
                 } else {
                     $errorMsg = 'thumbnail dimension must be [' . self::SMALL_THUMB_WIDTH . '] on [' . self::SMALL_THUMB_HEIGHT . '] , or [' . self::LARGE_THUMB_WIDTH . '] on [' . self::LARGE_THUMB_HEIGHT . ']';
                     $validationError = $this->createValidationError($action, DistributionErrorType::INVALID_DATA);
                     $validationError->setValidationErrorType(DistributionValidationErrorType::CUSTOM_ERROR);
                     $validationError->setValidationErrorParam($errorMsg);
                     $validationError->setDescription($errorMsg);
                     $validationErrors[] = $validationError;
                 }
             }
         }
     } else {
         $errorMsg = 'no thumbnails were supplied';
         $validationError = $this->createValidationError($action, DistributionErrorType::INVALID_DATA);
         $validationError->setValidationErrorType(DistributionValidationErrorType::CUSTOM_ERROR);
         $validationError->setValidationErrorParam($errorMsg);
         $validationError->setDescription($errorMsg);
         $validationErrors[] = $validationError;
     }
     return $validationErrors;
 }
Exemplo n.º 30
0
 /**
  * Restore deleted entry.
  *
  * @action restoreDeletedEntry
  * @param string $entryId
  * @return KalturaBaseEntry The restored entry
  */
 public function restoreDeletedEntryAction($entryId)
 {
     $deletedEntry = entryPeer::retrieveByPKNoFilter($entryId);
     if (!$deletedEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $fileSyncKeys = array();
     foreach (self::$fileSyncKeysToRestore as $key) {
         $fileSyncKeys[] = $deletedEntry->getSyncKey($key);
     }
     $c = new Criteria();
     $c->add(assetPeer::ENTRY_ID, $entryId, Criteria::EQUAL);
     assetPeer::setUseCriteriaFilter(false);
     $deletedAssets = assetPeer::doSelect($c);
     assetPeer::setUseCriteriaFilter(true);
     foreach ($deletedAssets as $deletedAsset) {
         array_push($fileSyncKeys, $deletedAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET), $deletedAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_CONVERT_LOG));
     }
     $fileSyncs = array();
     FileSyncPeer::setUseCriteriaFilter(false);
     foreach ($fileSyncKeys as $fileSyncKey) {
         $fileSyncs = array_merge($fileSyncs, FileSyncPeer::retrieveAllByFileSyncKey($fileSyncKey));
     }
     FileSyncPeer::setUseCriteriaFilter(true);
     if (!$this->validateEntryForRestoreDelete($deletedEntry, $fileSyncs, $deletedAssets)) {
         throw new KalturaAPIException(KalturaAdminConsoleErrors::ENTRY_ASSETS_WRONG_STATUS_FOR_RESTORE, $entryId);
     }
     $this->restoreFileSyncs($fileSyncs);
     //restore assets
     foreach ($deletedAssets as $deletedAsset) {
         $deletedAsset->setStatus(asset::ASSET_STATUS_READY);
         $deletedAsset->save();
     }
     //restore entry
     $deletedEntry->setStatusReady();
     $deletedEntry->setThumbnail($deletedEntry->getFromCustomData("deleted_original_thumb"), true);
     $deletedEntry->setData($deletedEntry->getFromCustomData("deleted_original_data"), true);
     //data should be resotred even if it's NULL
     $deletedEntry->save();
     kEventsManager::flushEvents();
     kMemoryManager::clearMemory();
     $entry = KalturaEntryFactory::getInstanceByType($deletedEntry->getType(), true);
     $entry->fromObject($deletedEntry, $this->getResponseProfile());
     return $entry;
 }