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 {
<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 -->