Example #1
0
 /**
  * Add new entry after the file was recored on the server and the token id exists
  *
  * @action addFromRecordedWebcam
  * @param KalturaMediaEntry $mediaEntry Media entry metadata
  * @param string $webcamTokenId Token id for the recored webcam file
  * @return KalturaMediaEntry The new media entry
  *
  * @throws KalturaErrors::PROPERTY_VALIDATION_MIN_LENGTH
  * @throws KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL
  * @throws KalturaErrors::RECORDED_WEBCAM_FILE_NOT_FOUND
  *
  * @deprecated use media.add instead
  */
 function addFromRecordedWebcamAction(KalturaMediaEntry $mediaEntry, $webcamTokenId)
 {
     if ($mediaEntry->conversionQuality && !$mediaEntry->conversionProfileId) {
         $mediaEntry->conversionProfileId = $mediaEntry->conversionQuality;
     }
     // check that the webcam file exists
     $content = myContentStorage::getFSContentRootPath();
     $webcamContentRootDir = $content . "/content/webcam/";
     $webcamBasePath = $webcamContentRootDir . $webcamTokenId;
     // Make sure that the root path of the webcam content is not modified by $webcamTokenId (with the value of "../" for example )
     $webcamContentRootDir = realpath($webcamContentRootDir);
     $webcamBaseRootDir = realpath(dirname($webcamBasePath));
     // Get realpath of target directory
     if (strpos($webcamBaseRootDir, $webcamContentRootDir) !== 0) {
         KalturaLog::err("webcamTokenId [{$webcamTokenId}] points outside of webcam content directory");
         throw new KalturaAPIException(KalturaErrors::INVALID_WEBCAM_TOKEN_ID);
     }
     if (!file_exists("{$webcamBasePath}.flv") && !file_exists("{$webcamBasePath}.f4v") && !file_exists("{$webcamBasePath}.f4v.mp4")) {
         if (kDataCenterMgr::dcExists(1 - kDataCenterMgr::getCurrentDcId())) {
             kFileUtils::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()));
         }
         throw new KalturaAPIException(KalturaErrors::RECORDED_WEBCAM_FILE_NOT_FOUND);
     }
     $dbEntry = $this->prepareEntryForInsert($mediaEntry);
     $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());
     $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();
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry);
     $mediaEntry->fromObject($dbEntry, $this->getResponseProfile());
     return $mediaEntry;
 }
Example #2
0
 /**
  * Update an existing KalturaDropFolder object
  * 
  * @action update
  * @param int $dropFolderId
  * @param KalturaDropFolder $dropFolder
  * @return KalturaDropFolder
  *
  * @throws KalturaErrors::INVALID_OBJECT_ID
  * @throws KalturaErrors::INGESTION_PROFILE_ID_NOT_FOUND
  * @throws KalturaErrors::DATA_CENTER_ID_NOT_FOUND
  */
 public function updateAction($dropFolderId, KalturaDropFolder $dropFolder)
 {
     $dbDropFolder = DropFolderPeer::retrieveByPK($dropFolderId);
     if (!$dbDropFolder) {
         throw new KalturaAPIException(KalturaErrors::INVALID_OBJECT_ID, $dropFolderId);
     }
     $dropFolder->validatePropertyMinValue('fileSizeCheckInterval', 0, true);
     $dropFolder->validatePropertyMinValue('autoFileDeleteDays', 0, true);
     if (!is_null($dropFolder->path) && $dropFolder->path != $dbDropFolder->getPath() && $dropFolder->type == KalturaDropFolderType::LOCAL) {
         $existingDropFolder = DropFolderPeer::retrieveByPathDefaultFilter($dropFolder->path);
         if ($existingDropFolder) {
             throw new KalturaAPIException(KalturaDropFolderErrors::DROP_FOLDER_ALREADY_EXISTS, $dropFolder->path);
         }
     }
     if (!is_null($dropFolder->dc)) {
         if (!kDataCenterMgr::dcExists($dropFolder->dc)) {
             throw new KalturaAPIException(KalturaErrors::DATA_CENTER_ID_NOT_FOUND, $dropFolder->dc);
         }
     }
     if (!is_null($dropFolder->conversionProfileId)) {
         $conversionProfileDb = conversionProfile2Peer::retrieveByPK($dropFolder->conversionProfileId);
         if (!$conversionProfileDb) {
             throw new KalturaAPIException(KalturaErrors::INGESTION_PROFILE_ID_NOT_FOUND, $dropFolder->conversionProfileId);
         }
     }
     $dbDropFolder = $dropFolder->toUpdatableObject($dbDropFolder);
     $dbDropFolder->save();
     $dropFolder = KalturaDropFolder::getInstanceByType($dbDropFolder->getType());
     $dropFolder->fromObject($dbDropFolder, $this->getResponseProfile());
     return $dropFolder;
 }