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; }
/** * Generic add entry using an uploaded file, should be used when the uploaded entry type is not known. * * @action addFromUploadedFile * @param KalturaBaseEntry $entry * @param string $uploadTokenId * @param KalturaEntryType $type * @return KalturaBaseEntry */ function addFromUploadedFileAction(KalturaBaseEntry $entry, $uploadTokenId, $type = -1) { try { // check that the uploaded file exists $entryFullPath = kUploadTokenMgr::getFullPathByUploadTokenId($uploadTokenId); } catch (kCoreException $ex) { if ($ex->getCode() == kUploadTokenException::UPLOAD_TOKEN_INVALID_STATUS) { } throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_INVALID_STATUS_FOR_ADD_ENTRY); throw $ex; } if (!file_exists($entryFullPath)) { $remoteDCHost = kUploadTokenMgr::getRemoteHostForUploadToken($uploadTokenId, kDataCenterMgr::getCurrentDcId()); if ($remoteDCHost) { kFile::dumpApiRequest($remoteDCHost); } else { throw new KalturaAPIException(KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN); } } // validate the input object //$entry->validatePropertyMinLength("name", 1); if (!$entry->name) { $entry->name = $this->getPartnerId() . '_' . time(); } // first copy all the properties to the db entry, then we'll check for security stuff $dbEntry = $entry->toInsertableObject(new entry()); $dbEntry->setType($type); $dbEntry->setMediaType(entry::ENTRY_MEDIA_TYPE_AUTOMATIC); $this->checkAndSetValidUserInsert($entry, $dbEntry); $this->checkAdminOnlyInsertProperties($entry); $this->validateAccessControlId($entry); $this->validateEntryScheduleDates($entry, $dbEntry); $dbEntry->setPartnerId($this->getPartnerId()); $dbEntry->setSubpId($this->getPartnerId() * 100); $dbEntry->setSourceId($uploadTokenId); $dbEntry->setSourceLink($entryFullPath); myEntryUtils::setEntryTypeAndMediaTypeFromFile($dbEntry, $entryFullPath); $dbEntry->setDefaultModerationStatus(); // hack due to KCW of version from KMC if (!is_null(parent::getConversionQualityFromRequest())) { $dbEntry->setConversionQuality(parent::getConversionQualityFromRequest()); } $dbEntry->save(); $kshow = $this->createDummyKShow(); $kshowId = $kshow->getId(); // setup the needed params for my insert entry helper $paramsArray = array("entry_media_source" => KalturaSourceType::FILE, "entry_media_type" => $dbEntry->getMediaType(), "entry_full_path" => $entryFullPath, "entry_license" => $dbEntry->getLicenseType(), "entry_credit" => $dbEntry->getCredit(), "entry_source_link" => $dbEntry->getSourceLink(), "entry_tags" => $dbEntry->getTags()); $token = $this->getKsUniqueString(); $insert_entry_helper = new myInsertEntryHelper(null, $dbEntry->getKuserId(), $kshowId, $paramsArray); $insert_entry_helper->setPartnerId($this->getPartnerId(), $this->getPartnerId() * 100); $insert_entry_helper->insertEntry($token, $dbEntry->getType(), $dbEntry->getId(), $dbEntry->getName(), $dbEntry->getTags(), $dbEntry); $dbEntry = $insert_entry_helper->getEntry(); kUploadTokenMgr::closeUploadTokenById($uploadTokenId); myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry); $entry->fromObject($dbEntry); return $entry; }