changed return values in AudioClip and Playlist from Ptr<std::string>::Ref

and Ptr<Glib::ustring>::Ref to Ptr<const ... >::Ref
finished adding audio clip methods to WebStorageClient
modified helix install script to copy the splay executable to $LS/usr/bin
    (HELIX_LIBS needs to be set to "$LS/usr/lib/helix/" for this to work)
This commit is contained in:
fgerlits 2004-12-29 19:16:33 +00:00
parent 11f46d11ba
commit 562705b031
10 changed files with 388 additions and 101 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.14 $
Version : $Revision: 1.15 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $
------------------------------------------------------------------------------*/
@ -283,6 +283,83 @@ static const std::string storeAudioClipUrlParamName = "url";
static const std::string storeAudioClipTokenParamName = "token";
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: acquireAudioClip */
/*------------------------------------------------------------------------------
* The name of the acquire audio clip method on the storage server
*----------------------------------------------------------------------------*/
static const std::string acquireAudioClipMethodName
= "locstor.accessRawAudioData";
/*------------------------------------------------------------------------------
* The name of the session ID parameter in the input structure
*----------------------------------------------------------------------------*/
static const std::string acquireAudioClipSessionIdParamName = "sessid";
/*------------------------------------------------------------------------------
* The name of the audio clip unique ID parameter in the input structure
*----------------------------------------------------------------------------*/
static const std::string acquireAudioClipAudioClipIdParamName = "gunid";
/*------------------------------------------------------------------------------
* The name of the result URL parameter returned by the method
*----------------------------------------------------------------------------*/
static const std::string acquireAudioClipUrlParamName = "url";
/*------------------------------------------------------------------------------
* The name of the token parameter returned by the method
*----------------------------------------------------------------------------*/
static const std::string acquireAudioClipTokenParamName = "token";
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: releaseAudioClip */
/*------------------------------------------------------------------------------
* The name of the release audio clip method on the storage server
*----------------------------------------------------------------------------*/
static const std::string releaseAudioClipMethodName
= "locstor.releaseRawAudioData";
/*------------------------------------------------------------------------------
* The name of the session ID parameter in the input structure
*----------------------------------------------------------------------------*/
static const std::string releaseAudioClipSessionIdParamName = "sessid";
/*------------------------------------------------------------------------------
* The name of the token parameter in the input structure
*----------------------------------------------------------------------------*/
static const std::string releaseAudioClipTokenParamName = "token";
/*------------------------------------------------------------------------------
* The name of the result parameter returned by the method
*----------------------------------------------------------------------------*/
static const std::string releaseAudioClipResultParamName = "status";
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: deleteAudioClip */
/*------------------------------------------------------------------------------
* The name of the delete audio clip method on the storage server
*----------------------------------------------------------------------------*/
static const std::string deleteAudioClipMethodName
= "locstor.deleteAudioClip";
/*------------------------------------------------------------------------------
* The name of the session ID parameter in the input structure
*----------------------------------------------------------------------------*/
static const std::string deleteAudioClipSessionIdParamName = "sessid";
/*------------------------------------------------------------------------------
* The name of the audio clip unique ID parameter in the input structure
*----------------------------------------------------------------------------*/
static const std::string deleteAudioClipAudioClipIdParamName = "gunid";
/*------------------------------------------------------------------------------
* The name of the result parameter returned by the method
*----------------------------------------------------------------------------*/
static const std::string deleteAudioClipResultParamName = "status";
/* =============================================== local function prototypes */
@ -651,7 +728,7 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
}
std::string metadata = audioClip->toXml()
->write_to_string("UTF-8");
->write_to_string("utf-8");
// temporary hack; we will expect an absolute file name from getUri()
// in the final version
@ -799,9 +876,61 @@ WebStorageClient :: acquireAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (StorageException)
{
Ptr<AudioClip>::Ref playlist(new AudioClip);
return playlist;
Ptr<AudioClip>::Ref audioClip = getAudioClip(sessionId, id);
XmlRpcValue parameters;
XmlRpcValue result;
XmlRpcClient xmlRpcClient(storageServerName.c_str(), storageServerPort,
storageServerPath.c_str(), false);
parameters.clear();
parameters[acquireAudioClipSessionIdParamName]
= sessionId->getId();
parameters[acquireAudioClipAudioClipIdParamName]
= std::string(*id);
result.clear();
if (!xmlRpcClient.execute(acquireAudioClipMethodName.c_str(),
parameters, result)) {
std::string eMsg = "cannot execute XML-RPC method '";
eMsg += acquireAudioClipMethodName;
eMsg += "'";
throw XmlRpcCommunicationException(eMsg);
}
if (xmlRpcClient.isFault()) {
std::stringstream eMsg;
eMsg << "XML-RPC method '"
<< acquireAudioClipMethodName
<< "' returned error message:\n"
<< result;
throw XmlRpcMethodFaultException(eMsg.str());
}
if (! result.hasMember(acquireAudioClipUrlParamName)
|| result[acquireAudioClipUrlParamName].getType()
!= XmlRpcValue::TypeString
|| ! result.hasMember(acquireAudioClipTokenParamName)
|| result[acquireAudioClipTokenParamName].getType()
!= XmlRpcValue::TypeString) {
std::stringstream eMsg;
eMsg << "XML-RPC method '"
<< acquireAudioClipMethodName
<< "' returned unexpected value:\n"
<< result;
throw XmlRpcMethodResponseException(eMsg.str());
}
Ptr<const std::string>::Ref uri(new const std::string(
result[acquireAudioClipUrlParamName] ));
Ptr<const std::string>::Ref token(new const std::string(
result[acquireAudioClipTokenParamName] ));
audioClip->setUri(uri);
audioClip->setToken(token);
return audioClip;
}
@ -813,7 +942,58 @@ WebStorageClient :: releaseAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip) const
throw (StorageException)
{
XmlRpcValue parameters;
XmlRpcValue result;
XmlRpcClient xmlRpcClient(storageServerName.c_str(), storageServerPort,
storageServerPath.c_str(), false);
parameters.clear();
parameters[releaseAudioClipSessionIdParamName]
= sessionId->getId();
parameters[releaseAudioClipTokenParamName]
= *audioClip->getToken();
result.clear();
if (!xmlRpcClient.execute(releaseAudioClipMethodName.c_str(),
parameters, result)) {
std::string eMsg = "cannot execute XML-RPC method '";
eMsg += releaseAudioClipMethodName;
eMsg += "'";
throw XmlRpcCommunicationException(eMsg);
}
if (xmlRpcClient.isFault()) {
std::stringstream eMsg;
eMsg << "XML-RPC method '"
<< releaseAudioClipMethodName
<< "' returned error message:\n"
<< result;
throw XmlRpcMethodFaultException(eMsg.str());
}
if (! result.hasMember(releaseAudioClipResultParamName)
|| result[releaseAudioClipResultParamName].getType()
!= XmlRpcValue::TypeBoolean) {
std::stringstream eMsg;
eMsg << "XML-RPC method '"
<< releaseAudioClipMethodName
<< "' returned unexpected value:\n"
<< result;
throw XmlRpcMethodResponseException(eMsg.str());
}
if (! bool(result[releaseAudioClipResultParamName])) {
std::stringstream eMsg;
eMsg << "XML-RPC method '"
<< releaseAudioClipMethodName
<< "' returned 'false'";
throw XmlRpcMethodResponseException(eMsg.str());
}
Ptr<const std::string>::Ref nullpointer;
audioClip->setToken(nullpointer);
audioClip->setUri(nullpointer);
}
@ -825,7 +1005,54 @@ WebStorageClient :: deleteAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (StorageException)
{
XmlRpcValue parameters;
XmlRpcValue result;
XmlRpcClient xmlRpcClient(storageServerName.c_str(), storageServerPort,
storageServerPath.c_str(), false);
parameters.clear();
parameters[deleteAudioClipSessionIdParamName]
= sessionId->getId();
parameters[deleteAudioClipAudioClipIdParamName]
= std::string(*id);
result.clear();
if (!xmlRpcClient.execute(deleteAudioClipMethodName.c_str(),
parameters, result)) {
std::string eMsg = "cannot execute XML-RPC method '";
eMsg += deleteAudioClipMethodName;
eMsg += "'";
throw XmlRpcCommunicationException(eMsg);
}
if (xmlRpcClient.isFault()) {
std::stringstream eMsg;
eMsg << "XML-RPC method '"
<< deleteAudioClipMethodName
<< "' returned error message:\n"
<< result;
throw XmlRpcMethodFaultException(eMsg.str());
}
if (! result.hasMember(deleteAudioClipResultParamName)
|| result[deleteAudioClipResultParamName].getType()
!= XmlRpcValue::TypeBoolean) {
std::stringstream eMsg;
eMsg << "XML-RPC method '"
<< deleteAudioClipMethodName
<< "' returned unexpected value:\n"
<< result;
throw XmlRpcMethodResponseException(eMsg.str());
}
if (! bool(result[deleteAudioClipResultParamName])) {
std::stringstream eMsg;
eMsg << "XML-RPC method '"
<< deleteAudioClipMethodName
<< "' returned 'false'";
throw XmlRpcMethodResponseException(eMsg.str());
}
}

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.10 $
Version : $Revision: 1.11 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.h,v $
------------------------------------------------------------------------------*/
@ -99,7 +99,7 @@ using namespace LiveSupport::Core;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.10 $
* @version $Revision: 1.11 $
*/
class WebStorageClient :
virtual public Configurable,
@ -405,6 +405,10 @@ class WebStorageClient :
/**
* Return a list of all audio clips in the playlist store.
*
* Since this makes no sense whatsoever, this method currently returns
* an empty list. It will be replaced by a method which uses
* <code>locstor.searchMetadata</code>.
*
* @param sessionId the session ID from the authentication client
* @return a vector containing the playlists.
* @exception StorageException if there is a problem with the XML-RPC

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.16 $
Version : $Revision: 1.17 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClientTest.cxx,v $
------------------------------------------------------------------------------*/
@ -186,7 +186,7 @@ WebStorageClientTest :: audioClipTest(void)
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(uniqueIdVector->size() > 0);
Ptr<UniqueId>::Ref id01 = uniqueIdVector->at(0);
Ptr<UniqueId>::Ref id01 = uniqueIdVector->at(1);
/* std::cout << "\nReset storage result:\n";
for (unsigned i=0; i<uniqueIdVector->size(); i++) {
@ -202,6 +202,8 @@ WebStorageClientTest :: audioClipTest(void)
}
CPPUNIT_ASSERT(sessionId);
// test existsAudioClip(), deleteAudioClip() and getAudioClip()
bool exists = false;;
try {
exists = wsc->existsAudioClip(sessionId, id01);
@ -219,6 +221,21 @@ WebStorageClientTest :: audioClipTest(void)
CPPUNIT_FAIL(e.what());
}
try {
wsc->deleteAudioClip(sessionId, id01);
}
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
}
try {
exists = wsc->existsAudioClip(sessionId, id01);
}
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(!exists);
Ptr<UniqueId>::Ref id77(new UniqueId(10077));
try {
exists = wsc->existsAudioClip(sessionId, id77);
@ -228,10 +245,12 @@ WebStorageClientTest :: audioClipTest(void)
}
CPPUNIT_ASSERT(!exists);
Ptr<UniqueId>::Ref id02 = UniqueId::generateId();
// test storeAudioClip() and getAudioClip()
Ptr<UniqueId>::Ref idxx = UniqueId::generateId();
Ptr<time_duration>::Ref playlength(new time_duration(0,0,11,0));
Ptr<std::string>::Ref uri(new std::string("file:var/test10001.mp3"));
audioClip.reset(new AudioClip(id02, playlength, uri));
audioClip.reset(new AudioClip(idxx, playlength, uri));
try {
wsc->storeAudioClip(sessionId, audioClip);
@ -241,7 +260,7 @@ WebStorageClientTest :: audioClipTest(void)
}
try {
CPPUNIT_ASSERT( wsc->existsAudioClip(sessionId, id02));
CPPUNIT_ASSERT( wsc->existsAudioClip(sessionId, idxx));
}
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
@ -249,32 +268,53 @@ WebStorageClientTest :: audioClipTest(void)
Ptr<AudioClip>::Ref newAudioClip;
try {
newAudioClip = wsc->getAudioClip(sessionId, id02);
newAudioClip = wsc->getAudioClip(sessionId, idxx);
}
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(std::string(*newAudioClip->getId()) == std::string(*id02));
CPPUNIT_ASSERT(std::string(*newAudioClip->getId()) == std::string(*idxx));
CPPUNIT_ASSERT(newAudioClip->getPlaylength()->total_seconds()
== audioClip->getPlaylength()->total_seconds());
// test acquireAudioClip() and releaseAudioClip()
try {
newAudioClip = wsc->acquireAudioClip(sessionId, idxx);
}
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(newAudioClip->getUri());
// std::cerr << *newAudioClip->getUri() << std::endl;
// sleep(30);
try {
wsc->releaseAudioClip(sessionId, newAudioClip);
}
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(!newAudioClip->getUri());
// test getAllAudioClips() [pointless]
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref audioClipVector;
try {
audioClipVector = wsc->getAllAudioClips(sessionId);
}
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(audioClipVector->size() == 0);
try{
authentication->logout(sessionId);
}
catch (AuthenticationException &e) {
CPPUNIT_FAIL(e.what());
}
/*
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref audioClipVector =
wsc->getAllAudioClips();
CPPUNIT_ASSERT(audioClipVector->size() == 2);
audioClip = (*audioClipVector)[0];
CPPUNIT_ASSERT((int) (audioClip->getId()->getId()) == 10001);
wsc->deleteAudioClip(id2);
CPPUNIT_ASSERT(!wsc->existsAudioClip(id2));
*/
}