public function execute()
 {
     $this->forceSystemAuthentication();
     myDbHelper::$use_alternative_con = null;
     $go = $this->getP("go");
     $filter = new ConversionProfileFilter();
     $this->list = array();
     $fields_set = $filter->fillObjectFromRequest($_REQUEST, "filter_", null);
     if ($go) {
         $c = new Criteria();
         // filter
         $filter->attachToCriteria($c);
         //if ($order_by != -1) kshowPeer::setOrder( $c , $order_by );
         $this->list = ConversionProfilePeer::doSelect($c);
     }
     $the_conv = myConversionProfileUtils::getConversionProfile($filter->get("_eq_partner_id"), $filter->get("_eq_profile_type"));
     $selected = false;
     if ($the_conv) {
         foreach ($this->list as &$conv) {
             if ($conv->getId() == $the_conv->getId()) {
                 $selected = true;
                 $conv->selected = true;
             }
         }
     }
     // is none was selected - need to add the_conv to the list
     if (!$selected && $the_conv) {
         $the_conv->selected = true;
         $this->list[] = $the_conv;
     }
     $this->filter = $filter;
 }
Example #2
0
 /**
  * 
  * @param $version
  * @param $format
  * @return FileSync
  */
 public function getDownloadFileSyncAndLocal($version = NULL, $format = null, $sub_type = null)
 {
     $flavorParams = myConversionProfileUtils::getFlavorParamsFromFileFormat($this->getPartnerId(), $format);
     if (!$flavorParams) {
         return null;
     }
     $flavorAssets = assetPeer::retrieveByEntryIdAndParams($this->getId(), $flavorParams->getId());
     if (!$flavorAssets) {
         return null;
     }
     $syncKey = $flavorAssets->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     if (!$syncKey) {
         return null;
     }
     return kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
 }
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     KalturaLog::log("adddownloadAction: executeImpl ( {$partner_id} , {$subp_id} , {$puser_id} , {$partner_prefix} , {$puser_kuser})");
     $entry_id = $this->getPM("entry_id");
     $version = $this->getP("version");
     $file_format = strtolower($this->getPM("file_format"));
     $conversion_quality = $this->getP("conversion_quality", null);
     $force_download = $this->getP("force_download", null);
     $entry = entryPeer::retrieveByPK($entry_id);
     if (!$entry) {
         KalturaLog::log("add download Action entry not found");
         $this->addError(APIErrors::INVALID_ENTRY_ID, $this->getObjectPrefix(), $entry_id);
         return;
     }
     KalturaLog::log("adddownloadAction: entry found [{$entry_id}]");
     /*			
     $content_path = myContentStorage::getFSContentRootPath();
     $file_name = $content_path . $entry->getDataPath( $version ); // replaced__getDataPath
     if (!file_exists($file_name))
     */
     $sync_key = null;
     $originalFlavorAsset = assetPeer::retrieveOriginalByEntryId($entry->getId());
     if ($originalFlavorAsset) {
         $sync_key = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     }
     if (!$sync_key) {
         $sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version);
     }
     if (!kFileSyncUtils::file_exists($sync_key)) {
         // if not found local file - perhaps wasn't created here and wasn't synced yet
         // try to see if remote exists - and proxy the request if it is.
         list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($sync_key, true, true);
         if (!$local) {
             // take input params and add to URL
             $queryArr = array('entry_id' => $entry_id, 'version' => $version, 'file_format' => $file_format, 'conversion_quality' => $conversion_quality, 'force_download' => $force_download, 'ks' => $this->ks->toSecureString(), 'partner_id' => $partner_id, 'subp_id' => $subp_id, 'format' => $this->response_type);
             $get_query = http_build_query($queryArr, '', '&');
             $remote_url = kDataCenterMgr::getRedirectExternalUrl($fileSync, $_SERVER['REQUEST_URI']);
             $url = strpos($remote_url, '?') === FALSE ? $remote_url . '?' . $get_query : $remote_url . '&' . $get_query;
             // prxoy request to other DC
             KalturaLog::log(__METHOD__ . ": redirecting to [{$url}]");
             kFileUtils::dumpUrl($url);
         }
         KalturaLog::log("add download Action sync key doesn't exists");
         $this->addError(APIErrors::INVALID_ENTRY_VERSION, $this->getObjectPrefix(), $entry_id, $version);
         return;
     }
     if ($entry->getType() == entryType::MIX) {
         KalturaLog::log("The Batch job for flattening a mix is no longer supported");
         $this->addError(APIErrors::INVALID_ENTRY_TYPE, $this->getObjectPrefix(), $entry_id, $version);
         return;
     }
     $flavorParamsId = 0;
     if ($file_format != "original") {
         if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO) {
             $file_format = "flv";
         }
         // Backward compatebility
         if (!$file_format && $entry->getType() == entryType::DOCUMENT) {
             $file_format = "swf";
         }
         $flavorParams = myConversionProfileUtils::getFlavorParamsFromFileFormat($partner_id, $file_format);
         $flavorParamsId = $flavorParams->getId();
     }
     $jobs = kJobsManager::addBulkDownloadJob($partner_id, $puser_id, $entry->getId(), $flavorParamsId);
     $job = $jobs[0];
     // remove kConvertJobData object from batchJob.data
     $job->setData(null);
     $jobWrapperClass = objectWrapperBase::getWrapperClass($job, objectWrapperBase::DETAIL_LEVEL_DETAILED);
     $this->addMsg("download", $jobWrapperClass);
     // Backwards compatebilty for document entries
     if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_DOCUMENT || $entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_PDF) {
         $this->addMsg("OOconvert", $jobWrapperClass);
         $download_path = $entry->getDownloadUrl();
         //TODO: once api_v3 will support parameters with '/' instead of '?', we can change this to war with api_v3
         $download_path .= '/direct_serve/true/type/download/forceproxy/true/format/' . $file_format;
         $this->addMsg('downloadUrl', $download_path);
     }
 }
Example #4
0
 /**
  * @param int $partner_id
  * @return conversionProfile2
  */
 public static function getConversionProfile2ForPartner($partner_id, $conversionProfile2Id = null)
 {
     if ($conversionProfile2Id == conversionProfile2::CONVERSION_PROFILE_NONE) {
         return null;
     }
     if (!$conversionProfile2Id) {
         // try to extract the conversion profile from the partner
         $partner = PartnerPeer::retrieveByPK($partner_id);
         if (!$partner) {
             throw new Exception("Cannot find partner for id [{$partner_id}]");
         }
         $partner_kmc_version = $partner->getKmcVersion();
         if (is_null($partner_kmc_version) || version_compare($partner_kmc_version, "2", "<")) {
             $old_conversion_profile = self::getCurrentConversionProfile($partner->getId());
             if (!$old_conversion_profile) {
                 throw new Exception("Cannot find conversion profile for partner id [{$partner_id}]");
             }
             return myConversionProfileUtils::createConversionProfile2FromConversionProfile($old_conversion_profile);
         }
         $conversionProfile2Id = $partner->getDefaultConversionProfileId();
     }
     return conversionProfile2Peer::retrieveByPk($conversionProfile2Id);
 }
Example #5
0
 /**
  * Request a new conversion job, this can be used to convert the media entry to a different format
  * 
  * @action requestConversion
  * @param string $entryId Media entry id
  * @param string $fileFormat Format to convert
  * @return int The queued job id
  * 
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  */
 public function requestConversionAction($entryId, $fileFormat)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry || $dbEntry->getType() != KalturaEntryType::MEDIA_CLIP) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     if ($dbEntry->getMediaType() == KalturaMediaType::AUDIO) {
         // for audio - force format flv regardless what the user really asked for
         $fileFormat = "flv";
     }
     //		$job = myBatchDownloadVideoServer::addJob($this->getKuser()->getPuserId(), $dbEntry, null, $fileFormat);
     $flavorParams = myConversionProfileUtils::getFlavorParamsFromFileFormat($this->getPartnerId(), $fileFormat);
     $err = null;
     $job = kBusinessPreConvertDL::decideAddEntryFlavor(null, $dbEntry->getId(), $flavorParams->getId(), $err);
     if ($job) {
         return $job->getId();
     } else {
         return null;
     }
 }
Example #6
0
 /**
  * This will queue a batch job for converting the document file to swf
  * Returns the URL where the new swf will be available 
  * 
  * @action convertPptToSwf
  * @param string $entryId
  * @return string
  */
 function convertPptToSwf($entryId)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry || $dbEntry->getType() != KalturaEntryType::DOCUMENT) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $flavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
     if (is_null($flavorAsset) || !$flavorAsset->isLocalReadyStatus()) {
         throw new KalturaAPIException(KalturaErrors::ORIGINAL_FLAVOR_ASSET_IS_MISSING);
     }
     $sync_key = null;
     $sync_key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     if (!kFileSyncUtils::file_exists($sync_key)) {
         // if not found local file - perhaps wasn't created here and wasn't synced yet
         // try to see if remote exists - and proxy the request if it is.
         list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($sync_key, true, true);
         if (!$local) {
             $remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrl($fileSync);
             kFileUtils::dumpApiRequest($remoteDCHost);
         }
         KalturaLog::log("convertPptToSwf sync key doesn't exists");
         return;
     }
     $flavorParams = myConversionProfileUtils::getFlavorParamsFromFileFormat($dbEntry->getPartnerId(), flavorParams::CONTAINER_FORMAT_SWF);
     $flavorParamsId = $flavorParams->getId();
     $puserId = $this->getKuser()->getPuserId();
     $err = "";
     kBusinessPreConvertDL::decideAddEntryFlavor(null, $dbEntry->getId(), $flavorParamsId, $err);
     $downloadPath = $dbEntry->getDownloadUrl();
     //TODO: once api_v3 will support parameters with '/' instead of '?', we can change this to war with api_v3
     return $downloadPath . '/direct_serve/true/type/download/forceproxy/true/format/swf';
 }
        KalturaLog::debug("Partner was set with DefaultConversionProfileId: " . $partner->getDefaultConversionProfileId());
        $partner->setKmcVersion('4');
        $partner->save();
        die;
    }
} else {
    // no currentConversionProfileType, lets see what on default
    $defConversionProfileType = $partner->getFromCustomData('defConversionProfileType');
    if (!is_null($defConversionProfileType)) {
        $oldCp = myConversionProfileUtils::getConversionProfile($partner->getId(), $defConversionProfileType);
        if (!$oldCp->getConversionProfile2Id() && $oldCp->getPartnerId() == $partner->getId()) {
            if (DEBUG) {
                KalturaLog::debug("This was dry-run, going to convert old default conversion profile according to defConversionProfileType");
                die;
            } else {
                myConversionProfileUtils::createConversionProfile2FromConversionProfile($oldCp);
                // set new id on defaultConversionProfileId
                $partner->setDefaultConversionProfileId($oldCp->getConversionProfile2Id());
                $partner->setKmcVersion('4');
                $partner->save();
                KalturaLog::debug("converted old default conversion profile. new DefaultConversionProfileId is: " . $partner->getDefaultConversionProfileId());
                die;
            }
        }
    }
}
// if we didn't exit so far, copy from template
if (DEBUG) {
    KalturaLog::debug("This was dry-run, going to copy from template_partner_id");
    die;
} else {
Example #8
0
 /**
  * This will queue a batch job for converting the document file to swf
  * Returns the URL where the new swf will be available 
  * 
  * @action convertPptToSwf
  * @param string $entryId
  * @return string
  */
 function convertPptToSwf($entryId)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry || $dbEntry->getType() != KalturaEntryType::DOCUMENT) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     assetPeer::resetInstanceCriteriaFilter();
     $flavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
     if (is_null($flavorAsset) || $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) {
         throw new KalturaAPIException(KalturaErrors::ORIGINAL_FLAVOR_ASSET_IS_MISSING);
     }
     $sync_key = null;
     $sync_key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     if (!kFileSyncUtils::file_exists($sync_key)) {
         // if not found local file - perhaps wasn't created here and wasn't synced yet
         // try to see if remote exists - and proxy the request if it is.
         list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($sync_key, true, true);
         if (!$local) {
             // take input params and add to URL
             $queryArr = array('service' => 'document', 'action' => 'convertPptToSwf', 'entryId' => $entryId, 'format' => $this->params["format"], 'ks' => $this->getKs()->toSecureString());
             $get_query = http_build_query($queryArr, '', '&');
             $remote_url = kDataCenterMgr::getRedirectExternalUrl($fileSync, $_SERVER['REQUEST_URI']);
             $url = strpos($remote_url, '?') === FALSE ? $remote_url . '?' . $get_query : $remote_url . '&' . $get_query;
             // prxoy request to other DC
             KalturaLog::log(__METHOD__ . ": redirecting to [{$url}]");
             kFile::dumpUrl($url);
         }
         KalturaLog::log("convertPptToSwf sync key doesn't exists");
         return;
     }
     $flavorParams = myConversionProfileUtils::getFlavorParamsFromFileFormat($dbEntry->getPartnerId(), flavorParams::CONTAINER_FORMAT_SWF);
     $flavorParamsId = $flavorParams->getId();
     $puserId = $this->getKuser()->getPuserId();
     $err = "";
     kBusinessPreConvertDL::decideAddEntryFlavor(null, $dbEntry->getId(), $flavorParamsId, $err);
     $downloadPath = $dbEntry->getDownloadUrl();
     //TODO: once api_v3 will support parameters with '/' instead of '?', we can change this to war with api_v3
     return $downloadPath . '/direct_serve/true/type/download/forceproxy/true/format/swf';
 }