Major changes in transport subsystem to accept playlists.

Transport audioclips rewritten.
This commit is contained in:
tomas 2005-01-19 05:22:20 +00:00
parent 3e40ad4707
commit b4d240a096
9 changed files with 1235 additions and 454 deletions

View file

@ -23,7 +23,7 @@
Author : $Author: tomas $ 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 $ 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_NOTF', 47);
define('GBERR_SESS', 48); define('GBERR_SESS', 48);
define('GBERR_PREF', 49); 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 "../../../alib/var/alib.php";
require_once "StoredFile.php"; require_once "StoredFile.php";
#require_once "Transport.php"; require_once "Transport.php";
/** /**
* BasicStor class * BasicStor class
@ -50,7 +52,7 @@ require_once "StoredFile.php";
* Core of LiveSupport file storage module * Core of LiveSupport file storage module
* *
* @author $Author: tomas $ * @author $Author: tomas $
* @version $Revision: 1.20 $ * @version $Revision: 1.21 $
* @see Alib * @see Alib
*/ */
class BasicStor extends Alib{ class BasicStor extends Alib{
@ -111,16 +113,17 @@ class BasicStor extends Alib{
* @param mdataFileLP string, local path of metadata file * @param mdataFileLP string, local path of metadata file
* @param gunid string, global unique id OPTIONAL * @param gunid string, global unique id OPTIONAL
* @param ftype string, internal file type * @param ftype string, internal file type
* @param mdataLoc string 'file'|'string' (optional)
* @return int * @return int
* @exception PEAR::error * @exception PEAR::error
*/ */
function bsPutFile($parid, $fileName, function bsPutFile($parid, $fileName, $mediaFileLP, $mdataFileLP,
$mediaFileLP, $mdataFileLP, $gunid=NULL, $ftype='unKnown') $gunid=NULL, $ftype='unKnown', $mdataLoc='file')
{ {
$name = "$fileName"; $name = "$fileName";
$id = $this->addObj($name , 'File', $parid); $id = $this->addObj($name , 'File', $parid);
$ac =& StoredFile::insert( $ac =& StoredFile::insert(
&$this, $id, $name, $mediaFileLP, $mdataFileLP, 'file', &$this, $id, $name, $mediaFileLP, $mdataFileLP, $mdataLoc,
$gunid, $ftype $gunid, $ftype
); );
if(PEAR::isError($ac)){ if(PEAR::isError($ac)){
@ -236,11 +239,12 @@ class BasicStor extends Alib{
* Delete file * Delete file
* *
* @param id int, virt.file's local id * @param id int, virt.file's local id
* @param forced boolean, unconditional delete
* @return true or PEAR::error * @return true or PEAR::error
*/ */
function bsDeleteFile($id) function bsDeleteFile($id, $forced=FALSE)
{ {
$res = $this->removeObj($id); $res = $this->removeObj($id, $forced);
return $res; return $res;
} }
@ -353,7 +357,8 @@ class BasicStor extends Alib{
* *
* @param id int, virt.file's local id * @param id int, virt.file's local id
* @param part string, 'media'|'metadata' * @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') function bsOpenDownload($id, $part='media')
{ {
@ -361,18 +366,31 @@ class BasicStor extends Alib{
if(PEAR::isError($ac)) return $ac; if(PEAR::isError($ac)) return $ac;
$gunid = $ac->gunid; $gunid = $ac->gunid;
switch($part){ switch($part){
case"media": case"media":
$fname = $ac->_getRealRADFname(); $realfile = $ac->_getRealRADFname();
$ext = $ac->_getExt(); $ext = $ac->_getExt();
break; $filename = $ac->_getFileName();
case"metadata": break;
$fname = $ac->_getRealMDFname(); case"metadata":
$ext = "xml"; $realfile = $ac->_getRealMDFname();
break; $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']); $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 = ''; $ext = '';
$token = StoredFile::_createGunid(); $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(" $res = $this->dbc->query("
INSERT INTO {$this->accessTable} INSERT INTO {$this->accessTable}
(gunid, token, ext, chsum, type, ts) (gunid, token, ext, chsum, type, ts)
@ -426,9 +448,11 @@ class BasicStor extends Alib{
*/ */
function bsClosePut($token) function bsClosePut($token)
{ {
$token = StoredFile::_normalizeGunid($token);
if(!$this->bsCheckToken($token, 'put')){ if(!$this->bsCheckToken($token, 'put')){
return PEAR::raiseError( return PEAR::raiseError(
"BasicStor::bsClosePut: invalid token ($token)" "BasicStor::bsClosePut: invalid token ($token)",
GBERR_TOKEN
); );
} }
$chsum = $this->dbc->getOne(" $chsum = $this->dbc->getOne("
@ -444,12 +468,47 @@ class BasicStor extends Alib{
if($chsum != $md5sum){ if($chsum != $md5sum){
if(file_exists($fname)) @unlink($fname); if(file_exists($fname)) @unlink($fname);
return PEAR::raiseError( return PEAR::raiseError(
"BasicStor::bsClosePut: md5sum does not match (token=$token)" "BasicStor::bsClosePut: md5sum does not match (token=$token)",
GBERR_PUT
); );
} }
return $fname; 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 * Return starting part of storageServer URL
* *
@ -644,7 +703,7 @@ class BasicStor extends Alib{
if($v['type'] == 'File'){ if($v['type'] == 'File'){
$gunid = $this->_gunidFromId($v['id']); $gunid = $this->_gunidFromId($v['id']);
$listArr[$i]['type'] = $listArr[$i]['type'] =
StoredFile::_getType($gunid); $this->_getType($gunid);
$listArr[$i]['gunid'] = $gunid; $listArr[$i]['gunid'] = $gunid;
if(StoredFIle::_getState($gunid) == 'incomplete') if(StoredFIle::_getState($gunid) == 'incomplete')
unset($listArr[$i]); unset($listArr[$i]);
@ -725,12 +784,47 @@ class BasicStor extends Alib{
$type = $this->getObjName($oid, 'type'); $type = $this->getObjName($oid, 'type');
if($type == 'File'){ if($type == 'File'){
$ftype = $ftype =
StoredFile::_getType($this->_gunidFromId($oid)); $this->_getType($this->_gunidFromId($oid));
if(!is_null($ftype)) $type=$ftype; if(!is_null($ftype)) $type=$ftype;
} }
return $type; 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 */ /* ==================================================== "private" methods */
/** /**
* Check authorization - auxiliary method * Check authorization - auxiliary method
@ -767,6 +861,10 @@ class BasicStor extends Alib{
$parid = $this->getObjId( $parid = $this->getObjId(
$this->getSessLogin($sessid), $this->storId $this->getSessLogin($sessid), $this->storId
); );
if(is_null($parid)){
return PEAR::raiseError("BasicStor::_getHomeDirId: ".
"homedir not found", GBERR_NOTF);
}
return $parid; return $parid;
} }
@ -801,6 +899,21 @@ class BasicStor extends Alib{
return StoredFile::_normalizeGunid($gunid); 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 */ /* ------------------------------------------ redefined "private" methods */
/** /**
* Copy virtual file.<br> * Copy virtual file.<br>
@ -845,21 +958,22 @@ class BasicStor extends Alib{
* Redefined from parent class. * Redefined from parent class.
* *
* @param id int, local id of removed object * @param id int, local id of removed object
* @param forced boolean, unconditional delete
* @return true or PEAR::error * @return true or PEAR::error
*/ */
function removeObj($id) function removeObj($id, $forced=FALSE)
{ {
switch($ot = $this->getObjType($id)){ switch($ot = $this->getObjType($id)){
case"audioclip": case"audioclip":
case"playlist": case"playlist":
$ac =& StoredFile::recall(&$this, $id); $ac =& StoredFile::recall(&$this, $id);
if(PEAR::isError($ac)) return $ac; if(PEAR::isError($ac)) return $ac;
if($ac->isEdited()){ if($ac->isEdited() && !$forced){
return PEAR::raiseError( return PEAR::raiseError(
'BasicStor.php: removeObj: is edited' 'BasicStor.php: removeObj: is edited'
); );
} }
if($ac->isAccessed()){ if($ac->isAccessed() && !$forced){
return PEAR::raiseError( return PEAR::raiseError(
'BasicStor.php: removeObj: is accessed' 'BasicStor.php: removeObj: is accessed'
); );
@ -923,7 +1037,7 @@ class BasicStor extends Alib{
// $this->dbc->query("DELETE FROM {$this->filesTable}"); // $this->dbc->query("DELETE FROM {$this->filesTable}");
$ids = $this->dbc->getAll("SELECT id FROM {$this->filesTable}"); $ids = $this->dbc->getAll("SELECT id FROM {$this->filesTable}");
if(is_array($ids)) foreach($ids as $i=>$item){ if(is_array($ids)) foreach($ids as $i=>$item){
$this->bsDeleteFile($item['id']); $this->bsDeleteFile($item['id'], TRUE);
} }
parent::deleteData(); parent::deleteData();
$this->initData(); $this->initData();

View file

@ -23,7 +23,7 @@
Author : $Author: tomas $ 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 $ 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 * LiveSupport file storage module
* *
* @author $Author: tomas $ * @author $Author: tomas $
* @version $Revision: 1.23 $ * @version $Revision: 1.24 $
* @see BasicStor * @see BasicStor
*/ */
class GreenBox extends BasicStor{ class GreenBox extends BasicStor{
@ -278,41 +278,6 @@ class GreenBox extends BasicStor{
/* ---------------------------------------------------- redefined methods */ /* ---------------------------------------------------- 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 * Get file's path in virtual filesystem
* *

View file

@ -23,7 +23,7 @@
Author : $Author: tomas $ 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 $ 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 * @param chsum string, md5 checksum of media file
* @return struct {url:writable URL for HTTP PUT, token:access token * @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: // test if specified gunid exists:
if(!preg_match("|^([0-9a-fA-F]{16})?$|", $gunid)){ if(!preg_match("|^([0-9a-fA-F]{16})?$|", $gunid)){
@ -59,8 +61,9 @@ class LocStor extends BasicStor{
$ac =& StoredFile::recallByGunid(&$this, $gunid); $ac =& StoredFile::recallByGunid(&$this, $gunid);
if(!PEAR::isError($ac)){ if(!PEAR::isError($ac)){
// gunid exists - do replace // gunid exists - do replace
$oid = $ac->getId();
if(($res = $this->_authorize( if(($res = $this->_authorize(
'write', $ac->getId(), $sessid 'write', $oid, $sessid
)) !== TRUE) return $res; )) !== TRUE) return $res;
if($ac->isAccessed()){ if($ac->isAccessed()){
return PEAR::raiseError( return PEAR::raiseError(
@ -68,7 +71,7 @@ class LocStor extends BasicStor{
); );
} }
$res = $ac->replace( $res = $ac->replace(
$ac->getId(), $ac->name, '', $metadata, 'string' $oid, $ac->name, '', $metadata, 'string'
); );
if(PEAR::isError($res)) return $res; if(PEAR::isError($res)) return $res;
}else{ }else{
@ -82,7 +85,7 @@ class LocStor extends BasicStor{
if(PEAR::isError($oid)) return $oid; if(PEAR::isError($oid)) return $oid;
$ac =& StoredFile::insert( $ac =& StoredFile::insert(
&$this, $oid, '', '', $metadata, 'string', &$this, $oid, '', '', $metadata, 'string',
$gunid, 'audioclip' $gunid, $ftype
); );
if(PEAR::isError($ac)){ if(PEAR::isError($ac)){
$res = $this->removeObj($oid); $res = $this->removeObj($oid);
@ -121,6 +124,17 @@ class LocStor extends BasicStor{
return $ac->gunid; 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 */ /* --------------------------------------------------------------- access */
/** /**
* Make access to audio clip * Make access to audio clip
@ -158,16 +172,18 @@ class LocStor extends BasicStor{
* *
* @param sessid string, session id * @param sessid string, session id
* @param gunid string, global unique 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) function downloadRawAudioDataOpen($sessid, $gunid)
{ {
$res = $this->existsAudioClip($sessid, $gunid); $ex = $this->existsAudioClip($sessid, $gunid);
if(PEAR::isError($res)) return $res; if(PEAR::isError($ex)) return $ex;
$id = $this->_idFromGunid($gunid); $id = $this->_idFromGunid($gunid);
if(is_null($id)){ if(is_null($id) || !$ex){
return PEAR::raiseError( 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) if(($res = $this->_authorize('read', $id, $sessid)) !== TRUE)
@ -191,12 +207,13 @@ class LocStor extends BasicStor{
* *
* @param sessid string, session id * @param sessid string, session id
* @param gunid string, global unique 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) function downloadMetadataOpen($sessid, $gunid)
{ {
$res = $this->existsAudioClip($sessid, $gunid); # $res = $this->existsAudioClip($sessid, $gunid);
if(PEAR::isError($res)) return $res; # if(PEAR::isError($res)) return $res;
$id = $this->_idFromGunid($gunid); $id = $this->_idFromGunid($gunid);
if(is_null($id)){ if(is_null($id)){
return PEAR::raiseError( return PEAR::raiseError(
@ -205,7 +222,9 @@ class LocStor extends BasicStor{
} }
if(($res = $this->_authorize('read', $id, $sessid)) !== TRUE) if(($res = $this->_authorize('read', $id, $sessid)) !== TRUE)
return $res; 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; 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) if(($res = $this->_authorize('read', $ac->getId(), $sessid)) !== TRUE)
return $res; return $res;
return TRUE; return TRUE;
@ -399,6 +418,10 @@ class LocStor extends BasicStor{
function resetStorage($input='') function resetStorage($input='')
{ {
$this->deleteData(); $this->deleteData();
if(!$this->config['isArchive']){
$tr =& new Transport($this->dbc, $this, $this->config);
$tr->resetData();
}
$rootHD = $this->getObjId('root', $this->storId); $rootHD = $this->getObjId('root', $this->storId);
include"../tests/sampleData.php"; include"../tests/sampleData.php";
$res = array('audioclips'=>array(), 'playlists'=>array()); $res = array('audioclips'=>array(), 'playlists'=>array());
@ -483,7 +506,8 @@ class LocStor extends BasicStor{
* *
* @param sessid string, session ID * @param sessid string, session ID
* @param playlistId string, playlist global unique 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) function editPlaylist($sessid, $playlistId)
{ {
@ -505,6 +529,7 @@ class LocStor extends BasicStor{
$res = $this->bsOpenDownload($id, 'metadata'); $res = $this->bsOpenDownload($id, 'metadata');
if(PEAR::isError($res)){ return $res; } if(PEAR::isError($res)){ return $res; }
$this->_setEditFlag($playlistId, TRUE); $this->_setEditFlag($playlistId, TRUE);
unset($res['filename']);
return $res; return $res;
} }
@ -557,7 +582,8 @@ class LocStor extends BasicStor{
* *
* @param sessid string, session ID * @param sessid string, session ID
* @param playlistId string, playlist global unique 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) function accessPlaylist($sessid, $playlistId)
{ {
@ -565,13 +591,16 @@ class LocStor extends BasicStor{
if(PEAR::isError($ex)){ return $ex; } if(PEAR::isError($ex)){ return $ex; }
if(!$ex){ if(!$ex){
return PEAR::raiseError( return PEAR::raiseError(
'LocStor.php: accessPlaylist: playlist not found' "LocStor.php: accessPlaylist: playlist not found ($playlistId)",
GBERR_NOTF
); );
} }
$id = $this->_idFromGunid($playlistId); $id = $this->_idFromGunid($playlistId);
if(($res = $this->_authorize('read', $id, $sessid)) !== TRUE) if(($res = $this->_authorize('read', $id, $sessid)) !== TRUE)
return $res; return $res;
return $this->bsOpenDownload($id, 'metadata'); $res = $this->bsOpenDownload($id, 'metadata');
unset($res['filename']);
return $res;
} }
/** /**

View file

@ -23,7 +23,7 @@
Author : $Author: tomas $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/StoredFile.php,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -93,7 +93,7 @@ class StoredFile{
$ac->mime = "unKnown"; $ac->mime = "unKnown";
$emptyState = TRUE; $emptyState = TRUE;
if($ac->name=='') $ac->name=$ac->gunid; if($ac->name=='') $ac->name=$ac->gunid;
$this->dbc->query("BEGIN"); $ac->dbc->query("BEGIN");
$res = $ac->dbc->query(" $res = $ac->dbc->query("
INSERT INTO {$ac->filesTable} INSERT INTO {$ac->filesTable}
(id, name, gunid, mime, state, ftype) (id, name, gunid, mime, state, ftype)
@ -101,7 +101,7 @@ class StoredFile{
('$oid', '{$ac->name}', x'{$ac->gunid}'::bigint, ('$oid', '{$ac->name}', x'{$ac->gunid}'::bigint,
'{$ac->mime}', 'incomplete', '$ftype') '{$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: // --- metadata insert:
if($metadata != ''){ if($metadata != ''){
if($mdataLoc=='file' && !file_exists($metadata)) if($mdataLoc=='file' && !file_exists($metadata))
@ -111,7 +111,7 @@ class StoredFile{
} }
$res = $ac->md->insert($metadata, $mdataLoc); $res = $ac->md->insert($metadata, $mdataLoc);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$this->dbc->query("ROLLBACK"); return $res; $ac->dbc->query("ROLLBACK"); return $res;
} }
$emptyState = FALSE; $emptyState = FALSE;
} }
@ -124,7 +124,7 @@ class StoredFile{
} }
$res = $ac->rmd->insert($mediaFileLP); $res = $ac->rmd->insert($mediaFileLP);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$this->dbc->query("ROLLBACK"); return $res; $ac->dbc->query("ROLLBACK"); return $res;
} }
$mime = $ac->rmd->getMime(); $mime = $ac->rmd->getMime();
//$gb->debugLog("gunid={$ac->gunid}, mime=$mime"); //$gb->debugLog("gunid={$ac->gunid}, mime=$mime");
@ -140,8 +140,8 @@ class StoredFile{
$res = $ac->setState('ready'); $res = $ac->setState('ready');
if(PEAR::isError($res)){ $ac->dbc->query("ROLLBACK"); return $res; } if(PEAR::isError($res)){ $ac->dbc->query("ROLLBACK"); return $res; }
} }
$res = $this->dbc->query("COMMIT"); $res = $ac->dbc->query("COMMIT");
if(PEAR::isError($res)){ $this->dbc->query("ROLLBACK"); return $res; } if(PEAR::isError($res)){ $ac->dbc->query("ROLLBACK"); return $res; }
return $ac; return $ac;
} }
@ -224,7 +224,7 @@ class StoredFile{
{ {
$ac =& StoredFile::insert( $ac =& StoredFile::insert(
&$src->gb, $nid, $src->name, $src->_getRealRADFname(), &$src->gb, $nid, $src->name, $src->_getRealRADFname(),
'', '', NULL, $src->_getType() '', '', NULL, $src->gb->_getType($src->gunid)
); );
if(PEAR::isError($ac)) return $ac; if(PEAR::isError($ac)) return $ac;
$ac->md->replace($src->md->getMetaData(), 'string'); $ac->md->replace($src->md->getMetaData(), 'string');
@ -256,7 +256,7 @@ class StoredFile{
$this->dbc->query("ROLLBACK"); return $res; $this->dbc->query("ROLLBACK"); return $res;
} }
if($metadata != ''){ // metadata if($metadata != ''){ // metadata
$res = $this->md->replace($metadata, $mdataLoc); $res = $this->replaceMetaData($metadata, $mdataLoc);
}else{ }else{
$res = $this->md->delete(); $res = $this->md->delete();
} }
@ -495,6 +495,7 @@ class StoredFile{
SELECT to_hex(gunid) FROM {$this->filesTable} SELECT to_hex(gunid) FROM {$this->filesTable}
WHERE gunid=x'{$this->gunid}'::bigint WHERE gunid=x'{$this->gunid}'::bigint
"); ");
if(PEAR::isError($indb)) return $indb;
return (!is_null($indb) && $this->rmd->exists()); 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 * Get storage-internal file state
* *
@ -639,8 +624,9 @@ class StoredFile{
function _getResDir() function _getResDir()
{ {
$resDir="{$this->gb->storageDir}/".substr($this->gunid, 0, 3); $resDir="{$this->gb->storageDir}/".substr($this->gunid, 0, 3);
#$this->gb->debugLog("$resDir");
// see Transport::_getResDir too for resDir name create code // 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; return $resDir;
} }
@ -671,6 +657,7 @@ class StoredFile{
*/ */
function _getAccessFname($token, $ext='EXT') function _getAccessFname($token, $ext='EXT')
{ {
$token = StoredFile::_normalizeGunid($token);
return "{$this->accessDir}/$token.$ext"; return "{$this->accessDir}/$token.$ext";
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,6 @@
#!/usr/bin/php -q #!/usr/bin/php -q
<?php <?php
chdir(dirname(__FILE__));
require_once "../conf.php"; require_once "../conf.php";
require_once "DB.php"; require_once "DB.php";
require_once '../LocStor.php'; require_once '../LocStor.php';
@ -9,8 +10,21 @@ $dbc = DB::connect($config['dsn'], TRUE);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC); $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb = &new LocStor(&$dbc, $config); $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);
?> ?>

View file

@ -23,7 +23,7 @@
Author : $Author: tomas $ 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 $ 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> sessid : string - session id </li>
* <li> gunid : string - global unique id of AudioCLip</li> * <li> gunid : string - global unique id of AudioCLip</li>
* <li> metadata : string - metadata XML string</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> * with extension corresponding to filetype</li>
* <li> chsum : string - md5 checksum of media file</li> * <li> chsum : string - md5 checksum of media file</li>
* </ul> * </ul>
@ -254,6 +254,7 @@ class XR_LocStor extends LocStor{
* <li> 801 - wrong 1st parameter, struct expected.</li> * <li> 801 - wrong 1st parameter, struct expected.</li>
* <li> 805 - xr_storeAudioClipClose: * <li> 805 - xr_storeAudioClipClose:
* &lt;message from lower layer&gt; </li> * &lt;message from lower layer&gt; </li>
* <li> 850 - wrong 1st parameter, struct expected.</li>
* </ul> * </ul>
* *
* @param input XMLRPC struct * @param input XMLRPC struct
@ -266,7 +267,9 @@ class XR_LocStor extends LocStor{
if(!$ok) return $r; if(!$ok) return $r;
$res = $this->storeAudioClipClose($r['sessid'], $r['token']); $res = $this->storeAudioClipClose($r['sessid'], $r['token']);
if(PEAR::isError($res)){ 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(). "xr_storeAudioClipClose: ".$res->getMessage().
" ".$res->getUserInfo() " ".$res->getUserInfo()
); );
@ -384,6 +387,9 @@ class XR_LocStor extends LocStor{
* <ul> * <ul>
* <li> url : string - downloadable url</li> * <li> url : string - downloadable url</li>
* <li> token : string - download token</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> * </ul>
* *
* On errors, returns an XML-RPC error response. * 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> 801 - wrong 1st parameter, struct expected.</li>
* <li> 805 - xr_accessRawAudioDataOpen: * <li> 805 - xr_accessRawAudioDataOpen:
* &lt;message from lower layer&gt; </li> * &lt;message from lower layer&gt; </li>
* <li> 847 - invalid gunid.</li>
* </ul> * </ul>
* *
* @param input XMLRPC struct * @param input XMLRPC struct
@ -406,7 +413,9 @@ class XR_LocStor extends LocStor{
if(!$ok) return $r; if(!$ok) return $r;
$res = $this->downloadRawAudioDataOpen($r['sessid'], $r['gunid']); $res = $this->downloadRawAudioDataOpen($r['sessid'], $r['gunid']);
if(PEAR::isError($res)){ 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(). "xr_downloadRawAudioDataOpen: ".$res->getMessage().
" ".$res->getUserInfo() " ".$res->getUserInfo()
); );
@ -477,6 +486,8 @@ class XR_LocStor extends LocStor{
* <ul> * <ul>
* <li> url : string - downloadable url</li> * <li> url : string - downloadable url</li>
* <li> token : string - download token</li> * <li> token : string - download token</li>
* <li> chsum : string - md5 checksum</li>
* <li> filename : string - mnemonic filename</li>
* </ul> * </ul>
* *
* On errors, returns an XML-RPC error response. * On errors, returns an XML-RPC error response.
@ -497,6 +508,7 @@ class XR_LocStor extends LocStor{
{ {
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
#$this->debugLog("{$r['sessid']}, {$r['gunid']}");
$res = $this->downloadMetadataOpen($r['sessid'], $r['gunid']); $res = $this->downloadMetadataOpen($r['sessid'], $r['gunid']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
return new XML_RPC_Response(0, 805, return new XML_RPC_Response(0, 805,
@ -663,6 +675,7 @@ class XR_LocStor extends LocStor{
* <ul> * <ul>
* <li> url : string - readable url</li> * <li> url : string - readable url</li>
* <li> token : string - playlist token</li> * <li> token : string - playlist token</li>
* <li> chsum : string - md5 checksum</li>
* </ul> * </ul>
* *
* On errors, returns an XML-RPC error response. * On errors, returns an XML-RPC error response.
@ -802,6 +815,7 @@ class XR_LocStor extends LocStor{
* <ul> * <ul>
* <li> url : string - readable url</li> * <li> url : string - readable url</li>
* <li> token : string - playlist token</li> * <li> token : string - playlist token</li>
* <li> chsum : string - md5 checksum</li>
* </ul> * </ul>
* *
* On errors, returns an XML-RPC error response. * 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> 801 - wrong 1st parameter, struct expected.</li>
* <li> 805 - xr_accessPlaylist: * <li> 805 - xr_accessPlaylist:
* &lt;message from lower layer&gt; </li> * &lt;message from lower layer&gt; </li>
* <li> 847 - invalid plid.</li>
* </ul> * </ul>
* *
* @param input XMLRPC struct * @param input XMLRPC struct
@ -824,7 +839,9 @@ class XR_LocStor extends LocStor{
if(!$ok) return $r; if(!$ok) return $r;
$res = $this->accessPlaylist($r['sessid'], $r['plid']); $res = $this->accessPlaylist($r['sessid'], $r['plid']);
if(PEAR::isError($res)){ 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(). "xr_accessPlaylist: ".$res->getMessage().
" ".$res->getUserInfo() " ".$res->getUserInfo()
); );
@ -970,7 +987,7 @@ class XR_LocStor extends LocStor{
return new XML_RPC_Response(XML_RPC_encode(array('available'=>$res))); return new XML_RPC_Response(XML_RPC_encode(array('available'=>$res)));
} }
/* ----------------------------------------------------------------- etc. */ /* --------------------------------------------------------- info methods */
/** /**
* Check if audio clip exists and return TRUE/FALSE * 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))); return new XML_RPC_Response(XML_RPC_encode(array('exists'=>$res)));
} }
/* ----------------------------------------------------- metadata methods */
/** /**
* Return all file's metadata as XML string * 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)); return new XML_RPC_Response(XML_RPC_encode($res));
} }
/** /* ---------------------------------------------- methods for preferences */
* 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:
* &lt;message from lower layer&gt; </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));
}
/** /**
* Load user preference value * Load user preference value
* *
@ -1265,8 +1241,9 @@ class XR_LocStor extends LocStor{
$pr =& new Prefs(&$this); $pr =& new Prefs(&$this);
$res = $pr->loadPref($r['sessid'], $r['key']); $res = $pr->loadPref($r['sessid'], $r['key']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec = intval($res->getCode()); $ec0 = intval($res->getCode());
return new XML_RPC_Response(0, 800+($ec == 48 || $ec == 49 ? $ec : 5 ), $ec = ($ec0 == GBERR_SESS || $ec0 == GBERR_PREF ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec,
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
); );
@ -1315,9 +1292,9 @@ class XR_LocStor extends LocStor{
$pr =& new Prefs(&$this); $pr =& new Prefs(&$this);
$res = $pr->savePref($r['sessid'], $r['key'], $r['value']); $res = $pr->savePref($r['sessid'], $r['key'], $r['value']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
#return new XML_RPC_Response(0, 805, $ec0 = intval($res->getCode());
$ec = intval($res->getCode()); $ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, 800+($ec == 48 ? $ec : 5 ), return new XML_RPC_Response(0, $ec,
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
); );
} }
@ -1365,16 +1342,214 @@ class XR_LocStor extends LocStor{
$pr =& new Prefs(&$this); $pr =& new Prefs(&$this);
$res = $pr->delPref($r['sessid'], $r['key']); $res = $pr->delPref($r['sessid'], $r['key']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
#return new XML_RPC_Response(0, 805, $ec0 = intval($res->getCode());
$ec = intval($res->getCode()); $ec = ($ec0 == GBERR_SESS || $ec0 == GBERR_PREF ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, 800+($ec == 48 || $ec == 49 ? $ec : 5 ), return new XML_RPC_Response(0, $ec,
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
); );
} }
return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); 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:
* &lt;message from lower layer&gt; </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:
* &lt;message from lower layer&gt; </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:
* &lt;message from lower layer&gt; </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:
* &lt;message from lower layer&gt; </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, * Test XMLRPC - strupper and return given string,
* also return loginname of logged user * also return loginname of logged user

View file

@ -23,7 +23,7 @@
Author : $Author: tomas $ 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 $ 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.', 'loadPref' => 'Load user preference value.',
'savePref' => 'Save user preference value.', 'savePref' => 'Save user preference value.',
'delPref' => 'Delete user preference record.', '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(); $defs = array();

View file

@ -23,7 +23,7 @@
Author : $Author: tomas $ 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 $ 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'), 'p'=>array('sessid', 'key', 'value'), 'r'=>'status'),
"delPref" => array('m'=>"locstor.delPref", "delPref" => array('m'=>"locstor.delPref",
'p'=>array('sessid', 'key'), 'r'=>'status'), '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()), "openPut" => array('m'=>"locstor.openPut", 'p'=>array()),
"closePut" => array('m'=>"locstor.closePut", 'p'=>array()), "closePut" => array('m'=>"locstor.closePut", 'p'=>array()),
); );