public static function handleJobFinished(BatchJob $job, kScheduledTaskJobData $data)
 {
     $resultFilePath = $data->getResultsFilePath();
     if (!file_exists($resultFilePath)) {
         return self::finishJobWithError($job, 'Results file was not found');
     }
     // we are using the bulk upload sync key, as this should actually be a generic sync key for batch job object
     $syncKey = $job->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_BULKUPLOAD);
     try {
         kFileSyncUtils::moveFromFile($resultFilePath, $syncKey, true);
     } catch (Exception $ex) {
         KalturaLog::err($ex);
         return self::finishJobWithError($job, 'Failed to move file: ' . $ex->getMessage());
     }
     return $job;
 }
 /**
  *
  *
  * @action requestDryRun
  * @param int $scheduledTaskProfileId
  * @param int $maxResults
  * @return int
  *
  * @throws KalturaScheduledTaskErrors::SCHEDULED_TASK_PROFILE_NOT_FOUND
  */
 public function requestDryRunAction($scheduledTaskProfileId, $maxResults = 500)
 {
     // get the object
     $dbScheduledTaskProfile = ScheduledTaskProfilePeer::retrieveByPK($scheduledTaskProfileId);
     if (!$dbScheduledTaskProfile) {
         throw new KalturaAPIException(KalturaScheduledTaskErrors::SCHEDULED_TASK_PROFILE_NOT_FOUND, $scheduledTaskProfileId);
     }
     if (!in_array($dbScheduledTaskProfile->getStatus(), array(KalturaScheduledTaskProfileStatus::ACTIVE, KalturaScheduledTaskProfileStatus::DRY_RUN_ONLY))) {
         throw new KalturaAPIException(KalturaScheduledTaskErrors::SCHEDULED_TASK_DRY_RUN_NOT_ALLOWED, $scheduledTaskProfileId);
     }
     $jobData = new kScheduledTaskJobData();
     $jobData->setMaxResults($maxResults);
     $referenceTime = kCurrentContext::$ks_object->getPrivilegeValue(ks::PRIVILEGE_REFERENCE_TIME);
     if ($referenceTime) {
         $jobData->setReferenceTime($referenceTime);
     }
     $batchJob = $this->createScheduledTaskJob($dbScheduledTaskProfile, $jobData);
     return $batchJob->getId();
 }