diff --git a/livesupport/modules/storageServer/bin/setupDirs.sh b/livesupport/modules/storageServer/bin/setupDirs.sh index c86a838ce..7fa6a03bf 100755 --- a/livesupport/modules/storageServer/bin/setupDirs.sh +++ b/livesupport/modules/storageServer/bin/setupDirs.sh @@ -22,7 +22,7 @@ # # # Author : $Author: tomas $ -# Version : $Revision: 1.1 $ +# Version : $Revision: 1.2 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/bin/setupDirs.sh,v $ #------------------------------------------------------------------------------- diff --git a/livesupport/modules/storageServer/doc/INSTALL b/livesupport/modules/storageServer/doc/INSTALL deleted file mode 100644 index 6ea527ab3..000000000 --- a/livesupport/modules/storageServer/doc/INSTALL +++ /dev/null @@ -1,16 +0,0 @@ - -- required packages: apache, php, mod_php, postgreSQL, wget, curl, PEAR_DB -- check if PEAR DB installed: 'pear list' or install it: 'pear install DB' -- check if include_path in php.ini points to PEAR too - (/usr/lib/php or /usr/local/lib/php) -- setup var/conf.php - at least "basic configuration" part - (follow comments in the source - or use doxygen and its output) -- setup archiveServer/var/conf.php too - test scripts will use archive -- create symlink with name corresponding to "URL configuration" part - of var/conf.php file - example for default values: - http://localhost:80/livesupportStorageServer/ should point to - /modules/storageServer/var directory -- configure apache for archiveServer file upload - (as described in archiveServer/doc/INSTALL) -- run 'make check' to: setup directories, create db tables and run test scripts - OR 'make all' without tests diff --git a/livesupport/modules/storageServer/doc/index.html b/livesupport/modules/storageServer/doc/index.html index 611efcae6..b8db4fc5b 100644 --- a/livesupport/modules/storageServer/doc/index.html +++ b/livesupport/modules/storageServer/doc/index.html @@ -14,7 +14,7 @@ Development Loan Fund, under the GNU GPL.

Scope

@@ -25,8 +25,7 @@ The links below provide useful documentation for the storageServer developer or user.

Static documentation.

Generated documentation

+ * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see Subjects::authenticate + */ + function xr_authenticate($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->authenticate($r['login'], $r['pass']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 804,"xr_authenticate: database error"); + } + $retval = ($res !== FALSE); + return new XML_RPC_Response( + XML_RPC_encode(array('authenticate'=>$retval)) + ); + } + + /** + * Checks the login name and password of the user. If the login is + * correct, a new session ID string is generated, to be used in all + * subsequent XML-RPC calls as the "sessid" field of the + * parameters. + * + * The XML-RPC name of this method is "locstor.login". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see Alib::login + */ + function xr_login($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->login($r['login'], $r['pass']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 804,"xr_login: database error"); + } + if($res === FALSE) + return new XML_RPC_Response(0, 802, + "xr_login: login failed - incorrect username or password." + ); + else + return new XML_RPC_Response(XML_RPC_encode(array('sessid'=>$res))); + } + + /** + * Logout, destroy session and return status. + * If session is not valid error message is returned. + * + * The XML-RPC name of this method is "locstor.logout". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see GreenBox::logout + */ + function xr_logout($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->logout($r['sessid']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 803, + "xr_logout: logout failed - not logged." + ); + } + return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); + } + + /* ---------------------------------------------------------------- store */ + /** + * Open writable URL for store new AudioClip or replace existing one. + * Writing to returned URL is possible using HTTP PUT method + * (as e.g. curl -T <filename> command does) + * + * The XML-RPC name of this method is "locstor.storeAudioClipOpen". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::storeAudioClipOpen + */ + function xr_storeAudioClipOpen($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->storeAudioClipOpen( + $r['sessid'], $r['gunid'], $r['metadata'], $r['fname'], $r['chsum'] + ); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_storeAudioClipOpen: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode($res)); + } + + /** + * Close writable URL for store new AudioClip or replace existing one. + * + * The XML-RPC name of this method is "locstor.storeAudioClip". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::storeAudioClipClose + */ + function xr_storeAudioClipClose($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->storeAudioClipClose($r['sessid'], $r['token']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_storeAudioClipClose: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode(array('gunid'=>$res))); + } + + /* ------------------------------------------------ access raw audio data */ + /** + * Make access to audio clip. + * + * The XML-RPC name of this method is "locstor.accessRawAudioData". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::accessRawAudioData + */ + function xr_accessRawAudioData($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->accessRawAudioData($r['sessid'], $r['gunid']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_accessRawAudioData: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode($res)); + } + + /** + * Release access to audio clip + * + * The XML-RPC name of this method is "locstor.releaseRawAudioData". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::releaseRawAudioData + */ + function xr_releaseRawAudioData($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->releaseRawAudioData($r['sessid'], $r['token']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_releaseRawAudioData: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); + } + + /* ---------------------------------------------- download raw audio data */ + /** + * Create downlodable URL for stored file + * + * The XML-RPC name of this method is "locstor.downloadRawAudioDataOpen". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::downloadRawAudioDataOpen + */ + function xr_downloadRawAudioDataOpen($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->downloadRawAudioDataOpen($r['sessid'], $r['gunid']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_downloadRawAudioDataOpen: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode($res)); + } + + /** + * Delete downlodable URL with media file. + * + * The XML-RPC name of this method is "locstor.downloadRawAudioDataClose". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::downloadRawAudioDataClose + */ + function xr_downloadRawAudioDataClose($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->downloadRawAudioDataClose($r['token']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_downloadRawAudioDataClose: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode(array('gunid'=>$res))); + } + + /* ---------------------------------------------------- download metadata */ + /** + * Create downlodable URL for metadata part of stored file + * + * The XML-RPC name of this method is "locstor.downloadMetadataOpen". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::downloadRawAudioDataOpen + */ + function xr_downloadMetadataOpen($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->downloadMetadataOpen($r['sessid'], $r['gunid']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_downloadMetadataOpen: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode($res)); + } + + /** + * Delete downlodable URL with metadata. + * + * The XML-RPC name of this method is "locstor.downloadMetadataClose". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::downloadRawAudioDataClose + */ + function xr_downloadMetadataClose($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->downloadMetadataClose($r['token']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_downloadMetadataClose: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode(array('gunid'=>$res))); + } + + /* --------------------------------------------------------------- delete */ + /** + * Delete existing audio clip + * + * The XML-RPC name of this method is "locstor.deleteAudioClip". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::deleteAudioClip + */ + function xr_deleteAudioClip($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->deleteAudioClip($r['sessid'], $r['gunid']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_deleteAudioClip: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); + } + + /*====================================================== playlist methods */ + /** + * Create a new Playlist metafile. + * + * The XML-RPC name of this method is "locstor.createPlaylist". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::createPlaylist + */ + function xr_createPlaylist($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->createPlaylist($r['sessid'], $r['plid'], $r['fname']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_createPlaylist: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode(array('plid'=>$res))); + } + + /** + * Open a Playlist metafile for editing. + * Open readable URL and mark file as beeing edited. + * + * The XML-RPC name of this method is "locstor.editPlaylist". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::editPlaylist + */ + function xr_editPlaylist($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->editPlaylist($r['sessid'], $r['plid']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_editPlaylist: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode($res)); + } + + /** + * Store a new Playlist metafile in place of the old one. + * + * The XML-RPC name of this method is "locstor.savePlaylist". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::savePlaylist + */ + function xr_savePlaylist($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->savePlaylist( + $r['sessid'], $r['token'], $r['newPlaylist']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_savePlaylist: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); + } + + /** + * Delete a Playlist metafile. + * + * The XML-RPC name of this method is "locstor.deletePlaylist". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::deletePlaylist + */ + function xr_deletePlaylist($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->deletePlaylist($r['sessid'], $r['plid']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_deletePlaylist: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); + } + + /** + * Access (read) a Playlist metafile. + * + * The XML-RPC name of this method is "locstor.accessPlaylist". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::accessPlaylist + */ + function xr_accessPlaylist($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->accessPlaylist($r['sessid'], $r['plid']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_accessPlaylist: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode($res)); + } + + /** + * Release the resources obtained earlier by accessPlaylist(). + * + * The XML-RPC name of this method is "locstor.releasePlaylist". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::releasePlaylist + */ + function xr_releasePlaylist($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->releasePlaylist($r['sessid'], $r['token']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_releasePlaylist: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode(array('plid'=>$res))); + } + + /** + * Check whether a Playlist metafile with the given playlist ID exists. + * + * The XML-RPC name of this method is "locstor.existsPlaylist". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::existsPlaylist + */ + function xr_existsPlaylist($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->existsPlaylist($r['sessid'], $r['plid']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_existsPlaylist: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode(array('exists'=>$res))); + } + + /** + * Check whether a Playlist metafile with the given playlist ID + * is available for editing, i.e., exists and is not marked as + * beeing edited. + * + * The XML-RPC name of this method is "locstor.playlistIsAvailable". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::playlistIsAvailable + */ + function xr_playlistIsAvailable($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->playlistIsAvailable($r['sessid'], $r['plid']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_playlistIsAvailable: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode(array('available'=>$res))); + } + + /* ----------------------------------------------------------------- etc. */ + /** + * Check if audio clip exists and return TRUE/FALSE + * + * The XML-RPC name of this method is "locstor.existsAudioClip". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::existsAudioClip + */ + function xr_existsAudioClip($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + #$this->debugLog(join(', ', $r)); + $res = $this->existsAudioClip($r['sessid'], $r['gunid']); + #$this->debugLog($res); + if(PEAR::isError($res)) + return new XML_RPC_Response(0, 805, + "xr_existsAudioClip: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + return new XML_RPC_Response(XML_RPC_encode(array('exists'=>$res))); + } + + /** + * Return all file's metadata as XML string + * + * The XML-RPC name of this method is "locstor.getAudioClip". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::getAudioClip + */ + function xr_getAudioClip($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->getAudioClip($r['sessid'], $r['gunid']); + 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(array('metadata'=>$res))); + } + + /** + * Update existing audio clip metadata + * + * The XML-RPC name of this method is "locstor.updateAudioClipMetadata". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::updateAudioClipMetadata + */ + function xr_updateAudioClipMetadata($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->updateAudioClipMetadata( + $r['sessid'], $r['gunid'], $r['metadata'] + ); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 805, + "xr_updateAudioClip: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); + } + + /** + * Search in local metadata database + * + * The XML-RPC name of this method is "locstor.searchMetadata". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with the following + * fields: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see LocStor::searchMetadata + * @see GreenBox::localSearch + */ + function xr_searchMetadata($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->searchMetadata($r['sessid'], $r['criteria']); + if(PEAR::isError($res)){ + return new XML_RPC_Response(0, 803, + "xr_searchAudioClip: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + 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 single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @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(array('gunids'=>$res))); + } + + + /* ------------------------------------------- test methods for debugging */ + /** + * Test XMLRPC - strupper and return given string, + * also return loginname of logged user + * - debug method only + * + * @param input XMLRPC struct + * @return XMLRPC struct + */ + function xr_test($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + return new XML_RPC_Response(XML_RPC_encode(array( + 'str'=>strtoupper($r['teststring']), + 'login'=>$this->getSessLogin($r['sessid']), + 'sessid'=>$r['sessid'] + ))); + } + + /** + * Open writable URL for put method - debug method only + * + * @param input XMLRPC struct + * @return XMLRPC struct + */ + function xr_openPut($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->bsOpenPut(); + 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)); + } + + /** + * Close writable URL - debug method only + * + * @param input XMLRPC struct + * @return XMLRPC struct + */ + function xr_closePut($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + $res = $this->bsClosePut($r['token'], $r['chsum']); + 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(array('fname'=>$res))); + } + + /* ---------------------------------------------------- "private" methods */ + /** + * Check and convert struct of parameters + * + * @param input XMLRPC parameters + * @return array + */ + function _xr_getPars($input) + { + $p = $input->getParam(0); + if(isset($p) && $p->scalartyp()=="struct"){ + $r = XML_RPC_decode($p); + return array(TRUE, $r); + } + else return array(FALSE, new XML_RPC_Response(0, 801, + "wrong 1st parameter, struct expected." + )); + } + +} // end of class definition + +?> diff --git a/livesupport/modules/storageServer/var/xmlrpc/put.php b/livesupport/modules/storageServer/var/xmlrpc/put.php index f194c1cae..5cb371cf4 100644 --- a/livesupport/modules/storageServer/var/xmlrpc/put.php +++ b/livesupport/modules/storageServer/var/xmlrpc/put.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/put.php,v $ ------------------------------------------------------------------------------*/ @@ -62,7 +62,7 @@ require_once '../LocStor.php'; PEAR::setErrorHandling(PEAR_ERROR_RETURN); $dbc = DB::connect($config['dsn'], TRUE); $dbc->setFetchMode(DB_FETCHMODE_ASSOC); -$gb = &new GreenBox(&$dbc, $config); +$gb = &new LocStor(&$dbc, $config); function http_error($code, $err){ header("HTTP/1.1 $code"); diff --git a/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php b/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php index 51409973c..eb70c0aa6 100644 --- a/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php +++ b/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.14 $ + Version : $Revision: 1.15 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php,v $ ------------------------------------------------------------------------------*/ @@ -54,7 +54,7 @@ header("Content-type: text/xml"); require_once 'DB.php'; require_once "XML/RPC/Server.php"; require_once '../conf.php'; -require_once '../LocStor.php'; +require_once 'XR_LocStor.php'; /* ============================================ setting default error handler */ function errHndl($errno, $errmsg, $filename, $linenum, $vars){ @@ -67,1251 +67,6 @@ function errHndl($errno, $errmsg, $filename, $linenum, $vars){ } $old_error_handler = set_error_handler("errHndl"); -/* ====================================== XML-RPC interface class for LocStor */ -/** - * XML-RPC interface for LocStor class - * - */ -class XR_LocStor extends LocStor{ - - /* ------------------------------------------------------- authentication */ - /** - * Checks the login name and password of the user and return - * true if login data are correct, othervise return false. - * - * The XML-RPC name of this method is "locstor.authenticate". - * - * Input parameters: XML-RPC struct with the following fields: - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see Subjects::authenticate - */ - function xr_authenticate($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->authenticate($r['login'], $r['pass']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 804,"xr_authenticate: database error"); - } - $retval = ($res !== FALSE); - return new XML_RPC_Response( - XML_RPC_encode(array('authenticate'=>$retval)) - ); - } - - /** - * Checks the login name and password of the user. If the login is - * correct, a new session ID string is generated, to be used in all - * subsequent XML-RPC calls as the "sessid" field of the - * parameters. - * - * The XML-RPC name of this method is "locstor.login". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see Alib::login - */ - function xr_login($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->login($r['login'], $r['pass']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 804,"xr_login: database error"); - } - if($res === FALSE) - return new XML_RPC_Response(0, 802, - "xr_login: login failed - incorrect username or password." - ); - else - return new XML_RPC_Response(XML_RPC_encode(array('sessid'=>$res))); - } - - /** - * Logout, destroy session and return status. - * If session is not valid error message is returned. - * - * The XML-RPC name of this method is "locstor.logout". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see GreenBox::logout - */ - function xr_logout($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->logout($r['sessid']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 803, - "xr_logout: logout failed - not logged." - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); - } - - /* ---------------------------------------------------------------- store */ - /** - * Open writable URL for store new AudioClip or replace existing one. - * Writing to returned URL is possible using HTTP PUT method - * (as e.g. curl -T <filename> command does) - * - * The XML-RPC name of this method is "locstor.storeAudioClipOpen". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::storeAudioClipOpen - */ - function xr_storeAudioClipOpen($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->storeAudioClipOpen( - $r['sessid'], $r['gunid'], $r['metadata'], $r['fname'], $r['chsum'] - ); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_storeAudioClipOpen: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Close writable URL for store new AudioClip or replace existing one. - * - * The XML-RPC name of this method is "locstor.storeAudioClip". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::storeAudioClipClose - */ - function xr_storeAudioClipClose($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->storeAudioClipClose($r['sessid'], $r['token']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_storeAudioClipClose: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('gunid'=>$res))); - } - - /* ------------------------------------------------ access raw audio data */ - /** - * Make access to audio clip. - * - * The XML-RPC name of this method is "locstor.accessRawAudioData". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::accessRawAudioData - */ - function xr_accessRawAudioData($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->accessRawAudioData($r['sessid'], $r['gunid']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_accessRawAudioData: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Release access to audio clip - * - * The XML-RPC name of this method is "locstor.releaseRawAudioData". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::releaseRawAudioData - */ - function xr_releaseRawAudioData($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->releaseRawAudioData($r['sessid'], $r['token']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_releaseRawAudioData: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); - } - - /* ---------------------------------------------- download raw audio data */ - /** - * Create downlodable URL for stored file - * - * The XML-RPC name of this method is "locstor.downloadRawAudioDataOpen". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::downloadRawAudioDataOpen - */ - function xr_downloadRawAudioDataOpen($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->downloadRawAudioDataOpen($r['sessid'], $r['gunid']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_downloadRawAudioDataOpen: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Delete downlodable URL with media file. - * - * The XML-RPC name of this method is "locstor.downloadRawAudioDataClose". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::downloadRawAudioDataClose - */ - function xr_downloadRawAudioDataClose($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->downloadRawAudioDataClose($r['token']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_downloadRawAudioDataClose: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('gunid'=>$res))); - } - - /* ---------------------------------------------------- download metadata */ - /** - * Create downlodable URL for metadata part of stored file - * - * The XML-RPC name of this method is "locstor.downloadMetadataOpen". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::downloadRawAudioDataOpen - */ - function xr_downloadMetadataOpen($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->downloadMetadataOpen($r['sessid'], $r['gunid']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_downloadMetadataOpen: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Delete downlodable URL with metadata. - * - * The XML-RPC name of this method is "locstor.downloadMetadataClose". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::downloadRawAudioDataClose - */ - function xr_downloadMetadataClose($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->downloadMetadataClose($r['token']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_downloadMetadataClose: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('gunid'=>$res))); - } - - /* --------------------------------------------------------------- delete */ - /** - * Delete existing audio clip - * - * The XML-RPC name of this method is "locstor.deleteAudioClip". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::deleteAudioClip - */ - function xr_deleteAudioClip($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->deleteAudioClip($r['sessid'], $r['gunid']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_deleteAudioClip: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); - } - - /*====================================================== playlist methods */ - /** - * Create a new Playlist metafile. - * - * The XML-RPC name of this method is "locstor.createPlaylist". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::createPlaylist - */ - function xr_createPlaylist($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->createPlaylist($r['sessid'], $r['plid'], $r['fname']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_createPlaylist: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('plid'=>$res))); - } - - /** - * Open a Playlist metafile for editing. - * Open readable URL and mark file as beeing edited. - * - * The XML-RPC name of this method is "locstor.editPlaylist". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::editPlaylist - */ - function xr_editPlaylist($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->editPlaylist($r['sessid'], $r['plid']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_editPlaylist: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Store a new Playlist metafile in place of the old one. - * - * The XML-RPC name of this method is "locstor.savePlaylist". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::savePlaylist - */ - function xr_savePlaylist($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->savePlaylist( - $r['sessid'], $r['token'], $r['newPlaylist']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_savePlaylist: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); - } - - /** - * Delete a Playlist metafile. - * - * The XML-RPC name of this method is "locstor.deletePlaylist". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::deletePlaylist - */ - function xr_deletePlaylist($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->deletePlaylist($r['sessid'], $r['plid']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_deletePlaylist: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); - } - - /** - * Access (read) a Playlist metafile. - * - * The XML-RPC name of this method is "locstor.accessPlaylist". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::accessPlaylist - */ - function xr_accessPlaylist($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->accessPlaylist($r['sessid'], $r['plid']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_accessPlaylist: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Release the resources obtained earlier by accessPlaylist(). - * - * The XML-RPC name of this method is "locstor.releasePlaylist". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::releasePlaylist - */ - function xr_releasePlaylist($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->releasePlaylist($r['sessid'], $r['token']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_releasePlaylist: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('plid'=>$res))); - } - - /** - * Check whether a Playlist metafile with the given playlist ID exists. - * - * The XML-RPC name of this method is "locstor.existsPlaylist". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::existsPlaylist - */ - function xr_existsPlaylist($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->existsPlaylist($r['sessid'], $r['plid']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_existsPlaylist: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('exists'=>$res))); - } - - /** - * Check whether a Playlist metafile with the given playlist ID - * is available for editing, i.e., exists and is not marked as - * beeing edited. - * - * The XML-RPC name of this method is "locstor.playlistIsAvailable". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::playlistIsAvailable - */ - function xr_playlistIsAvailable($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->playlistIsAvailable($r['sessid'], $r['plid']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_playlistIsAvailable: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('available'=>$res))); - } - - /* ----------------------------------------------------------------- etc. */ - /** - * Check if audio clip exists and return TRUE/FALSE - * - * The XML-RPC name of this method is "locstor.existsAudioClip". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::existsAudioClip - */ - function xr_existsAudioClip($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - #$this->debugLog(join(', ', $r)); - $res = $this->existsAudioClip($r['sessid'], $r['gunid']); - #$this->debugLog($res); - if(PEAR::isError($res)) - return new XML_RPC_Response(0, 805, - "xr_existsAudioClip: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - return new XML_RPC_Response(XML_RPC_encode(array('exists'=>$res))); - } - - /** - * Return all file's metadata as XML string - * - * The XML-RPC name of this method is "locstor.getAudioClip". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::getAudioClip - */ - function xr_getAudioClip($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->getAudioClip($r['sessid'], $r['gunid']); - 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(array('metadata'=>$res))); - } - - /** - * Update existing audio clip metadata - * - * The XML-RPC name of this method is "locstor.updateAudioClipMetadata". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::updateAudioClipMetadata - */ - function xr_updateAudioClipMetadata($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->updateAudioClipMetadata( - $r['sessid'], $r['gunid'], $r['metadata'] - ); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 805, - "xr_updateAudioClip: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); - } - - /** - * Search in local metadata database - * - * The XML-RPC name of this method is "locstor.searchMetadata". - * - * The input parameters are an XML-RPC struct with the following - * fields: - * - * - * On success, returns a XML-RPC struct with single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @param input XMLRPC struct - * @return XMLRPC struct - * @see LocStor::searchMetadata - * @see GreenBox::localSearch - */ - function xr_searchMetadata($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->searchMetadata($r['sessid'], $r['criteria']); - if(PEAR::isError($res)){ - return new XML_RPC_Response(0, 803, - "xr_searchAudioClip: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - 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 single field: - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - * - * - * @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(array('gunids'=>$res))); - } - - - /* ------------------------------------------- test methods for debugging */ - /** - * Test XMLRPC - strupper and return given string, - * also return loginname of logged user - * - debug method only - * - * @param input XMLRPC struct - * @return XMLRPC struct - */ - function xr_test($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - return new XML_RPC_Response(XML_RPC_encode(array( - 'str'=>strtoupper($r['teststring']), - 'login'=>$this->getSessLogin($r['sessid']), - 'sessid'=>$r['sessid'] - ))); - } - - /** - * Open writable URL for put method - debug method only - * - * @param input XMLRPC struct - * @return XMLRPC struct - */ - function xr_openPut($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->bsOpenPut(); - 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)); - } - - /** - * Close writable URL - debug method only - * - * @param input XMLRPC struct - * @return XMLRPC struct - */ - function xr_closePut($input) - { - list($ok, $r) = $this->_xr_getPars($input); - if(!$ok) return $r; - $res = $this->bsClosePut($r['token'], $r['chsum']); - 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(array('fname'=>$res))); - } - - /* ---------------------------------------------------- "private" methods */ - /** - * Check and convert struct of parameters - * - * @param input XMLRPC parameters - * @return array - */ - function _xr_getPars($input) - { - $p = $input->getParam(0); - if(isset($p) && $p->scalartyp()=="struct"){ - $r = XML_RPC_decode($p); - return array(TRUE, $r); - } - else return array(FALSE, new XML_RPC_Response(0, 801, - "wrong 1st parameter, struct expected." - )); - } - -} // end of class definition /* ============================================================= runable code */ PEAR::setErrorHandling(PEAR_ERROR_RETURN); diff --git a/livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.py b/livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.py index 632daa674..697f13fe1 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.10 $ +# Version : $Revision: 1.11 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/Attic/xr_cli_test.py,v $ # #------------------------------------------------------------------------------ @@ -34,7 +34,7 @@ import sys if len(sys.argv)<3: print """ - Usage: xr_cli_pok.py [-v] [-s http:////xmlrpc/xrGreenBox.php] + Usage: xr_cli_pok.py [-v] [-s http:////xmlrpc/xrLocStor.php] commands and args: listMethods methodHelp