/**
  * @param CaptionAsset $captionAsset
  * @param BatchJob $parentJob
  * @throws kCoreException FILE_NOT_FOUND
  * @return BatchJob
  */
 public function addParseCaptionAssetJob(CaptionAsset $captionAsset, BatchJob $parentJob = null)
 {
     $syncKey = $captionAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
     $fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
     if (!$fileSync) {
         if (!PermissionPeer::isValidForPartner(CaptionPermissionName::IMPORT_REMOTE_CAPTION_FOR_INDEXING, $captionAsset->getPartnerId())) {
             throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
         }
         $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
         if (!$fileSync) {
             throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
         }
         $fullPath = myContentStorage::getFSUploadsPath() . '/' . $captionAsset->getId() . '.tmp';
         if (!kFile::downloadUrlToFile($fileSync->getExternalUrl($captionAsset->getEntryId()), $fullPath)) {
             throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
         }
         kFileSyncUtils::moveFromFile($fullPath, $syncKey, true, false, true);
     }
     $jobData = new kParseCaptionAssetJobData();
     $jobData->setCaptionAssetId($captionAsset->getId());
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild();
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($captionAsset->getEntryId());
         $batchJob->setPartnerId($captionAsset->getPartnerId());
     }
     return kJobsManager::addJob($batchJob, $jobData, CaptionSearchPlugin::getBatchJobTypeCoreValue(CaptionSearchBatchJobType::PARSE_CAPTION_ASSET));
 }
 public function initService($serviceId, $serviceName, $actionName)
 {
     parent::initService($serviceId, $serviceName, $actionName);
     if ($actionName != 'parse') {
         parent::applyPartnerFilterForClass(new assetPeer());
         parent::applyPartnerFilterForClass(new CaptionAssetItemPeer());
     }
     if (!CaptionSearchPlugin::isAllowedPartner($this->getPartnerId())) {
         throw new KalturaAPIException(KalturaErrors::SERVICE_FORBIDDEN, $this->serviceName . '->' . $this->actionName);
     }
 }
Пример #3
0
 public function initService($serviceId, $serviceName, $actionName)
 {
     $ks = kCurrentContext::$ks_object ? kCurrentContext::$ks_object : null;
     if ($actionName == 'search' && (!$ks || !$ks->isAdmin() && !$ks->verifyPrivileges(ks::PRIVILEGE_LIST, ks::PRIVILEGE_WILDCARD))) {
         KalturaCriterion::enableTag(KalturaCriterion::TAG_WIDGET_SESSION);
         entryPeer::setUserContentOnly(true);
     }
     parent::initService($serviceId, $serviceName, $actionName);
     if ($actionName != 'parse') {
         $this->applyPartnerFilterForClass('asset');
         $this->applyPartnerFilterForClass('CaptionAssetItem');
     }
     if (!CaptionSearchPlugin::isAllowedPartner($this->getPartnerId())) {
         throw new KalturaAPIException(KalturaErrors::FEATURE_FORBIDDEN, CaptionSearchPlugin::PLUGIN_NAME);
     }
 }
Пример #4
0
 public static function getCaptionSearchData(entry $entry)
 {
     $captionAssets = assetPeer::retrieveByEntryId($entry->getId(), array(CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)));
     if (!$captionAssets || !count($captionAssets)) {
         return null;
     }
     $data = array();
     foreach ($captionAssets as $captionAsset) {
         /* @var $captionAsset CaptionAsset */
         $syncKey = $captionAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         $content = kFileSyncUtils::file_get_contents($syncKey, true, false);
         if (!$content) {
             continue;
         }
         $captionsContentManager = kCaptionsContentManager::getCoreContentManager($captionAsset->getContainerFormat());
         if (!$captionsContentManager) {
             KalturaLog::err("Captions content manager not found for format [" . $captionAsset->getContainerFormat() . "]");
             continue;
         }
         $content = $captionsContentManager->getContent($content);
         if (!$content) {
             continue;
         }
         $data[] = $captionAsset->getId() . " ca_prefix {$content} ca_sufix";
     }
     $dataField = CaptionSearchPlugin::getSearchFieldName(CaptionSearchPlugin::SEARCH_FIELD_DATA);
     $searchValues = array($dataField => CaptionSearchPlugin::PLUGIN_NAME . ' ' . implode(' ', $data) . ' ' . CaptionSearchPlugin::SEARCH_TEXT_SUFFIX);
     return $searchValues;
 }
 protected function createSphinxMatchPhrase($text)
 {
     $condition = "ca_prefix<<{$text}<<ca_sufix";
     $prefix = '@' . CaptionSearchPlugin::getSearchFieldName(CaptionSearchPlugin::SEARCH_FIELD_DATA);
     return $prefix . ' ' . $condition;
 }
 private function addCondition($conditionStr, IKalturaIndexQuery $query)
 {
     if (!is_null($conditionStr)) {
         $condition = "ca_prefix<<{$conditionStr}<<ca_sufix";
         KalturaLog::debug("condition [" . print_r($condition, true) . "]");
         $key = '@' . CaptionSearchPlugin::getSearchFieldName(CaptionSearchPlugin::SEARCH_FIELD_DATA);
         $query->addMatch("({$key} {$condition})");
     }
 }