minor changes
This commit is contained in:
parent
bc954ea07b
commit
c0ccb18a82
6 changed files with 75 additions and 44 deletions
|
@ -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/BasicStor.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -48,7 +48,7 @@ require_once "Transport.php";
|
|||
* Core of LiveSupport file storage module
|
||||
*
|
||||
* @author $Author: tomas $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see Alib
|
||||
*/
|
||||
class BasicStor extends Alib{
|
||||
|
@ -261,7 +261,7 @@ class BasicStor extends Alib{
|
|||
*
|
||||
* @param token string, access token
|
||||
* @param type string 'access'|'download'
|
||||
* @return boolean
|
||||
* @return string, global unique ID
|
||||
*/
|
||||
function bsRelease($token, $type='access')
|
||||
{
|
||||
|
@ -270,11 +270,13 @@ class BasicStor extends Alib{
|
|||
"BasicStor::bsRelease: invalid token ($token)"
|
||||
);
|
||||
}
|
||||
$ext = $this->dbc->getOne("
|
||||
SELECT ext FROM {$this->accessTable}
|
||||
$acc = $this->dbc->getRow("
|
||||
SELECT gunid, ext FROM {$this->accessTable}
|
||||
WHERE token='{$token}' AND type='$type'
|
||||
");
|
||||
if(PEAR::isError($ext)){ return $ext; }
|
||||
$ext = $acc['ext'];
|
||||
$gunid = $acc['gunid'];
|
||||
if(PEAR::isError($acc)){ return $acc; }
|
||||
$linkFname = "{$this->accessDir}/$token.$ext";
|
||||
$res = $this->dbc->query("
|
||||
DELETE FROM {$this->accessTable} WHERE token='$token'
|
||||
|
@ -285,7 +287,7 @@ class BasicStor extends Alib{
|
|||
"BasicStor::bsRelease: unlink failed ($linkFname)",
|
||||
GBERR_FILEIO);
|
||||
}
|
||||
return TRUE;
|
||||
return $gunid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -331,7 +333,7 @@ class BasicStor extends Alib{
|
|||
*
|
||||
* @param token string, download token
|
||||
* @param part string, 'media'|'metadata'
|
||||
* @return boolean
|
||||
* @return string, gunid
|
||||
*/
|
||||
function bsCloseDownload($token, $part='media')
|
||||
{
|
||||
|
@ -534,15 +536,27 @@ class BasicStor extends Alib{
|
|||
* Mode is "match all" or "match any".
|
||||
* Query parts is array of [fieldname, operator, value] entities.
|
||||
*
|
||||
* @param searchData string, search query -
|
||||
* @param criteria string, search query -
|
||||
* only one SQL LIKE term supported now.
|
||||
* It will be searched in all literal object values
|
||||
* in metadata database
|
||||
* @return array of gunid strings
|
||||
*/
|
||||
function bsLocalSearch($searchData)
|
||||
function bsLocalSearch($criteria)
|
||||
{
|
||||
$ftsrch = $searchData;
|
||||
$ops = array('full'=>"like '%s'", 'partial'=>"like '%%%s%%'", 'prefix'=>"like '%s%%'",
|
||||
'<'=>"< '%s'", '='=>"= '%s'", '>'=>"> '%s'", '<='=>"<= '%s'", '>='=>">= '%s'"
|
||||
);
|
||||
# var_dump($criteria);
|
||||
$type = $criteria['type'];
|
||||
$conds = $criteria['conds'];
|
||||
foreach($conds as $cond){
|
||||
$cat = $cond['cat'];
|
||||
$opVal = sprintf($ops[$cond['op']], $cond['val']);
|
||||
$sqlCond = "$cat $opVal";
|
||||
echo "$sqlCond\n";
|
||||
}
|
||||
$ftsrch = $criteria;
|
||||
$res = $this->dbc->getCol("SELECT md.gunid as gunid
|
||||
FROM {$this->filesTable} f, {$this->mdataTable} md
|
||||
WHERE f.gunid=md.gunid AND md.objns='_L' AND
|
||||
|
@ -761,11 +775,11 @@ class BasicStor extends Alib{
|
|||
/**
|
||||
* Search in central metadata database
|
||||
*
|
||||
* @param searchData string, search query - see localSearch method
|
||||
* @param criteria string, search query - see localSearch method
|
||||
* @param sessid string, session id
|
||||
* @return string - job id or PEAR::error
|
||||
*/
|
||||
function globalSearch($searchData, $sessid='')
|
||||
function globalSearch($criteria, $sessid='')
|
||||
{
|
||||
return PEAR::raiseError(
|
||||
'GreenBox::globalSearch: not implemented', GBERR_NOTIMPL
|
||||
|
@ -773,7 +787,7 @@ class BasicStor extends Alib{
|
|||
/*
|
||||
$srchid = md5($sessid.mtime());
|
||||
$fh = fopen($this->transDir."/$srchid", "w");
|
||||
fwrite($fh, serialize($searchData));
|
||||
fwrite($fh, serialize($criteria));
|
||||
fclose($fh);
|
||||
$res = $tr->uploadOpen($srchid, 'search', $sessid, $gunid);
|
||||
if(PEAR::isError($res)) return $res;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.11 $
|
||||
Version : $Revision: 1.12 $
|
||||
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.11 $
|
||||
* @version $Revision: 1.12 $
|
||||
* @see BasicStor
|
||||
*/
|
||||
class GreenBox extends BasicStor{
|
||||
|
@ -300,16 +300,16 @@ class GreenBox extends BasicStor{
|
|||
* Query parts is array of [fieldname, operator, value] entities.
|
||||
*
|
||||
*
|
||||
* @param searchData string, search query -
|
||||
* @param criteria string, search query -
|
||||
* only one SQL LIKE term supported now.
|
||||
* It will be searched in all literal object values
|
||||
* in metadata database
|
||||
* @param sessid string, session id
|
||||
* @return array of gunid strings
|
||||
*/
|
||||
function localSearch($searchData, $sessid='')
|
||||
function localSearch($criteria, $sessid='')
|
||||
{
|
||||
return $this->bsLocalSearch($searchData);
|
||||
return $this->bsLocalSearch($criteria);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------- info methods */
|
||||
|
@ -456,6 +456,20 @@ class GreenBox extends BasicStor{
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return users's home folder local ID
|
||||
*
|
||||
* @param sessid string, session ID
|
||||
* @return local folder id
|
||||
*/
|
||||
function _getHomeDirId($sessid)
|
||||
{
|
||||
$parid = $this->getObjId(
|
||||
$this->getSessLogin($sessid), $this->storId
|
||||
);
|
||||
return $parid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check authorization - auxiliary method
|
||||
*
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.9 $
|
||||
Version : $Revision: 1.10 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/LocStor.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -67,9 +67,7 @@ class LocStor extends GreenBox{
|
|||
}else{
|
||||
// gunid doesn't exists - do insert
|
||||
$tmpid = uniqid('');
|
||||
$parid = $this->getObjId(
|
||||
$this->getSessLogin($sessid), $this->storId
|
||||
);
|
||||
$parid = $this->_getHomeDirId($sessid);
|
||||
if(PEAR::isError($parid)) return $parid;
|
||||
if(($res = $this->_authorize('write', $parid, $sessid)) !== TRUE)
|
||||
return $res;
|
||||
|
@ -168,7 +166,7 @@ class LocStor extends GreenBox{
|
|||
* Discard downloadable URL for audio file
|
||||
*
|
||||
* @param token string, download token
|
||||
* @return boolean
|
||||
* @return string, gunid
|
||||
*/
|
||||
function downloadRawAudioDataClose($token)
|
||||
{
|
||||
|
@ -201,7 +199,7 @@ class LocStor extends GreenBox{
|
|||
* Discard downloadable URL for metadata
|
||||
*
|
||||
* @param token string, download token
|
||||
* @return boolean
|
||||
* @return string, gunid
|
||||
*/
|
||||
function downloadMetadataClose($token)
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.7 $
|
||||
Version : $Revision: 1.8 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/StoredFile.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -329,6 +329,7 @@ class StoredFile{
|
|||
*
|
||||
* @param metadata string, local path to metadata XML file or XML string
|
||||
* @param mdataLoc string 'file'|'string'
|
||||
* @return boolean
|
||||
*/
|
||||
function replaceMetaData($metadata, $mdataLoc='file')
|
||||
{
|
||||
|
@ -457,11 +458,11 @@ class StoredFile{
|
|||
if(PEAR::isError($res)) return $res;
|
||||
$res = $this->md->delete();
|
||||
if(PEAR::isError($res)) return $res;
|
||||
$tokens = $this->dbc->getAll("SELECT token FROM {$this->accessTable}
|
||||
$tokens = $this->dbc->getAll("SELECT token, ext FROM {$this->accessTable}
|
||||
WHERE gunid='{$this->gunid}'");
|
||||
if(is_array($tokens)) foreach($tokens as $i=>$item){
|
||||
$file = _getAccessFname($item['token'], $item['ext']);
|
||||
@unlink($file);
|
||||
$file = $this->_getAccessFname($item['token'], $item['ext']);
|
||||
if(file_exists($file)){ @unlink($file); }
|
||||
}
|
||||
$res = $this->dbc->query("DELETE FROM {$this->accessTable}
|
||||
WHERE gunid='{$this->gunid}'");
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#
|
||||
#
|
||||
# Author : $Author: tomas $
|
||||
# Version : $Revision: 1.7 $
|
||||
# Version : $Revision: 1.8 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh,v $
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
@ -60,12 +60,13 @@ storeAudioClip() {
|
|||
# echo -n "# storeAudioClip: "
|
||||
# MEDIA=../tests/ex1.mp3
|
||||
MEDIA=var/tests/ex1.mp3
|
||||
METADATA=../tests/testStorage.xml
|
||||
# METADATA=var/tests/mdata4.xml
|
||||
# RGUNID=`$XR_CLI storeAudioClip "$SESSID" '' "$MEDIA" "$METADATA"` || \
|
||||
# { ERN=$?; echo $RGUNID; exit $ERN; }
|
||||
MD5=`md5sum $MEDIA`; for i in $MD5; do MD5=$i; break; done
|
||||
echo "md5=$MD5"
|
||||
echo -n "# storeAudioClipOpen: "
|
||||
RES=`$XR_CLI storeAudioClipOpen "$SESSID" '' '<metadata><title>Title XY</title></metadata>' "$MD5"` || \
|
||||
RES=`$XR_CLI storeAudioClipOpen "$SESSID" '' '<metadata><title>ěščřžé</title></metadata>' "$MD5"` || \
|
||||
{ ERN=$?; echo $RES; exit $ERN; }
|
||||
unset URL
|
||||
for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#
|
||||
#
|
||||
# Author : $Author: tomas $
|
||||
# Version : $Revision: 1.4 $
|
||||
# Version : $Revision: 1.5 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/Attic/xr_cli_test.py,v $
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
@ -43,15 +43,16 @@ if len(sys.argv)<3:
|
|||
login <username> <password>
|
||||
authenticate <username> <password>
|
||||
logout <session_id>
|
||||
existsAudioClip <session_id> <global_unique_id>
|
||||
storeAudioClip <session_id> <global_unique_id> <media_file_path> <metadata_file_path>
|
||||
deleteAudioClip <session_id> <global_unique_id>
|
||||
updateAudioClipMetadata <session_id> <global_unique_id> <metadata_file_path>
|
||||
searchMetadata <session_id> <criteria>
|
||||
accessRawAudioData <session_id> <global_unique_id>
|
||||
releaseRawAudioData <session_id> <tmp_link_path>
|
||||
getAudioClip <session_id> <global_unique_id>
|
||||
...
|
||||
"""
|
||||
# existsAudioClip <session_id> <global_unique_id>
|
||||
# storeAudioClip <session_id> <global_unique_id> <media_file_path> <metadata_file_path>
|
||||
# deleteAudioClip <session_id> <global_unique_id>
|
||||
# updateAudioClipMetadata <session_id> <global_unique_id> <metadata_file_path>
|
||||
# searchMetadata <session_id> <criteria>
|
||||
# accessRawAudioData <session_id> <global_unique_id>
|
||||
# releaseRawAudioData <session_id> <tmp_link_path>
|
||||
# getAudioClip <session_id> <global_unique_id>
|
||||
sys.exit(1)
|
||||
|
||||
pars = sys.argv
|
||||
|
@ -63,7 +64,7 @@ if pars[1]=="-s":
|
|||
pars.pop(1)
|
||||
serverPath = pars.pop(1)
|
||||
else:
|
||||
serverPath = 'http://localhost:80/storage/xmlrpc/xrLocStor.php'
|
||||
serverPath = 'http://localhost:80/livesupportStorageServer/xmlrpc/xrLocStor.php'
|
||||
server = Server(serverPath)
|
||||
method = pars.pop(1)
|
||||
pars.pop(0)
|
||||
|
@ -116,9 +117,11 @@ try:
|
|||
elif method=="updateAudioClipMetadata":
|
||||
print server.locstor.updateAudioClipMetadata({'sessid':pars[0], 'gunid':pars[1], 'mdataFileLP':pars[2]})
|
||||
elif method=="searchMetadata":
|
||||
print server.locstor.searchMetadata({'sessid':pars[0], 'criteria':pars[1]})
|
||||
# print server.locstor.searchMetadata({'sessid':pars[0], 'criteria':pars[1]})
|
||||
print server.locstor.searchMetadata({'sessid':pars[0], 'criteria':{'type':'and', 'conds':['a', 'b']}})
|
||||
elif method=="getAudioClip":
|
||||
print server.locstor.getAudioClip({'sessid':pars[0], 'gunid':pars[1]})
|
||||
r = server.locstor.getAudioClip({'sessid':pars[0], 'gunid':pars[1]})
|
||||
print r['metadata']
|
||||
elif method=="resetStorage":
|
||||
print server.locstor.resetStorage({})
|
||||
elif method=="openPut":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue