diff --git a/livesupport/modules/storageServer/var/BasicStor.php b/livesupport/modules/storageServer/var/BasicStor.php
index 5d887b80c..74d2ac5f8 100644
--- a/livesupport/modules/storageServer/var/BasicStor.php
+++ b/livesupport/modules/storageServer/var/BasicStor.php
@@ -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;
diff --git a/livesupport/modules/storageServer/var/GreenBox.php b/livesupport/modules/storageServer/var/GreenBox.php
index 1ade2ce4f..88534e0aa 100644
--- a/livesupport/modules/storageServer/var/GreenBox.php
+++ b/livesupport/modules/storageServer/var/GreenBox.php
@@ -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
*
diff --git a/livesupport/modules/storageServer/var/LocStor.php b/livesupport/modules/storageServer/var/LocStor.php
index ca09dafcd..70a58b959 100644
--- a/livesupport/modules/storageServer/var/LocStor.php
+++ b/livesupport/modules/storageServer/var/LocStor.php
@@ -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)
{
diff --git a/livesupport/modules/storageServer/var/StoredFile.php b/livesupport/modules/storageServer/var/StoredFile.php
index b8d59f457..3401544a2 100644
--- a/livesupport/modules/storageServer/var/StoredFile.php
+++ b/livesupport/modules/storageServer/var/StoredFile.php
@@ -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}'");
diff --git a/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh b/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh
index 95485fe6b..8276a761f 100755
--- a/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh
+++ b/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh
@@ -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" '' 'Title XY' "$MD5"` || \
+ RES=`$XR_CLI storeAudioClipOpen "$SESSID" '' 'ěščřžé' "$MD5"` || \
{ ERN=$?; echo $RES; exit $ERN; }
unset URL
for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done
diff --git a/livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.py b/livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.py
index 20b4bd30e..ca065aecb 100755
--- a/livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.py
+++ b/livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.py
@@ -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
authenticate
logout
- existsAudioClip
- storeAudioClip
- deleteAudioClip
- updateAudioClipMetadata
- searchMetadata
- accessRawAudioData
- releaseRawAudioData
- getAudioClip
+ ...
"""
+# existsAudioClip
+# storeAudioClip
+# deleteAudioClip
+# updateAudioClipMetadata
+# searchMetadata
+# accessRawAudioData
+# releaseRawAudioData
+# getAudioClip
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":