]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Use new delete module in volume and job endpoints
authorMarcin Haba <marcin.haba@bacula.pl>
Fri, 15 Sep 2023 08:21:31 +0000 (10:21 +0200)
committerEric Bollengier <eric@baculasystems.com>
Tue, 31 Oct 2023 15:00:30 +0000 (16:00 +0100)
gui/baculum/protected/API/Pages/API/Job.php
gui/baculum/protected/API/Pages/API/Volume.php

index 7b352594a7d3bef617756a12012892de22dc7f85..257b4a1239efd545acc56817ab4ec8b4850b9b90 100644 (file)
@@ -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;
index 1eecb2e1a813da852b0812950853fe2283b8333a..27944b08e019fc9949c89980fedb1f29e317547d 100644 (file)
@@ -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;
                }
        }
 }
-
 ?>