Ejemplo n.º 1
0
 /**
  * Handles drop folder file status change to PENDING
  * 1. set parsed slug and flavor
  * 2. in case there is no parsed flavor (no related files) - add ContentProcessor job
  * 3. otherwise
  * 	a. verify all required flavors are ready 
  *	b. if yes - add content processor 
  *	c. else - change files status to WAITING
  * @param DropFolder $folder
  * @param DropFolderFile $file
  */
 private function onContentDropFolderFileStatusChangedToPending(DropFolder $folder, DropFolderFile $file)
 {
     $updatedFile = $this->setParsedSlugFlavor($folder, $file);
     if ($updatedFile) {
         $file = $updatedFile;
         if (is_null($file->getParsedFlavor())) {
             KalturaLog::log('Parsed flavor is null, triggering ContentProcessing job for source');
             $this->triggerContentDropFolderFileProcessing($folder, $file);
         } else {
             $assetParamsList = flavorParamsConversionProfilePeer::retrieveByConversionProfile($folder->getConversionProfileId());
             $flavorNameValid = $this->validateFlavorName($file, $assetParamsList);
             if ($flavorNameValid) {
                 KalturaLog::log('Parsed flavor is set, verifying if all files ready');
                 $statuses = array(DropFolderFileStatus::PENDING, DropFolderFileStatus::WAITING, DropFolderFileStatus::NO_MATCH);
                 $relatedFiles = DropFolderFilePeer::retrieveByDropFolderIdStatusesAndSlug($folder->getId(), $statuses, $file->getParsedSlug());
                 $isReady = $this->isAllContentDropFolderIngestedFilesReady($folder, $relatedFiles, $assetParamsList);
                 if ($isReady) {
                     $this->triggerContentDropFolderFileProcessing($folder, $file, $relatedFiles);
                 } else {
                     $file->setStatus(DropFolderFileStatus::WAITING);
                     $file->save();
                 }
             }
         }
     } else {
         $this->setFileError($file, DropFolderFileStatus::ERROR_HANDLING, DropFolderFileErrorCode::SLUG_REGEX_NO_MATCH, DropFolderPlugin::SLUG_REGEX_NO_MATCH_MESSAGE);
     }
 }