class BVFSError extends GenericError {
const ERROR_JOB_DOES_NOT_EXISTS = 70;
- const ERROR_INVALID_PATH = 71;
+ const ERROR_INVALID_RPATH = 71;
+ const ERROR_INVALID_RESTORE_PATH = 72;
const MSG_ERROR_JOB_DOES_NOT_EXISTS = 'Job with inputed jobid does not exist.';
- const MSG_ERROR_INVALID_PATH = 'Inputed path for restore is invalid. Proper format is b2[0-9]+.';
+ const MSG_ERROR_INVALID_RPATH = 'Inputed path for restore is invalid. Proper format is b2[0-9]+.';
+ const MSG_ERROR_INVALID_RESTORE_PATH = 'Inputted BVFS path param is invalid.';
}
?>
class BVFSLsDirs extends BaculumAPI {
- public function get() {
- $ids = $this->Request['id'];
- $path = $this->Request['path'];
+ public function get() {}
+
+ public function set($param, $ids) {
$limit = intval($this->Request['limit']);
$offset = intval($this->Request['offset']);
- $jobids = explode(',', $ids);
$isValid = true;
- for($i = 0; $i < count($jobids); $i++) {
- $job = $this->getModule('job')->getJobById($jobids[$i]);
- if(is_null($job)) {
- $isValid = false;
- break;
+ if (property_exists($ids, 'jobids')) {
+ $jobids = explode(',', $ids->jobids);
+ for($i = 0; $i < count($jobids); $i++) {
+ $job = $this->getModule('job')->getJobById($jobids[$i]);
+ if(is_null($job)) {
+ $isValid = false;
+ break;
+ }
}
+ } else {
+ $isValid = false;
+ }
+
+ $path = null;
+ if (property_exists($ids, 'path')) {
+ $path = $ids->path;
}
if($isValid === true) {
- $cmd = array('.bvfs_lsdirs', 'jobid="' . $ids . '"', 'path="' . $path . '"');
-
- if($offset > 0) {
- array_push($cmd, 'offset="' . $offset . '"');
- }
- if($limit > 0) {
- array_push($cmd, 'limit="' . $limit . '"');
+ if (!is_null($path)) {
+ $cmd = array('.bvfs_lsdirs', 'jobid="' . $ids->jobids . '"', 'path="' . $path . '"');
+
+ if($offset > 0) {
+ array_push($cmd, 'offset="' . $offset . '"');
+ }
+ if($limit > 0) {
+ array_push($cmd, 'limit="' . $limit . '"');
+ }
+ $result = $this->getModule('bconsole')->bconsoleCommand($this->director, $cmd, $this->user);
+ $this->output = $result->output;
+ $this->error = (integer)$result->exitcode;
+ } else {
+ $this->output = BVFSError::ERROR_INVALID_RESTORE_PATH;
+ $this->error = BVFSError::MSG_ERROR_INVALID_RESTORE_PATH;
}
- $result = $this->getModule('bconsole')->bconsoleCommand($this->director, $cmd, $this->user);
- $this->output = $result->output;
- $this->error = (integer)$result->exitcode;
} else {
$this->output = BVFSError::MSG_ERROR_JOB_DOES_NOT_EXISTS;
$this->error = BVFSError::ERROR_JOB_DOES_NOT_EXISTS;
class BVFSLsFiles extends BaculumAPI {
- public function get() {
- $ids = $this->Request['id'];
- $path = $this->Request['path'];
+ public function get() {}
+
+ public function set($param, $ids) {
$limit = intval($this->Request['limit']);
$offset = intval($this->Request['offset']);
- $jobids = explode(',', $ids);
$isValid = true;
- for($i = 0; $i < count($jobids); $i++) {
- $job = $this->getModule('job')->getJobById($jobids[$i]);
- if(is_null($job)) {
- $isValid = false;
- break;
+ if (property_exists($ids, 'jobids')) {
+ $jobids = explode(',', $ids->jobids);
+ for($i = 0; $i < count($jobids); $i++) {
+ $job = $this->getModule('job')->getJobById($jobids[$i]);
+ if(is_null($job)) {
+ $isValid = false;
+ break;
+ }
}
+ } else {
+ $isValid = false;
+ }
+
+ $path = null;
+ if (property_exists($ids, 'path')) {
+ $path = $ids->path;
}
-
+
if($isValid === true) {
- $cmd = array('.bvfs_lsfiles', 'jobid="' . $ids . '"', 'path="' . $path . '"');
- if($offset > 0) {
- array_push($cmd, 'offset="' . $offset . '"');
- }
- if($limit > 0) {
- array_push($cmd, 'limit="' . $limit . '"');
+ if (!is_null($path)) {
+ $cmd = array('.bvfs_lsfiles', 'jobid="' . $ids->jobids . '"', 'path="' . $path . '"');
+ if($offset > 0) {
+ array_push($cmd, 'offset="' . $offset . '"');
+ }
+ if($limit > 0) {
+ array_push($cmd, 'limit="' . $limit . '"');
+ }
+ $result = $this->getModule('bconsole')->bconsoleCommand($this->director, $cmd, $this->user);
+ $this->output = $result->output;
+ $this->error = (integer)$result->exitcode;
+ } else {
+ $this->output = BVFSError::ERROR_INVALID_RESTORE_PATH;
+ $this->error = BVFSError::MSG_ERROR_INVALID_RESTORE_PATH;
}
- $result = $this->getModule('bconsole')->bconsoleCommand($this->director, $cmd, $this->user);
- $this->output = $result->output;
- $this->error = (integer)$result->exitcode;
} else {
$this->output = BVFSError::MSG_ERROR_JOB_DOES_NOT_EXISTS;
$this->error = BVFSError::ERROR_JOB_DOES_NOT_EXISTS;
$this->output = $result->output;
$this->error = (integer)$result->exitcode;
} else {
- $this->output = BVFSError::MSG_ERROR_INVALID_PATH;
- $this->error = BVFSError::ERROR_INVALID_PATH;
+ $this->output = BVFSError::MSG_ERROR_INVALID_RPATH;
+ $this->error = BVFSError::ERROR_INVALID_RPATH;
}
} else {
$this->output = BVFSError::MSG_ERROR_JOB_DOES_NOT_EXISTS;
public function get() {}
- public function set($ids, $params) {
- $jobids = explode(',', $ids);
+ public function set($param, $ids) {
$isValid = true;
- for($i = 0; $i < count($jobids); $i++) {
- $job = $this->getModule('job')->getJobById($jobids[$i]);
- if(is_null($job)) {
- $isValid = false;
- break;
+ if (property_exists($ids, 'jobids')) {
+ $jobids = explode(',', $ids->jobids);
+ for($i = 0; $i < count($jobids); $i++) {
+ $job = $this->getModule('job')->getJobById($jobids[$i]);
+ if(is_null($job)) {
+ $isValid = false;
+ break;
+ }
}
+ } else {
+ $isValid = false;
}
if($isValid === true) {
- $result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.bvfs_update', 'jobid="' . $ids . '"'), $this->user);
+ $result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.bvfs_update', 'jobid="' . $ids->jobids . '"'), $this->user);
$this->output = $result->output;
$this->error = (integer)$result->exitcode;
} else {
// generating Bvfs may takes a moment
$this->generateBvfsCacheByJobids($jobids);
- $bvfsDirsList = $this->getModule('api')->get(array('bvfs', 'lsdirs', $jobids, '?path=' . urlencode($this->getBrowserPath(true)) . ''));
+ $bvfsDirsList = $this->getModule('api')->set(array('bvfs', 'lsdirs'), array('jobids' => $jobids, 'path' => $this->getBrowserPath(true)));
$bvfsDirs = is_object($bvfsDirsList) ? $bvfsDirsList->output : array();
$dirs = $this->getModule('misc')->parseBvfsList($bvfsDirs);
- $bvfsFilesList = $this->getModule('api')->get(array('bvfs', 'lsfiles', $jobids, '?path=' . urlencode($this->getBrowserPath(true)) . ''));
+ $bvfsFilesList = $this->getModule('api')->set(array('bvfs', 'lsfiles'), array('jobids' => $jobids, 'path' => $this->getBrowserPath(true)));
$bvfsFiles = is_object($bvfsFilesList) ? $bvfsFilesList->output : array();
$files = $this->getModule('misc')->parseBvfsList($bvfsFiles);
$elements = array_merge($dirs, $files);
}
private function generateBvfsCacheByJobids($jobids) {
- $this->getModule('api')->set(array('bvfs', 'update', $jobids), array());
+ $this->getModule('api')->set(array('bvfs', 'update'), array('jobids' => $jobids));
}
private function setFileVersions($versions) {
<url ServiceParameter="API.RestoreRun" pattern="jobs/restore/" />
<!-- END Jobs -->
<!-- START BVFS -->
- <url ServiceParameter="API.BVFSUpdate" pattern="bvfs/update/{id}/" parameters.id="[\d\,]+" />
- <url ServiceParameter="API.BVFSLsDirs" pattern="bvfs/lsdirs/{id}/" parameters.id="[\d\,]+" parameters.path=".+" />
- <url ServiceParameter="API.BVFSLsDirs" pattern="bvfs/lsdirs/{id}/limit/{limit}/" parameters.id="[\d\,]+" parameters.path=".+" parameters.limit="\d+" />
- <url ServiceParameter="API.BVFSLsDirs" pattern="bvfs/lsdirs/{id}/limit/{limit}/{offset}/" parameters.id="[\d\,]+" parameters.path=".+" parameters.limit="\d+" parameters.offset="\d+" />
- <url ServiceParameter="API.BVFSLsFiles" pattern="bvfs/lsfiles/{id}/" parameters.id="[\d\,]+" parameters.path=".+" />
- <url ServiceParameter="API.BVFSLsFiles" pattern="bvfs/lsfiles/{id}/limit/{limit}/" parameters.id="[\d\,]+" parameters.path=".+" parameters.limit="\d+" />
- <url ServiceParameter="API.BVFSLsFiles" pattern="bvfs/lsfiles/{id}/limit/{limit}/{offset}/" parameters.id="[\d\,]+" parameters.path=".+" parameters.limit="\d+" parameters.offset="\d+" />
+ <url ServiceParameter="API.BVFSUpdate" pattern="bvfs/update/" />
+ <url ServiceParameter="API.BVFSLsDirs" pattern="bvfs/lsdirs/" />
+ <url ServiceParameter="API.BVFSLsDirs" pattern="bvfs/lsdirs/limit/{limit}/" parameters.limit="\d+" />
+ <url ServiceParameter="API.BVFSLsDirs" pattern="bvfs/lsdirs/limit/{limit}/{offset}/" parameters.limit="\d+" parameters.offset="\d+" />
+ <url ServiceParameter="API.BVFSLsFiles" pattern="bvfs/lsfiles/" />
+ <url ServiceParameter="API.BVFSLsFiles" pattern="bvfs/lsfiles/limit/{limit}/" parameters.limit="\d+" />
+ <url ServiceParameter="API.BVFSLsFiles" pattern="bvfs/lsfiles/limit/{limit}/{offset}/" parameters.limit="\d+" parameters.offset="\d+" />
<url ServiceParameter="API.BVFSVersions" pattern="bvfs/versions/{client}/{jobid}/{pathid}/{filenameid}/" parameters.client=".+" parameters.jobid="\d+" parameters.pathid="\d+" parameters.filenameid="\d+" />
<url ServiceParameter="API.BVFSGetJobids" pattern="bvfs/getjobids/{id}/" parameters.id="[\d\,]+" />
<url ServiceParameter="API.BVFSRestore" pattern="bvfs/restore/" />