/** * @param BatchJob $dbBatchJob * @param kDistributionDeleteJobData $data * @param BatchJob $twinJob * @return BatchJob */ public static function onDistributionDeleteJobUpdated(BatchJob $dbBatchJob, kDistributionDeleteJobData $data, BatchJob $twinJob = null) { if ($data->getResults() || $data->getSentData()) { $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId()); if (!$entryDistribution) { KalturaLog::err("Entry distribution [" . $data->getEntryDistributionId() . "] not found"); return $dbBatchJob; } if ($data->getResults()) { $entryDistribution->incrementDeleteResultsVersion(); } if ($data->getSentData()) { $entryDistribution->incrementDeleteDataVersion(); } $entryDistribution->save(); if ($data->getResults()) { $key = $entryDistribution->getSyncKey(EntryDistribution::FILE_SYNC_ENTRY_DISTRIBUTION_DELETE_RESULTS); kFileSyncUtils::file_put_contents($key, $data->getResults()); $data->setResults(null); } if ($data->getSentData()) { $key = $entryDistribution->getSyncKey(EntryDistribution::FILE_SYNC_ENTRY_DISTRIBUTION_DELETE_DATA); kFileSyncUtils::file_put_contents($key, $data->getSentData()); $data->setSentData(null); } $dbBatchJob->setData($data); $dbBatchJob->save(); } switch ($dbBatchJob->getStatus()) { case BatchJob::BATCHJOB_STATUS_PENDING: return self::onDistributionDeleteJobPending($dbBatchJob, $data, $twinJob); case BatchJob::BATCHJOB_STATUS_FINISHED: return self::onDistributionDeleteJobFinished($dbBatchJob, $data, $twinJob); case BatchJob::BATCHJOB_STATUS_FAILED: case BatchJob::BATCHJOB_STATUS_FATAL: return self::onDistributionDeleteJobFailed($dbBatchJob, $data, $twinJob); default: return $dbBatchJob; } }