diff --git a/livesupport/src/modules/storageServer/var/BasicStor.php b/livesupport/src/modules/storageServer/var/BasicStor.php
index 80d6da763..7761a516e 100644
--- a/livesupport/src/modules/storageServer/var/BasicStor.php
+++ b/livesupport/src/modules/storageServer/var/BasicStor.php
@@ -1623,7 +1623,7 @@ class BasicStor extends Alib{
if($filesOnly) $this->deleteFiles();
else $this->deleteData();
if(!$this->config['isArchive']){
- $tr =& new Transport($this->dbc, $this, $this->config);
+ $tr =& new Transport($this);
$tr->resetData();
}
$res = array(
diff --git a/livesupport/src/modules/storageServer/var/GreenBox.php b/livesupport/src/modules/storageServer/var/GreenBox.php
index 7b6be3786..f796ced81 100644
--- a/livesupport/src/modules/storageServer/var/GreenBox.php
+++ b/livesupport/src/modules/storageServer/var/GreenBox.php
@@ -1133,35 +1133,19 @@ class GreenBox extends BasicStor{
*
* @param trtok: string - transport token
* @return struct/hasharray with fields:
+ * trtype: string - audioclip | playlist | search | file
* state: string - transport state
- * expectedSize: int - file size in bytes
- * realSize: int - currently transported bytes
- * expectedChsum: string - orginal file checksum
- * realChsum: string - transported file checksum
+ * direction: string - up | down
+ * expectedsize: int - file size in bytes
+ * realsize: int - currently transported bytes
+ * expectedchsum: string - orginal file checksum
+ * realchsum: string - transported file checksum
* ... ?
*/
- // DUMMY
- function getTransportInfo($trtok)
- {
- switch($trtok){
- case'123456789abcdeff'; // upload/download
- return array(
- 'state' => 'finished',
- 'expectedSize' => 1024,
- 'realSize' => 1024,
- 'expectedChsum' => '12dd9137a855cf600881dd6d3ffa7517',
- 'realChsum' => '12dd9137a855cf600881dd6d3ffa7517',
- );
- case'123456789abcdefe'; // search
- return array(
- 'state' => 'finished',
- );
- default:
- return PEAR::raiseError(
- "GreenBox::getTransportInfo:".
- " invalid transport token ($trtok)"
- );
- }
+ function getTransportInfo($trtok) {
+ require_once"Transport.php";
+ $tr =& new Transport($this);
+ return $tr->getTransportInfo($trtok);
}
/**
@@ -1170,12 +1154,12 @@ class GreenBox extends BasicStor{
* @param onOff: boolean optional (if not used, current state is returned)
* @return boolean - previous state
*/
- // DUMMY
- function turnOnOffTransports($onOff)
- {
- return TRUE;
+ function turnOnOffTransports($onOff) {
+ require_once"Transport.php";
+ $tr =& new Transport($this);
+ return $tr->turnOnOffTransports($onOff);
}
-
+
/* ------------------------ methods for ls-archive-format file transports */
/**
* Open async file transfer from local storageServer to network hub,
@@ -1184,17 +1168,12 @@ class GreenBox extends BasicStor{
* @param filePath string - local path to uploaded file
* @return string - transport token
*/
- // DUMMY
- function uploadFile2Hub($filePath)
- {
- if(!file_exists($filePath)){
- return PEAR::raiseError(
- "GreenBox::uploadFile2Hub: file not found ($filePath)"
- );
- }
- return '123456789abcdeff';
+ function uploadFile2Hub($filePath) {
+ require_once"Transport.php";
+ $tr =& new Transport($this);
+ return $tr->uploadFile2Hub($filePath);
}
-
+
/**
* Get list of prepared transfers initiated by hub
*
@@ -1202,16 +1181,12 @@ class GreenBox extends BasicStor{
* trtok: string transport token
* ... ?
*/
- // DUMMY
- function getHubInitiatedTransfers()
- {
- return array(
- array(
- 'trtok' => '123456789abcdeff',
- ),
- );
+ function getHubInitiatedTransfers() {
+ require_once"Transport.php";
+ $tr =& new Transport($this);
+ return $tr->getHubInitiatedTransfers();
}
-
+
/**
* Start of download initiated by hub
*
@@ -1219,79 +1194,65 @@ class GreenBox extends BasicStor{
* the getHubInitiatedTransfers method
* @return string - transport token
*/
- // DUMMY
- function startHubInitiatedTransfer($trtok)
- {
- if($trtok != '123456789abcdeff'){
- return PEAR::raiseError(
- "GreenBox::startHubInitiatedTransfer:".
- " invalid transport token ($trtok)"
- );
- }
- return $trtok;
+ function startHubInitiatedTransfer($trtok) {
+ require_once"Transport.php";
+ $tr =& new Transport($this);
+ return $tr->startHubInitiatedTransfer($trtok);
}
-
+
/* ------------- special methods for audioClip/webstream object transport */
/**
* Start upload of audioClip/webstream from local storageServer to hub
*
* @param gunid: string - global unique id of object being transported
- * @return boolean true - status
+ * @return string - transport token
*/
- // DUMMY
- function uploadAudioClip2Hub($gunid)
- {
- $ac = StoredFile::recallByGunid($this, $gunid);
- if(PEAR::isError($ac)){ return $ac; }
- return TRUE;
+ function uploadAudioClip2Hub($gunid) {
+ require_once"Transport.php";
+ $tr =& new Transport($this);
+ return $tr->uploadAudioClip2Hub($gunid);
}
-
+
/**
* Start download of audioClip/webstream from hub to local storageServer
*
* @param gunid: string - global unique id of object being transported
- * @return boolean true - status
+ * @return string - transport token
*/
- // DUMMY
- function downloadAudioClipFromHub($gunid)
- {
- $ac = StoredFile::recallByGunid($this, $gunid);
- if(PEAR::isError($ac)){ return $ac; }
- return TRUE;
+ function downloadAudioClipFromHub($gunid) {
+ require_once"Transport.php";
+ $tr =& new Transport($this);
+ return $tr->downloadAudioClipFromHub($gunid);
}
-
+
/* ------------------------------- special methods for playlist transport */
/**
* Start upload of playlist from local storageServer to hub
*
* @param plid: string - global unique id of playlist being transported
* @param withContent: boolean - if true, transport playlist content too
- * @return boolean true - status
+ * @return string - transport token
*/
- // DUMMY
- function uploadPlaylist2Hub($plid, $withContent)
- {
- $pl = Playlist::recallByGunid($this, $plid);
- if(PEAR::isError($pl)){ return $pl; }
- return TRUE;
+ function uploadPlaylist2Hub($plid, $withContent) {
+ require_once"Transport.php";
+ $tr =& new Transport($this);
+ return $tr->uploadPlaylist2Hub($plid, $withContent);
}
-
+
/**
* Start download of playlist from hub to local storageServer
*
* @param plid: string - global unique id of playlist being transported
* @param withContent: boolean - if true, transport playlist content too
- * @return boolean true - status
+ * @return string - transport token
*/
- // DUMMY
- function downloadPlaylistFromHub($plid, $withContent)
- {
- $pl = Playlist::recallByGunid($this, $plid);
- if(PEAR::isError($pl)){ return $pl; }
- return TRUE;
+ function downloadPlaylistFromHub($plid, $withContent) {
+ require_once"Transport.php";
+ $tr =& new Transport($this);
+ return $tr->downloadPlaylistFromHub($plid, $withContent);
}
-
+
/* ------------------------------------------------ global-search methods */
/**
* Start search job on network hub
@@ -1299,40 +1260,23 @@ class GreenBox extends BasicStor{
* @param criteria: LS criteria format (see localSearch)
* @return string - transport token
*/
- // DUMMY
- function globalSearch($criteria)
- {
- return '123456789abcdefe';
+ function globalSearch($criteria) {
+ require_once"Transport.php";
+ $tr =& new Transport($this);
+ return $tr->globalSearch($criteria);
}
-
+
/**
* Get results from search job on network hub
*
* @param trtok: string - transport token
* @return : LS search result format (see localSearch)
*/
- // DUMMY
- function getSearchResults($trtok)
- {
- if($trtok != '123456789abcdefe'){
- return PEAR::raiseError(
- "GreenBox::getSearchResults: invalid transport token ($trtok)"
- );
- }
- return array(
- 'results' => array('0000000000010001', '0000000000010002'),
- 'cnt' => 2,
- );
+ function getSearchResults($trtok) {
+ require_once"Transport.php";
+ $tr =& new Transport($this);
+ return $tr->getSearchResults($trtok);
}
-
- /**
- *
- * @param
- * @return
- function ()
- {
- }
- */
/* ========================================================= info methods */
/**
diff --git a/livesupport/src/modules/storageServer/var/Transport.php b/livesupport/src/modules/storageServer/var/Transport.php
index 0fc6baa2a..a6976beaf 100644
--- a/livesupport/src/modules/storageServer/var/Transport.php
+++ b/livesupport/src/modules/storageServer/var/Transport.php
@@ -36,12 +36,29 @@ include_once "XML/RPC.php";
/**
* Class for handling file tranport between StorageServer and ArchiveServer
* over unreliable network and from behind firewall
+ *
+ * Transport states:
+ * - init: transport is prepared, but not started
+ * (e.g. no network connection is present)
+ * - pending: transport is in progress, file is not fully transported to
+ * target system
+ * - finished: transport is finished, but file processing on target side
+ * is not completed
+ * - closed: processing on target side is completed without errors
+ * - failed: error - error message stored in errmsg field
+ *
*/
-class Transport{
+class Transport
+{
var $dbc;
- var $timeout=20;
- var $waitretry=6;
- var $retries=6;
+ var $downTimeout = 20;
+ var $downWaitretry = 6;
+ var $downRetries = 6;
+
+ var $upTrMaxTime = 600;
+ var $upTrSpeedTime = 20;
+ var $upTrSpeedLimit = 500;
+ var $upTrConnectTimeout = 20;
/**
* Constructor
@@ -50,720 +67,251 @@ class Transport{
* @param gb LocStor object reference
* @param config config array
*/
- function Transport(&$dbc, &$gb, $config)
+ function Transport(&$gb)
{
- $this->dbc =& $dbc;
- $this->config = $config;
- $this->transTable = $config['tblNamePrefix'].'trans';
- $this->transDir = $config['transDir'];
$this->gb =& $gb;
+ $this->dbc =& $gb->dbc;
+ $this->config =& $gb->config;
+ $this->transTable = $gb->config['tblNamePrefix'].'trans';
+ $this->transDir = $gb->config['transDir'];
}
- /* ================================================== status info methods */
- /**
- * Return state of transport job
- *
- * @param trtok string, transport token
- * @return string, transport state
- */
- function getState($trtok)
- {
- $row = $this->dbc->getRow(
- "SELECT state FROM {$this->transTable} WHERE trtok='$trtok'"
- );
- if(PEAR::isError($row)) return $row;
- if(is_null($row)){
- return PEAR::raiseError("Transport::getState:".
- " invalid transport token ($trtok)", TRERR_TOK
- );
- }
- return $row['state'];
- }
+/*
+ /* ======================================================= public methods * /
+ function getTransportInfo($trtok)
+ function turnOnOffTransports($onOff)
+ function uploadFile2Hub($filePath)
+ function getHubInitiatedTransfers()
+ function startHubInitiatedTransfer($trtok)
+ function uploadAudioClip2Hub($gunid)
+ function downloadAudioClipFromHub($gunid)
+ function uploadPlaylist2Hub($plid, $withContent)
+ function downloadPlaylistFromHub($plid, $withContent)
+ function globalSearch($criteria)
+ function getSearchResults($trtok)
+ /* ======================================================== cron methods * /
+ function cronMain()
+ function cronInit($row, $asessid)
+ function cronPending($row, $asessid)
+ function cronFinished($row, $asessid)
+ function cronFailed($row, $asessid)
+? function cronCheck($pdtoken)
+
+ /* ========================================================= misc methods * /
+ function loginToArchive()
+ function logoutFromArchive($sessid)
+ function pingToArchive()
+ function xmlrpcCall($method, $pars=array())
+*/
+
+ /* =============================== DUMMY ================================ */
+ /* ------------------------------------------------------- common methods */
/**
- * Return hash with useful information about transport
+ * Common "check" method for transports
*
- * @param trtok string, transport token
- * @return hash:
- * trtype,
- * direction,
- * status,
- * expectedsize,
- * realsize,
- * expectedsum,
- * realsum
+ * @param trtok: string - transport token
+ * @return struct/hasharray with fields:
+ * trtype: string - audioclip | playlist | search | file
+ * state: string - transport state
+ * init | pending | finished | closed | failed
+ * direction: string - up | down
+ * expectedsize: int - file size in bytes
+ * realsize: int - currently transported bytes
+ * expectedchsum: string - orginal file checksum
+ * realchsum: string - transported file checksum
+ * title: string - dc:title or filename etc.
+ * errmsg: string - error message for failed transports
+ * ... ?
*/
function getTransportInfo($trtok)
{
- $row = $this->dbc->getRow("
- SELECT
- trtype, direction, state,
- expectedsize, realsize,
- expectedsum, realsum
- FROM {$this->transTable}
- WHERE trtok='$trtok'
- ");
- if(PEAR::isError($row)){ return $row; }
- if(is_null($row)){
- return PEAR::raiseError("Transport::getTransportInfo:".
- " invalid transport token ($trtok)", TRERR_TOK
- );
- }
- $row['status'] == ($row['state'] == 'closed');
-# unset($row['state']);
- return $row;
- }
-
- /* ======================================================= upload methods */
-
- /**
- *
- */
- function uploadToArchive($gunid, $sessid='')
- {
- $trtype = $this->gb->_getType($gunid);
- switch($trtype){
- case"audioclip":
- $ex = $this->gb->existsAudioClip($sessid, $gunid);
- break;
- case"playlist":
- $ex = $this->gb->existsPlaylist($sessid, $gunid);
- break;
- default:
- return PEAR::raiseError("Transport::uploadToArchive:".
- " unknown trtype ($trtype)"
- );
- }
- if(PEAR::isError($ex)) return $ex;
- if(!$ex){
- return PEAR::raiseError("Transport::uploadToArchive:".
- " $trtype not found ($gunid)"
- );
- }
- $trtok = $this->_createTrtok();
- $id = $this->dbc->nextId("{$this->transTable}_id_seq");
- $res = $this->dbc->query("
- INSERT INTO {$this->transTable}
- (id, trtok, direction, state, trtype,
- gunid,
- expectedsum, realsum, expectedsize, realsize
- )
- VALUES
- ($id, '$trtok', 'up', 'init', '$trtype',
- x'$gunid'::bigint,
- '?e', '?r', '0', '0'
- )
- ");
- if(PEAR::isError($res)) return $res;
-#?? $this->uploadCron();
- return $trtok;
- }
-
- /**
- *
- */
- function uploadCron()
- {
- // fetch all opened uploads
- $rows = $this->dbc->getAll("
- SELECT
- id, trtok, state, trtype,
- to_hex(gunid)as gunid, to_hex(pdtoken)as pdtoken,
- fname, localfile, expectedsum, expectedsize, url
- FROM {$this->transTable}
- WHERE direction='up' AND state<>'closed'
- ");
- if(PEAR::isError($rows)){ $this->trLogPear($rows); return FALSE; }
- if(count($rows)==0) return TRUE;
- // login to archive server
- $r = $this->loginToArchive();
- if(PEAR::isError($r)){ $this->trLog("Login error"); return FALSE; }
- $asessid = $r['sessid'];
- chdir($this->config['transDir']);
- // for all opened uploads:
- foreach($rows as $i=>$row){
- $row['pdtoken'] = StoredFile::_normalizeGunid($row['pdtoken']);
- $row['gunid'] = StoredFile::_normalizeGunid($row['gunid']);
- #var_dump($row);
- switch($row['state']){
- case"init": // ------ new uploads
- $ret = $this->uploadCronInit($row, $asessid);
- if(PEAR::isError($ret)){
- $this->trLogPear($ret, $row); break;
- }
- $row = array_merge($row, $ret);
- // break;
- case"pending": // ------ pending uploads
- $ret = $this->uploadCronPending($row, $asessid);
- if(PEAR::isError($ret)){ $this->trLogPear($ret, $row); }
- break;
- case"finished": // ------ finished uploads
- $ret = $this->uploadCronFinished($row, $asessid);
- if(PEAR::isError($ret)){ $this->trLogPear($ret, $row); }
- break;
- case"failed": // ------ failed uploads
- $ret = $this->uploadCronFailed($row, $asessid);
- if(PEAR::isError($ret)){ $this->trLogPear($ret, $row); }
- break;
- default:
- $this->trLog("uploadCron: unknown state ".
- "({$row['state']}, id={$row['id']})");
- } // switch state
- } // foreach opened
- $r = $this->logoutFromArchive($asessid);
- if(PEAR::isError($r)) $this->trLog("Logout error");
- return TRUE;
- }
-
- /**
- *
- */
- function uploadCronInit($row, $asessid)
- {
- $this->trLog("INIT UP id={$row['id']}, trtok={$row['trtok']}");
- switch($row['trtype']){
- case"audioclip":
- $ac =& StoredFile::recallByGunid($this->gb, $row['gunid']);
- if(PEAR::isError($ac)) return $ac;
- $fpath = $ac->_getRealRADFname();
- $fname = $ac->_getFileName();
- $chsum = $this->_chsum($fpath);
- $size = filesize($fpath);
- $metadata = file_get_contents($ac->_getRealMDFname());
- $ret = $this->xmlrpcCall( 'archive.storeAudioClipOpen',
- array(
- 'sessid' => $asessid,
- 'gunid' => $row['gunid'],
- 'metadata' => $metadata,
- 'fname' => $fname,
- 'chsum' => $chsum,
- )
- );
- if(PEAR::isError($ret)) return $ret;
- $r = $this->dbc->query("
- UPDATE {$this->transTable}
- SET
- state = 'pending',
- fname = '$fname',
- localfile = '$fpath',
- expectedsum = '$chsum',
- expectedsize= $size,
- url = '{$ret['url']}',
- pdtoken = x'{$ret['token']}'::bigint
- WHERE id={$row['id']}
- ");
- if(PEAR::isError($r)) return $r;
+ // DUMMY
+ switch($trtok){
+ case'123456789abcdeff'; // upload/download
return array(
- 'state'=>'pending',
- 'url'=>$ret['url'], 'pdtoken'=>$ret['token'],
- 'localfile'=>$fpath, 'fname'=>$fname,
- 'expectedsum'=>$chsum, 'expectedsize'=>$size,
+ 'state' => 'finished',
+ 'direction' => 'up',
+ 'trtype' => 'audioclip',
+ 'expectedsize' => 1024,
+ 'realsize' => 1024,
+ 'expectedchsum' => '12dd9137a855cf600881dd6d3ffa7517',
+ 'realchsum' => '12dd9137a855cf600881dd6d3ffa7517',
+ 'title' => 'DUMMY !',
+ 'errmsg' => '',
);
- break;
- case"playlist":
- $ac =& StoredFile::recallByGunid($this->gb, $row['gunid']);
- if(PEAR::isError($ac)) return $ac;
- $fname = $ac->_getFileName();
- $size = filesize($fpath);
- $metadata = file_get_contents($ac->_getRealMDFname());
- $ret = $this->xmlrpcCall( 'archive.createPlaylist',
- array(
- 'sessid' => $asessid,
- 'plid' => $row['gunid'],
- 'fname' => $fname,
- )
- );
- if(PEAR::isError($ret)) return $ret;
- $ret = $this->xmlrpcCall( 'archive.editPlaylist',
- array(
- 'sessid' => $asessid,
- 'plid' => $row['gunid'],
- 'metadata' => $metadata,
- )
- );
- if(PEAR::isError($ret)) return $ret;
-# $this->trLog("INIT UP after edit {$ret['token']}");
- $r = $this->xmlrpcCall( 'archive.savePlaylist',
- array(
- 'sessid' => $asessid,
- 'token' => $ret['token'],
- 'newPlaylist' => $metadata,
- )
- );
- if(PEAR::isError($r)) return $r;
-# $this->trLog("INIT UP after save {$r['plid']}");
- $r = $this->dbc->query("
- UPDATE {$this->transTable}
- SET
- state = 'closed',
- fname = '$fname',
- url = '{$ret['url']}'
- WHERE id={$row['id']}
- ");
- if(PEAR::isError($r)) return $r;
+ case'123456789abcdefe'; // search
return array(
- 'state'=>'closed',
- 'url'=>$ret['url'], 'pdtoken'=>$ret['token'],
- 'fname'=>$fname,
+ 'state' => 'finished',
);
- break;
- case"searchjob":
- return array();
default:
- return PEAR::raiseError("Transport::uploadCronInit:".
- " unknown trtype ({$row['trtype']})"
+ return PEAR::raiseError(
+ "Transport::getTransportInfo:".
+ " invalid transport token ($trtok)"
);
- } // switch $row['trtype']
- }
-
- /**
- *
- */
- function uploadCronPending($row, $asessid)
- {
- if($row['trtype'] != 'audioclip') return;
- $check = $this->uploadCheck($row['pdtoken']);
- if(PEAR::isError($check)) return $check;
- #var_dump($row);
- #var_dump($check);
- // test filesize
- if(intval($check['size']) < $row['expectedsize']){
- // not finished - upload next part
- $command =
- "curl -s -C {$check['size']} --max-time 600".
- " --speed-time 20 --speed-limit 500".
- " --connect-timeout 20".
- " -T {$row['localfile']} {$row['url']}";
-# echo "$command\n";
- $res = system($command, $status);
- }else{
- // hmmm - we are finished? OK - continue
- $status = 0;
- }
- // status 18 - Partial file. Only a part of the file was transported.
- if($status == 0 || $status == 18){
- $check = $this->uploadCheck($row['pdtoken']);
- if(PEAR::isError($check)) return $check;
- #var_dump($check);
- // test checksum
- if($check['status'] == TRUE){
- // finished
- $res = $this->dbc->query("
- UPDATE {$this->transTable}
- SET state ='finished',
- realsum ='{$check['realsum']}',
- realsize={$check['size']}
- WHERE id='{$row['id']}'
- ");
- if(PEAR::isError($res)) return $res;
- }else{
- if(intval($check['size']) < $row['expectedsize']){
- $res = $this->dbc->query("
- UPDATE {$this->transTable}
- SET
- realsum ='{$check['realsum']}',
- realsize={$check['realsize']}
- WHERE id='{$row['id']}'
- ");
- if(PEAR::isError($res)) return $res;
- }else{
- // wrong md5 at finish - TODO: start again
- // $this->xmlrpcCall('archive.uploadReset', array());
- return PEAR::raiseError("Transport::uploadCron:".
- " file uploaded with bad md5 ".
- "({$check['realsum']}/{$check['expectedsum']})"
- );
- }
- }
}
}
/**
- *
- */
- function uploadCronFinished($row, $asessid)
- {
- if($row['trtype'] != 'audioclip') return;
- $res = $this->xmlrpcCall(
- 'archive.storeAudioClipClose',
- array('sessid'=>$asessid, 'token'=>$row['pdtoken'])
- );
-// if(PEAR::isError($res)) return $res;
- if(PEAR::isError($res)){
- switch($res->getCode()){
- case GBERR_PUT:
- // mark as failed
- $this->dbc->query("
- UPDATE {$this->transTable} SET state='failed'
- WHERE id='{$row['id']}'
- ");
- break;
- return FALSE;
- default:
- return $res;
- }
- }
- // close upload in db
- $r = $this->dbc->query("
- UPDATE {$this->transTable} SET state='closed'
- WHERE id='{$row['id']}'
- ");
- /*
- $r = $this->dbc->query("
- DELETE FROM {$this->transTable}
- WHERE id='{$row['id']}'
- ");
- */
- if(PEAR::isError($r)) return $r;
- $this->trLog("FIN UP id={$row['id']}, trtok={$row['trtok']}".
- "\n ".serialize($row));
- }
-
- /**
- *
- */
- function uploadCronFailed($row, $asessid)
- {
- /*
- $r = $this->dbc->query("
- DELETE FROM {$this->transTable}
- WHERE id='{$row['id']}'
- ");
- if(PEAR::isError($r)) return $r;
- */
- }
-
- /**
- * Check state of uploaded file
+ * Turn transports on/off, optionaly return current state.
*
- * @param pdtoken string, put token
- * @return hash: chsum, size, url
+ * @param onOff: boolean optional (if not used, current state is returned)
+ * @return boolean - previous state
*/
- function uploadCheck($pdtoken)
+ // DUMMY
+ function turnOnOffTransports($onOff)
{
- $ret = $this->xmlrpcCall(
- 'archive.uploadCheck',
- array('token'=>$pdtoken)
- );
- return $ret;
- }
-
- /* ===================================================== download methods */
- /**
- *
- */
- function downloadFromArchive($gunid, $sessid='')
- {
- // insert transport record to db
- $uid = $this->gb->getSessUserId($sessid);
- if(PEAR::isError($uid)) return $uid;
- if(is_null($uid)){
- return PEAR::raiseError("Transport::downloadFromArchive: ".
- "invalid session id", GBERR_SESS);
- }
- $parid = $this->gb->_getHomeDirIdFromSess($sessid);
- if(PEAR::isError($parid)) return $parid;
- $trtok = $this->_createTrtok();
- $id = $this->dbc->nextId("{$this->transTable}_id_seq");
- if(PEAR::isError($id)) return $id;
- $res = $this->dbc->query("
- INSERT INTO {$this->transTable}
- (id, trtok, direction, state, trtype,
- gunid,
- expectedsum, realsum, expectedsize, realsize,
- uid, parid
- )
- VALUES
- ($id, '$trtok', 'down', 'init', '?',
- x'$gunid'::bigint,
- '?e', '?r', '0', '0',
- $uid, $parid
- )
- ");
- if(PEAR::isError($res)) return $res;
-#?? $this->downloadCron();
- return $trtok;
- }
-
- /**
- *
- */
- function downloadCron()
- {
- // fetch all opened downloads
- $rows = $this->dbc->getAll("
- SELECT
- id, trtok, state, trtype,
- to_hex(gunid)as gunid, to_hex(pdtoken)as pdtoken,
- fname, localfile, expectedsum, expectedsize, url,
- uid, parid
- FROM {$this->transTable}
- WHERE direction='down' AND state<>'closed'
- ");
- if(PEAR::isError($rows)){ $this->trLogPear($rows); return FALSE; }
- if(count($rows)==0) return TRUE;
- // login to archive server
- $r = $this->loginToArchive();
- if(PEAR::isError($r)){ $this->trLog("Login error"); return FALSE; }
- $asessid = $r['sessid'];
- chdir($this->config['transDir']);
- // for all opened downloads:
- foreach($rows as $i=>$row){
- $row['pdtoken'] = StoredFile::_normalizeGunid($row['pdtoken']);
- $row['gunid'] = StoredFile::_normalizeGunid($row['gunid']);
- switch($row['state']){
- case"init": // ------ new downloads
- $ret = $this->downloadCronInit($row, $asessid);
- if(PEAR::isError($ret)){
- $this->trLogPear($ret, $row); break;
- }
- $row = array_merge($row, $ret);
- #break;
- case"pending": // ------ pending downloads
- $ret = $this->downloadCronPending($row, $asessid);
- if(PEAR::isError($ret)){ $this->trLogPear($ret, $row); }
- break;
- case"finished": // ------ finished downloads
- $ret = $this->downloadCronFinished($row, $asessid);
- if(PEAR::isError($ret)){ $this->trLogPear($ret, $row); }
- break;
- case"failed": // ------ failed downloads
- $ret = $this->downloadCronFailed($row, $asessid);
- if(PEAR::isError($ret)){ $this->trLogPear($ret, $row); }
- break;
- default:
- $this->trLog("downloadCron: unknown state ".
- "({$row['state']}, id={$row['id']})");
- } // switch state
- } // foreach opened
- $r = $this->logoutFromArchive($asessid);
- if(PEAR::isError($r)) $this->trLog("Logout error");
return TRUE;
}
-
+
+ /* ------------------------ methods for ls-archive-format file transports */
/**
- *
+ * Open async file transfer from local storageServer to network hub,
+ * file should be ls-archive-format file.
+ *
+ * @param filePath string - local path to uploaded file
+ * @return string - transport token
*/
- function downloadCronInit($row, $asessid)
+ function uploadFile2Hub($filePath)
{
- $ret = $this->xmlrpcCall('archive.downloadRawAudioDataOpen',
- array('sessid'=>$asessid, 'gunid'=>$row['gunid'])
- );
- if(PEAR::isError($ret)){
- // catch 'not found' exception:
- if($ret->getCode() != 847) return $ret;
- else $trtype = '?';
- }else $trtype = 'audioclip';
- if($trtype == '?'){
- $ret = $this->xmlrpcCall('archive.existsPlaylist',
- array('sessid'=>$asessid, 'plid'=>$row['gunid'])
- );
- if(PEAR::isError($ret)){
- // catch 'not found' exception:
- if($ret->getCode() != 847) return $ret;
- else $trtype = '?';
- }else{
- $trtype = 'playlist';
- $r1 = $this->downloadMetadata($row['gunid'], $asessid);
- if(PEAR::isError($r1)) return $r1;
- $r2 = $this->gb->bsPutFile($row['parid'], $r1['filename'],
- '', $r1['mdata'], $row['gunid'], $trtype, 'string');
- if(PEAR::isError($r2)) return $r2;
- $res = $this->dbc->query("
- UPDATE {$this->transTable}
- SET state='closed',
- trtype='$trtype'
- WHERE id='{$row['id']}'
- ");
- if(PEAR::isError($res)) return $res;
- return array(
- 'state'=>'closed', 'trtype'=>$trtype,
- 'fname'=>$r1['filename'],
- );
- }
- }
- if($trtype == '?'){
- return PEAR::raiseError("Transport::downloadCronInit:".
- " unknown trtype ({$row['trtype']})"
+ // DUMMY
+ if(!file_exists($filePath)){
+ return PEAR::raiseError(
+ "Transport::uploadFile2Hub: file not found ($filePath)"
);
}
- $fpath = $this->transDir."/".basename($ret['url']); // ***
- touch($fpath);
- $res = $this->dbc->query("
- UPDATE {$this->transTable}
- SET
- state = 'pending',
- trtype = '$trtype',
- fname = '{$ret['filename']}',
- localfile = '$fpath',
- expectedsum = '{$ret['chsum']}',
- expectedsize= '{$ret['size']}',
- url = '{$ret['url']}',
- pdtoken = x'{$ret['token']}'::bigint
- WHERE id='{$row['id']}'
- ");
- if(PEAR::isError($res)) return $res;
- $this->trLog("INIT DOWN id={$row['id']}, trtok={$row['trtok']}");
- return array(
- 'state'=>'pending', 'trtype'=>$trtype,
- 'url'=>$ret['url'], 'pdtoken'=>$ret['token'],
- 'localfile'=>$fpath, 'fname'=>$ret['filename'],
- 'expectedsum'=>$ret['chsum'], 'expectedsize'=>$ret['size'],
- );
- }
-
- /**
- *
- */
- function downloadCronPending($row, $asessid)
- {
- if($row['trtype'] != 'audioclip') return;
- // wget the file
- $command =
- "wget -q -c --timeout={$this->timeout}".
- " --waitretry={$this->waitretry}".
- " -t {$this->retries} {$row['url']}";
-# echo "$command\n";
- $res = system($command, $status);
- // check consistency
- $chsum = $this->_chsum($row['localfile']);
- $size = filesize($row['localfile']);
- if($status == 0){
- if($chsum == $row['expectedsum']){
- // mark download as finished
- $res = $this->dbc->query("
- UPDATE {$this->transTable}
- SET state='finished',
- realsum ='{$chsum}',
- realsize={$size}
- WHERE id='{$row['id']}'
- ");
- if(PEAR::isError($res)) return $res;
- }else{
- @unlink($row['localfile']);
- $res = $this->dbc->query("
- UPDATE {$this->transTable}
- SET
- realsum ='{$chsum}',
- realsize={$size}
- WHERE id='{$row['id']}'
- ");
- if(PEAR::isError($res)) return $res;
- }
- }
- }
-
- /**
- *
- */
- function downloadCronFinished($row, $asessid)
- {
- if($row['trtype'] != 'audioclip') return;
- // call archive that downloads have been finished OK
- $res = $this->xmlrpcCall(
- 'archive.downloadRawAudioDataClose',
- array('sessid'=>$asessid, 'token'=>$row['pdtoken'])
- );
- if(PEAR::isError($res)) return $res;
- $res2 = $this->downloadMetadata($row['gunid'], $asessid);
- if(PEAR::isError($res2)) return $res2;
- $mdata = $res2['mdata'];
- $name = $row['fname'];
- $this->trLog("FIN1 DOWN id={$row['id']}, trtok={$row['trtok']}".
- "\n ".serialize($row));
- $ac =& StoredFile::recallByGunid($this->gb, $row['gunid']);
- if(!PEAR::isError($ac)){
- // gunid exists - do replace
- $id = $ac->getId();
- $ac->replace(
- $id, $name, $row['localfile'], $mdata, 'string'
- );
- if(PEAR::isError($ac)) return $ac;
- }else{
- // gunid doesn't exists - do insert
- $id = $this->gb->addObj($name , 'File', $row['parid']);
- if(PEAR::isError($id)) return $id;
- $ac =& StoredFile::insert(
- $this->gb, $id, $name, $row['localfile'], $mdata, 'string',
- $row['gunid'], 'audioclip'
- );
- if(PEAR::isError($ac)) return $ac;
- }
- // close download in db
- $res = $this->dbc->query("
- UPDATE {$this->transTable}
- SET state='closed'
- WHERE id='{$row['id']}'
- ");
- /*
- $res = $this->dbc->query("
- DELETE FROM {$this->transTable}
- WHERE id='{$row['id']}'
- ");
- */
- if(PEAR::isError($res)) return $res;
- $this->trLog("FIN DOWN id={$row['id']}, trtok={$row['trtok']}".
- "\n ".serialize($row));
- }
-
- /**
- *
- */
- function downloadCronFailed($row, $asessid)
- {
- /*
- $r = $this->dbc->query("
- DELETE FROM {$this->transTable}
- WHERE id='{$row['id']}'
- ");
- if(PEAR::isError($r)) return $r;
- */
- }
-
- /**
- *
- */
- function downloadMetadata($gunid, $asessid)
- {
- $ret = $this->xmlrpcCall('archive.downloadMetadataOpen',
- array('sessid'=>$asessid, 'gunid'=>$gunid)
- );
- if(PEAR::isError($ret)) return $ret;
- #echo "{$ret['url']}\n";
- if(($mdata = file_get_contents($ret['url'])) === FALSE){
- return PEAR::raiseError("Transport::downloadCronInit: ".
- "metadata download failed ({$gunid})", TRERR_MD
- );
- }
- $filename = $ret['filename'];
- $ret = $this->xmlrpcCall('archive.downloadMetadataClose',
- array('token'=>$ret['token'])
- );
- if(PEAR::isError($ret)) return $ret;
- return array('mdata'=>$mdata, 'filename'=>$filename);
- }
-
- /* ======================================================= search methods */
- /**
- * Start search in archive
- */
- function globalSearch()
- {
- // create searchJob from searchData
- // uploadFile searchJob
- // downloadFile searchResults
- // not implemented yet
+ return '123456789abcdeff';
}
/**
- * Returns results from archive search
+ * Get list of prepared transfers initiated by hub
+ *
+ * @return array of structs/hasharrays with fields:
+ * trtok: string transport token
+ * ... ?
*/
- function getSearchResults()
+ // DUMMY
+ function getHubInitiatedTransfers()
{
- // return downloaded file with search results
- // not implemented yet
+ return array(
+ array(
+ 'trtok' => '123456789abcdeff',
+ ),
+ );
}
-
+
+ /**
+ * Start of download initiated by hub
+ *
+ * @param trtok: string - transport token obtained from
+ * the getHubInitiatedTransfers method
+ * @return string - transport token
+ */
+ // DUMMY
+ function startHubInitiatedTransfer($trtok)
+ {
+ if($trtok != '123456789abcdeff'){
+ return PEAR::raiseError(
+ "Transport::startHubInitiatedTransfer:".
+ " invalid transport token ($trtok)"
+ );
+ }
+ return $trtok;
+ }
+
+ /* ------------- special methods for audioClip/webstream object transport */
+
+ /**
+ * Start upload of audioClip/webstream from local storageServer to hub
+ *
+ * @param gunid: string - global unique id of object being transported
+ * @return string - transport token
+ */
+ function uploadAudioClip2Hub($gunid)
+ {
+ // DUMMY
+ $ac = StoredFile::recallByGunid($this->gb, $gunid);
+ if(PEAR::isError($ac)){ return $ac; }
+ return '123456789abcdeff';
+ }
+
+ /**
+ * Start download of audioClip/webstream from hub to local storageServer
+ *
+ * @param gunid: string - global unique id of object being transported
+ * @return string - transport token
+ */
+ // DUMMY
+ function downloadAudioClipFromHub($gunid)
+ {
+ return '123456789abcdeff';
+ }
+
+ /* ------------------------------- special methods for playlist transport */
+ /**
+ * Start upload of playlist from local storageServer to hub
+ *
+ * @param plid: string - global unique id of playlist being transported
+ * @param withContent: boolean - if true, transport playlist content too
+ * @return string - transport token
+ */
+ // DUMMY
+ function uploadPlaylist2Hub($plid, $withContent)
+ {
+ $pl = Playlist::recallByGunid($this->gb, $plid);
+ if(PEAR::isError($pl)){ return $pl; }
+ return TRUE;
+ }
+
+ /**
+ * Start download of playlist from hub to local storageServer
+ *
+ * @param plid: string - global unique id of playlist being transported
+ * @param withContent: boolean - if true, transport playlist content too
+ * @return string - transport token
+ */
+ // DUMMY
+ function downloadPlaylistFromHub($plid, $withContent)
+ {
+ $pl = Playlist::recallByGunid($this->gb, $plid);
+ if(PEAR::isError($pl)){ return $pl; }
+ return TRUE;
+ }
+
+ /* ------------------------------------------------ global-search methods */
+ /**
+ * Start search job on network hub
+ *
+ * @param criteria: LS criteria format (see localSearch)
+ * @return string - transport token
+ */
+ // DUMMY
+ function globalSearch($criteria)
+ {
+ return '123456789abcdefe';
+ }
+
+ /**
+ * Get results from search job on network hub
+ *
+ * @param trtok: string - transport token
+ * @return : LS search result format (see localSearch)
+ */
+ // DUMMY
+ function getSearchResults($trtok)
+ {
+ if($trtok != '123456789abcdefe'){
+ return PEAR::raiseError(
+ "Transport::getSearchResults: invalid transport token ($trtok)"
+ );
+ }
+ return array(
+ 'results' => array('0000000000010001', '0000000000010002'),
+ 'cnt' => 2,
+ );
+ }
+
+
/* =============================================== authentication methods */
/**
@@ -800,6 +348,8 @@ class Transport{
return $res;
}
+ /* ========================================================= cron methods */
+ /* -------------------------------------------------- common cron methods */
/* ==================================================== auxiliary methods */
/**
*
@@ -814,6 +364,28 @@ class Transport{
return $res;
}
+ /**
+ *
+ */
+ function getTransports($direction=NULL)
+ {
+ switch($direction){
+ case 'up': $dirCond = "direction='up' AND"; break;
+ case 'down': $dirCond = "direction='down' AND"; break;
+ default: $dirCond = ''; break;
+ }
+ $rows = $this->dbc->getAll("
+ SELECT
+ id, trtok, state, trtype, direction,
+ to_hex(gunid)as gunid, to_hex(pdtoken)as pdtoken,
+ fname, localfile, expectedsum, expectedsize, url
+ FROM {$this->transTable}
+ WHERE $dirCond state<>'closed'
+ ");
+ if(PEAR::isError($rows)){ $this->trLogPear($rows); return FALSE; }
+ return $rows;
+ }
+
/**
*
*/
@@ -834,7 +406,7 @@ class Transport{
$res = $this->xmlrpcCall(
'archive.ping',
array(
- 'par'=>'testString_'.date('H:i:s')
+ 'par'=>'ping_'.date('H:i:s')
)
);
return $res;
@@ -889,7 +461,12 @@ class Transport{
*/
function trLog($msg)
{
- $fp=fopen("{$this->transDir}/log", "a") or die("Can't write to log\n");
+ $logfile = "{$this->transDir}/log";
+ if(FALSE === ($fp = fopen($logfile, "a"))){
+ return PEAR::raiseError(
+ "Transport::trLog: Can't write to log ($logfile)"
+ );
+ }
fputs($fp, "---".date("H:i:s")."---\n $msg\n");
fclose($fp);
}
@@ -908,17 +485,17 @@ class Transport{
*
* direction: up | down
* state: init | pending | finished | closed | failed
- * trtype: audioclip | playlist | searchjob
+ * trtype: audioclip | playlist | searchjob | file
*
*/
function install()
{
$this->dbc->query("CREATE TABLE {$this->transTable} (
- id int not null,
+ id int not null, -- primary key
trtok char(16) not null, -- transport token
- direction varchar(128) not null,
- state varchar(128) not null,
- trtype varchar(128) not null,
+ direction varchar(128) not null, -- direction: up|down
+ state varchar(128) not null, -- state
+ trtype varchar(128) not null, -- transport type
gunid bigint, -- global unique id
pdtoken bigint, -- put/download token from archive
url varchar(255),
@@ -952,3 +529,5 @@ class Transport{
$this->dbc->dropSequence("{$this->transTable}_id_seq");
}
}
+
+?>
\ No newline at end of file
diff --git a/livesupport/src/modules/storageServer/var/install/install.php b/livesupport/src/modules/storageServer/var/install/install.php
index 94a168318..0fa4d1395 100644
--- a/livesupport/src/modules/storageServer/var/install/install.php
+++ b/livesupport/src/modules/storageServer/var/install/install.php
@@ -73,7 +73,7 @@ if(PEAR::isError($dbc)){
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb =& new GreenBox($dbc, $config);
-$tr =& new Transport($dbc, $gb, $config);
+$tr =& new Transport($gb);
$pr =& new Prefs($gb);
//------------------------------------------------------------------------------
diff --git a/livesupport/src/modules/storageServer/var/install/uninstall.php b/livesupport/src/modules/storageServer/var/install/uninstall.php
index ec0289fc0..012738375 100644
--- a/livesupport/src/modules/storageServer/var/install/uninstall.php
+++ b/livesupport/src/modules/storageServer/var/install/uninstall.php
@@ -66,7 +66,7 @@ if(PEAR::isError($dbc)){
echo "#StorageServer uninstall:\n";
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb = &new GreenBox($dbc, $config);
-$tr =& new Transport($dbc, $gb, $config);
+$tr =& new Transport($gb);
$pr =& new Prefs($gb);
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
diff --git a/livesupport/src/modules/storageServer/var/xmlrpc/XR_LocStor.php b/livesupport/src/modules/storageServer/var/xmlrpc/XR_LocStor.php
index abc65c810..1c04eade9 100644
--- a/livesupport/src/modules/storageServer/var/xmlrpc/XR_LocStor.php
+++ b/livesupport/src/modules/storageServer/var/xmlrpc/XR_LocStor.php
@@ -1773,6 +1773,9 @@ class XR_LocStor extends LocStor{
{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
+
+# return new XML_RPC_Response(XML_RPC_encode(var_export($this, TRUE)));
+
$res = $this->createBackupOpen($r['sessid'], $r['criteria']);
if(PEAR::isError($res)){
return new XML_RPC_Response(0, 805,
@@ -2210,7 +2213,7 @@ class XR_LocStor extends LocStor{
*
* @param input XMLRPC struct
* @return XMLRPC struct
- * @see Pref::browseCategory
+ * @see LocStor::browseCategory
*/
function xr_browseCategory($input)
{
@@ -2237,7 +2240,7 @@ class XR_LocStor extends LocStor{
return new XML_RPC_Response($xv);
}
- /* ---------------------------------------------- methods for preferences */
+ /* ============================================== methods for preferences */
/**
* Load user preference value
*
@@ -2497,8 +2500,586 @@ class XR_LocStor extends LocStor{
return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res)));
}
- /* -------------------------------------------- remote repository methods */
+ /* =============================== remote repository (networking) methods */
+ /* ------------------------------------------------------- common methods */
/**
+ * Common "check" method for transports
+ *
+ * The XML-RPC name of this method is "locstor.getTransportInfo".
+ *
+ * The input parameters are an XML-RPC struct with the following
+ * fields:
+ *
+ * - trtok : string - transport token
+ *
+ *
+ * On success, returns a XML-RPC struct with the following fields:
+ *
+ * - trtype: string - audioclip | playlist | search | file
+ * - direction: string - up | down
+ * - state: string - transport state
+ * - expectedsize: int - expected size
+ * - realsize: int - size of transported file
+ * - expectedchsum: string - expected checksum
+ * - realchsum: string - checksum of transported file
+ * - title: string - file title
+ * - errmsg: string - error message from failed transports
+ *
+ *
+ * On errors, returns an XML-RPC error response.
+ * The possible error codes and error message are:
+ *
+ * - 3 - Incorrect parameters passed to method:
+ * Wanted ... , got ... at param
+ * - 801 - wrong 1st parameter, struct expected.
+ * - 805 - xr_getTransportInfo:
+ * <message from lower layer>
+ * - 848 - invalid session id.
+ * - 872 - invalid tranport token.
+ *
+ *
+ * @param input XMLRPC struct
+ * @return XMLRPC struct
+ * @see Transport::getTransportInfo
+ */
+ function xr_getTransportInfo($input)
+ {
+ list($ok, $r) = $this->_xr_getPars($input);
+ if(!$ok) return $r;
+ require_once '../Transport.php';
+ $tr =& new Transport($this);
+ $res = $tr->getTransportInfo($r['trtok']);
+ if(PEAR::isError($res)){
+ $ec0 = intval($res->getCode());
+ $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
+ return new XML_RPC_Response(0, $ec,
+ "xr_getTransportInfo: ".$res->getMessage()." ".$res->getUserInfo()
+ );
+ }
+ return new XML_RPC_Response(XML_RPC_encode($res));
+ }
+
+ /**
+ * Turn transports on/off, optionaly return current state.
+ *
+ * The XML-RPC name of this method is "locstor.turnOnOffTransports".
+ *
+ * The input parameters are an XML-RPC struct with the following
+ * fields:
+ *
+ * - sessid : string - session id
+ * - onOff: boolean optional
+ * (if not used, current state is returned)
+ *
+ *
+ * On success, returns a XML-RPC struct with the following fields:
+ *
+ * - state : boolean - previous state
+ *
+ *
+ * On errors, returns an XML-RPC error response.
+ * The possible error codes and error message are:
+ *
+ * - 3 - Incorrect parameters passed to method:
+ * Wanted ... , got ... at param
+ * - 801 - wrong 1st parameter, struct expected.
+ * - 805 - xr_turnOnOffTransports:
+ * <message from lower layer>
+ * - 848 - invalid session id.
+ * - 872 - invalid tranport token.
+ *
+ *
+ * @param input XMLRPC struct
+ * @return XMLRPC struct
+ * @see Transport::turnOnOffTransports
+ */
+ function xr_turnOnOffTransports($input) {
+ list($ok, $r) = $this->_xr_getPars($input);
+ if(!$ok) return $r;
+ require_once '../Transport.php';
+ $tr =& new Transport($this);
+ $res = $tr->turnOnOffTransports($r['onOff']);
+ if(PEAR::isError($res)){
+ $ec0 = intval($res->getCode());
+ $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
+ return new XML_RPC_Response(0, $ec,
+ "xr_turnOnOffTransports: ".$res->getMessage()." ".$res->getUserInfo()
+ );
+ }
+ return new XML_RPC_Response(XML_RPC_encode(array('state'=>$res)));
+ }
+
+ /* ------------------------ methods for ls-archive-format file transports */
+ /**
+ * Open async file transfer from local storageServer to network hub,
+ * file should be ls-archive-format file.
+ *
+ * The XML-RPC name of this method is "locstor.uploadFile2Hub".
+ *
+ * The input parameters are an XML-RPC struct with the following
+ * fields:
+ *
+ * - sessid : string - session id
+ * - filePath string - local path to uploaded file
+ *
+ *
+ * On success, returns a XML-RPC struct with the following fields:
+ *
+ * - trtok : string - transport token
+ *
+ *
+ * On errors, returns an XML-RPC error response.
+ * The possible error codes and error message are:
+ *
+ * - 3 - Incorrect parameters passed to method:
+ * Wanted ... , got ... at param
+ * - 801 - wrong 1st parameter, struct expected.
+ * - 805 - xr_uploadFile2Hub:
+ * <message from lower layer>
+ * - 848 - invalid session id.
+ * - 872 - invalid tranport token.
+ *
+ *
+ * @param input XMLRPC struct
+ * @return XMLRPC struct
+ * @see Transport::uploadFile2Hub
+ */
+ function xr_uploadFile2Hub($input) {
+ list($ok, $r) = $this->_xr_getPars($input);
+ if(!$ok) return $r;
+ require_once '../Transport.php';
+ $tr =& new Transport($this);
+ $res = $tr->uploadFile2Hub($r['filePath']); // local files on XML-RPC :(
+ // there should be something as uploadFile2storageServer
+ if(PEAR::isError($res)){
+ $ec0 = intval($res->getCode());
+ $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
+ return new XML_RPC_Response(0, $ec,
+ "xr_uploadFile2Hub: ".$res->getMessage()." ".$res->getUserInfo()
+ );
+ }
+ return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
+ }
+
+ /**
+ * Get list of prepared transfers initiated by hub
+ *
+ * The XML-RPC name of this method is "locstor.getHubInitiatedTransfers".
+ *
+ * The input parameters are an XML-RPC struct with the following
+ * fields:
+ *
+ * - sessid : string - session id
+ *
+ *
+ * On success, returns a XML-RPC struct with the following fields:
+ *
+ * - results : array of structs with fields:
+ *
+ * - trtok : string - transport token
+ * - ... ?
+ *
+ *
+ *
+ *
+ * On errors, returns an XML-RPC error response.
+ * The possible error codes and error message are:
+ *
+ * - 3 - Incorrect parameters passed to method:
+ * Wanted ... , got ... at param
+ * - 801 - wrong 1st parameter, struct expected.
+ * - 805 - xr_getHubInitiatedTransfers:
+ * <message from lower layer>
+ * - 848 - invalid session id.
+ * - 872 - invalid tranport token.
+ *
+ *
+ * @param input XMLRPC struct
+ * @return XMLRPC struct
+ * @see Transport::getHubInitiatedTransfers
+ */
+ function xr_getHubInitiatedTransfers($input) {
+ list($ok, $r) = $this->_xr_getPars($input);
+ if(!$ok) return $r;
+ require_once '../Transport.php';
+ $tr =& new Transport($this);
+ $res = $tr->getHubInitiatedTransfers();
+ if(PEAR::isError($res)){
+ $ec0 = intval($res->getCode());
+ $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
+ return new XML_RPC_Response(0, $ec,
+ "xr_getHubInitiatedTransfers: ".$res->getMessage()." ".$res->getUserInfo()
+ );
+ }
+ return new XML_RPC_Response(XML_RPC_encode($res));
+ }
+
+ /**
+ * Start of download initiated by hub
+ *
+ * The XML-RPC name of this method is "locstor.startHubInitiatedTransfer".
+ *
+ * The input parameters are an XML-RPC struct with the following
+ * fields:
+ *
+ * - trtok : string - transport token obtained from
+ * the getHubInitiatedTransfers method
+ *
+ *
+ * On success, returns a XML-RPC struct with the following fields:
+ *
+ * - trtok : string - transport token
+ *
+ *
+ * On errors, returns an XML-RPC error response.
+ * The possible error codes and error message are:
+ *
+ * - 3 - Incorrect parameters passed to method:
+ * Wanted ... , got ... at param
+ * - 801 - wrong 1st parameter, struct expected.
+ * - 805 - xr_startHubInitiatedTransfer:
+ * <message from lower layer>
+ * - 848 - invalid session id.
+ * - 872 - invalid tranport token.
+ *
+ *
+ * @param input XMLRPC struct
+ * @return XMLRPC struct
+ * @see Transport::startHubInitiatedTransfer
+ */
+ function xr_startHubInitiatedTransfer($input) {
+ list($ok, $r) = $this->_xr_getPars($input);
+ if(!$ok) return $r;
+ require_once '../Transport.php';
+ $tr =& new Transport($this);
+ $res = $tr->startHubInitiatedTransfer($r['trtok']);
+ if(PEAR::isError($res)){
+ $ec0 = intval($res->getCode());
+ $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
+ return new XML_RPC_Response(0, $ec,
+ "xr_startHubInitiatedTransfer: ".$res->getMessage()." ".$res->getUserInfo()
+ );
+ }
+ return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
+ }
+
+ /* ------------- special methods for audioClip/webstream object transport */
+
+ /**
+ * Common "check" method for transports
+ *
+ * The XML-RPC name of this method is "locstor.uploadAudioClip2Hub".
+ *
+ * The input parameters are an XML-RPC struct with the following
+ * fields:
+ *
+ * - sessid : string - session id
+ * - gunid: string - global unique id of object being transported
+ *
+ *
+ *
+ * On success, returns a XML-RPC struct with the following fields:
+ *
+ * - trtok : string - transport token
+ *
+ *
+ * On errors, returns an XML-RPC error response.
+ * The possible error codes and error message are:
+ *
+ * - 3 - Incorrect parameters passed to method:
+ * Wanted ... , got ... at param
+ * - 801 - wrong 1st parameter, struct expected.
+ * - 805 - xr_uploadAudioClip2Hub:
+ * <message from lower layer>
+ * - 848 - invalid session id.
+ * - 872 - invalid tranport token.
+ *
+ *
+ * @param input XMLRPC struct
+ * @return XMLRPC struct
+ * @see Transport::uploadAudioClip2Hub
+ */
+ function xr_uploadAudioClip2Hub($input) {
+ list($ok, $r) = $this->_xr_getPars($input);
+ if(!$ok) return $r;
+ require_once '../Transport.php';
+ $tr =& new Transport($this);
+ $res = $tr->uploadAudioClip2Hub($r['gunid']);
+ if(PEAR::isError($res)){
+ $ec0 = intval($res->getCode());
+ $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
+ return new XML_RPC_Response(0, $ec,
+ "xr_uploadAudioClip2Hub: ".$res->getMessage()." ".$res->getUserInfo()
+ );
+ }
+ return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
+ }
+
+ /**
+ * Start download of audioClip/webstream from hub to local storageServer
+ *
+ * The XML-RPC name of this method is "locstor.downloadAudioClipFromHub".
+ *
+ * The input parameters are an XML-RPC struct with the following
+ * fields:
+ *
+ * - sessid : string - session id
+ * - gunid: string - global unique id of object being transported
+ *
+ *
+ *
+ * On success, returns a XML-RPC struct with the following fields:
+ *
+ * - trtok : string - transport token
+ *
+ *
+ * On errors, returns an XML-RPC error response.
+ * The possible error codes and error message are:
+ *
+ * - 3 - Incorrect parameters passed to method:
+ * Wanted ... , got ... at param
+ * - 801 - wrong 1st parameter, struct expected.
+ * - 805 - xr_downloadAudioClipFromHub:
+ * <message from lower layer>
+ * - 848 - invalid session id.
+ * - 872 - invalid tranport token.
+ *
+ *
+ * @param input XMLRPC struct
+ * @return XMLRPC struct
+ * @see Transport::downloadAudioClipFromHub
+ */
+ function xr_downloadAudioClipFromHub($input) {
+ list($ok, $r) = $this->_xr_getPars($input);
+ if(!$ok) return $r;
+ require_once '../Transport.php';
+ $tr =& new Transport($this);
+ $res = $tr->downloadAudioClipFromHub($r['gunid']);
+ if(PEAR::isError($res)){
+ $ec0 = intval($res->getCode());
+ $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
+ return new XML_RPC_Response(0, $ec,
+ "xr_downloadAudioClipFromHub: ".$res->getMessage()." ".$res->getUserInfo()
+ );
+ }
+ return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
+ }
+
+ /* ------------------------------- special methods for playlist transport */
+ /**
+ * Start upload of playlist from local storageServer to hub
+ *
+ * The XML-RPC name of this method is "locstor.uploadPlaylist2Hub".
+ *
+ * The input parameters are an XML-RPC struct with the following
+ * fields:
+ *
+ * - sessid : string - session id
+ * - plid: string - global unique id of playlist being transported
+ *
+ *
+ *
+ * On success, returns a XML-RPC struct with the following fields:
+ *
+ * - trtok : string - transport token
+ *
+ *
+ * On errors, returns an XML-RPC error response.
+ * The possible error codes and error message are:
+ *
+ * - 3 - Incorrect parameters passed to method:
+ * Wanted ... , got ... at param
+ * - 801 - wrong 1st parameter, struct expected.
+ * - 805 - xr_uploadPlaylist2Hub:
+ * <message from lower layer>
+ * - 848 - invalid session id.
+ * - 872 - invalid tranport token.
+ *
+ *
+ * @param input XMLRPC struct
+ * @return XMLRPC struct
+ * @see Transport::uploadPlaylist2Hub
+ */
+ function xr_uploadPlaylist2Hub($input) {
+ list($ok, $r) = $this->_xr_getPars($input);
+ if(!$ok) return $r;
+ require_once '../Transport.php';
+ $tr =& new Transport($this);
+ $res = $tr->uploadPlaylist2Hub($r['plid'], $r['withContent']);
+ if(PEAR::isError($res)){
+ $ec0 = intval($res->getCode());
+ $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
+ return new XML_RPC_Response(0, $ec,
+ "xr_uploadPlaylist2Hub: ".$res->getMessage()." ".$res->getUserInfo()
+ );
+ }
+ return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
+ }
+
+ /**
+ * Start download of playlist from hub to local storageServer
+ *
+ * The XML-RPC name of this method is "locstor.downloadPlaylistFromHub".
+ *
+ * The input parameters are an XML-RPC struct with the following
+ * fields:
+ *
+ * - sessid : string - session id
+ * - plid: string - global unique id of playlist being transported
+ *
+ * - withContent: boolean - if true, transport playlist content too
+ *
+ *
+ *
+ * On success, returns a XML-RPC struct with the following fields:
+ *
+ * - trtok : string - transport token
+ *
+ *
+ * On errors, returns an XML-RPC error response.
+ * The possible error codes and error message are:
+ *
+ * - 3 - Incorrect parameters passed to method:
+ * Wanted ... , got ... at param
+ * - 801 - wrong 1st parameter, struct expected.
+ * - 805 - xr_downloadPlaylistFromHub:
+ * <message from lower layer>
+ * - 848 - invalid session id.
+ * - 872 - invalid tranport token.
+ *
+ *
+ * @param input XMLRPC struct
+ * @return XMLRPC struct
+ * @see Transport::downloadPlaylistFromHub
+ */
+ function xr_downloadPlaylistFromHub($input) {
+ list($ok, $r) = $this->_xr_getPars($input);
+ if(!$ok) return $r;
+ require_once '../Transport.php';
+ $tr =& new Transport($this);
+ $res = $tr->downloadPlaylistFromHub($r['plid'], $r['withContent']);
+ if(PEAR::isError($res)){
+ $ec0 = intval($res->getCode());
+ $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
+ return new XML_RPC_Response(0, $ec,
+ "xr_downloadPlaylistFromHub: ".$res->getMessage()." ".$res->getUserInfo()
+ );
+ }
+ return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
+ }
+
+ /* ------------------------------------------------ global-search methods */
+ /**
+ * Start search job on network hub
+ *
+ * The XML-RPC name of this method is "locstor.globalSearch".
+ *
+ * The input parameters are an XML-RPC struct with the following
+ * fields:
+ *
+ * - sessid : string - session id
+ * - criteria: LS criteria format (see localSearch)
+ *
+ *
+ * On success, returns a XML-RPC struct with the following fields:
+ *
+ * - trtok : string - transport token
+ *
+ *
+ * On errors, returns an XML-RPC error response.
+ * The possible error codes and error message are:
+ *
+ * - 3 - Incorrect parameters passed to method:
+ * Wanted ... , got ... at param
+ * - 801 - wrong 1st parameter, struct expected.
+ * - 805 - xr_globalSearch:
+ * <message from lower layer>
+ * - 848 - invalid session id.
+ * - 872 - invalid tranport token.
+ *
+ *
+ * @param input XMLRPC struct
+ * @return XMLRPC struct
+ * @see Transport::globalSearch
+ */
+ function xr_globalSearch($input) {
+ list($ok, $r) = $this->_xr_getPars($input);
+ if(!$ok) return $r;
+ require_once '../Transport.php';
+ $tr =& new Transport($this);
+ $res = $tr->globalSearch($r['criteria']);
+ if(PEAR::isError($res)){
+ $ec0 = intval($res->getCode());
+ $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
+ return new XML_RPC_Response(0, $ec,
+ "xr_globalSearch: ".$res->getMessage()." ".$res->getUserInfo()
+ );
+ }
+ return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
+ }
+
+ /**
+ * Get results from search job on network hub
+ *
+ * The XML-RPC name of this method is "locstor.getSearchResults".
+ *
+ * The input parameters are an XML-RPC struct with the following
+ * fields:
+ *
+ * - trtok : string - transport token
+ *
+ *
+ * On success, returns a XML-RPC struct with the following fields:
+ *
+ * - audioClipResults : array with gunid strings
+ * of audioClips have been found
+ * - audioClipCnt : int - number of audioClips matching
+ * the criteria
+ * - webstreamResults : array with gunid strings
+ * of webstreams have been found
+ * - webstreamCnt : int - number of webstreams matching
+ * the criteria
+ * - playlistResults : array with gunid strings
+ * of playlists have been found
+ * - playlistCnt : int - number of playlists matching
+ * the criteria
+ *
+ * (cnt values may be greater than size of arrays - see limit param)
+ *
+ * On errors, returns an XML-RPC error response.
+ * The possible error codes and error message are:
+ *
+ * - 3 - Incorrect parameters passed to method:
+ * Wanted ... , got ... at param
+ * - 801 - wrong 1st parameter, struct expected.
+ * - 805 - xr_getSearchResults:
+ * <message from lower layer>
+ * - 848 - invalid session id.
+ * - 872 - invalid tranport token.
+ *
+ *
+ * @param input XMLRPC struct
+ * @return XMLRPC struct
+ * @see Transport::getSearchResults
+ */
+ function xr_getSearchResults($input) {
+ list($ok, $r) = $this->_xr_getPars($input);
+ if(!$ok) return $r;
+ require_once '../Transport.php';
+ $tr =& new Transport($this);
+ $res = $tr->getSearchResults($r['trtok']); // *** search results format differs between GB and XML_RPC ifaces
+ if(PEAR::isError($res)){
+ $ec0 = intval($res->getCode());
+ $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
+ return new XML_RPC_Response(0, $ec,
+ "xr_getSearchResults: ".$res->getMessage()." ".$res->getUserInfo()
+ );
+ }
+ return new XML_RPC_Response(XML_RPC_encode($res));
+ }
+
+ /**
+ * OBSOLETE
* Starts upload audioclip to remote archive
*
* The XML-RPC name of this method is "locstor.uploadToArchive".
@@ -2528,14 +3109,14 @@ class XR_LocStor extends LocStor{
*
* @param input XMLRPC struct
* @return XMLRPC struct
- * @see Pref::uploadToArchive
+ * @see Transport::uploadToArchive
*/
function xr_uploadToArchive($input)
{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once dirname(__FILE__).'/../Transport.php';
- $tr =& new Transport($this->dbc, $this, $this->config);
+ $tr =& new Transport($this);
$res = $tr->uploadToArchive($r['gunid'], $r['sessid']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
@@ -2548,6 +3129,7 @@ class XR_LocStor extends LocStor{
}
/**
+ * OBSOLETE
* Starts download audioclip from remote archive
*
* The XML-RPC name of this method is "locstor.downloadFromArchive".
@@ -2577,14 +3159,14 @@ class XR_LocStor extends LocStor{
*
* @param input XMLRPC struct
* @return XMLRPC struct
- * @see Pref::downloadFromArchive
+ * @see Transport::downloadFromArchive
*/
function xr_downloadFromArchive($input)
{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once dirname(__FILE__).'/../Transport.php';
- $tr =& new Transport($this->dbc, $this, $this->config);
+ $tr =& new Transport($this);
$res = $tr->downloadFromArchive($r['gunid'], $r['sessid']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
@@ -2596,64 +3178,7 @@ class XR_LocStor extends LocStor{
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
}
- /**
- * Checking status of transported file
- *
- * The XML-RPC name of this method is "locstor.getTransportInfo".
- *
- * The input parameters are an XML-RPC struct with the following
- * fields:
- *
- * - sessid : string - session id
- * - trtok : string - transport token
- *
- *
- * On success, returns a XML-RPC struct with the following fields:
- *
- * - trtype: string - audioclip | playlist
- * - direction: string - up | down
- * - status: boolean - true if file have been
- * succesfully transported
- * - expectedsize: int - expected size
- * - realsize: int - size of transported file
- * - expectedsum: string - expected checksum
- * - realsum: string - checksum of transported file
- *
- *
- * On errors, returns an XML-RPC error response.
- * The possible error codes and error message are:
- *
- * - 3 - Incorrect parameters passed to method:
- * Wanted ... , got ... at param
- * - 801 - wrong 1st parameter, struct expected.
- * - 805 - xr_getTransportInfo:
- * <message from lower layer>
- * - 848 - invalid session id.
- * - 872 - invalid tranport token.
- *
- *
- * @param input XMLRPC struct
- * @return XMLRPC struct
- * @see Pref::getTransportInfo
- */
- function xr_getTransportInfo($input)
- {
- list($ok, $r) = $this->_xr_getPars($input);
- if(!$ok) return $r;
- require_once dirname(__FILE__).'/../Transport.php';
- $tr =& new Transport($this->dbc, $this, $this->config);
- $res = $tr->getTransportInfo($r['trtok'], $r['sessid']);
- if(PEAR::isError($res)){
- $ec0 = intval($res->getCode());
- $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
- return new XML_RPC_Response(0, $ec,
- "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
- );
- }
- return new XML_RPC_Response(XML_RPC_encode($res));
- }
-
- /* ------------------------------------------------ methods for debugging */
+ /* ================================================ methods for debugging */
/**
* Reset storageServer for debugging.
*
@@ -2768,7 +3293,7 @@ class XR_LocStor extends LocStor{
)));
}
- /* ---------------------------------------------------- "private" methods */
+ /* ==================================================== "private" methods */
/**
* Check and convert struct of parameters
*
diff --git a/livesupport/src/modules/storageServer/var/xmlrpc/testRunner.sh b/livesupport/src/modules/storageServer/var/xmlrpc/testRunner.sh
index 7a1991ab6..f99e301bd 100755
--- a/livesupport/src/modules/storageServer/var/xmlrpc/testRunner.sh
+++ b/livesupport/src/modules/storageServer/var/xmlrpc/testRunner.sh
@@ -301,18 +301,23 @@ importPlaylist() {
$XR_CLI deleteAudioClip $SESSID 0000000000010002 1
$XR_CLI deleteAudioClip $SESSID 0000000000010003 1
CHSUM=`md5sum $ARCHIVE | cut -d ' ' -f 1 `
- RES=`$XR_CLI importPlaylistOpen $SESSID $CHSUM` || \
+ RES=`$XR_CLI importPlaylistOpen $SESSID $CHSUM` || \
{ ERN=$?; echo $RES; exit $ERN; }
unset URL
for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done
echo $TOKEN
- echo -n "# curl (PUT): "
+ echo -n "# curl (PUT $URL): "
curl -C 0 -T $ARCHIVE $URL || { ERN=$?; echo "curl error"; exit $ERN; }
echo "status: $?"
echo -n "# importPlaylistClose (${TOKEN}): "
RES=`$XR_CLI importPlaylistClose $TOKEN` || \
{ ERN=$?; echo $RES; exit $ERN; }
echo $RES
+ GUNID=0000000000010001; existsAudioClip;
+ GUNID=0000000000010002; existsAudioClip;
+ GUNID=0000000000010003; existsAudioClip;
+ PLID=0000000000000001; existsPlaylist;
+ PLID=0000000000000003; existsPlaylist;
}
prefTest() {
diff --git a/livesupport/src/modules/storageServer/var/xmlrpc/xrLocStor.php b/livesupport/src/modules/storageServer/var/xmlrpc/xrLocStor.php
index fcff16716..be273340b 100644
--- a/livesupport/src/modules/storageServer/var/xmlrpc/xrLocStor.php
+++ b/livesupport/src/modules/storageServer/var/xmlrpc/xrLocStor.php
@@ -157,9 +157,21 @@ $methods = array(
'loadGroupPref' => 'Read group preference record.',
'saveGroupPref' => 'Delete user preference record.',
- 'uploadToArchive' => 'Starts upload audioclip to remote archive.',
- 'downloadFromArchive' => 'Starts download audioclip from remote archive.',
- 'getTransportInfo' => 'Checking status of transported file.',
+ 'getTransportInfo' => 'Common "check" method for transports',
+ 'turnOnOffTransports' => 'Turn transports on/off, optionaly return current state',
+ 'uploadFile2Hub' => 'Open async file transfer from local storageServer to network hub',
+ 'getHubInitiatedTransfers' => 'Get list of prepared transfers initiated by hub',
+ 'startHubInitiatedTransfer' => 'Start of download initiated by hub',
+ 'uploadAudioClip2Hub' => 'Common "check" method for transports',
+ 'downloadAudioClipFromHub' => 'Start download of audioClip/webstream from hub to local storageServer',
+ 'uploadPlaylist2Hub' => 'Start upload of playlist from local storageServer to hub',
+ 'downloadPlaylistFromHub' => 'Start download of playlist from hub to local storageServer',
+ 'globalSearch' => 'Start search job on network hub',
+ 'getSearchResults' => 'Get results from search job on network hub',
+
+# 'uploadToArchive' => 'Starts upload audioclip to remote archive.',
+# 'downloadFromArchive' => 'Starts download audioclip from remote archive.',
+# 'getTransportInfo' => 'Checking status of transported file.',
);
$defs = array();
diff --git a/livesupport/src/modules/storageServer/var/xmlrpc/xr_cli_test.php b/livesupport/src/modules/storageServer/var/xmlrpc/xr_cli_test.php
index 0107da3c7..74f7eec72 100644
--- a/livesupport/src/modules/storageServer/var/xmlrpc/xr_cli_test.php
+++ b/livesupport/src/modules/storageServer/var/xmlrpc/xr_cli_test.php
@@ -182,13 +182,36 @@ $infos = array(
"saveGroupPref" => array('m'=>"locstor.saveGroupPref",
'p'=>array('sessid', 'group', 'key', 'value'), 'r'=>'status'),
+ "getTransportInfo" => array('m'=>"locstor.getTransportInfo",
+ 'p'=>array('trtok'),
+ 'r'=>array('state', 'realsize', 'expectedsize', 'realchsum', 'expectedchsum')),
+ "turnOnOffTransports" => array('m'=>"locstor.turnOnOffTransports",
+ 'p'=>array('sessid', 'onOff'), 'r'=>array('state')),
+ "uploadFile2Hub" => array('m'=>"locstor.uploadFile2Hub",
+ 'p'=>array('sessid', 'filePath'), 'r'=>array('trtok')),
+ "getHubInitiatedTransfers" => array('m'=>"locstor.getHubInitiatedTransfers",
+ 'p'=>array('sessid'), 'r'=>array()),
+ "startHubInitiatedTransfer" => array('m'=>"locstor.startHubInitiatedTransfer",
+ 'p'=>array('trtok'), 'r'=>array()),
+ "uploadAudioClip2Hub" => array('m'=>"locstor.uploadAudioClip2Hub",
+ 'p'=>array('sessid', 'gunid'), 'r'=>array('trtok')),
+ "downloadAudioClipFromHub" => array('m'=>"locstor.downloadAudioClipFromHub",
+ 'p'=>array('sessid', 'gunid'), 'r'=>array('trtok')),
+ "uploadPlaylist2Hub" => array('m'=>"locstor.uploadPlaylist2Hub",
+ 'p'=>array('sessid', 'plid', 'withContent'), 'r'=>array('trtok')),
+ "downloadPlaylistFromHub" => array('m'=>"locstor.downloadPlaylistFromHub",
+ 'p'=>array('plid', 'withContent'), 'r'=>array('trtok')),
+ "globalSearch" => array('m'=>"locstor.globalSearch",
+ 'p'=>array('sessid', 'criteria'), 'r'=>array('trtok')),
+ "getSearchResults" => array('m'=>"locstor.getSearchResults",
+ 'p'=>array('trtok'), 'r'=>array()),
+
+/*
"uploadToArchive" => array('m'=>"locstor.uploadToArchive",
'p'=>array('sessid', 'gunid'), 'r'=>'trtok'),
"downloadFromArchive" => array('m'=>"locstor.downloadFromArchive",
'p'=>array('sessid', 'gunid'), 'r'=>'trtok'),
- "getTransportInfo" => array('m'=>"locstor.getTransportInfo",
- 'p'=>array('sessid', 'trtok'),
- 'r'=>array('state', 'realsize', 'realsum', 'expectedsize', 'expectedsum')),
+*/
"openPut" => array('m'=>"locstor.openPut", 'p'=>array()),
"closePut" => array('m'=>"locstor.closePut", 'p'=>array()),
@@ -197,6 +220,7 @@ $infos = array(
switch($method){
case"searchMetadata":
+case"createBackupOpen":
$parr = array(
'sessid'=>$pars[0],
'criteria'=>array(