/**
  * @param string $name
  * @return PDO
  */
 public static function getConnection($name)
 {
     if (!Propel::isInit()) {
         DbManager::setConfig(kConf::getDB());
         DbManager::initialize();
     }
     return Propel::getConnection($name);
 }
コード例 #2
0
 private function __construct($partnerId)
 {
     DbManager::setConfig(kConf::getDB());
     DbManager::initialize();
     $this->confPath = KALTURA_ROOT_PATH . '/configurations/wams/';
     $partner = PartnerPeer::retrieveByPK($partnerId);
     $wams_account_name = $partner->getWamsAccountName();
     $wams_access_key = $partner->getWamsAccountKey();
     self::testConnection($wams_account_name, $wams_access_key);
     $this->_mediaServiceProxy = ServicesBuilder::getInstance()->createMediaServicesService(new MediaServicesSettings($wams_account_name, $wams_access_key));
 }
 /**
  * @param string $srcWAMSAssetId
  * @param string $targetPath
  */
 public function __construct($srcWAMSAssetId, $targetPath)
 {
     KalturaLog::debug("Creation instance of KWAMSThumbnailMaker srcWAMSAssetId = [{$srcWAMSAssetId}] targetPath = [{$targetPath}]");
     $this->srcWAMSAssetId = $srcWAMSAssetId;
     $this->targetPath = $targetPath;
     DbManager::setConfig(kConf::getDB());
     DbManager::initialize();
     $fileSync = FileSyncPeer::retrieveByWamsAssetId($srcWAMSAssetId);
     if (!empty($fileSync)) {
         $this->partnerId = $fileSync->getPartnerId();
     }
 }
コード例 #4
0
ファイル: myDbHelper.class.php プロジェクト: DBezemer/server
 /**
  * @param string $name
  * @return PDO
  */
 public static function getConnection($name)
 {
     if (!Propel::isInit()) {
         DbManager::setConfig(kConf::getDB());
         DbManager::initialize();
     }
     $slaves = array(self::DB_HELPER_CONN_PROPEL2, self::DB_HELPER_CONN_PROPEL3);
     if (!in_array($name, $slaves)) {
         return Propel::getConnection($name);
     }
     list($connection, $connIndex) = DbManager::connectFallbackLogic(array('Propel', 'getConnection'), array(), $slaves);
     if (!$connection) {
         throw new PropelException('Could not connect to any database server');
     }
     return $connection;
 }
 /**
  * Creates instance of class and initializes properties
  * @param string $type
  * @param string $filePath
  * @param KSchedularTaskConfig $taskConfig
  */
 public function __construct($type, $filePath, KSchedularTaskConfig $taskConfig, KalturaBatchJob $job, $wamsAssetId)
 {
     $this->wamsAssetId = $wamsAssetId;
     $this->filePath = $filePath;
     $this->mediaInfoParser = parent::getParser($type, $filePath, $taskConfig, $job);
     $this->partnerId = $job->partnerId;
     DbManager::setConfig(kConf::getDB());
     DbManager::initialize();
     $fileSync = FileSyncPeer::retrieveByWamsAssetId($this->wamsAssetId);
     if ($fileSync) {
         $flavorAsset = kFileSyncUtils::retrieveObjectForFileSync($fileSync);
         if ($flavorAsset instanceof asset) {
             $this->originalMediaInfo = mediaInfoPeer::retrieveOriginalByEntryId($flavorAsset->getEntryId());
             $entry = $flavorAsset->getentry();
             if ($entry) {
                 $this->mediaType = $entry->getMediaType();
             }
         }
     }
 }
コード例 #6
0
 public function __construct($feedId)
 {
     myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3;
     $microTimeStart = microtime(true);
     KalturaLog::info("syndicationFeedRenderer- initialize ");
     // initialize the database for all services
     DbManager::setConfig(kConf::getDB());
     DbManager::initialize();
     $syndicationFeedDB = syndicationFeedPeer::retrieveByPK($feedId);
     if (!$syndicationFeedDB) {
         throw new Exception("Feed Id not found");
     }
     $tmpSyndicationFeed = KalturaSyndicationFeedFactory::getInstanceByType($syndicationFeedDB->getType());
     $tmpSyndicationFeed->fromObject($syndicationFeedDB);
     $this->syndicationFeed = $tmpSyndicationFeed;
     // add partner to default criteria
     categoryPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true);
     flavorAssetPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true);
     $this->baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS);
     $startDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::START_DATE, time(), Criteria::LESS_EQUAL);
     $startDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::START_DATE, null));
     $this->baseCriteria->addAnd($startDateCriterion);
     $endDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::END_DATE, time(), Criteria::GREATER_EQUAL);
     $endDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::END_DATE, null));
     $this->baseCriteria->addAnd($endDateCriterion);
     $entryFilter = new entryFilter();
     $entryFilter->setPartnerSearchScope($this->syndicationFeed->partnerId);
     $entryFilter->setStatusEquel(entryStatus::READY);
     $entryFilter->setTypeIn(array(entryType::MEDIA_CLIP, entryType::MIX));
     $entryFilter->setModerationStatusNot(entry::ENTRY_MODERATION_STATUS_REJECTED);
     $entryFilter->setDurationGreaterThan(0);
     $entryFilter->attachToCriteria($this->baseCriteria);
     if ($this->syndicationFeed->playlistId) {
         $this->entryFilters = myPlaylistUtils::getPlaylistFiltersById($this->syndicationFeed->playlistId);
     } else {
         $this->entryFilters = array();
     }
     $microTimeEnd = microtime(true);
     KalturaLog::info("syndicationFeedRenderer- initialization done [" . ($microTimeEnd - $microTimeStart) . "]");
 }
 protected function prepare(KalturaBatchJob $job, KalturaWebcamPrepareJobData $data)
 {
     DbManager::setConfig(kConf::getDB());
     DbManager::initialize();
     $dbEntry = entryPeer::retrieveByPK($job->entryId);
     $webcamTokenId = $data->webcamTokenId;
     $dbEntry->setStatus(entryStatus::PRECONVERT);
     $dbEntry->save();
     // check that the webcam file exists
     $content = myContentStorage::getFSContentRootPath();
     $this->webcam_basePath = $content . "/content/webcam/" . $webcamTokenId;
     $this->entryFullPath = $this->webcam_basePath . '.flv';
     if (!file_exists($this->entryFullPath)) {
         $dbEntry->setStatus(entryStatus::ERROR_CONVERTING);
         $dbEntry->save();
         return $this->closeJob($job, KalturaBatchJobErrorTypes::RUNTIME, null, "Error: " . self::MSG_ERROR_FILE_NOT_EXISTS, KalturaBatchJobStatus::FAILED);
     }
     $duration = myFlvStaticHandler::getLastTimestamp($this->entryFullPath);
     $this->fixFlv();
     $kWAMSWebcam = new kWAMSWebcam($this->webcam_basePath);
     if ($kWAMSWebcam->prepare()) {
         $this->entryFullPath = $kWAMSWebcam->getOutputFilePath();
     } else {
         $dbEntry->setStatus(entryStatus::ERROR_CONVERTING);
         $dbEntry->save();
         return $this->closeJob($job, KalturaBatchJobErrorTypes::RUNTIME, null, "Error: " . self::MSG_ERROR_WAMS_FAIL, KalturaBatchJobStatus::FAILED);
     }
     $kshowId = $dbEntry->getKshowId();
     // setup the needed params for my insert entry helper
     $paramsArray = array("entry_media_source" => KalturaSourceType::WEBCAM, "entry_media_type" => $dbEntry->getMediaType(), "webcam_suffix" => $webcamTokenId, "entry_license" => $dbEntry->getLicenseType(), "entry_credit" => $dbEntry->getCredit(), "entry_source_link" => $dbEntry->getSourceLink(), "entry_tags" => $dbEntry->getTags(), "duration" => $duration);
     $token = $this->getClient()->getKs();
     $insert_entry_helper = new myInsertEntryHelper(null, $dbEntry->getKuserId(), $kshowId, $paramsArray);
     $insert_entry_helper->setPartnerId($job->partnerId, $job->partnerId * 100);
     $insert_entry_helper->insertEntry($token, $dbEntry->getType(), $dbEntry->getId(), $dbEntry->getName(), $dbEntry->getTags(), $dbEntry);
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry);
     return $this->closeJob($job, null, null, '', KalturaBatchJobStatus::FINISHED, $data);
 }
<?php

error_reporting(E_ALL);
require_once dirname(__FILE__) . '/../alpha/config/sfrootdir.php';
require_once dirname(__FILE__) . '/../api_v3/bootstrap.php';
DbManager::setConfig(kConf::getDB());
DbManager::initialize();
/**************************************************
* PLEASE CONFIGURE REQUIRED SETTINGS
***************************************************/
// partner's ID - must be set!
$partnerId = null;
// please enter a name for the profile:
$profileName = 'virusScan';
// please entery profile's status (enabled/disabled):
$profileStatus = KalturaVirusScanProfileStatus::ENABLED;
// can be changed to KalturaVirusScanProfileStatus::DISABLED
// please choose engine type:
$engineType = SymantecScanEnginePlugin::getPluginName() . IKalturaEnumerator::PLUGIN_VALUE_DELIMITER . SymantecScanEngineVirusScanEngineType::SYMANTEC_SCAN_ENGINE;
// Value from KalturaVirusScanEngineType
// action if file is found infected:
$actionIfInfected = KalturaVirusFoundAction::CLEAN_DELETE;
// please enter required parameters for entry filter - only entries that suit the filter will be scanned by this profile
$entryFilter = new KalturaBaseEntryFilter();
$entryFilter->typeIn = KalturaEntryType::MEDIA_CLIP . "," . KalturaEntryType::MIX;
/**************************************************
* DON'T TOUCH THE FOLLOWING CODE
***************************************************/
if (!$partnerId) {
    die('$partnerId cannot be empty');
}
コード例 #9
0
<?php

ini_set("memory_limit", "256M");
define('ROOT_DIR', realpath(dirname(__FILE__) . '/../../'));
require_once ROOT_DIR . '/infra/bootstrap_base.php';
require_once ROOT_DIR . '/infra/KAutoloader.php';
KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "vendor", "propel", "*"));
KAutoloader::setClassMapFilePath('../cache/classMap.cache');
KAutoloader::register();
error_reporting(E_ALL);
KalturaLog::setLogger(new KalturaStdoutLogger());
$dbConf = array('datasources' => array('default' => 'propel', 'propel' => array('adapter' => 'mysql', 'connection' => array('classname' => 'KalturaPDO', 'phptype' => 'mysql', 'database' => 'kaltura', 'hostspec' => '192.168.192.4', 'user' => 'kaltura', 'password' => 'kaltura', 'dsn' => 'mysql:host=192.168.192.4;dbname=kaltura;user=kaltura;password=kaltura;')), 'propel2' => array('adapter' => 'mysql', 'connection' => array('classname' => 'KalturaPDO', 'phptype' => 'mysql', 'database' => 'kaltura', 'hostspec' => '192.168.192.4', 'user' => 'kaltura_read', 'password' => 'kaltura_read', 'dsn' => 'mysql:host=192.168.192.4;dbname=kaltura;user=kaltura_read;password=kaltura_read;')), 'propel3' => array('adapter' => 'mysql', 'connection' => array('classname' => 'KalturaPDO', 'phptype' => 'mysql', 'database' => 'kaltura', 'hostspec' => '192.168.192.4', 'user' => 'kaltura_read', 'password' => 'kaltura_read', 'dsn' => 'mysql:host=192.168.192.4;dbname=kaltura;user=kaltura_read;password=kaltura_read;'))), 'log' => array('ident' => 'kaltura', 'level' => '7'));
//$dbConf = kConf::getDB();
DbManager::setConfig($dbConf);
DbManager::initialize();
$entryIds = array("0_dborm9lg", "0_imoflf6p", "0_3wm9a6t5", "0_cic44kil", "0_t4yew63l", "0_j1w2l0uo", "0_hmfl6yqm", "0_j4ciu5i8", "0_9exkfida", "0_t8i28aed", "0_mfzy6fk8", "0_8iy78nc9", "0_k8ymic7i", "0_kebpfp7z", "0_f4wb8f7o", "0_21hgvyre", "0_yc4frw3n", "0_xcrrzimo", "0_ttu09fn8", "0_nv77ncna", "0_dx18o48f", "0_ssuzmxjb", "0_7o9752ad", "0_pdzuunaa", "0_tymuie23", "0_vt8j64df", "0_dn3be3s1", "0_1naibde2", "0_0215mb05", "0_l1qu67u2", "0_0qpt6fbl", "0_o9xrvyv3", "0_rjlbesk0", "0_0riz850n", "8ix7p4nf6s", "0_3bpvujdf", "0_ddhyy406", "0_jdzti6gj", "g940g7miui", "0_o6m9rxsx", "0_qbujfju1", "s5qjpsjdnq", "s1m3dg09dw", "4tl281rhe8", "0_r6ehikfb", "0_s1ymi20f", "0_c087s9fw", "0_0jxtpm3o", "0_bi1oond7", "0_26xr3ht9", "0_tt5bc5xi", "0_3vxvcx0c", "0_336gw1eq", "0_a7nnunh6", "0_bs3jytlv", "0_r5abi3sz", "0_107z8t15", "0_5y5jlxga", "8z8ejn2c05", "0_ls0qsskt", "scs2tb20nc", "kuag5odijy", "c3o8gn8zoy", "0_pjmp0pk5", "0_qepjemqa", "0_phw09gy2", "0_byhgfhm2", "0_cgdx8az5", "0_jyfskrz1", "0_taz94tkf", "0_tpg7dxfz", "0_jdnikam7", "0_faxgi5zh", "0_8q6agy4v", "0_za7d1dlv", "0_9rq9j3ue", "0_90x6alrf", "0_sgj0jpbp", "0_dzqp2hve", "0_2vo8i3zm", "0_pbj0mewb", "0_ecjqlvcx", "0_qwx5tnnh", "0_csow76ak", "0_ippmvqxb", "0_5haayn3s", "0_scx59ihb", "0_e3c218nb", "0_tsokmp6i", "0_6ffche90", "0_qo5oa2aa", "0_grjmi99x", "0_c43tio3q", "0_wdp2nukp", "0_im7bqzvs", "0_8znu0fzn", "0_r88o5k28", "0_lm0ctgv4", "0_861czc6n", "0_fxybu3tb", "0_dl09yagk", "fgh8g7uc4c", "0_3ruyl4so", "0_uz9wwbi0", "0_i0wm8ylp", "0_gj2hfml9", "0_k5fttrmg", "0_ucqrdlm7", "0_semkx9jy", "0_js9xbszt", "0_oho170pf", "kzawobh3ty", "0_a2ph89tt", "irp1nztkts", "66r541rpjs", "0_lrrvlb7w", "0_0k002875", "0_vx5hb6jn", "0_l4liidjf", "0_g3nzwjdz", "0_uqxgy01f", "0_ugw90c4t", "0_tf1dd91a", "0_30eeu66b", "mov5ips91k", "6ir3dui0d0", "0_opitrvgr", "0_oc5vhd33", "0_plefn9cl", "0_0stl9gvz", "0_vth1aakn", "0_eyqbhsq9", "0_52na77mr", "0_7yi05auv", "0_dh11mjm2", "0_4evhzdbl", "dz727fptf0", "0_xqncw5pv", "0_2rl97bry", "0_x8uxq77g", "0_9784h9p5", "0_hwhdajmr", "0_fuqs22j4", "4la8ruega0", "0_zoq8xc3k", "0_beiaainf", "0_v0agxi9k", "umuobsfqos", "sfmrr36r5c", "0_63sprljk", "0_ktgi5sdv", "0_j5w9grsg", "0_z4rvq5m3", "sns6g8rp40", "0_szhtu39v", "wkwm07e2mw", "0_3mp68oqn", "0_un7q4ujm", "0_k9yu4jt2", "h2a4caf7nk", "fvjac6zlmk", "36ko97bsy4", "0_6pqen4pp", "gmvioznyq0", "gkiq0jsp90", "q6ojro0zhg", "0_fwectuev", "0_n04gvx36", "0_5aot3gzv", "p21ippxs70", "ncrww3l4j4", "q3fucnyueo", "58bjik2zbc", "3ck2qf1rnk", "dk2957a76g", "heo5zst99c", "ri5waxv6hs", "gtthmlm78s", "yzcgjotw0o", "6o4z2tp314", "0_d90mqlli", "qfnu55tt7k", "ybugoe78ai", "6h1pb6f3to", "1k9vxhvpk0", "2lvaw1odvm", "2i8t6vxyuo", "3nkrks76w4", "0_xjdcym4v", "0_ez86zub3", "0_xjnit0g7", "0_njp5gk8s", "dfoymlus6t");
$sizeFile = fopen('size.csv', 'a');
$entries = entryPeer::retrieveByPKs($entryIds);
foreach ($entries as $entry) {
    $size = myEntryUtils::calcStorageSize($entry);
    fputcsv($sizeFile, array($size, $entry->getId()));
}
fclose($sizeFile);
echo 'Done';
コード例 #10
0
 public function __construct()
 {
     DbManager::setConfig(kConf::getDB());
     DbManager::initialize();
     //TODO: initialize $this->serviceName here instead of in initService method
 }
コード例 #11
0
 /**
  * 
  * Used to initialize the ui conf deployment like a bootstarp fiel
  * @param unknown_type $conf_file_path
  */
 public static function init($conf_file_path)
 {
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "infra" . DIRECTORY_SEPARATOR . "bootstrap_base.php";
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "infra" . DIRECTORY_SEPARATOR . "kConf.php";
     define("KALTURA_API_PATH", KALTURA_ROOT_PATH . DIRECTORY_SEPARATOR . "api_v3");
     // Autoloader
     require_once KALTURA_INFRA_PATH . DIRECTORY_SEPARATOR . "KAutoloader.php";
     KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "vendor", "propel", "*"));
     KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_API_PATH, "lib", "*"));
     KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_API_PATH, "services", "*"));
     KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "alpha", "plugins", "*"));
     // needed for testmeDoc
     KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "plugins", "*"));
     KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "generator"));
     // needed for testmeDoc
     KAutoloader::setClassMapFilePath(kConf::get("cache_root_path") . '/deploy/' . basename(__FILE__) . '.cache');
     //KAutoloader::dumpExtra();
     KAutoloader::register();
     $dbConf = kConf::getDB();
     DbManager::setConfig($dbConf);
     DbManager::initialize();
     date_default_timezone_set(kConf::get("date_default_timezone"));
     //		try
     //		{
     $confObj = new Zend_Config_Ini($conf_file_path);
     //		}
     //		catch(Exception $ex)
     //		{
     //			echo 'Exiting on ERROR: '.$ex->getMessage().PHP_EOL;
     //			exit(1);
     //		}
     return $confObj;
 }
 public function __construct($feedId)
 {
     myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3;
     $microTimeStart = microtime(true);
     KalturaLog::info("syndicationFeedRenderer- initialize ");
     // initialize the database for all services
     DbManager::setConfig(kConf::getDB());
     DbManager::initialize();
     $this->syndicationFeedDB = $syndicationFeedDB = syndicationFeedPeer::retrieveByPK($feedId);
     if (!$syndicationFeedDB) {
         throw new Exception("Feed Id not found");
     }
     kEntitlementUtils::initEntitlementEnforcement($syndicationFeedDB->getPartnerId(), $syndicationFeedDB->getEnforceEntitlement());
     if (!is_null($syndicationFeedDB->getPrivacyContext()) && $syndicationFeedDB->getPrivacyContext() != '') {
         kEntitlementUtils::setPrivacyContextSearch($syndicationFeedDB->getPrivacyContext());
     }
     $tmpSyndicationFeed = KalturaSyndicationFeedFactory::getInstanceByType($syndicationFeedDB->getType());
     $tmpSyndicationFeed->fromObject($syndicationFeedDB);
     $this->syndicationFeed = $tmpSyndicationFeed;
     // add partner to default criteria
     categoryPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true);
     assetPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true);
     entryPeer::setDefaultCriteriaFilter();
     $this->baseCriteria = entryPeer::getDefaultCriteriaFilter();
     $startDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::START_DATE, time(), Criteria::LESS_EQUAL);
     $startDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::START_DATE, null));
     $this->baseCriteria->addAnd($startDateCriterion);
     $endDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::END_DATE, time(), Criteria::GREATER_EQUAL);
     $endDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::END_DATE, null));
     $this->baseCriteria->addAnd($endDateCriterion);
     $entryFilter = new entryFilter();
     $entryFilter->setPartnerSearchScope($this->syndicationFeed->partnerId);
     $entryFilter->setStatusEquel(entryStatus::READY);
     $entryFilter->setTypeIn(array(entryType::MEDIA_CLIP, entryType::MIX));
     $entryFilter->setModerationStatusNotIn(array(entry::ENTRY_MODERATION_STATUS_REJECTED, entry::ENTRY_MODERATION_STATUS_PENDING_MODERATION));
     $entryFilter->attachToCriteria($this->baseCriteria);
     if ($this->syndicationFeed->playlistId) {
         $this->entryFilters = myPlaylistUtils::getPlaylistFiltersById($this->syndicationFeed->playlistId);
         foreach ($this->entryFilters as $entryFilter) {
             $entryFilter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE);
             // partner scope already attached
         }
         $playlist = entryPeer::retrieveByPK($this->syndicationFeed->playlistId);
         if ($playlist) {
             if ($playlist->getMediaType() != entry::ENTRY_MEDIA_TYPE_XML) {
                 $this->staticPlaylist = true;
                 $this->staticPlaylistEntriesIdsOrder = explode(',', $playlist->getDataContent());
             }
         }
     } else {
         $this->entryFilters = array();
     }
     $microTimeEnd = microtime(true);
     KalturaLog::info("syndicationFeedRenderer- initialization done [" . ($microTimeEnd - $microTimeStart) . "]");
 }
コード例 #13
0
ファイル: deploy.php プロジェクト: richhl/kalturaCE
 public static function init($conf_file_path)
 {
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "infra" . DIRECTORY_SEPARATOR . "bootstrap_base.php";
     require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'kConf.php';
     define("KALTURA_API_PATH", KALTURA_ROOT_PATH . DIRECTORY_SEPARATOR . "api_v3");
     // Autoloader
     require_once KALTURA_INFRA_PATH . DIRECTORY_SEPARATOR . "KAutoloader.php";
     KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "vendor", "propel", "*"));
     KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_API_PATH, "lib", "*"));
     KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_API_PATH, "services", "*"));
     KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "alpha", "plugins", "*"));
     // needed for testmeDoc
     KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "plugins", "*"));
     KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "generator"));
     // needed for testmeDoc
     KAutoloader::setClassMapFilePath(kConf::get("cache_root_path") . '/deploy/classMap.cache');
     //KAutoloader::dumpExtra();
     KAutoloader::register();
     $dbConf = kConf::getDB();
     DbManager::setConfig($dbConf);
     DbManager::initialize();
     $conf = parse_ini_file($conf_file_path, true);
     $confObj = new Zend_Config_Ini($conf_file_path);
     return $confObj;
 }
 protected static function initDb($should_perform_shutdown = false)
 {
     KalturaLog::debug("----------------- Initializing DB ------------------- ");
     if (self::$s_databaseManager == NULL) {
         $dbConf = kConf::getDB();
         DbManager::setConfig($dbConf);
         //self::$s_databaseManager = new sfDatabaseManager();
     }
     if ($should_perform_shutdown) {
         KalturaLog::debug("Attempting shutdown of DB due to errors");
         // All of this brutal shutdown & init is to release all DB connections and restart as clean as possible
         //
         //self::$s_databaseManager->shutdown();
         //propel::close();
         //propel::initialize();
         DbManager::shutdown();
         DbManager::initialize();
     }
     DbManager::initialize();
     //self::$s_databaseManager->initialize();
 }
 /**
  * @param KalturaBatchJob $job
  * @param KalturaPostConvertJobData $data
  * @return KalturaBatchJob
  */
 private function postConvert(KalturaBatchJob $job, KalturaPostConvertJobData $data)
 {
     DbManager::setConfig(kConf::getDB());
     DbManager::initialize();
     $flavorAsset = assetPeer::retrieveByPK($data->flavorAssetId);
     if (!empty($flavorAsset) && $this->checkMediaInfoExists($data->flavorAssetId) && $flavorAsset->getIsOriginal() && $flavorAsset->getSize() !== 0) {
         $data->createThumb = false;
         return $this->closeJob($job, null, null, 'Media info already exists', KalturaBatchJobStatus::FINISHED, $data);
     }
     if ($data->flavorParamsOutputId) {
         $data->flavorParamsOutput = $this->kClient->flavorParamsOutput->get($data->flavorParamsOutputId);
     }
     try {
         $mediaFile = trim($data->srcFileSyncLocalPath);
         $mediaFileExt = pathinfo($mediaFile, PATHINFO_EXTENSION);
         if (!is_null($data->srcFileSyncWamsAssetId)) {
             $tempFile = kWAMS::getInstance($job->partnerId)->createTempFileForAssetId($data->srcFileSyncWamsAssetId, $mediaFileExt);
             if (file_exists($tempFile)) {
                 $mediaFile = $tempFile;
             }
         }
         if (!$data->flavorParamsOutput || !$data->flavorParamsOutput->sourceRemoteStorageProfileId) {
             if (!$this->pollingFileExists($mediaFile)) {
                 return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::NFS_FILE_DOESNT_EXIST, "Source file {$mediaFile} does not exist", KalturaBatchJobStatus::RETRY);
             }
             if (!is_file($mediaFile)) {
                 return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::NFS_FILE_DOESNT_EXIST, "Source file {$mediaFile} is not a file", KalturaBatchJobStatus::FAILED);
             }
         }
         KalturaLog::debug("mediaFile [{$mediaFile}]");
         $this->updateJob($job, "Extracting file media info on {$mediaFile}", KalturaBatchJobStatus::QUEUED, 1);
     } catch (Exception $ex) {
         return $this->closeJob($job, KalturaBatchJobErrorTypes::RUNTIME, $ex->getCode(), "Error: " . $ex->getMessage(), KalturaBatchJobStatus::FAILED);
     }
     $mediaInfo = null;
     try {
         $engine = KBaseMediaParser::getParser($job->jobSubType, realpath($mediaFile), $this->taskConfig, $job, $data->srcFileSyncWamsAssetId);
         if ($engine) {
             KalturaLog::info("Media info engine [" . get_class($engine) . "]");
             $mediaInfo = $engine->getMediaInfo();
             if (!empty($data->srcFileSyncWamsAssetId)) {
                 kWAMS::getInstance($job->partnerId)->deleteTempFileForAssetId($data->srcFileSyncWamsAssetId, $mediaFileExt);
             }
         } else {
             $err = "Media info engine not found for job subtype [" . $job->jobSubType . "]";
             KalturaLog::info($err);
             return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::ENGINE_NOT_FOUND, $err, KalturaBatchJobStatus::FAILED);
         }
     } catch (Exception $ex) {
         KalturaLog::err("Error: " . $ex->getMessage());
         $mediaInfo = null;
     }
     /* @var $mediaInfo KalturaMediaInfo */
     if (is_null($mediaInfo)) {
         return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::EXTRACT_MEDIA_FAILED, "Failed to extract media info: {$mediaFile}", KalturaBatchJobStatus::FAILED);
     }
     try {
         $mediaInfo->flavorAssetId = $data->flavorAssetId;
         $createdMediaInfo = $this->getClient()->batch->addMediaInfo($mediaInfo);
         if ($createdMediaInfo instanceof KalturaMediaInfo) {
             $mediaInfo = $createdMediaInfo;
         }
         // must save the mediaInfoId before reporting that the task is finished
         $this->updateJob($job, "Saving media info id {$createdMediaInfo->id}", KalturaBatchJobStatus::PROCESSED, 50, $data);
         $data->thumbPath = null;
         if (!$data->createThumb) {
             return $this->closeJob($job, null, null, "Media info id {$createdMediaInfo->id} saved", KalturaBatchJobStatus::FINISHED, $data);
         }
         // creates a temp file path
         $rootPath = $this->taskConfig->params->localTempPath;
         $this->createDir($rootPath);
         // creates the path
         $uniqid = uniqid('thumb_');
         $thumbPath = realpath($rootPath) . "/{$uniqid}";
         $videoDurationSec = floor($mediaInfo->videoDuration / 1000);
         $data->thumbOffset = max(0, min($data->thumbOffset, $videoDurationSec));
         if ($mediaInfo->videoHeight) {
             $data->thumbHeight = $mediaInfo->videoHeight;
         }
         if ($mediaInfo->videoBitRate) {
             $data->thumbBitrate = $mediaInfo->videoBitRate;
         }
         // generates the thumbnail
         if (!is_null($data->srcFileSyncWamsAssetId)) {
             $thumbMaker = new KWAMSThumbnailMaker($data->srcFileSyncWamsAssetId, $thumbPath);
             $created = $thumbMaker->createThumbnail($data->thumbOffset, $mediaInfo->videoWidth, $mediaInfo->videoHeight, $mediaInfo->videoDar);
         } else {
             $thumbMaker = new KFFMpegThumbnailMaker($mediaFile, $thumbPath, $this->taskConfig->params->FFMpegCmd);
             $created = $thumbMaker->createThumnail($data->thumbOffset, $mediaInfo->videoWidth, $mediaInfo->videoHeight, null, null, $mediaInfo->videoDar);
         }
         if (!$created || !file_exists($thumbPath)) {
             $data->createThumb = false;
             return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::THUMBNAIL_NOT_CREATED, 'Thumbnail not created', KalturaBatchJobStatus::FINISHED, $data);
         }
         $data->thumbPath = $thumbPath;
         $job = $this->moveFile($job, $data);
         if ($this->checkFileExists($job->data->thumbPath)) {
             return $this->closeJob($job, null, null, null, KalturaBatchJobStatus::FINISHED, $data);
         }
         $data->createThumb = false;
         return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::NFS_FILE_DOESNT_EXIST, 'File not moved correctly', KalturaBatchJobStatus::FINISHED, $data);
     } catch (Exception $ex) {
         return $this->closeJob($job, KalturaBatchJobErrorTypes::RUNTIME, $ex->getCode(), "Error: " . $ex->getMessage(), KalturaBatchJobStatus::FAILED);
     }
 }