modified the authentication and storage modules to throw their

own exception classes AuthenticationException and StorageException
instead of invalid_argument and logic_error
This commit is contained in:
fgerlits 2004-12-23 11:37:55 +00:00
parent adf05eaf29
commit de2b5a49a2
61 changed files with 1121 additions and 539 deletions

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/include/LiveSupport/Authentication/AuthenticationClientInterface.h,v $
------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/SessionId.h"
#include "LiveSupport/Authentication/AuthenticationException.h"
namespace LiveSupport {
namespace Authentication {
@ -63,34 +64,50 @@ using namespace LiveSupport::Core;
* An interface for authentication clients.
*
* @author $Author: fgerlits $
* @version $Revision: 1.3 $
* @version $Revision: 1.4 $
*/
class AuthenticationClientInterface
{
public:
/**
* Login to the authentication server.
* Returns a new session ID; in case of an error, returns a
* null pointer.
* Returns a new session ID; in case of an error, throws
* AuthenticationException or one of its subclasses.
*
* @param login the login to the server
* @param password the password to the server
* @exception XmlRpcCommunicationException problem with performing
* XML-RPC call
* @exception XmlRpcMethodFaultException XML-RPC method returned
* fault response
* @exception XmlRpcMethodResponseException response from XML-RPC
* method is incorrect
* @exception AuthenticationException other error
* (TestStorageClient only)
* @return the new session ID
*/
virtual Ptr<SessionId>::Ref
login(const std::string &login, const std::string &password)
throw ()
throw (AuthenticationException)
= 0;
/**
* Logout from the authentication server.
*
* @param sessionId the ID of the session to end
* @return true if logged out successfully, false if not
* @exception XmlRpcCommunicationException problem with performing
* XML-RPC call
* @exception XmlRpcMethodFaultException XML-RPC method returned
* fault response
* @exception XmlRpcMethodResponseException response from XML-RPC
* method is incorrect
* @exception AuthenticationException other error
* (TestStorageClient only)
*/
virtual const bool
virtual void
logout(Ptr<SessionId>::Ref sessionId)
throw ()
throw (AuthenticationException)
= 0;
};

View File

@ -0,0 +1,115 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/include/LiveSupport/Authentication/Attic/AuthenticationException.h,v $
------------------------------------------------------------------------------*/
#ifndef LiveSupport_Authentication_AuthenticationException_h
#define LiveSupport_Authentication_AuthenticationException_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <stdexcept>
namespace LiveSupport {
namespace Authentication {
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* Common parent of exception classes for this module.
*
* @author $Author: fgerlits $
* @version $Revision: 1.1 $
*/
class AuthenticationException : public std::runtime_error
{
public:
AuthenticationException(const std::string &msg)
: std::runtime_error(msg) {
}
};
/**
* XML-RPC communication problem.
*/
class XmlRpcCommunicationException : public AuthenticationException
{
public:
XmlRpcCommunicationException(const std::string &msg)
: AuthenticationException(msg) {
}
};
/**
* XML-RPC fault thrown by the method called.
*/
class XmlRpcMethodFaultException : public AuthenticationException
{
public:
XmlRpcMethodFaultException(const std::string &msg)
: AuthenticationException(msg) {
}
};
/**
* Unexpected response from the XML-RPC method.
*/
class XmlRpcMethodResponseException : public AuthenticationException
{
public:
XmlRpcMethodResponseException(const std::string &msg)
: AuthenticationException(msg) {
}
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace Authentication
} // namespace LiveSupport
#endif // LiveSupport_Authentication_AuthenticationException_h

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/AuthenticationClientFactoryTest.cxx,v $
------------------------------------------------------------------------------*/
@ -116,8 +116,20 @@ AuthenticationClientFactoryTest :: firstTest(void)
Ptr<SessionId>::Ref sessionId;
try {
sessionId = authentication->login("root", "q");
CPPUNIT_ASSERT(sessionId);
CPPUNIT_ASSERT(authentication->logout(sessionId));
}
catch (AuthenticationException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(sessionId);
try {
authentication->logout(sessionId);
}
catch (AuthenticationException &e) {
CPPUNIT_FAIL(e.what());
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/TestAuthenticationClient.cxx,v $
------------------------------------------------------------------------------*/
@ -96,8 +96,7 @@ static const std::string dummySessionIdString = "dummySessionId";
*----------------------------------------------------------------------------*/
void
TestAuthenticationClient :: configure(const xmlpp::Element & element)
throw (std::invalid_argument,
std::logic_error)
throw (std::invalid_argument)
{
if (element.get_name() != configElementNameStr) {
std::string eMsg = "Bad configuration element ";
@ -156,9 +155,9 @@ TestAuthenticationClient :: configure(const xmlpp::Element & element)
Ptr<SessionId>::Ref
TestAuthenticationClient :: login(const std::string & login,
const std::string & password)
throw ()
throw (AuthenticationException)
{
Ptr<SessionId>::Ref sessionId; // initialized to 0
Ptr<SessionId>::Ref sessionId;
if (login == userLogin && password == userPassword) {
std::stringstream sessionIdStream;
@ -168,24 +167,27 @@ TestAuthenticationClient :: login(const std::string & login,
<< rand();
sessionIdList.insert(sessionIdStream.str());
sessionId.reset(new SessionId(sessionIdStream.str()));
}
return sessionId;
}
else {
throw AuthenticationException("Incorrect login or password.");
}
}
/*------------------------------------------------------------------------------
* Logout from the authentication server.
*----------------------------------------------------------------------------*/
const bool
void
TestAuthenticationClient :: logout(Ptr<SessionId>::Ref sessionId)
throw ()
throw (AuthenticationException)
{
// this returns the number of entries found and erased
if (sessionIdList.erase(sessionId->getId())) {
return true;
return;
}
else {
return false;
throw AuthenticationException("Logout called without previous login.");
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/TestAuthenticationClient.h,v $
------------------------------------------------------------------------------*/
@ -92,7 +92,7 @@ using namespace LiveSupport::Core;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.5 $
* @version $Revision: 1.6 $
*/
class TestAuthenticationClient :
virtual public Configurable,
@ -164,8 +164,7 @@ class TestAuthenticationClient :
*/
virtual void
configure(const xmlpp::Element & element)
throw (std::invalid_argument,
std::logic_error);
throw (std::invalid_argument);
/**
* Login to the authentication server, using the data read from the
@ -174,20 +173,23 @@ class TestAuthenticationClient :
* null pointer.
*
* @return the new session ID
* @exception AuthenticationException login or password is incorrect
* (does not match those given in the configuration file)
*/
virtual Ptr<SessionId>::Ref
login(const std::string &login, const std::string &password)
throw ();
throw (AuthenticationException);
/**
* Logout from the authentication server.
*
* @param sessionId the ID of the session to end
* @return true if logged out successfully, false if not
* @exception AuthenticationException the sessionId does not match
* one issued by login()
*/
virtual const bool
virtual void
logout(Ptr<SessionId>::Ref sessionId)
throw ();
throw (AuthenticationException);
};

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/TestAuthenticationClientTest.cxx,v $
------------------------------------------------------------------------------*/
@ -111,13 +111,41 @@ TestAuthenticationClientTest :: firstTest(void)
{
Ptr<SessionId>::Ref sessionId;
CPPUNIT_ASSERT(!(sessionId = tac->login("Piszkos Fred", "malnaszor")));
sessionId.reset(new SessionId("ceci n'est pas un session ID"));
CPPUNIT_ASSERT(!tac->logout(sessionId));
CPPUNIT_ASSERT( sessionId = tac->login("root", "q"));
CPPUNIT_ASSERT( tac->logout(sessionId));
CPPUNIT_ASSERT(!tac->logout(sessionId));
try {
sessionId = tac->login("Piszkos Fred", "malnaszor");
CPPUNIT_FAIL("Allowed login with incorrect login and password.");
}
catch (AuthenticationException &e) {
}
// TODO: this call writes some garbage to cerr; it should be told not to
sessionId.reset(new SessionId("ceci n'est pas un session ID"));
try {
tac->logout(sessionId);
CPPUNIT_FAIL("Allowed logout without previous login.");
}
catch (AuthenticationException &e) {
}
try {
sessionId = tac->login("root", "q");
}
catch (AuthenticationException &e) {
CPPUNIT_FAIL(e.what());
}
try {
tac->logout(sessionId);
}
catch (AuthenticationException &e) {
CPPUNIT_FAIL(e.what());
}
try {
tac->logout(sessionId);
CPPUNIT_FAIL("Allowed to logout twice.");
}
catch (AuthenticationException &e) {
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/WebAuthenticationClient.cxx,v $
------------------------------------------------------------------------------*/
@ -137,8 +137,7 @@ static const std::string statusParamName = "status";
*----------------------------------------------------------------------------*/
void
WebAuthenticationClient :: configure(const xmlpp::Element & element)
throw (std::invalid_argument,
std::logic_error)
throw (std::invalid_argument)
{
if (element.get_name() != configElementNameStr) {
std::string eMsg = "Bad configuration element ";
@ -203,28 +202,43 @@ WebAuthenticationClient :: configure(const xmlpp::Element & element)
Ptr<SessionId>::Ref
WebAuthenticationClient :: login(const std::string & login,
const std::string & password)
throw ()
throw (AuthenticationException)
{
XmlRpcValue parameters;
XmlRpcValue result;
Ptr<SessionId>::Ref sessionId; // initialized to 0
Ptr<SessionId>::Ref sessionId;
XmlRpcClient xmlRpcClient(storageServerName.c_str(), storageServerPort,
storageServerPath.c_str(), false);
parameters.clear();
parameters[loginParamName] = login.c_str();
parameters[passwordParamName] = password.c_str();
result.clear();
if (!xmlRpcClient.execute(loginMethodName.c_str(), parameters, result)) {
return sessionId;
throw Authentication::XmlRpcCommunicationException("Login failed.");
}
if (xmlRpcClient.isFault()) {
std::stringstream eMsg;
eMsg << "Login method returned fault response:\n"
<< result;
throw Authentication::XmlRpcMethodFaultException(eMsg.str());
}
if (! result.hasMember(outputSessionIdParamName)) {
return sessionId;
std::stringstream eMsg;
eMsg << "Login method returned unexpected response:\n"
<< result;
throw Authentication::XmlRpcMethodResponseException(eMsg.str());
}
if (result[outputSessionIdParamName].getType() != XmlRpcValue::TypeString) {
return sessionId;
std::stringstream eMsg;
eMsg << "Login method returned unexpected response:\n"
<< result;
throw Authentication::XmlRpcMethodResponseException(eMsg.str());
}
sessionId.reset(new SessionId(result[outputSessionIdParamName]));
@ -235,9 +249,9 @@ WebAuthenticationClient :: login(const std::string & login,
/*------------------------------------------------------------------------------
* Logout from the authentication server.
*----------------------------------------------------------------------------*/
const bool
void
WebAuthenticationClient :: logout(Ptr<SessionId>::Ref sessionId)
throw ()
throw (AuthenticationException)
{
XmlRpcValue parameters;
XmlRpcValue result;
@ -245,28 +259,28 @@ WebAuthenticationClient :: logout(Ptr<SessionId>::Ref sessionId)
XmlRpcClient xmlRpcClient(storageServerName.c_str(), storageServerPort,
storageServerPath.c_str(), false);
parameters.clear();
parameters[inputSessionIdParamName] = sessionId->getId().c_str();
result.clear();
if (!xmlRpcClient.execute(logoutMethodName.c_str(), parameters, result)) {
return false;
throw Authentication::XmlRpcCommunicationException("Logout failed.");
}
if (xmlRpcClient.isFault()) {
return false;
std::stringstream eMsg;
eMsg << "Logout method returned fault response:\n"
<< result;
throw Authentication::XmlRpcMethodFaultException(eMsg.str());
}
if (! result.hasMember(statusParamName)) {
return sessionId;
}
if (result[statusParamName].getType() != XmlRpcValue::TypeBoolean) {
return sessionId;
}
if (!(bool(result[statusParamName]))) {
return sessionId;
}
return true;
if (! result.hasMember(statusParamName)
|| result[statusParamName].getType() != XmlRpcValue::TypeBoolean
|| ! bool(result[statusParamName])) {
std::stringstream eMsg;
eMsg << "Logout method returned unexpected response:\n"
<< result;
throw Authentication::XmlRpcMethodResponseException(eMsg.str());
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/WebAuthenticationClient.h,v $
------------------------------------------------------------------------------*/
@ -46,6 +46,7 @@
#include "LiveSupport/Core/Configurable.h"
#include "LiveSupport/Core/SessionId.h"
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
#include "LiveSupport/Authentication/AuthenticationException.h"
namespace LiveSupport {
@ -93,7 +94,7 @@ using namespace LiveSupport::Core;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @version $Revision: 1.3 $
*/
class WebAuthenticationClient :
virtual public Configurable,
@ -156,30 +157,43 @@ class WebAuthenticationClient :
*/
virtual void
configure(const xmlpp::Element & element)
throw (std::invalid_argument,
std::logic_error);
throw (std::invalid_argument);
/**
* Login to the authentication server, using the data read from the
* configuration file.
* Returns a new session ID; in case of an error, returns a
* null pointer.
* Returns a new session ID; in case of an error, throws one of three
* types of AuthenticationException.
*
* @param login the login to the server
* @param password the password to the server
* @exception XmlRpcCommunicationException problem with performing
* XML-RPC call
* @exception XmlRpcMethodFaultException XML-RPC method returned
* fault response
* @exception XmlRpcMethodResponseException response from XML-RPC
* method is incorrect
* @return the new session ID
*/
virtual Ptr<SessionId>::Ref
login(const std::string &login, const std::string &password)
throw ();
throw (AuthenticationException);
/**
* Logout from the authentication server.
*
* @param sessionId the ID of the session to end
* @exception XmlRpcCommunicationException problem with performing
* XML-RPC call
* @exception XmlRpcMethodFaultException XML-RPC method returned
* fault response
* @exception XmlRpcMethodResponseException response from XML-RPC
* method is incorrect
* @return true if logged out successfully, false if not
*/
virtual const bool
virtual void
logout(Ptr<SessionId>::Ref sessionId)
throw ();
throw (AuthenticationException);
};

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/WebAuthenticationClientTest.cxx,v $
------------------------------------------------------------------------------*/
@ -111,15 +111,40 @@ WebAuthenticationClientTest :: firstTest(void)
{
Ptr<SessionId>::Ref sessionId;
CPPUNIT_ASSERT(!(sessionId = wac->login("Piszkos Fred", "malnaszor")));
// TODO: this call writes some garbage to cerr; it should be told not to
sessionId.reset(new SessionId("ceci n'est pas un session ID"));
CPPUNIT_ASSERT(!wac->logout(sessionId));
CPPUNIT_ASSERT( sessionId = wac->login("root", "q"));
CPPUNIT_ASSERT( wac->logout(sessionId));
// this does not work due to a bug in the storage server
// CPPUNIT_ASSERT(!wac->logout(sessionId));
try {
sessionId = wac->login("Piszkos Fred", "malnaszor");
CPPUNIT_FAIL("Allowed login with incorrect login and password.");
}
catch (AuthenticationException &e) {
}
sessionId.reset(new SessionId("bad_session_ID"));
try {
wac->logout(sessionId);
CPPUNIT_FAIL("Allowed logout without previous login.");
}
catch (AuthenticationException &e) {
}
try {
sessionId = wac->login("root", "q");
}
catch (AuthenticationException &e) {
CPPUNIT_FAIL(e.what());
}
try {
wac->logout(sessionId);
}
catch (AuthenticationException &e) {
CPPUNIT_FAIL(e.what());
}
try {
wac->logout(sessionId);
CPPUNIT_FAIL("Allowed to logout twice.");
}
catch (AuthenticationException &e) {
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h,v $
------------------------------------------------------------------------------*/
@ -45,6 +45,7 @@
#include "LiveSupport/Core/UniqueId.h"
#include "LiveSupport/Core/Playlist.h"
#include "LiveSupport/Core/SessionId.h"
#include "LiveSupport/Storage/StorageException.h"
namespace LiveSupport {
@ -64,7 +65,7 @@ using namespace Core;
* An interface for storage clients.
*
* @author $Author: fgerlits $
* @version $Revision: 1.1 $
* @version $Revision: 1.2 $
*/
class StorageClientInterface
{
@ -76,11 +77,13 @@ class StorageClientInterface
* @param id the id of the playlist to check for.
* @return true if a playlist with the specified id exists,
* false otherwise.
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual const bool
existsPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -89,13 +92,14 @@ class StorageClientInterface
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to return.
* @return the requested playlist.
* @exception std::logic_error if no playlist with the specified
* @exception StorageException if there is a problem with the XML-RPC
* call or no playlist with the specified
* id exists.
*/
virtual Ptr<Playlist>::Ref
getPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -104,13 +108,14 @@ class StorageClientInterface
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to return.
* @return the requested playlist.
* @exception std::logic_error if no playlist with the specified
* @exception StorageException if there is a problem with the XML-RPC
* call or no playlist with the specified
* id exists.
*/
virtual Ptr<Playlist>::Ref
editPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -118,13 +123,14 @@ class StorageClientInterface
*
* @param sessionId the session ID from the authentication client
* @param playlist the playlist to save.
* @exception std::logic_error if the playlist has not been previously
* opened by getPlaylist()
* @exception StorageException if there is a problem with the XML-RPC
* call or the playlist has not been
* previously opened by getPlaylist()
*/
virtual void
savePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -135,13 +141,14 @@ class StorageClientInterface
* @return a new Playlist instance containing a uri field which
* points to an executable (playable) SMIL representation of
* the playlist (in the local storage).
* @exception std::logic_error if no playlist with the specified
* @exception StorageException if there is a problem with the XML-RPC
* call or no playlist with the specified
* specified id exists.
*/
virtual Ptr<Playlist>::Ref
acquirePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -150,26 +157,28 @@ class StorageClientInterface
*
* @param sessionId the session ID from the authentication client
* @param playlist the playlist to release.
* @exception std::logic_error if the playlist has no uri field,
* @exception StorageException if there is a problem with the XML-RPC
* call or the playlist has no uri field,
* or the file does not exist, etc.
*/
virtual void
releasePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
* Delete a playlist with the specified id.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to be deleted.
* @exception std::logic_error if no playlist with the specified
* @exception StorageException if there is a problem with the XML-RPC
* call or no playlist with the specified
* id exists.
*/
virtual void
deletePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -177,10 +186,12 @@ class StorageClientInterface
*
* @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
* call.
*/
virtual Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
getAllPlaylists(Ptr<SessionId>::Ref sessionId) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -188,10 +199,12 @@ class StorageClientInterface
*
* @param sessionId the session ID from the authentication client
* @return the newly created playlist.
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual Ptr<Playlist>::Ref
createPlaylist(Ptr<SessionId>::Ref sessionId)
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -201,11 +214,13 @@ class StorageClientInterface
* @param id the id of the audio clip to check for.
* @return true if an audio clip with the specified id exists,
* false otherwise.
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual const bool
existsAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -214,13 +229,14 @@ class StorageClientInterface
* @param sessionId the session ID from the authentication client
* @param id the id of the audio clip to return.
* @return the requested audio clip.
* @exception std::logic_error if no audio clip with the
* @exception StorageException if there is a problem with the XML-RPC
* call or no audio clip with the
* specified id exists.
*/
virtual Ptr<AudioClip>::Ref
getAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -230,12 +246,13 @@ class StorageClientInterface
* @param audioClip the audio clip to store.
* @return true if the operation was successful.
*
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call or we have not logged in yet.
*/
virtual bool
storeAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip)
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -245,13 +262,14 @@ class StorageClientInterface
* @param id the id of the audio clip to acquire.
* @return a new AudioClip instance, containing a uri field which
* points to (a way of getting) the sound file.
* @exception std::logic_error if no audio clip with the
* @exception StorageException if there is a problem with the XML-RPC
* call or if no audio clip with the
* specified id exists.
*/
virtual Ptr<AudioClip>::Ref
acquireAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -259,13 +277,14 @@ class StorageClientInterface
*
* @param sessionId the session ID from the authentication client
* @param audioClip the id of the audio clip to release.
* @exception std::logic_error if the audio clip has no uri field,
* @exception StorageException if there is a problem with the XML-RPC
* call or the audio clip has no uri field,
* or the file does not exist, etc.
*/
virtual void
releaseAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -273,13 +292,14 @@ class StorageClientInterface
*
* @param sessionId the session ID from the authentication client
* @param id the id of the audio clip to be deleted.
* @exception std::logic_error if no audio clip with the
* @exception StorageException if there is a problem with the XML-RPC
* call or no audio clip with the
* specified id exists.
*/
virtual void
deleteAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -287,10 +307,12 @@ class StorageClientInterface
*
* @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
* call.
*/
virtual Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref
getAllAudioClips(Ptr<SessionId>::Ref sessionId) const
throw (std::logic_error)
throw (StorageException)
= 0;
};

View File

@ -0,0 +1,115 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/include/LiveSupport/Storage/Attic/StorageException.h,v $
------------------------------------------------------------------------------*/
#ifndef LiveSupport_Storage_StorageException_h
#define LiveSupport_Storage_StorageException_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <stdexcept>
namespace LiveSupport {
namespace Storage {
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* Common parent of exception classes for this module.
*
* @author $Author: fgerlits $
* @version $Revision: 1.1 $
*/
class StorageException : public std::runtime_error
{
public:
StorageException(const std::string &msg)
: std::runtime_error(msg) {
}
};
/**
* XML-RPC communication problem.
*/
class XmlRpcCommunicationException : public StorageException
{
public:
XmlRpcCommunicationException(const std::string &msg)
: StorageException(msg) {
}
};
/**
* XML-RPC fault thrown by the method called.
*/
class XmlRpcMethodFaultException : public StorageException
{
public:
XmlRpcMethodFaultException(const std::string &msg)
: StorageException(msg) {
}
};
/**
* Unexpected response from the XML-RPC method.
*/
class XmlRpcMethodResponseException : public StorageException
{
public:
XmlRpcMethodResponseException(const std::string &msg)
: StorageException(msg) {
}
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace Storage
} // namespace LiveSupport
#endif // LiveSupport_Storage_StorageException_h

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/StorageClientFactoryTest.cxx,v $
------------------------------------------------------------------------------*/
@ -149,10 +149,32 @@ StorageClientFactoryTest :: firstTest(void)
Ptr<UniqueId>::Ref id01(new UniqueId(1));
Ptr<UniqueId>::Ref id77(new UniqueId(77));
try {
CPPUNIT_ASSERT( storage->existsPlaylist(sessionId, id01));
CPPUNIT_ASSERT(!storage->existsPlaylist(sessionId, id77));
}
catch (StorageException &e) {
std::string eMsg = "existsPlaylist returned error:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
try {
CPPUNIT_ASSERT(!storage->existsPlaylist(sessionId, id77));
}
catch (StorageException &e) {
std::string eMsg = "existsPlaylist returned error:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
try {
Ptr<Playlist>::Ref playlist = storage->getPlaylist(sessionId, id01);
CPPUNIT_ASSERT(playlist->getId()->getId() == id01->getId());
}
catch (StorageException &e) {
std::string eMsg = "getPlaylist returned error:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.21 $
Version : $Revision: 1.22 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.cxx,v $
------------------------------------------------------------------------------*/
@ -137,8 +137,7 @@ static const std::string smilPlaylistUriAttrName = "src";
*----------------------------------------------------------------------------*/
void
TestStorageClient :: configure(const xmlpp::Element & element)
throw (std::invalid_argument,
std::logic_error)
throw (std::invalid_argument)
{
if (element.get_name() != configElementNameStr) {
std::string eMsg = "Bad configuration element ";
@ -206,12 +205,12 @@ TestStorageClient :: existsPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref
TestStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::invalid_argument)
throw (StorageException)
{
PlaylistMap::const_iterator it = playlistMap.find(id->getId());
if (it == playlistMap.end()) {
throw std::invalid_argument("no such playlist");
throw StorageException("no such playlist");
}
return it->second;
@ -224,12 +223,12 @@ TestStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref
TestStorageClient :: editPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::invalid_argument)
throw (StorageException)
{
PlaylistMap::const_iterator it = playlistMap.find(id->getId());
if (it == playlistMap.end()) {
throw std::invalid_argument("no such playlist");
throw StorageException("no such playlist");
}
return it->second;
@ -242,7 +241,7 @@ TestStorageClient :: editPlaylist(Ptr<SessionId>::Ref sessionId,
void
TestStorageClient :: savePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error)
throw ()
{
}
@ -253,12 +252,12 @@ TestStorageClient :: savePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref
TestStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
PlaylistMap::const_iterator playlistMapIt = playlistMap.find(id->getId());
if (playlistMapIt == playlistMap.end()) {
throw std::invalid_argument("no such playlist");
throw StorageException("no such playlist");
}
Ptr<Playlist>::Ref oldPlaylist = playlistMapIt->second;
@ -342,16 +341,16 @@ TestStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
void
TestStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error)
throw (StorageException)
{
if (! playlist->getUri()) {
throw std::logic_error("playlist URI not found");
throw StorageException("playlist URI not found");
}
std::ifstream ifs(playlist->getUri()->substr(7).c_str());
if (!ifs) {
ifs.close();
throw std::logic_error("playlist temp file not found");
throw StorageException("playlist temp file not found");
}
ifs.close();
@ -365,7 +364,7 @@ TestStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
try {
releaseAudioClip(sessionId, it->second->getAudioClip());
}
catch (std::invalid_argument &e) {
catch (StorageException &e) {
++badPlaylistElements;
}
++it;
@ -374,7 +373,7 @@ TestStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
try {
releasePlaylist(sessionId, it->second->getPlaylist());
}
catch (std::invalid_argument &e) {
catch (StorageException &e) {
++badPlaylistElements;
}
++it;
@ -391,7 +390,7 @@ TestStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
std::stringstream eMsg;
eMsg << "could not release " << badPlaylistElements
<< " playlist elements in playlist";
throw std::logic_error(eMsg.str());
throw StorageException(eMsg.str());
}
}
@ -402,11 +401,11 @@ TestStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
void
TestStorageClient :: deletePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::invalid_argument)
throw (StorageException)
{
// erase() returns the number of entries found & erased
if (!playlistMap.erase(id->getId())) {
throw std::invalid_argument("no such playlist");
throw StorageException("no such playlist");
}
}
@ -474,12 +473,12 @@ TestStorageClient :: existsAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref
TestStorageClient :: getAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::invalid_argument)
throw (StorageException)
{
AudioClipMap::const_iterator it = audioClipMap.find(id->getId());
if (it == audioClipMap.end()) {
throw std::invalid_argument("no such audio clip");
throw StorageException("no such audio clip");
}
return it->second;
@ -492,7 +491,7 @@ TestStorageClient :: getAudioClip(Ptr<SessionId>::Ref sessionId,
bool
TestStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip)
throw (std::invalid_argument)
throw (StorageException)
{
audioClipMap[audioClip->getId()->getId()] = audioClip;
return true;
@ -505,18 +504,18 @@ TestStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref
TestStorageClient :: acquireAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
AudioClipMap::const_iterator it = audioClipMap.find(id->getId());
if (it == audioClipMap.end()) {
throw std::invalid_argument("no such audio clip");
throw StorageException("no such audio clip");
}
Ptr<AudioClip>::Ref storedAudioClip = it->second;
if (! storedAudioClip->getUri()) {
throw std::logic_error("audio clip URI not found");
throw StorageException("audio clip URI not found");
}
// cut the "file:" off
std::string audioClipFileName = storedAudioClip->getUri()->substr(5);
@ -524,7 +523,7 @@ TestStorageClient :: acquireAudioClip(Ptr<SessionId>::Ref sessionId,
std::ifstream ifs(audioClipFileName.c_str());
if (!ifs) {
ifs.close();
throw std::logic_error("could not read audio clip");
throw StorageException("could not read audio clip");
}
ifs.close();
@ -546,10 +545,10 @@ TestStorageClient :: acquireAudioClip(Ptr<SessionId>::Ref sessionId,
void
TestStorageClient :: releaseAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip) const
throw (std::logic_error)
throw (StorageException)
{
if (*(audioClip->getUri()) == "") {
throw std::logic_error("audio clip URI not found");
throw StorageException("audio clip URI not found");
}
Ptr<std::string>::Ref nullPointer;
@ -563,11 +562,11 @@ TestStorageClient :: releaseAudioClip(Ptr<SessionId>::Ref sessionId,
void
TestStorageClient :: deleteAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::invalid_argument)
throw (StorageException)
{
// erase() returns the number of entries found & erased
if (!audioClipMap.erase(id->getId())) {
throw std::invalid_argument("no such audio clip");
throw StorageException("no such audio clip");
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.19 $
Version : $Revision: 1.20 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.h,v $
------------------------------------------------------------------------------*/
@ -90,7 +90,7 @@ using namespace LiveSupport::Core;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.19 $
* @version $Revision: 1.20 $
*/
class TestStorageClient :
virtual public Configurable,
@ -157,13 +157,11 @@ class TestStorageClient :
* @param element the XML element to configure the object from.
* @exception std::invalid_argument if the supplied XML element
* contains bad configuraiton information
* @exception std::logic_error if the scheduler daemon has already
* been configured, and can not be reconfigured.
*/
virtual void
configure(const xmlpp::Element & element)
throw (std::invalid_argument,
std::logic_error);
throw (std::invalid_argument);
/**
* Tell if a playlist with a given id exists.
@ -178,19 +176,21 @@ class TestStorageClient :
Ptr<UniqueId>::Ref id) const
throw ();
/**
* Return a playlist with the specified id, to be displayed.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to return.
* @return the requested playlist.
* @exception std::invalid_argument if no playlist with the specified
* @exception StorageException if no playlist with the specified
* id exists.
*/
virtual Ptr<Playlist>::Ref
getPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::invalid_argument);
throw (StorageException);
/**
* Return a playlist with the specified id, to be edited.
@ -198,26 +198,26 @@ class TestStorageClient :
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to return.
* @return the requested playlist.
* @exception std::invalid_argument if no playlist with the specified
* @exception StorageException if no playlist with the specified
* id exists.
*/
virtual Ptr<Playlist>::Ref
editPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::invalid_argument);
throw (StorageException);
/**
* Save the playlist after editing.
*
* @param sessionId the session ID from the authentication client
* @param playlist the playlist to save.
* @exception std::logic_error if the playlist has not been previously
* opened by getPlaylist()
*/
virtual void
savePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error);
throw ();
/**
* Acquire the resources for the playlist.
@ -232,13 +232,14 @@ class TestStorageClient :
* @return a new Playlist instance containing a uri field which
* points to an executable (playable) SMIL representation of
* the playlist (in the local storage).
* @exception std::invalid_argument if no playlist with the specified
* @exception StorageException if no playlist with the specified
* specified id exists.
*/
virtual Ptr<Playlist>::Ref
acquirePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
throw (StorageException);
/**
* Release the resources (audio clips, other playlists) used
@ -246,26 +247,27 @@ class TestStorageClient :
*
* @param sessionId the session ID from the authentication client
* @param playlist the playlist to release.
* @exception std::logic_error if the playlist has no uri field,
* @exception StorageException if the playlist has no uri field,
* or the file does not exist, etc.
*/
virtual void
releasePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error);
throw (StorageException);
/**
* Delete the playlist with the specified id.
* Delete a playlist with the specified id.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to be deleted.
* @exception std::invalid_argument if no playlist with the specified
* @exception StorageException if no playlist with the specified
* id exists.
*/
virtual void
deletePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::invalid_argument);
throw (StorageException);
/**
* Return a list of all playlists in the playlist store.
@ -277,6 +279,7 @@ class TestStorageClient :
getAllPlaylists(Ptr<SessionId>::Ref sessionId) const
throw ();
/**
* Create a new playlist.
*
@ -287,6 +290,7 @@ class TestStorageClient :
createPlaylist(Ptr<SessionId>::Ref sessionId)
throw ();
/**
* Tell if an audio clip with a given id exists.
*
@ -306,13 +310,13 @@ class TestStorageClient :
* @param sessionId the session ID from the authentication client
* @param id the id of the audio clip to return.
* @return the requested audio clip.
* @exception std::invalid_argument if no audio clip with the
* @exception StorageException if no audio clip with the
* specified id exists.
*/
virtual Ptr<AudioClip>::Ref
getAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::invalid_argument);
throw (StorageException);
/**
* Store an audio clip.
@ -320,12 +324,13 @@ class TestStorageClient :
* @param sessionId the session ID from the authentication client
* @param audioClip the audio clip to store.
* @return true if the operation was successful.
* @exception std::invalid_argument never in this implementation
*
* @exception StorageException if we have not logged in yet.
*/
virtual bool
storeAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip)
throw (std::invalid_argument);
throw (StorageException);
/**
* Acquire the resources for the audio clip with the specified id.
@ -339,50 +344,52 @@ class TestStorageClient :
* @param id the id of the audio clip to acquire.
* @return a new AudioClip instance, containing a uri field which
* points to (a way of getting) the sound file.
* @exception std::invalid_argument if no audio clip with the
* @exception StorageException if no audio clip with the
* specified id exists.
*/
virtual Ptr<AudioClip>::Ref
acquireAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
throw (StorageException);
/**
* Release the resource (sound file) used by an audio clip.
*
* @param sessionId the session ID from the authentication client
* @param audioClip the audio clip to release.
* @exception std::logic_error if the audio clip has no uri field,
* @param audioClip the id of the audio clip to release.
* @exception StorageException if the audio clip has no uri field,
* or the file does not exist, etc.
*/
virtual void
releaseAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip) const
throw (std::logic_error);
throw (StorageException);
/**
* Delete the audio clip with the specified id.
* Delete an audio clip with the specified id.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the audio clip to be deleted.
* @exception std::invalid_argument if no audio clip with the
* @exception StorageException if no audio clip with the
* specified id exists.
*/
virtual void
deleteAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::invalid_argument);
throw (StorageException);
/**
* Return a list of all audio clips in the playlist store.
*
* @param sessionId the session ID from the authentication client
* @return a vector containing the audio clips.
* @return a vector containing the playlists.
*/
virtual Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref
getAllAudioClips(Ptr<SessionId>::Ref sessionId) const
throw ();
};

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/TestStorageClientTest.cxx,v $
------------------------------------------------------------------------------*/
@ -135,17 +135,17 @@ TestStorageClientTest :: deletePlaylistTest(void)
try {
tsc->deletePlaylist(dummySessionId, id2);
CPPUNIT_FAIL("allowed to delete non-existent playlist");
} catch (std::invalid_argument &e) {
} catch (StorageException &e) {
}
try {
tsc->deletePlaylist(dummySessionId, id1);
} catch (std::invalid_argument &e) {
} catch (StorageException &e) {
CPPUNIT_FAIL("cannot delete existing playlist");
}
try {
tsc->deletePlaylist(dummySessionId, id1);
CPPUNIT_FAIL("allowed to delete non-existent playlist");
} catch (std::invalid_argument &e) {
} catch (StorageException &e) {
}
}
@ -227,7 +227,7 @@ TestStorageClientTest :: acquireAudioClipTest(void)
try {
audioClip = tsc->acquireAudioClip(dummySessionId, id2);
}
catch (std::logic_error &e) {
catch (StorageException &e) {
std::string eMsg = "could not acquire audio clip:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
@ -240,7 +240,7 @@ TestStorageClientTest :: acquireAudioClipTest(void)
try {
tsc->releaseAudioClip(dummySessionId, audioClip);
}
catch (std::logic_error &e) {
catch (StorageException &e) {
std::string eMsg = "could not release audio clip:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
@ -250,7 +250,7 @@ TestStorageClientTest :: acquireAudioClipTest(void)
audioClip = tsc->acquireAudioClip(dummySessionId, id77);
CPPUNIT_FAIL("allowed to acquire non-existent audio clip");
}
catch (std::logic_error &e) {
catch (StorageException &e) {
}
}
@ -269,7 +269,7 @@ TestStorageClientTest :: acquirePlaylistTest(void)
try {
playlist = tsc->acquirePlaylist(dummySessionId, id1);
}
catch (std::logic_error &e) {
catch (StorageException &e) {
std::string eMsg = "could not acquire playlist:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
@ -288,7 +288,7 @@ TestStorageClientTest :: acquirePlaylistTest(void)
try {
tsc->releasePlaylist(dummySessionId, playlist);
}
catch (std::logic_error &e) {
catch (StorageException &e) {
std::string eMsg = "could not release playlist:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
@ -305,6 +305,6 @@ TestStorageClientTest :: acquirePlaylistTest(void)
playlist = tsc->acquirePlaylist(dummySessionId, id77);
CPPUNIT_FAIL("allowed to acquire non-existent playlist");
}
catch (std::logic_error &e) {
catch (StorageException &e) {
}
}

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.cxx,v $
------------------------------------------------------------------------------*/
@ -275,8 +275,7 @@ static const std::string storeAudioClipMethodMetadataFileParamName
*----------------------------------------------------------------------------*/
void
WebStorageClient :: configure(const xmlpp::Element & element)
throw (std::invalid_argument,
std::logic_error)
throw (std::invalid_argument)
{
if (element.get_name() != configElementNameStr) {
std::string eMsg = "Bad configuration element ";
@ -349,7 +348,7 @@ WebStorageClient :: configure(const xmlpp::Element & element)
const bool
WebStorageClient :: existsPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
return false;
}
@ -361,7 +360,7 @@ WebStorageClient :: existsPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref
WebStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
Ptr<Playlist>::Ref playlist(new Playlist);
return playlist;
@ -374,7 +373,7 @@ WebStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref
WebStorageClient :: editPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
Ptr<Playlist>::Ref playlist(new Playlist);
return playlist;
@ -387,7 +386,7 @@ WebStorageClient :: editPlaylist(Ptr<SessionId>::Ref sessionId,
void
WebStorageClient :: savePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error)
throw (StorageException)
{
}
@ -398,7 +397,7 @@ WebStorageClient :: savePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref
WebStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
Ptr<Playlist>::Ref playlist(new Playlist);
return playlist;
@ -411,7 +410,7 @@ WebStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
void
WebStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error)
throw (StorageException)
{
}
@ -423,7 +422,7 @@ WebStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
void
WebStorageClient :: deletePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::logic_error)
throw (StorageException)
{
}
@ -434,7 +433,7 @@ WebStorageClient :: deletePlaylist(Ptr<SessionId>::Ref sessionId,
*----------------------------------------------------------------------------*/
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
WebStorageClient :: getAllPlaylists(Ptr<SessionId>::Ref sessionId) const
throw (std::logic_error)
throw (StorageException)
{
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlistVector(
new std::vector<Ptr<Playlist>::Ref>);
@ -447,7 +446,7 @@ WebStorageClient :: getAllPlaylists(Ptr<SessionId>::Ref sessionId) const
*----------------------------------------------------------------------------*/
Ptr<Playlist>::Ref
WebStorageClient :: createPlaylist(Ptr<SessionId>::Ref sessionId)
throw (std::logic_error)
throw (StorageException)
{
Ptr<Playlist>::Ref playlist(new Playlist);
return playlist;
@ -460,7 +459,7 @@ WebStorageClient :: createPlaylist(Ptr<SessionId>::Ref sessionId)
const bool
WebStorageClient :: existsAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
XmlRpcValue parameters;
XmlRpcValue result;
@ -480,7 +479,7 @@ WebStorageClient :: existsAudioClip(Ptr<SessionId>::Ref sessionId,
std::string eMsg = "cannot execute XML-RPC method '";
eMsg += existsAudioClipMethodName;
eMsg += "'";
throw std::logic_error(eMsg);
throw StorageException(eMsg);
}
if (xmlRpcClient.isFault()
@ -492,7 +491,7 @@ WebStorageClient :: existsAudioClip(Ptr<SessionId>::Ref sessionId,
<< existsAudioClipMethodName
<< "' returned error message:\n"
<< result;
throw std::logic_error(eMsg.str());
throw StorageException(eMsg.str());
}
return bool(result[existsAudioClipMethodResultParamName]);
@ -505,7 +504,7 @@ WebStorageClient :: existsAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref
WebStorageClient :: getAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
XmlRpcValue parameters;
XmlRpcValue result;
@ -525,7 +524,7 @@ WebStorageClient :: getAudioClip(Ptr<SessionId>::Ref sessionId,
std::string eMsg = "cannot execute XML-RPC method '";
eMsg += getAudioClipOpenMethodName;
eMsg += "'";
throw std::logic_error(eMsg);
throw StorageException(eMsg);
}
if (xmlRpcClient.isFault()
@ -540,35 +539,12 @@ WebStorageClient :: getAudioClip(Ptr<SessionId>::Ref sessionId,
<< getAudioClipOpenMethodName
<< "' returned error message:\n"
<< result;
throw std::logic_error(eMsg.str());
throw StorageException(eMsg.str());
}
std::string url = result[getAudioClipMethodUrlParamName];
std::string token = result[getAudioClipMethodTokenParamName];
/*
int offset = 353;
std::cout << "\n" << xmlAudioClip.at(offset+0) << "\n";
std::cout << xmlAudioClip.at(offset+1) << "\n";
std::cout << xmlAudioClip.at(offset+2) << "\n";
std::cout << xmlAudioClip.at(offset+3) << "\n";
std::cout << xmlAudioClip.at(offset+4) << "\n";
std::cout << xmlAudioClip.at(offset+5) << "\n";
std::cout << xmlAudioClip.at(offset+6) << "\n";
std::cout << xmlAudioClip.at(offset+7) << "\n";
std::cout << xmlAudioClip.at(offset+8) << "\n";
std::cout << xmlAudioClip.at(offset+9) << "\n";
std::cout << xmlAudioClip.at(offset+10) << "\n";
std::cout << xmlAudioClip.at(offset+11) << "\n";
std::cout << xmlAudioClip.at(offset+12) << "\n";
std::cout << xmlAudioClip.at(offset+13) << "\n";
std::cout << xmlAudioClip.at(offset+14) << "\n";
std::cout << xmlAudioClip.at(offset+15) << "\n";
std::cout << xmlAudioClip.at(offset+16) << "\n";
std::cout << xmlAudioClip.at(offset+17) << "\n";
std::cout << xmlAudioClip.at(offset+18) << "\n";
std::cout << xmlAudioClip.at(offset+19) << "\n";
std::cout << xmlAudioClip.at(offset+20) << "\n";
*/
Ptr<AudioClip>::Ref audioClip(new AudioClip(id));
try {
@ -579,9 +555,9 @@ std::cout << xmlAudioClip.at(offset+20) << "\n";
audioClip->configure(*root);
} catch (std::invalid_argument &e) {
throw std::logic_error("semantic error in audio clip metafile");
throw StorageException("semantic error in audio clip metafile");
} catch (xmlpp::exception &e) {
throw std::logic_error("error parsing audio clip metafile");
throw StorageException("error parsing audio clip metafile");
}
parameters.clear();
@ -596,7 +572,7 @@ std::cout << xmlAudioClip.at(offset+20) << "\n";
std::string eMsg = "cannot execute XML-RPC method '";
eMsg += getAudioClipCloseMethodName;
eMsg += "'";
throw std::logic_error(eMsg);
throw StorageException(eMsg);
}
if (xmlRpcClient.isFault()
@ -610,7 +586,7 @@ std::cout << xmlAudioClip.at(offset+20) << "\n";
<< getAudioClipCloseMethodName
<< "' returned error message:\n"
<< result;
throw std::logic_error(eMsg.str());
throw StorageException(eMsg.str());
}
return audioClip;
@ -618,22 +594,22 @@ std::cout << xmlAudioClip.at(offset+20) << "\n";
/*------------------------------------------------------------------------------
* Store an audio clip.
* Upload an audio clip to the local storage.
*----------------------------------------------------------------------------*/
bool
WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip)
throw (std::logic_error)
throw (StorageException)
{
if (!audioClip || !audioClip->getUri()) {
throw std::logic_error("binary audio clip file not found");
throw StorageException("binary audio clip file not found");
}
Ptr<xmlpp::Document>::Ref metadata = audioClip->getMetadata();
std::stringstream metadataFileName;
metadataFileName << localTempStorage << "-audioClipMetadata-"
<< audioClip->getId()->getId()
<< std::string(*audioClip->getId())
<< "-" << rand() << ".xml";
metadata->write_to_file(metadataFileName.str(), "UTF-8");
@ -644,7 +620,7 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
std::ifstream ifs(binaryFileName.c_str());
if (!ifs) {
ifs.close();
throw std::logic_error("could not read audio clip");
throw StorageException("could not read audio clip");
}
ifs.close();
std::string binaryFilePrefix("file://");
@ -661,7 +637,7 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
parameters[storeAudioClipMethodSessionIdParamName]
= sessionId->getId();
parameters[storeAudioClipMethodAudioClipIdParamName]
= int(audioClip->getId()->getId());
= std::string(*audioClip->getId());
parameters[storeAudioClipMethodBinaryFileParamName]
= binaryFileName;
parameters[storeAudioClipMethodMetadataFileParamName]
@ -675,7 +651,7 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
std::string eMsg = "cannot execute XML-RPC method '";
eMsg += storeAudioClipMethodName;
eMsg += "'";
throw std::logic_error(eMsg);
throw StorageException(eMsg);
}
if (xmlRpcClient.isFault()
@ -685,7 +661,7 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
<< storeAudioClipMethodName
<< "' returned error message:\n"
<< result;
throw std::logic_error(eMsg.str());
throw StorageException(eMsg.str());
}
return true;
@ -698,7 +674,7 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref
WebStorageClient :: acquireAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
Ptr<AudioClip>::Ref playlist(new AudioClip);
return playlist;
@ -712,7 +688,7 @@ WebStorageClient :: acquireAudioClip(Ptr<SessionId>::Ref sessionId,
void
WebStorageClient :: releaseAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip) const
throw (std::logic_error)
throw (StorageException)
{
}
@ -724,7 +700,7 @@ WebStorageClient :: releaseAudioClip(Ptr<SessionId>::Ref sessionId,
void
WebStorageClient :: deleteAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::logic_error)
throw (StorageException)
{
}
@ -736,7 +712,7 @@ WebStorageClient :: deleteAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref
WebStorageClient :: getAllAudioClips(Ptr<SessionId>::Ref sessionId)
const
throw (std::logic_error)
throw (StorageException)
{
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref audioClipVector(
new std::vector<Ptr<AudioClip>::Ref>);
@ -749,7 +725,7 @@ WebStorageClient :: getAllAudioClips(Ptr<SessionId>::Ref sessionId)
*----------------------------------------------------------------------------*/
Ptr<std::vector<Ptr<UniqueId>::Ref> >::Ref
WebStorageClient :: reset(void)
throw (std::logic_error)
throw (StorageException)
{
XmlRpcValue parameters;
XmlRpcValue result;
@ -766,7 +742,7 @@ WebStorageClient :: reset(void)
std::string eMsg = "cannot execute XML-RPC method '";
eMsg += resetStorageMethodName;
eMsg += "'";
throw std::logic_error(eMsg);
throw StorageException(eMsg);
}
if (xmlRpcClient.isFault()
@ -778,7 +754,7 @@ WebStorageClient :: reset(void)
<< resetStorageMethodName
<< "' returned error message:\n"
<< result;
throw std::logic_error(eMsg.str());
throw StorageException(eMsg.str());
}
XmlRpcValue uniqueIdArray = result[resetStorageMethodResultParamName];
@ -792,7 +768,7 @@ WebStorageClient :: reset(void)
<< resetStorageMethodName
<< "':\n"
<< result;
throw std::logic_error(eMsg.str());
throw StorageException(eMsg.str());
}
Ptr<UniqueId>::Ref uniqueId(new UniqueId(std::string(uniqueIdArray[i])));
returnValue->push_back(uniqueId);

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.9 $
Version : $Revision: 1.10 $
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.9 $
* @version $Revision: 1.10 $
*/
class WebStorageClient :
virtual public Configurable,
@ -153,19 +153,18 @@ class WebStorageClient :
return configElementNameStr;
}
/**
* Configure the object based on the XML element supplied.
*
* @param element the XML element to configure the object from.
* @exception std::invalid_argument if the supplied XML element
* contains bad configuraiton information
* @exception std::logic_error if the scheduler daemon has already
* been configured, and can not be reconfigured.
*/
virtual void
configure(const xmlpp::Element & element)
throw (std::invalid_argument,
std::logic_error);
throw (std::invalid_argument);
/**
* Tell if a playlist with a given id exists.
@ -174,12 +173,13 @@ class WebStorageClient :
* @param id the id of the playlist to check for.
* @return true if a playlist with the specified id exists,
* false otherwise.
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual const bool
existsPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
throw (StorageException);
/**
* Return a playlist with the specified id, to be displayed.
@ -187,14 +187,15 @@ class WebStorageClient :
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to return.
* @return the requested playlist.
* @exception std::logic_error if no playlist with the specified
* @exception StorageException if there is a problem with the XML-RPC
* call or no playlist with the specified
* id exists.
* @exception std::logic_error if we have not logged in yet.
*/
virtual Ptr<Playlist>::Ref
getPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
throw (StorageException);
/**
* Return a playlist with the specified id, to be edited.
@ -202,27 +203,29 @@ class WebStorageClient :
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to return.
* @return the requested playlist.
* @exception std::logic_error if no playlist with the specified
* @exception StorageException if there is a problem with the XML-RPC
* call or no playlist with the specified
* id exists.
* @exception std::logic_error if we have not logged in yet.
*/
virtual Ptr<Playlist>::Ref
editPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
throw (StorageException);
/**
* Save the playlist after editing.
*
* @param sessionId the session ID from the authentication client
* @param playlist the playlist to save.
* @exception std::logic_error if the playlist has not been previously
* opened by getPlaylist()
* @exception StorageException if there is a problem with the XML-RPC
* call or the playlist has not been
* previously opened by getPlaylist()
*/
virtual void
savePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error);
throw (StorageException);
/**
* Acquire the resources for the playlist.
@ -237,14 +240,14 @@ class WebStorageClient :
* @return a new Playlist instance containing a uri field which
* points to an executable (playable) SMIL representation of
* the playlist (in the local storage).
* @exception std::logic_error if no playlist with the specified
* @exception StorageException if there is a problem with the XML-RPC
* call or no playlist with the specified
* specified id exists.
* @exception std::logic_error if we have not logged in yet.
*/
virtual Ptr<Playlist>::Ref
acquirePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
throw (StorageException);
/**
* Release the resources (audio clips, other playlists) used
@ -253,50 +256,52 @@ class WebStorageClient :
*
* @param sessionId the session ID from the authentication client
* @param playlist the playlist to release.
* @exception std::logic_error if the playlist has no uri field,
* @exception StorageException if there is a problem with the XML-RPC
* call or the playlist has no uri field,
* or the file does not exist, etc.
* @exception std::logic_error if we have not logged in yet.
*/
virtual void
releasePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error);
throw (StorageException);
/**
* Delete the playlist with the specified id.
* Delete a playlist with the specified id.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to be deleted.
* @exception std::logic_error if no playlist with the specified
* @exception StorageException if there is a problem with the XML-RPC
* call or no playlist with the specified
* id exists.
* @exception std::logic_error if we have not logged in yet.
*/
virtual void
deletePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::logic_error);
throw (StorageException);
/**
* Return a list of all playlists in the playlist store.
*
* @param sessionId the session ID from the authentication client
* @return a vector containing the playlists.
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
getAllPlaylists(Ptr<SessionId>::Ref sessionId) const
throw (std::logic_error);
throw (StorageException);
/**
* Create a new playlist.
*
* @param sessionId the session ID from the authentication client
* @return the newly created playlist.
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual Ptr<Playlist>::Ref
createPlaylist(Ptr<SessionId>::Ref sessionId)
throw (std::logic_error);
throw (StorageException);
/**
* Tell if an audio clip with a given id exists.
@ -305,12 +310,13 @@ class WebStorageClient :
* @param id the id of the audio clip to check for.
* @return true if an audio clip with the specified id exists,
* false otherwise.
* @exception std::logic_error if we have not logged in yet
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual const bool
existsAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
throw (StorageException);
/**
* Return an audio clip with the specified id.
@ -318,14 +324,14 @@ class WebStorageClient :
* @param sessionId the session ID from the authentication client
* @param id the id of the audio clip to return.
* @return the requested audio clip.
* @exception std::logic_error if no audio clip with the
* @exception StorageException if there is a problem with the XML-RPC
* call or no audio clip with the
* specified id exists.
* @exception std::logic_error if we have not logged in yet.
*/
virtual Ptr<AudioClip>::Ref
getAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
throw (StorageException);
/**
* Store an audio clip. The <code>uri</code> field of the audio clip
@ -339,12 +345,13 @@ class WebStorageClient :
* @param audioClip the audio clip to store.
* @return true if the operation was successful.
*
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call or we have not logged in yet.
*/
virtual bool
storeAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip)
throw (std::logic_error);
throw (StorageException);
/**
* Acquire the resources for the audio clip with the specified id.
@ -356,14 +363,14 @@ class WebStorageClient :
* @param id the id of the audio clip to acquire.
* @return a new AudioClip instance, containing a uri field which
* points to (a way of getting) the sound file.
* @exception std::logic_error if no audio clip with the
* @exception StorageException if there is a problem with the XML-RPC
* call or if no audio clip with the
* specified id exists.
* @exception std::logic_error if we have not logged in yet.
*/
virtual Ptr<AudioClip>::Ref
acquireAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
throw (StorageException);
/**
* Release the resource (sound file) used by an audio clip. The
@ -371,40 +378,42 @@ class WebStorageClient :
* deleted.
*
* @param sessionId the session ID from the authentication client
* @param audioClip the audio clip to release.
* @exception std::logic_error if the audio clip has no uri field,
* @param audioClip the id of the audio clip to release.
* @exception StorageException if there is a problem with the XML-RPC
* call or the audio clip has no uri field,
* or the file does not exist, etc.
* @exception std::logic_error if we have not logged in yet.
*/
virtual void
releaseAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip) const
throw (std::logic_error);
throw (StorageException);
/**
* Delete the audio clip with the specified id.
* Delete an audio clip with the specified id.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the audio clip to be deleted.
* @exception std::logic_error if no audio clip with the
* @exception StorageException if there is a problem with the XML-RPC
* call or no audio clip with the
* specified id exists.
* @exception std::logic_error if we have not logged in yet.
*/
virtual void
deleteAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::logic_error);
throw (StorageException);
/**
* Return a list of all audio clips in the playlist store.
*
* @param sessionId the session ID from the authentication client
* @return a vector containing the audio clips.
* @exception std::logic_error if we have not logged in yet.
* @return a vector containing the playlists.
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref
getAllAudioClips(Ptr<SessionId>::Ref sessionId) const
throw (std::logic_error);
throw (StorageException);
/**
* Reset the storage to its initial state. Used for testing.
@ -415,7 +424,7 @@ class WebStorageClient :
*/
Ptr<std::vector<Ptr<UniqueId>::Ref> >::Ref
reset(void)
throw (std::logic_error);
throw (StorageException);
};

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.9 $
Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClientTest.cxx,v $
------------------------------------------------------------------------------*/
@ -137,18 +137,37 @@ WebStorageClientTest :: firstTest(void)
{
Ptr<SessionId>::Ref sessionId(new SessionId("bad ID"));
// this does not currently work due to a bug in the storage server
// try {
// wsc->logout(sessionId);
// CPPUNIT_FAIL("allowed logout operation without login");
// }
// catch (std::logic_error &e) {
// }
try {
authentication->logout(sessionId);
CPPUNIT_FAIL("allowed logout operation without login");
}
catch (AuthenticationException &e) {
}
CPPUNIT_ASSERT(!(sessionId = authentication->login("noSuchUser",
"incorrectPassword")));
CPPUNIT_ASSERT( (sessionId = authentication->login("root", "q")));
CPPUNIT_ASSERT( authentication->logout(sessionId));
try {
sessionId = authentication->login("noSuchUser", "incorrectPassword");
CPPUNIT_FAIL("Allowed login with incorrect password.");
}
catch (AuthenticationException &e) {
}
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "Login failed.";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
try {
authentication->logout(sessionId);
}
catch (AuthenticationException &e) {
std::string eMsg = "Login failed.";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}
@ -175,7 +194,7 @@ WebStorageClientTest :: audioClipTest(void)
try {
exists = wsc->existsAudioClip(sessionId, id01);
}
catch (std::logic_error &e) {
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(exists);
@ -184,7 +203,7 @@ WebStorageClientTest :: audioClipTest(void)
try {
audioClip = wsc->getAudioClip(sessionId, id01);
}
catch (std::logic_error &e) {
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
}
@ -192,11 +211,10 @@ WebStorageClientTest :: audioClipTest(void)
try {
exists = wsc->existsAudioClip(sessionId, id77);
}
catch (std::logic_error &e) {
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(!exists);
/*
Ptr<time_duration>::Ref playlength(new time_duration(0,0,11,0));
Ptr<std::string>::Ref uri(new std::string("file:var/test10001.mp3"));
@ -205,7 +223,7 @@ WebStorageClientTest :: audioClipTest(void)
try {
wsc->storeAudioClip(sessionId, audioClip);
}
catch (std::logic_error &e) {
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
}
@ -213,11 +231,16 @@ WebStorageClientTest :: audioClipTest(void)
Ptr<AudioClip>::Ref newAudioClip
= wsc->getAudioClip(sessionId, id01);
CPPUNIT_ASSERT(newAudioClip->getId()->getId() == id01->getId());
CPPUNIT_ASSERT(std::string(*newAudioClip->getId()) == std::string(*id01);
CPPUNIT_ASSERT(newAudioClip->getPlaylength()->total_seconds()
== audioClip->getPlaylength()->total_seconds());
*/
CPPUNIT_ASSERT( authentication->logout(sessionId));
try{
authentication->logout(sessionId);
}
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
}
/*
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref audioClipVector =
wsc->getAllAudioClips();

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/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -111,7 +111,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try{
sessionId = XmlRpcTools::extractSessionId(parameters);
}
catch (std::invalid_argument &e) {
catch (StorageException &e) {
XmlRpcTools::markError(errorId+20,
"missing session ID argument",
returnValue);
@ -122,7 +122,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try{
playlistId = XmlRpcTools::extractPlaylistId(parameters);
}
catch (std::invalid_argument &e) {
catch (StorageException &e) {
XmlRpcTools::markError(errorId+2, "missing playlist ID argument",
returnValue);
return;
@ -132,7 +132,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try{
audioClipId = XmlRpcTools::extractAudioClipId(parameters);
}
catch (std::invalid_argument &e) {
catch (StorageException &e) {
XmlRpcTools::markError(errorId+3, "missing audio clip ID argument",
returnValue);
return;
@ -142,7 +142,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try{
relativeOffset = XmlRpcTools::extractRelativeOffset(parameters);
}
catch (std::invalid_argument &e) {
catch (StorageException &e) {
XmlRpcTools::markError(errorId+4, "missing relative offset argument",
returnValue);
return;
@ -157,7 +157,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try {
playlist = storage->getPlaylist(sessionId, playlistId);
}
catch (std::invalid_argument &e) {
catch (StorageException &e) {
XmlRpcTools::markError(errorId+5, "playlist not found",
returnValue);
return;
@ -174,7 +174,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try {
audioClip = storage->getAudioClip(sessionId, audioClipId);
}
catch (std::invalid_argument &e) {
catch (StorageException &e) {
XmlRpcTools::markError(errorId+7, "audio clip does not exist",
returnValue);
return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.7 $
Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -137,8 +137,13 @@ AddAudioClipToPlaylistMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}
@ -171,6 +176,7 @@ AddAudioClipToPlaylistMethodTest :: firstTest(void)
rootParameter.setSize(1);
XmlRpc::XmlRpcValue result;
parameters.clear();
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = 1;
parameters["audioClipId"] = 10001;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.7 $
Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -123,10 +123,21 @@ CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
scf = StorageClientFactory::getInstance();
storage = scf->getStorageClient();
Ptr<Playlist>::Ref playlist = storage->createPlaylist(sessionId);
Ptr<Playlist>::Ref playlist;
try {
playlist = storage->createPlaylist(sessionId);
}
catch (StorageException &e) {
std::string eMsg = "could not create playlist:\n";
eMsg += e.what();
XmlRpcTools :: markError(errorId+2,
eMsg,
returnValue);
return;
}
if (!playlist->setLockedForEditing(true)) { // this should never happen
XmlRpcTools :: markError(errorId+1,
XmlRpcTools :: markError(errorId+3,
"could not open new playlist for editing",
returnValue);
return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.6 $
Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.h,v $
------------------------------------------------------------------------------*/
@ -88,12 +88,14 @@ using namespace LiveSupport::Core;
* and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* possible errors are:
* <ul>
* <li>201 - could not open new playlist for editing</li>
* <li>201 - invalid argument format</li>
* <li>202 - could not create playlist</li>
* <li>203 - could not open new playlist for editing</li>
* <li>220 - missing session ID argument </li>
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.6 $
* @version $Revision: 1.7 $
*/
class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
{

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.9 $
Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -137,8 +137,13 @@ CreatePlaylistMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.7 $
Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -126,9 +126,10 @@ DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try {
playlist = storage->getPlaylist(sessionId, playlistId);
}
catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+3, "playlist not found",
returnValue);
catch (StorageException &e) {
std::string eMsg = "playlist not found:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+3, eMsg, returnValue);
return;
}
@ -141,9 +142,10 @@ DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try {
storage->deletePlaylist(sessionId, playlistId);
}
catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+5, "playlist could not be deleted",
returnValue);
catch (StorageException &e) {
std::string eMsg = "playlist could not be deleted:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+5, eMsg, returnValue);
return;
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -138,8 +138,13 @@ DeletePlaylistMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -137,9 +137,10 @@ DisplayAudioClipMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try {
audioClip = storage->getAudioClip(sessionId, id);
}
catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+3, "audio clip not found",
returnValue);
catch (StorageException &e) {
std::string eMsg = "audio clip not found:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+3, eMsg, returnValue);
return;
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -135,8 +135,13 @@ DisplayAudioClipMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipsMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -113,8 +113,16 @@ DisplayAudioClipsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
scf = StorageClientFactory::getInstance();
storage = scf->getStorageClient();
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref audioClipVector =
storage->getAllAudioClips(sessionId);
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref audioClipVector;
try {
audioClipVector = storage->getAllAudioClips(sessionId);
}
catch (StorageException &e) {
std::string eMsg = "getAllAudioClips returned error:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+2, eMsg, returnValue);
return;
}
XmlRpcTools::audioClipVectorToXmlRpcValue(audioClipVector, returnValue);
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipsMethod.h,v $
------------------------------------------------------------------------------*/
@ -93,11 +93,13 @@ using namespace LiveSupport::Core;
* and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* possible errors are:
* <ul>
* <li>1801 - invalid argument format </li>
* <li>1802 - XML-RPC error </li>
* <li>1820 - missing session ID argument </li>
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.4 $
* @version $Revision: 1.5 $
*/
class DisplayAudioClipsMethod : public XmlRpc::XmlRpcServerMethod
{

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -136,8 +136,13 @@ DisplayAudioClipsMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.6 $
Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -137,9 +137,10 @@ DisplayPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try {
playlist = storage->getPlaylist(sessionId, id);
}
catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+3, "playlist not found",
returnValue);
catch (StorageException &e) {
std::string eMsg = "playlist not found:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+3, eMsg, returnValue);
return;
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -135,8 +135,13 @@ DisplayPlaylistMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -114,8 +114,16 @@ DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
scf = StorageClientFactory::getInstance();
storage = scf->getStorageClient();
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlistVector =
storage->getAllPlaylists(sessionId);
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlistVector;
try {
playlistVector = storage->getAllPlaylists(sessionId);
}
catch (StorageException &e) {
std::string eMsg = "getAllPlaylists() returned error:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+2, eMsg, returnValue);
return;
}
XmlRpcTools::playlistVectorToXmlRpcValue(playlistVector, returnValue);
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.6 $
Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h,v $
------------------------------------------------------------------------------*/
@ -93,11 +93,13 @@ using namespace LiveSupport::Core;
* and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* possible errors are:
* <ul>
* <li>1701 - invalid argument format </li>
* <li>1702 - XML-RPC error </li>
* <li>1720 - missing session ID argument </li>
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.6 $
* @version $Revision: 1.7 $
*/
class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod
{

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -136,8 +136,13 @@ DisplayPlaylistsMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -122,6 +122,7 @@ DisplayScheduleMethodTest :: configure(
void
DisplayScheduleMethodTest :: setUp(void) throw ()
{
Ptr<AuthenticationClientFactory>::Ref acf;
try {
Ptr<StorageClientFactory>::Ref scf
= StorageClientFactory::getInstance();
@ -137,10 +138,8 @@ DisplayScheduleMethodTest :: setUp(void) throw ()
schedule = sf->getSchedule();
schedule->install();
Ptr<AuthenticationClientFactory>::Ref
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfig);
authentication = acf->getAuthenticationClient();
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL("semantic error in configuration file");
@ -150,8 +149,14 @@ DisplayScheduleMethodTest :: setUp(void) throw ()
CPPUNIT_FAIL(e.what());
}
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
authentication = acf->getAuthenticationClient();
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
insertEntries(); // this can only be called after sessionId is obtained

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -152,8 +152,13 @@ GeneratePlayReportMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.11 $
Version : $Revision: 1.12 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -138,9 +138,10 @@ OpenPlaylistForEditingMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try {
playlist = storage->getPlaylist(sessionId, id);
}
catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+4, "playlist not found",
returnValue);
catch (StorageException &e) {
std::string eMsg = "playlist not found:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+4, eMsg, returnValue);
return;
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.9 $
Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -136,8 +136,13 @@ OpenPlaylistForEditingMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.6 $
Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -150,9 +150,10 @@ RemoveAudioClipFromPlaylistMethod :: execute(
try {
playlist = storage->getPlaylist(sessionId, playlistId);
}
catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+4, "playlist does not exist",
returnValue);
catch (StorageException &e) {
std::string eMsg = "playlist does not exist:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+4, eMsg, returnValue);
return;
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -141,8 +141,13 @@ RemoveAudioClipFromPlaylistMethodTest :: setUp(void) thr
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -125,8 +125,13 @@ RemoveFromScheduleMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RescheduleMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -127,8 +127,13 @@ RescheduleMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -133,9 +133,10 @@ RevertEditedPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try {
playlist = storage->getPlaylist(sessionId, id);
}
catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+3, "playlist not found",
returnValue);
catch (StorageException &e) {
std::string eMsg = "playlist not found:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+3, eMsg, returnValue);
return;
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -139,8 +139,13 @@ RevertEditedPlaylistMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcAddAudioClipToPlaylistTest.cxx,v $
------------------------------------------------------------------------------*/
@ -154,8 +154,13 @@ RpcAddAudioClipToPlaylistTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcDisplayAudioClipTest.cxx,v $
------------------------------------------------------------------------------*/
@ -135,8 +135,13 @@ DisplayAudioClipMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcDisplayPlaylistTest.cxx,v $
------------------------------------------------------------------------------*/
@ -128,15 +128,15 @@ RpcDisplayPlaylistTest :: setUp(void) throw ()
// daemon->start();
// sleep(5);
Ptr<AuthenticationClientFactory>::Ref acf;
try {
Ptr<StorageClientFactory>::Ref scf
= StorageClientFactory::getInstance();
configure(scf, storageClientConfig);
Ptr<AuthenticationClientFactory>::Ref acf;
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfigFileName);
authentication = acf->getAuthenticationClient();
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("semantic error in authentication configuration file");
@ -145,8 +145,14 @@ RpcDisplayPlaylistTest :: setUp(void) throw ()
CPPUNIT_FAIL("error parsing authentication configuration file");
}
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
authentication = acf->getAuthenticationClient();
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcDisplayPlaylistsTest.cxx,v $
------------------------------------------------------------------------------*/
@ -136,8 +136,13 @@ DisplayPlaylistsMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcDisplayScheduleTest.cxx,v $
------------------------------------------------------------------------------*/
@ -121,11 +121,11 @@ RpcDisplayScheduleTest :: setUp(void) throw ()
// daemon->start();
// sleep(5);
try {
Ptr<AuthenticationClientFactory>::Ref acf;
try {
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfigFileName);
authentication = acf->getAuthenticationClient();
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("semantic error in authentication configuration file");
@ -134,8 +134,14 @@ RpcDisplayScheduleTest :: setUp(void) throw ()
CPPUNIT_FAIL("error parsing authentication configuration file");
}
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
authentication = acf->getAuthenticationClient();
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcRemoveFromScheduleTest.cxx,v $
------------------------------------------------------------------------------*/
@ -121,11 +121,11 @@ RpcRemoveFromScheduleTest :: setUp(void) throw ()
// daemon->start();
// sleep(5);
try {
Ptr<AuthenticationClientFactory>::Ref acf;
try {
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfigFileName);
authentication = acf->getAuthenticationClient();
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("semantic error in authentication configuration file");
@ -134,8 +134,14 @@ RpcRemoveFromScheduleTest :: setUp(void) throw ()
CPPUNIT_FAIL("error parsing authentication configuration file");
}
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
authentication = acf->getAuthenticationClient();
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcRescheduleTest.cxx,v $
------------------------------------------------------------------------------*/
@ -120,11 +120,11 @@ RpcRescheduleTest :: setUp(void) throw ()
// daemon->start();
// sleep(5);
try {
Ptr<AuthenticationClientFactory>::Ref acf;
try {
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfigFileName);
authentication = acf->getAuthenticationClient();
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("semantic error in authentication configuration file");
@ -133,8 +133,14 @@ RpcRescheduleTest :: setUp(void) throw ()
CPPUNIT_FAIL("error parsing authentication configuration file");
}
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
authentication = acf->getAuthenticationClient();
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcUploadPlaylistTest.cxx,v $
------------------------------------------------------------------------------*/
@ -123,11 +123,11 @@ RpcUploadPlaylistTest :: setUp(void) throw ()
// daemon->start();
// sleep(5);
try {
Ptr<AuthenticationClientFactory>::Ref acf;
try {
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfigFileName);
authentication = acf->getAuthenticationClient();
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("semantic error in authentication configuration file");
@ -136,8 +136,14 @@ RpcUploadPlaylistTest :: setUp(void) throw ()
CPPUNIT_FAIL("error parsing authentication configuration file");
}
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
authentication = acf->getAuthenticationClient();
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SavePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -133,9 +133,10 @@ SavePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try {
playlist = storage->getPlaylist(sessionId, id);
}
catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+3, "playlist not found",
returnValue);
catch (StorageException &e) {
std::string eMsg = "playlist not found:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+3, eMsg, returnValue);
return;
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SavePlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -136,8 +136,13 @@ SavePlaylistMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -174,9 +174,10 @@ UpdateFadeInFadeOutMethod :: execute(
try {
playlist = storage->getPlaylist(sessionId, playlistId);
}
catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+6, "playlist does not exist",
returnValue);
catch (StorageException &e) {
std::string eMsg = "playlist does not exist:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+6, eMsg, returnValue);
return;
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -139,8 +139,13 @@ UpdateFadeInFadeOutMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.9 $
Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -146,9 +146,10 @@ UploadPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try {
playlist = storage->getPlaylist(sessionId, playlistId);
}
catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+4, "playlist not found",
returnValue);
catch (StorageException &e) {
std::string eMsg = "playlist not found:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+4, eMsg, returnValue);
return;
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.7 $
Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -147,8 +147,13 @@ UploadPlaylistMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.6 $
Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -138,9 +138,10 @@ ValidatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try {
playlist = storage->getPlaylist(sessionId, playlistId);
}
catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+3, "playlist does not exist",
returnValue);
catch (StorageException &e) {
std::string eMsg = "playlist does not exist:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+3, eMsg, returnValue);
return;
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -139,8 +139,13 @@ ValidatePlaylistMethodTest :: setUp(void) throw ()
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}