Major changes in transport subsystem to accept playlists.
Transport audioclips rewritten.
This commit is contained in:
parent
3e40ad4707
commit
b4d240a096
9 changed files with 1235 additions and 454 deletions
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.20 $
|
||||
Version : $Revision: 1.21 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -37,12 +37,14 @@ define('GBERR_AOBJNEX', 46);
|
|||
define('GBERR_NOTF', 47);
|
||||
define('GBERR_SESS', 48);
|
||||
define('GBERR_PREF', 49);
|
||||
define('GBERR_TOKEN', 50);
|
||||
define('GBERR_PUT', 51);
|
||||
|
||||
define('GBERR_NOTIMPL', 50);
|
||||
define('GBERR_NOTIMPL', 69);
|
||||
|
||||
require_once "../../../alib/var/alib.php";
|
||||
require_once "StoredFile.php";
|
||||
#require_once "Transport.php";
|
||||
require_once "Transport.php";
|
||||
|
||||
/**
|
||||
* BasicStor class
|
||||
|
@ -50,7 +52,7 @@ require_once "StoredFile.php";
|
|||
* Core of LiveSupport file storage module
|
||||
*
|
||||
* @author $Author: tomas $
|
||||
* @version $Revision: 1.20 $
|
||||
* @version $Revision: 1.21 $
|
||||
* @see Alib
|
||||
*/
|
||||
class BasicStor extends Alib{
|
||||
|
@ -111,16 +113,17 @@ class BasicStor extends Alib{
|
|||
* @param mdataFileLP string, local path of metadata file
|
||||
* @param gunid string, global unique id OPTIONAL
|
||||
* @param ftype string, internal file type
|
||||
* @param mdataLoc string 'file'|'string' (optional)
|
||||
* @return int
|
||||
* @exception PEAR::error
|
||||
*/
|
||||
function bsPutFile($parid, $fileName,
|
||||
$mediaFileLP, $mdataFileLP, $gunid=NULL, $ftype='unKnown')
|
||||
function bsPutFile($parid, $fileName, $mediaFileLP, $mdataFileLP,
|
||||
$gunid=NULL, $ftype='unKnown', $mdataLoc='file')
|
||||
{
|
||||
$name = "$fileName";
|
||||
$id = $this->addObj($name , 'File', $parid);
|
||||
$ac =& StoredFile::insert(
|
||||
&$this, $id, $name, $mediaFileLP, $mdataFileLP, 'file',
|
||||
&$this, $id, $name, $mediaFileLP, $mdataFileLP, $mdataLoc,
|
||||
$gunid, $ftype
|
||||
);
|
||||
if(PEAR::isError($ac)){
|
||||
|
@ -236,11 +239,12 @@ class BasicStor extends Alib{
|
|||
* Delete file
|
||||
*
|
||||
* @param id int, virt.file's local id
|
||||
* @param forced boolean, unconditional delete
|
||||
* @return true or PEAR::error
|
||||
*/
|
||||
function bsDeleteFile($id)
|
||||
function bsDeleteFile($id, $forced=FALSE)
|
||||
{
|
||||
$res = $this->removeObj($id);
|
||||
$res = $this->removeObj($id, $forced);
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
@ -353,7 +357,8 @@ class BasicStor extends Alib{
|
|||
*
|
||||
* @param id int, virt.file's local id
|
||||
* @param part string, 'media'|'metadata'
|
||||
* @return array with: downloadable URL, download token
|
||||
* @return array with strings:
|
||||
* downloadable URL, download token, chsum, size, filename
|
||||
*/
|
||||
function bsOpenDownload($id, $part='media')
|
||||
{
|
||||
|
@ -362,17 +367,30 @@ class BasicStor extends Alib{
|
|||
$gunid = $ac->gunid;
|
||||
switch($part){
|
||||
case"media":
|
||||
$fname = $ac->_getRealRADFname();
|
||||
$realfile = $ac->_getRealRADFname();
|
||||
$ext = $ac->_getExt();
|
||||
$filename = $ac->_getFileName();
|
||||
break;
|
||||
case"metadata":
|
||||
$fname = $ac->_getRealMDFname();
|
||||
$realfile = $ac->_getRealMDFname();
|
||||
$ext = "xml";
|
||||
$filename = $ac->_getFileName();
|
||||
break;
|
||||
default:
|
||||
return PEAR::raiseError(
|
||||
"BasicStor::bsOpenDownload: unknown part ($part)"
|
||||
);
|
||||
}
|
||||
$acc = $this->bsAccess($fname, $ext, $gunid, 'download');
|
||||
$acc = $this->bsAccess($realfile, $ext, $gunid, 'download');
|
||||
if(PEAR::isError($acc)){ return $acc; }
|
||||
$url = $this->getUrlPart()."access/".basename($acc['fname']);
|
||||
return array('url'=>$url, 'token'=>$acc['token']);
|
||||
$chsum = md5_file($realfile);
|
||||
$size = filesize($realfile);
|
||||
return array(
|
||||
'url'=>$url, 'token'=>$acc['token'],
|
||||
'chsum'=>$chsum, 'size'=>$size,
|
||||
'filename'=>$filename
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -403,6 +421,10 @@ class BasicStor extends Alib{
|
|||
{
|
||||
$ext = '';
|
||||
$token = StoredFile::_createGunid();
|
||||
$res = $this->dbc->query("
|
||||
DELETE FROM {$this->accessTable} WHERE token=x'$token'::bigint
|
||||
");
|
||||
if(PEAR::isError($res)){ return $res; }
|
||||
$res = $this->dbc->query("
|
||||
INSERT INTO {$this->accessTable}
|
||||
(gunid, token, ext, chsum, type, ts)
|
||||
|
@ -426,9 +448,11 @@ class BasicStor extends Alib{
|
|||
*/
|
||||
function bsClosePut($token)
|
||||
{
|
||||
$token = StoredFile::_normalizeGunid($token);
|
||||
if(!$this->bsCheckToken($token, 'put')){
|
||||
return PEAR::raiseError(
|
||||
"BasicStor::bsClosePut: invalid token ($token)"
|
||||
"BasicStor::bsClosePut: invalid token ($token)",
|
||||
GBERR_TOKEN
|
||||
);
|
||||
}
|
||||
$chsum = $this->dbc->getOne("
|
||||
|
@ -444,12 +468,47 @@ class BasicStor extends Alib{
|
|||
if($chsum != $md5sum){
|
||||
if(file_exists($fname)) @unlink($fname);
|
||||
return PEAR::raiseError(
|
||||
"BasicStor::bsClosePut: md5sum does not match (token=$token)"
|
||||
"BasicStor::bsClosePut: md5sum does not match (token=$token)",
|
||||
GBERR_PUT
|
||||
);
|
||||
}
|
||||
return $fname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check uploaded file
|
||||
*
|
||||
* @param token string, put token
|
||||
* @return hash, (
|
||||
* status: boolean,
|
||||
* size: int - filesize
|
||||
* expectedsum: string - expected checksum
|
||||
* realsum: string - checksum of uploaded file
|
||||
* )
|
||||
*/
|
||||
function bsCheckPut($token)
|
||||
{
|
||||
if(!$this->bsCheckToken($token, 'put')){
|
||||
return PEAR::raiseError(
|
||||
"BasicStor::bsClosePut: invalid token ($token)"
|
||||
);
|
||||
}
|
||||
$chsum = $this->dbc->getOne("
|
||||
SELECT chsum FROM {$this->accessTable}
|
||||
WHERE token=x'{$token}'::bigint
|
||||
");
|
||||
if(PEAR::isError($chsum)){ return $chsum; }
|
||||
$fname = "{$this->accessDir}/$token";
|
||||
$md5sum = md5_file($fname);
|
||||
$size = filesize($fname);
|
||||
$status = ($chsum == $md5sum);
|
||||
return array(
|
||||
'status'=>$status, 'size'=>$size,
|
||||
'expectedsum'=>$chsum,
|
||||
'realsum'=>$md5sum,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return starting part of storageServer URL
|
||||
*
|
||||
|
@ -644,7 +703,7 @@ class BasicStor extends Alib{
|
|||
if($v['type'] == 'File'){
|
||||
$gunid = $this->_gunidFromId($v['id']);
|
||||
$listArr[$i]['type'] =
|
||||
StoredFile::_getType($gunid);
|
||||
$this->_getType($gunid);
|
||||
$listArr[$i]['gunid'] = $gunid;
|
||||
if(StoredFIle::_getState($gunid) == 'incomplete')
|
||||
unset($listArr[$i]);
|
||||
|
@ -725,12 +784,47 @@ class BasicStor extends Alib{
|
|||
$type = $this->getObjName($oid, 'type');
|
||||
if($type == 'File'){
|
||||
$ftype =
|
||||
StoredFile::_getType($this->_gunidFromId($oid));
|
||||
$this->_getType($this->_gunidFromId($oid));
|
||||
if(!is_null($ftype)) $type=$ftype;
|
||||
}
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new user with home folder
|
||||
*
|
||||
* @param login string
|
||||
* @param pass string OPT
|
||||
* @return int/err
|
||||
*/
|
||||
function addSubj($login, $pass=NULL)
|
||||
{
|
||||
$uid = parent::addSubj($login, $pass);
|
||||
if(PEAR::isError($uid)) return $uid;
|
||||
$fid = $this->bsCreateFolder($this->storId, $login);
|
||||
if(PEAR::isError($fid)) return $fid;
|
||||
$res = $this->addPerm($uid, '_all', $fid, 'A');
|
||||
if(PEAR::isError($res)) return $res;
|
||||
return $uid;
|
||||
}
|
||||
/**
|
||||
* Remove user and his home folder
|
||||
*
|
||||
* @param login string
|
||||
* @param uid int OPT
|
||||
* @return boolean/err
|
||||
*/
|
||||
function removeSubj($login, $uid=NULL)
|
||||
{
|
||||
$res = parent::removeSubj($login, $pass);
|
||||
if(PEAR::isError($res)) return $res;
|
||||
$id = $this->getObjId($login, $this->storId);
|
||||
if(PEAR::isError($id)) return $id;
|
||||
$res = $this->bsDeleteFile($id);
|
||||
if(PEAR::isError($res)) return $res;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* ==================================================== "private" methods */
|
||||
/**
|
||||
* Check authorization - auxiliary method
|
||||
|
@ -767,6 +861,10 @@ class BasicStor extends Alib{
|
|||
$parid = $this->getObjId(
|
||||
$this->getSessLogin($sessid), $this->storId
|
||||
);
|
||||
if(is_null($parid)){
|
||||
return PEAR::raiseError("BasicStor::_getHomeDirId: ".
|
||||
"homedir not found", GBERR_NOTF);
|
||||
}
|
||||
return $parid;
|
||||
}
|
||||
|
||||
|
@ -801,6 +899,21 @@ class BasicStor extends Alib{
|
|||
return StoredFile::_normalizeGunid($gunid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get storage-internal file type
|
||||
*
|
||||
* @param gunid string, global unique id of file
|
||||
* @return string, see install()
|
||||
*/
|
||||
function _getType($gunid)
|
||||
{
|
||||
$ftype = $this->dbc->getOne("
|
||||
SELECT ftype FROM {$this->filesTable}
|
||||
WHERE gunid=x'$gunid'::bigint
|
||||
");
|
||||
return $ftype;
|
||||
}
|
||||
|
||||
/* ------------------------------------------ redefined "private" methods */
|
||||
/**
|
||||
* Copy virtual file.<br>
|
||||
|
@ -845,21 +958,22 @@ class BasicStor extends Alib{
|
|||
* Redefined from parent class.
|
||||
*
|
||||
* @param id int, local id of removed object
|
||||
* @param forced boolean, unconditional delete
|
||||
* @return true or PEAR::error
|
||||
*/
|
||||
function removeObj($id)
|
||||
function removeObj($id, $forced=FALSE)
|
||||
{
|
||||
switch($ot = $this->getObjType($id)){
|
||||
case"audioclip":
|
||||
case"playlist":
|
||||
$ac =& StoredFile::recall(&$this, $id);
|
||||
if(PEAR::isError($ac)) return $ac;
|
||||
if($ac->isEdited()){
|
||||
if($ac->isEdited() && !$forced){
|
||||
return PEAR::raiseError(
|
||||
'BasicStor.php: removeObj: is edited'
|
||||
);
|
||||
}
|
||||
if($ac->isAccessed()){
|
||||
if($ac->isAccessed() && !$forced){
|
||||
return PEAR::raiseError(
|
||||
'BasicStor.php: removeObj: is accessed'
|
||||
);
|
||||
|
@ -923,7 +1037,7 @@ class BasicStor extends Alib{
|
|||
// $this->dbc->query("DELETE FROM {$this->filesTable}");
|
||||
$ids = $this->dbc->getAll("SELECT id FROM {$this->filesTable}");
|
||||
if(is_array($ids)) foreach($ids as $i=>$item){
|
||||
$this->bsDeleteFile($item['id']);
|
||||
$this->bsDeleteFile($item['id'], TRUE);
|
||||
}
|
||||
parent::deleteData();
|
||||
$this->initData();
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.23 $
|
||||
Version : $Revision: 1.24 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -35,7 +35,7 @@ require_once "BasicStor.php";
|
|||
* LiveSupport file storage module
|
||||
*
|
||||
* @author $Author: tomas $
|
||||
* @version $Revision: 1.23 $
|
||||
* @version $Revision: 1.24 $
|
||||
* @see BasicStor
|
||||
*/
|
||||
class GreenBox extends BasicStor{
|
||||
|
@ -278,41 +278,6 @@ class GreenBox extends BasicStor{
|
|||
|
||||
/* ---------------------------------------------------- redefined methods */
|
||||
|
||||
/**
|
||||
* Add new user with home folder
|
||||
*
|
||||
* @param login string
|
||||
* @param pass string OPT
|
||||
* @return int/err
|
||||
*/
|
||||
function addSubj($login, $pass=NULL)
|
||||
{
|
||||
$uid = parent::addSubj($login, $pass);
|
||||
if(PEAR::isError($uid)) return $uid;
|
||||
$fid = $this->bsCreateFolder($this->storId, $login);
|
||||
if(PEAR::isError($fid)) return $fid;
|
||||
$res = $this->addPerm($uid, '_all', $fid, 'A');
|
||||
if(PEAR::isError($res)) return $res;
|
||||
return $uid;
|
||||
}
|
||||
/**
|
||||
* Remove user and his home folder
|
||||
*
|
||||
* @param login string
|
||||
* @param uid int OPT
|
||||
* @return boolean/err
|
||||
*/
|
||||
function removeSubj($login, $uid=NULL)
|
||||
{
|
||||
$res = parent::removeSubj($login, $pass);
|
||||
if(PEAR::isError($res)) return $res;
|
||||
$id = $this->getObjId($login, $this->storId);
|
||||
if(PEAR::isError($id)) return $id;
|
||||
$res = $this->bsDeleteFile($id);
|
||||
if(PEAR::isError($res)) return $res;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file's path in virtual filesystem
|
||||
*
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.22 $
|
||||
Version : $Revision: 1.23 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/LocStor.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -48,7 +48,9 @@ class LocStor extends BasicStor{
|
|||
* @param chsum string, md5 checksum of media file
|
||||
* @return struct {url:writable URL for HTTP PUT, token:access token
|
||||
*/
|
||||
function storeAudioClipOpen($sessid, $gunid, $metadata, $fname, $chsum)
|
||||
function storeAudioClipOpen(
|
||||
$sessid, $gunid, $metadata, $fname, $chsum, $ftype='audioclip'
|
||||
)
|
||||
{
|
||||
// test if specified gunid exists:
|
||||
if(!preg_match("|^([0-9a-fA-F]{16})?$|", $gunid)){
|
||||
|
@ -59,8 +61,9 @@ class LocStor extends BasicStor{
|
|||
$ac =& StoredFile::recallByGunid(&$this, $gunid);
|
||||
if(!PEAR::isError($ac)){
|
||||
// gunid exists - do replace
|
||||
$oid = $ac->getId();
|
||||
if(($res = $this->_authorize(
|
||||
'write', $ac->getId(), $sessid
|
||||
'write', $oid, $sessid
|
||||
)) !== TRUE) return $res;
|
||||
if($ac->isAccessed()){
|
||||
return PEAR::raiseError(
|
||||
|
@ -68,7 +71,7 @@ class LocStor extends BasicStor{
|
|||
);
|
||||
}
|
||||
$res = $ac->replace(
|
||||
$ac->getId(), $ac->name, '', $metadata, 'string'
|
||||
$oid, $ac->name, '', $metadata, 'string'
|
||||
);
|
||||
if(PEAR::isError($res)) return $res;
|
||||
}else{
|
||||
|
@ -82,7 +85,7 @@ class LocStor extends BasicStor{
|
|||
if(PEAR::isError($oid)) return $oid;
|
||||
$ac =& StoredFile::insert(
|
||||
&$this, $oid, '', '', $metadata, 'string',
|
||||
$gunid, 'audioclip'
|
||||
$gunid, $ftype
|
||||
);
|
||||
if(PEAR::isError($ac)){
|
||||
$res = $this->removeObj($oid);
|
||||
|
@ -121,6 +124,17 @@ class LocStor extends BasicStor{
|
|||
return $ac->gunid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check uploaded file
|
||||
*
|
||||
* @param token string, put token
|
||||
* @return hash, (status: boolean, size: int - filesize)
|
||||
*/
|
||||
function uploadCheck($token)
|
||||
{
|
||||
return $this->bsCheckPut($token);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------- access */
|
||||
/**
|
||||
* Make access to audio clip
|
||||
|
@ -158,16 +172,18 @@ class LocStor extends BasicStor{
|
|||
*
|
||||
* @param sessid string, session id
|
||||
* @param gunid string, global unique id
|
||||
* @return array with: downloadable URL, download token
|
||||
* @return array with strings:
|
||||
* downloadable URL, download token, chsum, size, filename
|
||||
*/
|
||||
function downloadRawAudioDataOpen($sessid, $gunid)
|
||||
{
|
||||
$res = $this->existsAudioClip($sessid, $gunid);
|
||||
if(PEAR::isError($res)) return $res;
|
||||
$ex = $this->existsAudioClip($sessid, $gunid);
|
||||
if(PEAR::isError($ex)) return $ex;
|
||||
$id = $this->_idFromGunid($gunid);
|
||||
if(is_null($id)){
|
||||
if(is_null($id) || !$ex){
|
||||
return PEAR::raiseError(
|
||||
"LocStor::downloadRawAudioDataOpen: gunid not found ($gunid)"
|
||||
"LocStor::downloadRawAudioDataOpen: gunid not found ($gunid)",
|
||||
GBERR_NOTF
|
||||
);
|
||||
}
|
||||
if(($res = $this->_authorize('read', $id, $sessid)) !== TRUE)
|
||||
|
@ -191,12 +207,13 @@ class LocStor extends BasicStor{
|
|||
*
|
||||
* @param sessid string, session id
|
||||
* @param gunid string, global unique id
|
||||
* @return array with: downloadable URL, download token
|
||||
* @return array with strings:
|
||||
* downloadable URL, download token, chsum, filename
|
||||
*/
|
||||
function downloadMetadataOpen($sessid, $gunid)
|
||||
{
|
||||
$res = $this->existsAudioClip($sessid, $gunid);
|
||||
if(PEAR::isError($res)) return $res;
|
||||
# $res = $this->existsAudioClip($sessid, $gunid);
|
||||
# if(PEAR::isError($res)) return $res;
|
||||
$id = $this->_idFromGunid($gunid);
|
||||
if(is_null($id)){
|
||||
return PEAR::raiseError(
|
||||
|
@ -205,7 +222,9 @@ class LocStor extends BasicStor{
|
|||
}
|
||||
if(($res = $this->_authorize('read', $id, $sessid)) !== TRUE)
|
||||
return $res;
|
||||
return $this->bsOpenDownload($id, 'metadata');
|
||||
$res = $this->bsOpenDownload($id, 'metadata');
|
||||
#unset($res['filename']);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -350,7 +369,7 @@ class LocStor extends BasicStor{
|
|||
default: return $ac;
|
||||
}
|
||||
}
|
||||
if(!is_null($ftype) && ($ac->_getType() != $ftype)) return FALSE;
|
||||
if(!is_null($ftype) && ($this->_getType($gunid) != $ftype)) return FALSE;
|
||||
if(($res = $this->_authorize('read', $ac->getId(), $sessid)) !== TRUE)
|
||||
return $res;
|
||||
return TRUE;
|
||||
|
@ -399,6 +418,10 @@ class LocStor extends BasicStor{
|
|||
function resetStorage($input='')
|
||||
{
|
||||
$this->deleteData();
|
||||
if(!$this->config['isArchive']){
|
||||
$tr =& new Transport($this->dbc, $this, $this->config);
|
||||
$tr->resetData();
|
||||
}
|
||||
$rootHD = $this->getObjId('root', $this->storId);
|
||||
include"../tests/sampleData.php";
|
||||
$res = array('audioclips'=>array(), 'playlists'=>array());
|
||||
|
@ -483,7 +506,8 @@ class LocStor extends BasicStor{
|
|||
*
|
||||
* @param sessid string, session ID
|
||||
* @param playlistId string, playlist global unique ID
|
||||
* @return struct {url:readable URL for HTTP GET, token:access token}
|
||||
* @return struct
|
||||
* {url:readable URL for HTTP GET, token:access token, chsum:checksum}
|
||||
*/
|
||||
function editPlaylist($sessid, $playlistId)
|
||||
{
|
||||
|
@ -505,6 +529,7 @@ class LocStor extends BasicStor{
|
|||
$res = $this->bsOpenDownload($id, 'metadata');
|
||||
if(PEAR::isError($res)){ return $res; }
|
||||
$this->_setEditFlag($playlistId, TRUE);
|
||||
unset($res['filename']);
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
@ -557,7 +582,8 @@ class LocStor extends BasicStor{
|
|||
*
|
||||
* @param sessid string, session ID
|
||||
* @param playlistId string, playlist global unique ID
|
||||
* @return struct {url:readable URL for HTTP GET, token:access token
|
||||
* @return struct
|
||||
* {url:readable URL for HTTP GET, token:access token, chsum:checksum}
|
||||
*/
|
||||
function accessPlaylist($sessid, $playlistId)
|
||||
{
|
||||
|
@ -565,13 +591,16 @@ class LocStor extends BasicStor{
|
|||
if(PEAR::isError($ex)){ return $ex; }
|
||||
if(!$ex){
|
||||
return PEAR::raiseError(
|
||||
'LocStor.php: accessPlaylist: playlist not found'
|
||||
"LocStor.php: accessPlaylist: playlist not found ($playlistId)",
|
||||
GBERR_NOTF
|
||||
);
|
||||
}
|
||||
$id = $this->_idFromGunid($playlistId);
|
||||
if(($res = $this->_authorize('read', $id, $sessid)) !== TRUE)
|
||||
return $res;
|
||||
return $this->bsOpenDownload($id, 'metadata');
|
||||
$res = $this->bsOpenDownload($id, 'metadata');
|
||||
unset($res['filename']);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.16 $
|
||||
Version : $Revision: 1.17 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/StoredFile.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -93,7 +93,7 @@ class StoredFile{
|
|||
$ac->mime = "unKnown";
|
||||
$emptyState = TRUE;
|
||||
if($ac->name=='') $ac->name=$ac->gunid;
|
||||
$this->dbc->query("BEGIN");
|
||||
$ac->dbc->query("BEGIN");
|
||||
$res = $ac->dbc->query("
|
||||
INSERT INTO {$ac->filesTable}
|
||||
(id, name, gunid, mime, state, ftype)
|
||||
|
@ -101,7 +101,7 @@ class StoredFile{
|
|||
('$oid', '{$ac->name}', x'{$ac->gunid}'::bigint,
|
||||
'{$ac->mime}', 'incomplete', '$ftype')
|
||||
");
|
||||
if(PEAR::isError($res)){ $this->dbc->query("ROLLBACK"); return $res; }
|
||||
if(PEAR::isError($res)){ $ac->dbc->query("ROLLBACK"); return $res; }
|
||||
// --- metadata insert:
|
||||
if($metadata != ''){
|
||||
if($mdataLoc=='file' && !file_exists($metadata))
|
||||
|
@ -111,7 +111,7 @@ class StoredFile{
|
|||
}
|
||||
$res = $ac->md->insert($metadata, $mdataLoc);
|
||||
if(PEAR::isError($res)){
|
||||
$this->dbc->query("ROLLBACK"); return $res;
|
||||
$ac->dbc->query("ROLLBACK"); return $res;
|
||||
}
|
||||
$emptyState = FALSE;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ class StoredFile{
|
|||
}
|
||||
$res = $ac->rmd->insert($mediaFileLP);
|
||||
if(PEAR::isError($res)){
|
||||
$this->dbc->query("ROLLBACK"); return $res;
|
||||
$ac->dbc->query("ROLLBACK"); return $res;
|
||||
}
|
||||
$mime = $ac->rmd->getMime();
|
||||
//$gb->debugLog("gunid={$ac->gunid}, mime=$mime");
|
||||
|
@ -140,8 +140,8 @@ class StoredFile{
|
|||
$res = $ac->setState('ready');
|
||||
if(PEAR::isError($res)){ $ac->dbc->query("ROLLBACK"); return $res; }
|
||||
}
|
||||
$res = $this->dbc->query("COMMIT");
|
||||
if(PEAR::isError($res)){ $this->dbc->query("ROLLBACK"); return $res; }
|
||||
$res = $ac->dbc->query("COMMIT");
|
||||
if(PEAR::isError($res)){ $ac->dbc->query("ROLLBACK"); return $res; }
|
||||
return $ac;
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ class StoredFile{
|
|||
{
|
||||
$ac =& StoredFile::insert(
|
||||
&$src->gb, $nid, $src->name, $src->_getRealRADFname(),
|
||||
'', '', NULL, $src->_getType()
|
||||
'', '', NULL, $src->gb->_getType($src->gunid)
|
||||
);
|
||||
if(PEAR::isError($ac)) return $ac;
|
||||
$ac->md->replace($src->md->getMetaData(), 'string');
|
||||
|
@ -256,7 +256,7 @@ class StoredFile{
|
|||
$this->dbc->query("ROLLBACK"); return $res;
|
||||
}
|
||||
if($metadata != ''){ // metadata
|
||||
$res = $this->md->replace($metadata, $mdataLoc);
|
||||
$res = $this->replaceMetaData($metadata, $mdataLoc);
|
||||
}else{
|
||||
$res = $this->md->delete();
|
||||
}
|
||||
|
@ -495,6 +495,7 @@ class StoredFile{
|
|||
SELECT to_hex(gunid) FROM {$this->filesTable}
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
");
|
||||
if(PEAR::isError($indb)) return $indb;
|
||||
return (!is_null($indb) && $this->rmd->exists());
|
||||
}
|
||||
|
||||
|
@ -585,22 +586,6 @@ class StoredFile{
|
|||
");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get storage-internal file type
|
||||
*
|
||||
* @param gunid string, optional, global unique id of file
|
||||
* @return string, see install()
|
||||
*/
|
||||
function _getType($gunid=NULL)
|
||||
{
|
||||
if(is_null($gunid)) $gunid = $this->gunid;
|
||||
$ftype = $this->dbc->getOne("
|
||||
SELECT ftype FROM {$this->filesTable}
|
||||
WHERE gunid=x'$gunid'::bigint
|
||||
");
|
||||
return $ftype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get storage-internal file state
|
||||
*
|
||||
|
@ -639,8 +624,9 @@ class StoredFile{
|
|||
function _getResDir()
|
||||
{
|
||||
$resDir="{$this->gb->storageDir}/".substr($this->gunid, 0, 3);
|
||||
#$this->gb->debugLog("$resDir");
|
||||
// see Transport::_getResDir too for resDir name create code
|
||||
if(!file_exists($resDir)){ mkdir($resDir, 02775); chmod($resDir, 02775); }
|
||||
if(!is_dir($resDir)){ mkdir($resDir, 02775); chmod($resDir, 02775); }
|
||||
return $resDir;
|
||||
}
|
||||
|
||||
|
@ -671,6 +657,7 @@ class StoredFile{
|
|||
*/
|
||||
function _getAccessFname($token, $ext='EXT')
|
||||
{
|
||||
$token = StoredFile::_normalizeGunid($token);
|
||||
return "{$this->accessDir}/$token.$ext";
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/php -q
|
||||
<?php
|
||||
chdir(dirname(__FILE__));
|
||||
require_once "../conf.php";
|
||||
require_once "DB.php";
|
||||
require_once '../LocStor.php';
|
||||
|
@ -9,8 +10,21 @@ $dbc = DB::connect($config['dsn'], TRUE);
|
|||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$gb = &new LocStor(&$dbc, $config);
|
||||
$tr =& new Transport(&$dbc, &$gb, $config);
|
||||
$cnt = 1;
|
||||
|
||||
$res = $gb->cronJob();
|
||||
#$res = $gb->cronJob();
|
||||
#var_dump($res);
|
||||
|
||||
var_dump($res);
|
||||
for($i=0; $i<$cnt; $i++){
|
||||
$r = $tr->uploadCron();
|
||||
if(!$r) exit(1);
|
||||
}
|
||||
|
||||
for($i=0; $i<$cnt; $i++){
|
||||
$r = $tr->downloadCron();
|
||||
if(!$r) exit(1);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
?>
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.8 $
|
||||
Version : $Revision: 1.9 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/XR_LocStor.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -188,7 +188,7 @@ class XR_LocStor extends LocStor{
|
|||
* <li> sessid : string - session id </li>
|
||||
* <li> gunid : string - global unique id of AudioCLip</li>
|
||||
* <li> metadata : string - metadata XML string</li>
|
||||
* <li> fname : string - human readable menmonic file name
|
||||
* <li> fname : string - human readable mnemonic file name
|
||||
* with extension corresponding to filetype</li>
|
||||
* <li> chsum : string - md5 checksum of media file</li>
|
||||
* </ul>
|
||||
|
@ -254,6 +254,7 @@ class XR_LocStor extends LocStor{
|
|||
* <li> 801 - wrong 1st parameter, struct expected.</li>
|
||||
* <li> 805 - xr_storeAudioClipClose:
|
||||
* <message from lower layer> </li>
|
||||
* <li> 850 - wrong 1st parameter, struct expected.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param input XMLRPC struct
|
||||
|
@ -266,7 +267,9 @@ class XR_LocStor extends LocStor{
|
|||
if(!$ok) return $r;
|
||||
$res = $this->storeAudioClipClose($r['sessid'], $r['token']);
|
||||
if(PEAR::isError($res)){
|
||||
return new XML_RPC_Response(0, 805,
|
||||
$ec0 = intval($res->getCode());
|
||||
$ec = ($ec0 == GBERR_TOKEN ? 800+$ec0 : 805 );
|
||||
return new XML_RPC_Response(0, $ec,
|
||||
"xr_storeAudioClipClose: ".$res->getMessage().
|
||||
" ".$res->getUserInfo()
|
||||
);
|
||||
|
@ -384,6 +387,9 @@ class XR_LocStor extends LocStor{
|
|||
* <ul>
|
||||
* <li> url : string - downloadable url</li>
|
||||
* <li> token : string - download token</li>
|
||||
* <li> chsum : string - md5 checksum</li>
|
||||
* <li> size : int - file size</li>
|
||||
* <li> filename : string - human readable mnemonic file name</li>
|
||||
* </ul>
|
||||
*
|
||||
* On errors, returns an XML-RPC error response.
|
||||
|
@ -394,6 +400,7 @@ class XR_LocStor extends LocStor{
|
|||
* <li> 801 - wrong 1st parameter, struct expected.</li>
|
||||
* <li> 805 - xr_accessRawAudioDataOpen:
|
||||
* <message from lower layer> </li>
|
||||
* <li> 847 - invalid gunid.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param input XMLRPC struct
|
||||
|
@ -406,7 +413,9 @@ class XR_LocStor extends LocStor{
|
|||
if(!$ok) return $r;
|
||||
$res = $this->downloadRawAudioDataOpen($r['sessid'], $r['gunid']);
|
||||
if(PEAR::isError($res)){
|
||||
return new XML_RPC_Response(0, 805,
|
||||
$ec0 = intval($res->getCode());
|
||||
$ec = ($ec0 == GBERR_NOTF ? 800+$ec0 : 805 );
|
||||
return new XML_RPC_Response(0, $ec,
|
||||
"xr_downloadRawAudioDataOpen: ".$res->getMessage().
|
||||
" ".$res->getUserInfo()
|
||||
);
|
||||
|
@ -477,6 +486,8 @@ class XR_LocStor extends LocStor{
|
|||
* <ul>
|
||||
* <li> url : string - downloadable url</li>
|
||||
* <li> token : string - download token</li>
|
||||
* <li> chsum : string - md5 checksum</li>
|
||||
* <li> filename : string - mnemonic filename</li>
|
||||
* </ul>
|
||||
*
|
||||
* On errors, returns an XML-RPC error response.
|
||||
|
@ -497,6 +508,7 @@ class XR_LocStor extends LocStor{
|
|||
{
|
||||
list($ok, $r) = $this->_xr_getPars($input);
|
||||
if(!$ok) return $r;
|
||||
#$this->debugLog("{$r['sessid']}, {$r['gunid']}");
|
||||
$res = $this->downloadMetadataOpen($r['sessid'], $r['gunid']);
|
||||
if(PEAR::isError($res)){
|
||||
return new XML_RPC_Response(0, 805,
|
||||
|
@ -663,6 +675,7 @@ class XR_LocStor extends LocStor{
|
|||
* <ul>
|
||||
* <li> url : string - readable url</li>
|
||||
* <li> token : string - playlist token</li>
|
||||
* <li> chsum : string - md5 checksum</li>
|
||||
* </ul>
|
||||
*
|
||||
* On errors, returns an XML-RPC error response.
|
||||
|
@ -802,6 +815,7 @@ class XR_LocStor extends LocStor{
|
|||
* <ul>
|
||||
* <li> url : string - readable url</li>
|
||||
* <li> token : string - playlist token</li>
|
||||
* <li> chsum : string - md5 checksum</li>
|
||||
* </ul>
|
||||
*
|
||||
* On errors, returns an XML-RPC error response.
|
||||
|
@ -812,6 +826,7 @@ class XR_LocStor extends LocStor{
|
|||
* <li> 801 - wrong 1st parameter, struct expected.</li>
|
||||
* <li> 805 - xr_accessPlaylist:
|
||||
* <message from lower layer> </li>
|
||||
* <li> 847 - invalid plid.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param input XMLRPC struct
|
||||
|
@ -824,7 +839,9 @@ class XR_LocStor extends LocStor{
|
|||
if(!$ok) return $r;
|
||||
$res = $this->accessPlaylist($r['sessid'], $r['plid']);
|
||||
if(PEAR::isError($res)){
|
||||
return new XML_RPC_Response(0, 805,
|
||||
$ec0 = intval($res->getCode());
|
||||
$ec = ($ec0 == GBERR_NOTF ? 800+$ec0 : 805 );
|
||||
return new XML_RPC_Response(0, $ec,
|
||||
"xr_accessPlaylist: ".$res->getMessage().
|
||||
" ".$res->getUserInfo()
|
||||
);
|
||||
|
@ -970,7 +987,7 @@ class XR_LocStor extends LocStor{
|
|||
return new XML_RPC_Response(XML_RPC_encode(array('available'=>$res)));
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- etc. */
|
||||
/* --------------------------------------------------------- info methods */
|
||||
/**
|
||||
* Check if audio clip exists and return TRUE/FALSE
|
||||
*
|
||||
|
@ -1017,6 +1034,7 @@ class XR_LocStor extends LocStor{
|
|||
return new XML_RPC_Response(XML_RPC_encode(array('exists'=>$res)));
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------- metadata methods */
|
||||
/**
|
||||
* Return all file's metadata as XML string
|
||||
*
|
||||
|
@ -1181,49 +1199,7 @@ class XR_LocStor extends LocStor{
|
|||
return new XML_RPC_Response(XML_RPC_encode($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset storageServer for debugging.
|
||||
*
|
||||
* The XML-RPC name of this method is "locstor.resetStorage".
|
||||
*
|
||||
* The input parameters are an empty XML-RPC struct.
|
||||
*
|
||||
* On success, returns a XML-RPC struct with following
|
||||
* fields:
|
||||
* <ul>
|
||||
* <li> audioclips : array -
|
||||
* array with gunids of inserted audioclips </li>
|
||||
* <li> playlists : array -
|
||||
* array with gunids of inserted playlists </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_resetStorage:
|
||||
* <message from lower layer> </li>
|
||||
* </ul>
|
||||
*
|
||||
* @param input XMLRPC struct
|
||||
* @return XMLRPC struct
|
||||
* @see LocStor::getAudioClip
|
||||
*/
|
||||
function xr_resetStorage($input)
|
||||
{
|
||||
list($ok, $r) = $this->_xr_getPars($input);
|
||||
if(!$ok) return $r;
|
||||
$res = $this->resetStorage();
|
||||
if(PEAR::isError($res)){
|
||||
return new XML_RPC_Response(0, 805,
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
);
|
||||
}
|
||||
return new XML_RPC_Response(XML_RPC_encode($res));
|
||||
}
|
||||
|
||||
/* ---------------------------------------------- methods for preferences */
|
||||
/**
|
||||
* Load user preference value
|
||||
*
|
||||
|
@ -1265,8 +1241,9 @@ class XR_LocStor extends LocStor{
|
|||
$pr =& new Prefs(&$this);
|
||||
$res = $pr->loadPref($r['sessid'], $r['key']);
|
||||
if(PEAR::isError($res)){
|
||||
$ec = intval($res->getCode());
|
||||
return new XML_RPC_Response(0, 800+($ec == 48 || $ec == 49 ? $ec : 5 ),
|
||||
$ec0 = intval($res->getCode());
|
||||
$ec = ($ec0 == GBERR_SESS || $ec0 == GBERR_PREF ? 800+$ec0 : 805 );
|
||||
return new XML_RPC_Response(0, $ec,
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
|
||||
);
|
||||
|
@ -1315,9 +1292,9 @@ class XR_LocStor extends LocStor{
|
|||
$pr =& new Prefs(&$this);
|
||||
$res = $pr->savePref($r['sessid'], $r['key'], $r['value']);
|
||||
if(PEAR::isError($res)){
|
||||
#return new XML_RPC_Response(0, 805,
|
||||
$ec = intval($res->getCode());
|
||||
return new XML_RPC_Response(0, 800+($ec == 48 ? $ec : 5 ),
|
||||
$ec0 = intval($res->getCode());
|
||||
$ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 );
|
||||
return new XML_RPC_Response(0, $ec,
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
);
|
||||
}
|
||||
|
@ -1365,16 +1342,214 @@ class XR_LocStor extends LocStor{
|
|||
$pr =& new Prefs(&$this);
|
||||
$res = $pr->delPref($r['sessid'], $r['key']);
|
||||
if(PEAR::isError($res)){
|
||||
#return new XML_RPC_Response(0, 805,
|
||||
$ec = intval($res->getCode());
|
||||
return new XML_RPC_Response(0, 800+($ec == 48 || $ec == 49 ? $ec : 5 ),
|
||||
$ec0 = intval($res->getCode());
|
||||
$ec = ($ec0 == GBERR_SESS || $ec0 == GBERR_PREF ? 800+$ec0 : 805 );
|
||||
return new XML_RPC_Response(0, $ec,
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
);
|
||||
}
|
||||
return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res)));
|
||||
}
|
||||
|
||||
/* ------------------------------------------- test methods for debugging */
|
||||
/* -------------------------------------------- remote repository methods */
|
||||
/**
|
||||
* Starts upload audioclip to remote archive
|
||||
*
|
||||
* The XML-RPC name of this method is "locstor.uploadToArchive".
|
||||
*
|
||||
* The input parameters are an XML-RPC struct with the following
|
||||
* fields:
|
||||
* <ul>
|
||||
* <li> sessid : string - session id </li>
|
||||
* <li> gunid : string - global unique id </li>
|
||||
* </ul>
|
||||
*
|
||||
* On success, returns a XML-RPC struct with single field:
|
||||
* <ul>
|
||||
* <li> trtok : string - transport 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_uploadToArchive:
|
||||
* <message from lower layer> </li>
|
||||
* <li> 848 - invalid session id.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param input XMLRPC struct
|
||||
* @return XMLRPC struct
|
||||
* @see Pref::uploadToArchive
|
||||
*/
|
||||
function xr_uploadToArchive($input)
|
||||
{
|
||||
list($ok, $r) = $this->_xr_getPars($input);
|
||||
if(!$ok) return $r;
|
||||
require_once '../../../storageServer/var/Transport.php';
|
||||
$tr =& new Transport(&$this->dbc, &$this, $this->config);
|
||||
$res = $tr->uploadToArchive($r['gunid'], $r['sessid']);
|
||||
if(PEAR::isError($res)){
|
||||
$ec0 = intval($res->getCode());
|
||||
$ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 );
|
||||
return new XML_RPC_Response(0, $ec,
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
);
|
||||
}
|
||||
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts download audioclip from remote archive
|
||||
*
|
||||
* The XML-RPC name of this method is "locstor.downloadFromArchive".
|
||||
*
|
||||
* The input parameters are an XML-RPC struct with the following
|
||||
* fields:
|
||||
* <ul>
|
||||
* <li> sessid : string - session id </li>
|
||||
* <li> gunid : string - global unique id </li>
|
||||
* </ul>
|
||||
*
|
||||
* On success, returns a XML-RPC struct with single field:
|
||||
* <ul>
|
||||
* <li> trtok : string - transport 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_downloadFromArchive:
|
||||
* <message from lower layer> </li>
|
||||
* <li> 848 - invalid session id.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param input XMLRPC struct
|
||||
* @return XMLRPC struct
|
||||
* @see Pref::downloadFromArchive
|
||||
*/
|
||||
function xr_downloadFromArchive($input)
|
||||
{
|
||||
list($ok, $r) = $this->_xr_getPars($input);
|
||||
if(!$ok) return $r;
|
||||
require_once '../../../storageServer/var/Transport.php';
|
||||
$tr =& new Transport(&$this->dbc, &$this, $this->config);
|
||||
$res = $tr->downloadFromArchive($r['gunid'], $r['sessid']);
|
||||
if(PEAR::isError($res)){
|
||||
$ec0 = intval($res->getCode());
|
||||
$ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 );
|
||||
return new XML_RPC_Response(0, $ec,
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
);
|
||||
}
|
||||
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:
|
||||
* <ul>
|
||||
* <li> sessid : string - session id </li>
|
||||
* <li> trtok : string - transport token</li>
|
||||
* </ul>
|
||||
*
|
||||
* On success, returns a XML-RPC struct with the following fields:
|
||||
* <ul>
|
||||
* <li>trtype: string - audioclip | playlist</li>
|
||||
* <li>direction: string - up | down</li>
|
||||
* <li>status: boolean</li>
|
||||
* <li>expectedsize: int - expected size</li>
|
||||
* <li>realsize: int - size of transported file</li>
|
||||
* <li>expectedsum: string - expected checksum</li>
|
||||
* <li>realsum: string - checksum of transported file</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_getTransportInfo:
|
||||
* <message from lower layer> </li>
|
||||
* <li> 848 - invalid session id.</li>
|
||||
* <li> 872 - invalid tranport token.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @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 '../../../storageServer/var/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 */
|
||||
/**
|
||||
* Reset storageServer for debugging.
|
||||
*
|
||||
* The XML-RPC name of this method is "locstor.resetStorage".
|
||||
*
|
||||
* The input parameters are an empty XML-RPC struct.
|
||||
*
|
||||
* On success, returns a XML-RPC struct with following
|
||||
* fields:
|
||||
* <ul>
|
||||
* <li> audioclips : array -
|
||||
* array with gunids of inserted audioclips </li>
|
||||
* <li> playlists : array -
|
||||
* array with gunids of inserted playlists </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_resetStorage:
|
||||
* <message from lower layer> </li>
|
||||
* </ul>
|
||||
*
|
||||
* @param input XMLRPC struct
|
||||
* @return XMLRPC struct
|
||||
* @see LocStor::getAudioClip
|
||||
*/
|
||||
function xr_resetStorage($input)
|
||||
{
|
||||
list($ok, $r) = $this->_xr_getPars($input);
|
||||
if(!$ok) return $r;
|
||||
$res = $this->resetStorage();
|
||||
if(PEAR::isError($res)){
|
||||
return new XML_RPC_Response(0, 805,
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
);
|
||||
}
|
||||
return new XML_RPC_Response(XML_RPC_encode($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test XMLRPC - strupper and return given string,
|
||||
* also return loginname of logged user
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.17 $
|
||||
Version : $Revision: 1.18 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -117,6 +117,10 @@ $methods = array(
|
|||
'loadPref' => 'Load user preference value.',
|
||||
'savePref' => 'Save user preference value.',
|
||||
'delPref' => 'Delete user preference record.',
|
||||
|
||||
'uploadToArchive' => 'Starts upload audioclip to remote archive.',
|
||||
'downloadFromArchive' => 'Starts download audioclip from remote archive.',
|
||||
'getTransportInfo' => 'Checking status of transported file.',
|
||||
);
|
||||
|
||||
$defs = array();
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -122,6 +122,15 @@ $infos = array(
|
|||
'p'=>array('sessid', 'key', 'value'), 'r'=>'status'),
|
||||
"delPref" => array('m'=>"locstor.delPref",
|
||||
'p'=>array('sessid', 'key'), 'r'=>'status'),
|
||||
|
||||
"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()),
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue