/** * Function constructs a core object of type kBulkUploadJobData * @param int $conversionProfileId * @param string $filePath * @param string $userId * @param int $bulkUploadType * @param string $uploadedBy * @param string $fileName * @throws KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND */ protected function constructJobData($filePath, $fileName, Partner $partner, $puserId, $uploadedBy, $conversionProfileId = null, $coreBulkUploadType = null) { $data = KalturaPluginManager::loadObject('kBulkUploadJobData', $coreBulkUploadType); if (is_null($data)) { throw new KalturaAPIException(KalturaErrors::BULK_UPLOAD_BULK_UPLOAD_TYPE_NOT_VALID, $coreBulkUploadType); } $data->setFilePath($filePath); $data->setUserId($puserId); $data->setUploadedBy($uploadedBy); $data->setFileName($fileName); if (!$conversionProfileId) { $conversionProfileId = $partner->getDefaultConversionProfileId(); } $kmcVersion = $partner->getKmcVersion(); $check = null; if ($kmcVersion < 2) { $check = ConversionProfilePeer::retrieveByPK($conversionProfileId); } else { $check = conversionProfile2Peer::retrieveByPK($conversionProfileId); } if (!$check) { throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $conversionProfileId); } $objectData = new kBulkUploadEntryData(); $objectData->setConversionProfileId($conversionProfileId); $data->setObjectData($objectData); return $data; }
public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; $this->ok_to_save = $this->getP("oktosave"); $conv_profile_id = $this->getP("convprofile_id"); if ($conv_profile_id < 0) { $conv_profile_id = ""; } $this->message = ""; $this->display_disabled = $this->getP("display_disabled"); $command = $this->getP("command"); if ($command == "removeCache") { } elseif ($command == "save") { $conv_profile = new ConversionProfile(); $wrapper = objectWrapperBase::getWrapperClass($conv_profile, 0); $extra_fields = array("partnerId", "enabled"); // add fields that cannot be updated using the API $allowed_params = array_merge($wrapper->getUpdateableFields(), $extra_fields); $fields_modified = baseObjectUtils::fillObjectFromMap($_REQUEST, $conv_profile, "convprofile_", $allowed_params, BasePeer::TYPE_PHPNAME, true); if ($conv_profile_id) { $conv_profile_from_db = ConversionProfilePeer::retrieveByPK($conv_profile_id); if ($conv_profile_from_db) { baseObjectUtils::fillObjectFromObject($allowed_params, $conv_profile, $conv_profile_from_db, baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME, true); } $conv_profile_from_db->save(); } else { $conv_profile->save(); $conv_profile_id = $conv_profile->getId(); } } $this->conv_profile = ConversionProfilePeer::retrieveByPK($conv_profile_id); $this->conv_profile_id = $conv_profile_id; if ($this->conv_profile) { $this->conv_profile_type = $this->conv_profile->getProfileType(); $this->fallback_mode = array(); $this->conv_params_list = ConversionParamsPeer::retrieveByConversionProfile($this->conv_profile, $this->fallback_mode, false); // to see if there are any disabled params - call again with true $tmp_fallback = array(); $tmp_conv_params_list = ConversionParamsPeer::retrieveByConversionProfile($this->conv_profile, $tmp_fallback, true); if ($tmp_fallback["mode"] == $this->fallback_mode["mode"]) { $this->fallback_mode = $tmp_fallback; $this->conv_params_list = $tmp_conv_params_list; } else { if ($this->display_disabled) { $this->fallback_mode = $tmp_fallback; $this->conv_params_list = $tmp_conv_params_list; $this->message = "This display is missleading due to [dispaly disabled=true]<br>It shows params that are disabled for this profile and WOULD NOT be used at run-time"; } } } else { $this->conv_profile_type = null; $this->conv_params_list = null; } }
/** * Add new bulk upload batch job * Conversion profile id can be specified in the API or in the CSV file, the one in the CSV file will be stronger. * If no conversion profile was specified, partner's default will be used * * @action add * @param int $conversionProfileId Convertion profile id to use for converting the current bulk (-1 to use partner's default) * @param file $csvFileData CSV File * @return KalturaBulkUpload */ function addAction($conversionProfileId, $csvFileData) { // first we copy the file to "content/batchfiles/[partner_id]/" $origFilename = $csvFileData["name"]; $fileInfo = pathinfo($origFilename); $extension = strtolower($fileInfo["extension"]); if ($extension != "csv") { throw new KalturaAPIException(KalturaErrors::INVALID_FILE_EXTENSION); } $job = new BatchJob(); $job->setPartnerId($this->getPartnerId()); $job->save(); $syncKey = $job->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_BULKUPLOADCSV); // kFileSyncUtils::file_put_contents($syncKey, file_get_contents($csvFileData["tmp_name"])); try { kFileSyncUtils::moveFromFile($csvFileData["tmp_name"], $syncKey, true); } catch (Exception $e) { throw new KalturaAPIException(KalturaErrors::BULK_UPLOAD_CREATE_CSV_FILE_SYNC_ERROR); } $csvPath = kFileSyncUtils::getLocalFilePathForKey($syncKey); $data = new KalturaBulkUploadJobData(); $data->csvFilePath = $csvPath; $data->userId = $this->getKuser()->getPuserId(); $data->uploadedBy = $this->getKuser()->getScreenName(); if ($conversionProfileId === -1) { $conversionProfileId = $this->getPartner()->getDefaultConversionProfileId(); } $kmcVersion = $this->getPartner()->getKmcVersion(); $check = null; if ($kmcVersion < 2) { $check = ConversionProfilePeer::retrieveByPK($conversionProfileId); } else { $check = conversionProfile2Peer::retrieveByPK($conversionProfileId); } if (!$check) { throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $conversionProfileId); } $data->conversionProfileId = $conversionProfileId; $dbJob = kJobsManager::addJob($job, $data->toObject(), KalturaBatchJobType::BULKUPLOAD); $bulkUpload = new KalturaBulkUpload(); $bulkUpload->fromObject($dbJob); return $bulkUpload; }
public function getConversionProfile() { $conversion_profile = $this->getConversionQuality(); if ($conversion_profile) { return ConversionProfilePeer::retrieveByPK($conversion_profile); } return null; }
private function getConversionQuality($entry) { $conversionQuality = $entry->conversionQuality; if (parent::getConversionQualityFromRequest()) { $conversionQuality = parent::getConversionQualityFromRequest(); } if (is_null($conversionQuality)) { return null; } $conversionProfile2 = conversionProfile2Peer::retrieveByPK($conversionQuality); if (!$conversionProfile2) { KalturaLog::debug("Maybe old conversion profile"); $conversionProfile = ConversionProfilePeer::retrieveByPK($conversionQuality); if ($conversionProfile) { $conversionQuality = $conversionProfile->getConversionProfile2Id(); } } return $conversionQuality; }
/** * Function adds bulk upload job to the queue * @param Partner $partner * @param kBulkUploadJobData $jobData * @param string $bulkUploadType * @throws APIException * @return BatchJob */ public static function addBulkUploadJob(Partner $partner, kBulkUploadJobData $jobData, $bulkUploadType = null, $objectId = null, $objectType = null) { KalturaLog::debug("adding BulkUpload job"); $job = new BatchJob(); $job->setPartnerId($partner->getId()); $job->setJobType(BatchJobType::BULKUPLOAD); $job->setJobSubType($bulkUploadType); if (!is_null($objectId) && !is_null($objectType)) { $job->setObjectId($objectId); $job->setObjectType($objectType); } if (is_null($jobData)) { throw new APIException(APIErrors::BULK_UPLOAD_BULK_UPLOAD_TYPE_NOT_VALID, $bulkUploadType); } $job->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS); $job = kJobsManager::addJob($job, $jobData, BatchJobType::BULKUPLOAD, $bulkUploadType); if (!is_null($jobData->getFilePath())) { $syncKey = $job->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_BULKUPLOAD); // kFileSyncUtils::file_put_contents($syncKey, file_get_contents($csvFileData["tmp_name"])); try { kFileSyncUtils::moveFromFile($jobData->getFilePath(), $syncKey, true); } catch (Exception $e) { KalturaLog::err($e); throw new APIException(APIErrors::BULK_UPLOAD_CREATE_CSV_FILE_SYNC_ERROR); } $filePath = kFileSyncUtils::getLocalFilePathForKey($syncKey); $jobData->setFilePath($filePath); } if (!$jobData->getBulkUploadObjectType()) { $jobData->setBulkUploadObjectType(BulkUploadObjectType::ENTRY); } if ($jobData->getBulkUploadObjectType() == BulkUploadObjectType::ENTRY && !$jobData->getObjectData()->getConversionProfileId()) { $jobData->setConversionProfileId($partner->getDefaultConversionProfileId()); $kmcVersion = $partner->getKmcVersion(); $check = null; if ($kmcVersion < 2) { $check = ConversionProfilePeer::retrieveByPK($jobData->getConversionProfileId()); } else { $check = conversionProfile2Peer::retrieveByPK($jobData->getConversionProfileId()); } if (!$check) { throw new APIException(APIErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $jobData->getConversionProfileId()); } } $job->setData($jobData); return kJobsManager::updateBatchJob($job, BatchJob::BATCHJOB_STATUS_PENDING); }
public function createConversionCommandFromConverionProfileId($source_file, $target_file, $conv_profile_id, $entry = null) { $conv_profile = ConversionProfilePeer::retrieveByPK($conv_profile_id); return $this->createConversionCommandFromConverionProfile($source_file, $target_file, $conv_profile, $entry); }
public static function getConversionProfileById($partner_id, $conversion_profile_id) { if ($conversion_profile_id === null) { return null; } $conv_prof = ConversionProfilePeer::retrieveByPK($conversion_profile_id); if ($conv_prof) { if ($conv_prof->getPartnerId() == $partner_id || $conv_prof->getPartnerId() == ConversionProfile::GLOBAL_PARTNER_PROFILE) { return $conv_prof; } } return null; }
public static function getConversionProfileForPartner($partner_id, $partner_convrsion_string = null, $partner_flv_conversion_string = mull) { $conv_prof = ConversionProfilePeer::retrieveByPK($conversion_profile_id); }