From: Marcin Haba Date: Fri, 15 Sep 2023 08:21:31 +0000 (+0200) Subject: baculum: Use new delete module in volume and job endpoints X-Git-Tag: Beta-15.0.0~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5caa5ca44aa50f8cc86f37966678cac210dcd299;p=thirdparty%2Fbacula.git baculum: Use new delete module in volume and job endpoints --- diff --git a/gui/baculum/protected/API/Pages/API/Job.php b/gui/baculum/protected/API/Pages/API/Job.php index 7b352594a..257b4a123 100644 --- a/gui/baculum/protected/API/Pages/API/Job.php +++ b/gui/baculum/protected/API/Pages/API/Job.php @@ -20,6 +20,7 @@ * Bacula(R) is a registered trademark of Kern Sibbald. */ +use Baculum\API\Modules\Delete; use Baculum\API\Modules\BaculumAPIServer; use Baculum\Common\Modules\Errors\JobError; @@ -65,12 +66,13 @@ class Job extends BaculumAPIServer { if ($result->exitcode === 0) { $job = $this->getModule('job')->getJobById($jobid); if(is_object($job) && in_array($job->name, $result->output)) { - $result = $this->getModule('bconsole')->bconsoleCommand( + $result = $this->getModule('delete')->delete( $this->director, - array('delete', 'jobid="' . $job->jobid . '"') + Delete::TYPE_JOBID, + $job->jobid ); - $this->output = $result->output; - $this->error = $result->exitcode; + $this->output = $result['output']; + $this->error = $result['error']; } else { $this->output = JobError::MSG_ERROR_JOB_DOES_NOT_EXISTS; $this->error = JobError::ERROR_JOB_DOES_NOT_EXISTS; diff --git a/gui/baculum/protected/API/Pages/API/Volume.php b/gui/baculum/protected/API/Pages/API/Volume.php index 1eecb2e1a..27944b08e 100644 --- a/gui/baculum/protected/API/Pages/API/Volume.php +++ b/gui/baculum/protected/API/Pages/API/Volume.php @@ -20,6 +20,7 @@ * Bacula(R) is a registered trademark of Kern Sibbald. */ +use Baculum\API\Modules\Delete; use Baculum\API\Modules\BaculumAPIServer; use Baculum\Common\Modules\Errors\VolumeError; @@ -97,26 +98,17 @@ class Volume extends BaculumAPIServer { $mediaid = $this->Request->contains('id') ? intval($this->Request['id']) : 0; $volume = $this->getModule('volume')->getVolumeById($mediaid); if (is_object($volume)) { - $result = $this->getModule('bconsole')->bconsoleCommand( + $result = $this->getModule('delete')->delete( $this->director, - [ - 'delete', - 'volume="' . $volume->volumename . '"', - 'yes' - ] + Delete::TYPE_VOLUME, + $volume->volumename ); - if ($result->exitcode === 0) { - $this->output = $result->output; - $this->error = VolumeError::ERROR_NO_ERRORS; - } else { - $this->output = $result->output; - $this->error = VolumeError::ERROR_WRONG_EXITCODE; - } + $this->output = $result['output']; + $this->error = $result['error']; } else { $this->output = VolumeError::MSG_ERROR_VOLUME_DOES_NOT_EXISTS; $this->error = VolumeError::ERROR_VOLUME_DOES_NOT_EXISTS; } } } - ?>