]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Get job show result by job name or jobid
authorMarcin Haba <marcin.haba@bacula.pl>
Sat, 12 Dec 2015 12:52:56 +0000 (13:52 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Sat, 12 Dec 2015 12:52:56 +0000 (13:52 +0100)
gui/baculum/protected/Pages/API/JobShow.php
gui/baculum/protected/application.xml

index fddd516c951b4599da02fa4b4e3f7bab7a0cca2a..b378386f8b5d045e74fdf92ff29ab937993acff7 100644 (file)
 
 class JobShow extends BaculumAPI {
        public function get() {
-               $jobid = intval($this->Request['id']);
-               $job = $this->getModule('job')->getJobById($jobid);
-               if(!is_null($job)) {
-                       $jobShow = $this->getModule('bconsole')->bconsoleCommand($this->director, array('show', 'job="' . $job->name . '"'), $this->user);
+               $jobname = null;
+
+               if (isset($this->Request['id'])) {
+                       $jobid = intval($this->Request['id']);
+                       $job = $this->getModule('job')->getJobById($jobid);
+                       $jobname = property_exists($job, 'name') ? $job->name : null;
+               } elseif (isset($this->Request['name'])) {
+                       $allowedJobs = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.jobs'), $this->user)->output;
+                       $jobname = in_array($this->Request['name'], $allowedJobs) ? $this->Request['name'] : null;
+               }
+
+               if(!is_null($jobname)) {
+                       $jobShow = $this->getModule('bconsole')->bconsoleCommand($this->director, array('show', 'job="' . $jobname . '"'), $this->user);
                        $this->output = $jobShow->output;
                        $this->error = (integer)$jobShow->exitcode;
                } else {
index 99e3f67717db2356b5405015a2041b70c576b981..ad0e839f0df9e026ea78482b8341b7a3d360a5be 100644 (file)
@@ -65,6 +65,7 @@
                        <url ServiceParameter="API.JobCancel" pattern="jobs/cancel/{id}/" parameters.id="\d+"/>
                        <url ServiceParameter="API.JobsShow" pattern="jobs/show/" />
                        <url ServiceParameter="API.JobShow" pattern="jobs/show/{id}/" parameters.id="\d+" />
+                       <url ServiceParameter="API.JobShow" pattern="jobs/show/name/{name}/" parameters.name=".+" />
                        <url ServiceParameter="API.RestoreRun" pattern="jobs/restore/" />
                        <!-- END Jobs -->
                        <!-- START BVFS -->