$path = property_exists($params, 'path') ? $params->path : null;
$is_valid = true;
- $jobidsList = explode(',', $jobids);
- if(is_array($jobidsList)) {
- for($i = 0; $i < count($jobidsList); $i++) {
- $job = $this->getModule('job')->getJobById($jobidsList[$i]);
- if(is_null($job)) {
- $is_valid = false;
- break;
+ if (!is_null($jobids)) {
+ $jobidsList = explode(',', $jobids);
+ if(is_array($jobidsList)) {
+ for($i = 0; $i < count($jobidsList); $i++) {
+ $job = $this->getModule('job')->getJobById($jobidsList[$i]);
+ if(is_null($job)) {
+ $is_valid = false;
+ break;
+ }
}
+ } else {
+ $is_valid = false;
}
} else {
$is_valid = false;
$this->output = $estimation->output;
$this->error = (integer)$estimation->exitcode;
} else {
- $this->output = JobError::MSG_ERROR_CLIENTID_DOES_NOT_EXISTS;
- $this->error = JobError::ERROR_CLIENTID_DOES_NOT_EXISTS;
+ $this->output = JobError::MSG_ERROR_CLIENT_DOES_NOT_EXISTS;
+ $this->error = JobError::ERROR_CLIENT_DOES_NOT_EXISTS;
}
} else {
- $this->output = JobError::MSG_ERROR_FILESETID_DOES_NOT_EXISTS;
- $this->error = JobError::ERROR_FILESETID_DOES_NOT_EXISTS;
+ $this->output = JobError::MSG_ERROR_FILESET_DOES_NOT_EXISTS;
+ $this->error = JobError::ERROR_FILESET_DOES_NOT_EXISTS;
}
} else {
$this->output = JobError::MSG_ERROR_INVALID_JOBLEVEL;
$this->output = $run->output;
$this->error = (integer)$run->exitcode;
} else {
- $this->output = JobError::MSG_ERROR_POOLID_DOES_NOT_EXISTS;
- $this->error = JobError::ERROR_POOLID_DOES_NOT_EXISTS;
+ $this->output = JobError::MSG_ERROR_POOL_DOES_NOT_EXISTS;
+ $this->error = JobError::ERROR_POOL_DOES_NOT_EXISTS;
}
} else {
- $this->output = JobError::MSG_ERROR_STORAGEID_DOES_NOT_EXISTS;
- $this->error = JobError::ERROR_STORAGEID_DOES_NOT_EXISTS;
+ $this->output = JobError::MSG_ERROR_STORAGE_DOES_NOT_EXISTS;
+ $this->error = JobError::ERROR_STORAGE_DOES_NOT_EXISTS;
}
} else {
- $this->output = JobError::MSG_ERROR_CLIENTID_DOES_NOT_EXISTS;
- $this->error = JobError::ERROR_CLIENTID_DOES_NOT_EXISTS;
+ $this->output = JobError::MSG_ERROR_CLIENT_DOES_NOT_EXISTS;
+ $this->error = JobError::ERROR_CLIENT_DOES_NOT_EXISTS;
}
} else {
- $this->output = JobError::MSG_ERROR_FILESETID_DOES_NOT_EXISTS;
- $this->error = JobError::ERROR_FILESETID_DOES_NOT_EXISTS;
+ $this->output = JobError::MSG_ERROR_FILESET_DOES_NOT_EXISTS;
+ $this->error = JobError::ERROR_FILESET_DOES_NOT_EXISTS;
}
} else {
$this->output = JobError::MSG_ERROR_INVALID_JOBLEVEL;
public function create($params) {
$rfile = property_exists($params, 'rpath') ? $params->rpath : null;
- $clientid = property_exists($params, 'clientid') ? intval($params->clientid) : null;
- $fileset = property_exists($params, 'fileset') ? $params->fileset : null;
- $priority = property_exists($params, 'priority') ? intval($params->priority) : null;
+
+ $fileset = null;
+ if (property_exists($params, 'fileset') && $this->getModule('misc')->isValidName($params->fileset)) {
+ $fileset = $params->fileset;
+ }
+ $client = null;
+ if (property_exists($params, 'clientid')) {
+ $clientid = intval($params->clientid);
+ $client_row = $this->getModule('client')->getClientById($clientid);
+ $client = is_object($client_row) ? $client_row->name : null;
+ } elseif (property_exists($params, 'client') && $this->getModule('misc')->isValidName($params->client)) {
+ $client = $params->client;
+ }
+ $priority = property_exists($params, 'priority') ? intval($params->priority) : 10; // default priority is set to 10
$where = property_exists($params, 'where') ? $params->where : null;
$replace = property_exists($params, 'replace') ? $params->replace : null;
-
- $client = $this->getModule('client')->getClientById($clientid);
$misc = $this->getModule('misc');
if(!is_null($fileset)) {
if(preg_match($misc::RPATH_PATTERN, $rfile) === 1) {
if(!is_null($where)) {
if(!is_null($replace)) {
- $restore = $this->getModule('bconsole')->bconsoleCommand($this->director, array('restore', 'file="?' . $rfile . '"', 'client="' . $client->name . '"', 'where="' . $where . '"', 'replace="' . $replace . '"', 'fileset="' . $fileset . '"', 'priority="' . $priority . '"', 'yes'), $this->user);
+ $command = array('restore',
+ 'file="?' . $rfile . '"',
+ 'client="' . $client . '"',
+ 'where="' . $where . '"',
+ 'replace="' . $replace . '"',
+ 'fileset="' . $fileset . '"',
+ 'priority="' . $priority . '"',
+ 'yes'
+ );
+ $restore = $this->getModule('bconsole')->bconsoleCommand($this->director, $command, $this->user);
$this->removeTmpRestoreTable($rfile);
$this->output = $restore->output;
$this->error = (integer)$restore->exitcode;
$this->error = JobError::ERROR_INVALID_RPATH;
}
} else {
- $this->output = JobError::MSG_ERROR_CLIENTID_DOES_NOT_EXISTS;
- $this->error = JobError::ERROR_CLIENTID_DOES_NOT_EXISTS;
+ $this->output = JobError::MSG_ERROR_CLIENT_DOES_NOT_EXISTS;
+ $this->error = JobError::ERROR_CLIENT_DOES_NOT_EXISTS;
}
} else {
- $this->output = JobError::MSG_ERROR_FILESETID_DOES_NOT_EXISTS;
- $this->error = JobError::ERROR_FILESETID_DOES_NOT_EXISTS;
+ $this->output = JobError::MSG_ERROR_FILESET_DOES_NOT_EXISTS;
+ $this->error = JobError::ERROR_FILESET_DOES_NOT_EXISTS;
}
}
$connection->setActive(true);
$sql = "DROP TABLE $tableName";
$pdo = $connection->getPdoInstance();
- $pdo->exec($sql);
+ try {
+ $pdo->exec($sql);
+ } catch(PDOException $e) {
+ $emsg = 'Problem during delete temporary Bvfs table. ' . $e->getMessage();
+ $this->getModule('logging')->log(
+ __FUNCTION__,
+ $emsg,
+ Logging::CATEGORY_APPLICATION,
+ __FILE__,
+ __LINE__
+ );
+ }
$pdo = null;
}
}
class JobError extends GenericError {
const ERROR_JOB_DOES_NOT_EXISTS = 50;
const ERROR_INVALID_JOBLEVEL = 51;
- const ERROR_FILESETID_DOES_NOT_EXISTS = 52;
- const ERROR_CLIENTID_DOES_NOT_EXISTS = 53;
- const ERROR_STORAGEID_DOES_NOT_EXISTS = 54;
- const ERROR_POOLID_DOES_NOT_EXISTS = 55;
+ const ERROR_FILESET_DOES_NOT_EXISTS = 52;
+ const ERROR_CLIENT_DOES_NOT_EXISTS = 53;
+ const ERROR_STORAGE_DOES_NOT_EXISTS = 54;
+ const ERROR_POOL_DOES_NOT_EXISTS = 55;
const ERROR_INVALID_RPATH = 56;
const ERROR_INVALID_WHERE_OPTION = 57;
const ERROR_INVALID_REPLACE_OPTION = 58;
const MSG_ERROR_JOB_DOES_NOT_EXISTS = 'Job with inputted jobid does not exist.';
const MSG_ERROR_INVALID_JOBLEVEL = 'Inputted job level is invalid.';
- const MSG_ERROR_FILESETID_DOES_NOT_EXISTS = 'FileSet resource with inputted filesetid does not exist.';
- const MSG_ERROR_CLIENTID_DOES_NOT_EXISTS = 'Client with inputted clientid does not exist.';
- const MSG_ERROR_STORAGEID_DOES_NOT_EXISTS = 'Storage with inputted storageid does not exist.';
- const MSG_ERROR_POOLID_DOES_NOT_EXISTS = 'Pool with inputted poolid does not exist.';
+ const MSG_ERROR_FILESET_DOES_NOT_EXISTS = 'FileSet resource does not exist.';
+ const MSG_ERROR_CLIENT_DOES_NOT_EXISTS = 'Client does not exist.';
+ const MSG_ERROR_STORAGE_DOES_NOT_EXISTS = 'Storage does not exist.';
+ const MSG_ERROR_POOL_DOES_NOT_EXISTS = 'Pool does not exist.';
const MSG_ERROR_INVALID_RPATH = 'Inputted rpath for restore is invalid. Proper format is b2[0-9]+.';
const MSG_ERROR_INVALID_WHERE_OPTION = 'Inputted "where" option is invalid.';
const MSG_ERROR_INVALID_REPLACE_OPTION = 'Inputted "replace" option is invalid.';