#1704 restoreBackup XMLRPC fixed

This commit is contained in:
tomash 2006-11-09 14:38:59 +00:00
parent 3d79b7ce2a
commit c1253836d4
5 changed files with 96 additions and 18 deletions

View File

@ -1194,26 +1194,54 @@ class LocStor extends BasicStor {
/* ------------------------------------------------------ restore methods */
/**
* Restore a beckup file (open handle)
* Restore a backup file (open handle)
*
* @param string $sessid - session id
* @param string $filename - backup file path
* @param string $chsum, md5 checksum of imported file
* @return array
* array with:
* url string: writable URL
* fname string: writable local filename
* token string: PUT token
*/
function restoreBackupOpen($sessid, $chsum)
{
$userid = $r =$this->getSessUserId($sessid);
if ($this->dbc->isError($r)) {
return $r;
}
$r = $this->bsOpenPut($chsum, NULL, $userid);
if (PEAR::isError($r)) {
return $r;
}
return $r;
}
/**
* Restore a backup file (close put handle)
*
* @param string $sessid - session id
* @param string $token - put token
* @return string $token - restore token
*/
function restoreBackupOpen($sessid, $filename)
{
function restoreBackupClosePut($sessid, $token) {
$arr = $r = $this->bsClosePut($token);
if (PEAR::isError($r)) {
return $r;
}
$fname = $arr['fname'];
require_once 'Restore.php';
$rs = new Restore($this);
if (PEAR::isError($rs)) {
return $rs;
}
return $rs->openRestore($sessid,$filename);
return $rs->openRestore($sessid, $fname);
}
/**
* Restore a beckup file (check state)
*
* Restore a backup file (check state)
*
* @param string $token - restore token
* @return array status - fields:
* token: string - restore token

View File

@ -119,8 +119,9 @@ class Restore {
$r['status'] = $stat;
if ($stat=='fault') {
$r['faultString'] = $message;
} else {
$r['faultString'] = '';
}
// $r['token'] = $token;
return $r;
} else {
return PEAR::raiseError('Restore::checkRestore: invalid token!');

View File

@ -1935,11 +1935,12 @@ class XR_LocStor extends LocStor{
* fields:
* <ul>
* <li> sessid : string - session id </li>
* <li> filename: string - backup file</li>
* <li> chsum : string - md5 checksum of restore file</li>
* </ul>
*
* On success, returns a XML-RPC struct with following fields:
* <ul>
* <li> url : string - writable URL for HTTP PUT</li>
* <li> token : string - PUT token</li>
* </ul>
*
@ -1961,16 +1962,61 @@ class XR_LocStor extends LocStor{
{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
$res = $this->restoreBackupOpen($r['sessid'], $r['filename']);
$res = $this->restoreBackupOpen($r['sessid'], $r['chsum']);
if(PEAR::isError($res)){
return new XML_RPC_Response(0, 805,
"xr_restoreBackupOpen: ".$res->getMessage().
" ".$res->getUserInfo()
);
}
return new XML_RPC_Response(XML_RPC_encode(array(
'token'=>$res['token'],
)));
unset($res['fname']);
return new XML_RPC_Response(XML_RPC_encode($res));
}
/**
* Close writable URL for restore a backup file and start the restore
* process
*
* The XML-RPC name of this method is "locstor.restoreBackupClosePut".
*
* The input parameters are an XML-RPC struct with the following
* fields:
* <ul>
* <li> sessid : string - session id </li>
* <li> token : string - PUT token </li>
* </ul>
*
* On success, returns a XML-RPC struct with following fields:
* <ul>
* <li> token : string - restore token</li>
* </ul>
*
* On errors, returns an XML-RPC error response.
* The possible error codes and error message are:
* <ul>
* <li> 3 - Incorrect parameters passed to method:
* Wanted ... , got ... at param </li>
* <li> 801 - wrong 1st parameter, struct expected.</li>
* <li> 805 - xr_restoreBackupClosePut:
* &lt;message from lower layer&gt; </li>
* </ul>
*
* @param input XMLRPC struct
* @return XMLRPC struct
* @see LocStor::restoreBackupClosePut
*/
function xr_restoreBackupClosePut($input)
{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
$res = $this->restoreBackupClosePut($r['sessid'], $r['token']);
if(PEAR::isError($res)){
return new XML_RPC_Response(0, 805,
"xr_restoreBackupClosePut: ".$res->getMessage().
" ".$res->getUserInfo()
);
}
return new XML_RPC_Response(XML_RPC_encode($res));
}
/**
@ -1981,7 +2027,7 @@ class XR_LocStor extends LocStor{
* The input parameters are an XML-RPC struct with the following
* fields:
* <ul>
* <li> token : string - access token </li>
* <li> token : string - restore token </li>
* </ul>
*
* On success, returns a XML-RPC struct with following fields:
@ -2022,14 +2068,14 @@ class XR_LocStor extends LocStor{
}
/**
* Close writable URL for restore a backup file and restore the backup file
* Close the restore process
*
* The XML-RPC name of this method is "locstor.restoreBackupClose".
*
* The input parameters are an XML-RPC struct with the following
* fields:
* <ul>
* <li> token : string - access token </li>
* <li> token : string - restore token </li>
* </ul>
*
* On success, returns a XML-RPC struct with following fields:

View File

@ -131,6 +131,7 @@ $methods = array(
'createBackupClose' => 'Create backup of storage (close handle)',
'restoreBackupOpen' => 'Restore a backup file (open handle)',
'restoreBackupClosePut' => 'Restore a backup file (close PUT handle)',
'restoreBackupCheck' => 'Restore a backup file (check results)',
'restoreBackupClose' => 'Restore a backup file (close handle)',

View File

@ -187,7 +187,9 @@ $infos = array(
"createBackupClose" => array('m'=>"locstor.createBackupClose",
'p'=>array('token'), 'r'=>array('status')),
"restoreBackupOpen" => array('m'=>"locstor.restoreBackupOpen",
'p'=>array('sessid', 'filename'), 'r'=>array('token')),
'p'=>array('sessid', 'filename'), 'r'=>array('url', 'token')),
"restoreBackupClosePut" => array('m'=>"locstor.restoreBackupClosePut",
'p'=>array('sessid', 'token'), 'r'=>array('token')),
"restoreBackupCheck" => array('m'=>"locstor.restoreBackupCheck",
'p'=>array('token'), 'r'=>array('status', 'faultString')),
"restoreBackupClose" => array('m'=>"locstor.restoreBackupClose",