]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Fix restore when a lot of jobids given
authorMarcin Haba <marcin.haba@bacula.pl>
Sat, 12 Dec 2015 19:39:56 +0000 (20:39 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Sat, 12 Dec 2015 19:39:56 +0000 (20:39 +0100)
gui/baculum/protected/Class/Errors.php
gui/baculum/protected/Pages/API/BVFSLsDirs.php
gui/baculum/protected/Pages/API/BVFSLsFiles.php
gui/baculum/protected/Pages/API/BVFSRestore.php
gui/baculum/protected/Pages/API/BVFSUpdate.php
gui/baculum/protected/Pages/RestoreWizard.php
gui/baculum/protected/application.xml

index 410a3ca87890f86ec5d2ed53d48e862141c329f2..559760ad93df05719d0c23eb6ce40a67a7f462d2 100644 (file)
@@ -110,9 +110,11 @@ class FileSetError extends GenericError {
 
 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.';
 }
 ?>
index d409644b5281ce40e31277eee20f08ceac8dd82c..86617125678981ef351406f0ab8ee054cb9acc4c 100644 (file)
  
 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;
index d13f054ab02641425f9f4fc6d095bca2b3ccb2ec..a91223c54530f96b26ee4812e52d988697ae2130 100644 (file)
  
 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;
index ab8e00ad376d72347da715f1c61d57ec11a11ee3..085d6dc412c5ed08356448d5b10aab78b5965344 100644 (file)
@@ -57,8 +57,8 @@ class BVFSRestore extends BaculumAPI {
                                $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;
index 3d522512805c4e6bfb0a5daa62f1b24c4c80ec82..15b7c382f9f7da8143c7a184574167619a68e5d4 100644 (file)
@@ -24,19 +24,23 @@ class BVFSUpdate extends BaculumAPI {
 
        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 {
index 761a2257c527505bb7e4239f83056641faca75c1..67e7ddcd445785dda12cba588b1c2ed82d7568f5 100644 (file)
@@ -295,10 +295,10 @@ class RestoreWizard extends BaculumPage
        
                // 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);
@@ -332,7 +332,7 @@ class RestoreWizard extends BaculumPage
        }
 
        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) {
index ad0e839f0df9e026ea78482b8341b7a3d360a5be..2ec14fe6cf0d09ca0014717e6d2d3ead3beae9ea 100644 (file)
                        <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/" />