public static function abortEntryJobs($entryId)
 {
     $dbBatchJobs = BatchJobPeer::retrieveByEntryId($entryId);
     foreach ($dbBatchJobs as $dbBatchJob) {
         self::abortDbBatchJob($dbBatchJob);
     }
 }
 /**
  * batch addBulkUploadResultAction action adds KalturaBulkUploadResult to the DB
  * 
  * @action addBulkUploadResult
  * @param KalturaBulkUploadResult $bulkUploadResult The results to save to the DB
  * @param KalturaBulkUploadPluginDataArray $pluginDataArray
  * @return KalturaBulkUploadResult 
  */
 function addBulkUploadResultAction(KalturaBulkUploadResult $bulkUploadResult, KalturaBulkUploadPluginDataArray $pluginDataArray = null)
 {
     if (is_null($bulkUploadResult->action)) {
         $bulkUploadResult->action = KalturaBulkUploadAction::ADD;
     }
     $bulkUploadResult->pluginsData = $pluginDataArray;
     $dbBulkUploadResult = BulkUploadResultPeer::retrieveByBulkUploadIdAndIndex($bulkUploadResult->bulkUploadJobId, $bulkUploadResult->lineIndex);
     if ($dbBulkUploadResult) {
         $dbBulkUploadResult = $bulkUploadResult->toUpdatableObject($dbBulkUploadResult);
     } else {
         $dbBulkUploadResult = $bulkUploadResult->toInsertableObject();
     }
     /* @var $dbBulkUploadResult BulkUploadResult */
     $dbBulkUploadResult->save();
     if ($bulkUploadResult->objectId) {
         $dbBulkUploadResult->handleRelatedObjects();
         $jobs = BatchJobPeer::retrieveByEntryId($bulkUploadResult->objectId);
         foreach ($jobs as $job) {
             if (!$job->getParentJobId()) {
                 $job->setRootJobId($bulkUploadResult->bulkUploadJobId);
                 $job->setBulkJobId($bulkUploadResult->bulkUploadJobId);
                 $job->save();
             }
         }
         if ($dbBulkUploadResult->getObject() && $pluginDataArray && $pluginDataArray->count) {
             $pluginValues = $pluginDataArray->toValuesArray();
             if (count($pluginValues)) {
                 $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaBulkUploadHandler');
                 foreach ($pluginInstances as $pluginInstance) {
                     $pluginInstance->handleBulkUploadData($dbBulkUploadResult->getObject(), $pluginValues);
                 }
             }
         }
     }
     $bulkUploadResult->fromObject($dbBulkUploadResult);
     return $bulkUploadResult;
 }
示例#3
0
文件: entry.php 项目: AdiTal/server
 public function getBatchJobs()
 {
     return BatchJobPeer::retrieveByEntryId($this->getId());
 }
 public static function deleteEntry(entry $entry, $partner_id = null, $onlyIfAllJobsDone = false)
 {
     if ($entry->getStatus() == entryStatus::DELETED || $entry->getStatus() == entryStatus::BLOCKED) {
         return;
     }
     // don't do this twice !
     if ($onlyIfAllJobsDone) {
         KalturaLog::DEBUG("onlyIfAllJobsDone = " . (int) $onlyIfAllJobsDone);
         $dbEntryBatchJobs = BatchJobPeer::retrieveByEntryId($entry->getId());
         foreach ($dbEntryBatchJobs as $job) {
             /* @var $job BatchJob */
             if (in_array($job->getStatus(), BatchJobPeer::getUnClosedStatusList())) {
                 KalturaLog::DEBUG("Entry [" . $entry->getId() . "] still has an unhandled batchjob [" . $job->getId() . "] with status [" . $job->getStatus() . "] - aborting deletion process.");
                 //mark entry for later deletion
                 $entry->setMarkedForDeletion(true);
                 $entry->save();
                 return;
             }
         }
     }
     KalturaLog::log("myEntryUtils::delete Entry [" . $entry->getId() . "] Partner [" . $entry->getPartnerId() . "]");
     kJobsManager::abortEntryJobs($entry->getId());
     $media_type = $entry->getMediaType();
     $need_to_fix_roughcut = false;
     $thumb_template_file = "&deleted_image.jpg";
     KalturaLog::log("media type [{$media_type}]");
     switch ($media_type) {
         case entry::ENTRY_MEDIA_TYPE_AUDIO:
             $template_file = "&deleted_audio.flv";
             $need_to_fix_roughcut = true;
             break;
         case entry::ENTRY_MEDIA_TYPE_IMAGE:
             $template_file = "&deleted_image.jpg";
             $need_to_fix_roughcut = false;
             // no need to add a batch job for images
             break;
         case entry::ENTRY_MEDIA_TYPE_VIDEO:
             $template_file = "&deleted_video.flv";
             $need_to_fix_roughcut = true;
             break;
         case entry::ENTRY_MEDIA_TYPE_LIVE_STREAM_FLASH:
         case entry::ENTRY_MEDIA_TYPE_LIVE_STREAM_WINDOWS_MEDIA:
         case entry::ENTRY_MEDIA_TYPE_LIVE_STREAM_REAL_MEDIA:
         case entry::ENTRY_MEDIA_TYPE_LIVE_STREAM_QUICKTIME:
             kJobsManager::addProvisionDeleteJob(null, $entry);
             break;
         case entry::ENTRY_MEDIA_TYPE_SHOW:
         default:
             $template_file = "&deleted_rc.xml";
             $need_to_fix_roughcut = false;
             break;
     }
     // in this case we'll need some batch job to fix all related roughcuts for this entry
     // use the batch_job mechanism to indicate there is a deleted entry to handle
     if ($need_to_fix_roughcut) {
         //			Should use a different job type
         //			BatchJob::createDeleteEntryJob ( $entry );
     }
     $entry->putInCustomData("deleted_original_data", $entry->getData());
     $entry->putInCustomData("deleted_original_thumb", $entry->getThumbnail());
     $content_path = myContentStorage::getFSContentRootPath();
     //		Remarked by Tan-Tan 27/09/2010
     //		Handled by kObjectDeleteHandler
     //		$currentDataKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); // replaced__getDataPath
     //		$currentDataEditKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA_EDIT); // replaced__getDataPathEdit
     //		$currentThumbKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB); // replaced__getThumbnailPath
     $entry->setData($entry->getData());
     // once to increment the verions
     $entry->setData($template_file);
     // the other to set the template
     $entry->setThumbnail($entry->getThumbnail());
     // once to increment the verions
     $entry->setThumbnail($thumb_template_file);
     // the other to set the template
     //		Remarked by Tan-Tan 27/09/2010
     //		Handled by kObjectDeleteHandler
     //		// move file so there will be no access to it
     //		$deleted_content = kFileSyncUtils::deleteSyncFileForKey($currentDataKey);
     //		$deleted_content .= "|" . kFileSyncUtils::deleteSyncFileForKey($currentDataEditKey,false); // for some entries there may not be an edit version
     //		$deleted_content .= "|" . kFileSyncUtils::deleteSyncFileForKey($currentThumbKey,false); // for some entries (empty mix / audio) there may not be a thumb FileSync
     //		Remarked by Tan-Tan 27/09/2010
     //		$deleted_content is always null anyway
     //		$entry->putInCustomData( "deleted_file_path" , $deleted_content ? $deleted_content : serialize($currentDataKey) ) ;
     $entry->setStatus(entryStatus::DELETED);
     //$entry->setCategories("");
     // make sure the moderation_status is set to moderation::MODERATION_STATUS_DELETE
     $entry->setModerationStatus(moderation::MODERATION_STATUS_DELETE);
     $entry->setModifiedAt(time());
     $entry->save();
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_DELETE, $entry, null, null, null, null, $entry->getId());
 }