From de2b5a49a28bfebb8da48c87d293fbdf8ee178b2 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Thu, 23 Dec 2004 11:37:55 +0000 Subject: [PATCH] modified the authentication and storage modules to throw their own exception classes AuthenticationException and StorageException instead of invalid_argument and logic_error --- .../AuthenticationClientInterface.h | 37 +++-- .../Authentication/AuthenticationException.h | 115 +++++++++++++ .../src/AuthenticationClientFactoryTest.cxx | 18 +- .../src/TestAuthenticationClient.cxx | 24 +-- .../src/TestAuthenticationClient.h | 18 +- .../src/TestAuthenticationClientTest.cxx | 40 ++++- .../src/WebAuthenticationClient.cxx | 62 ++++--- .../src/WebAuthenticationClient.h | 32 +++- .../src/WebAuthenticationClientTest.cxx | 45 +++-- .../Storage/StorageClientInterface.h | 100 ++++++----- .../LiveSupport/Storage/StorageException.h | 115 +++++++++++++ .../storage/src/StorageClientFactoryTest.cxx | 32 +++- .../modules/storage/src/TestStorageClient.cxx | 57 ++++--- .../modules/storage/src/TestStorageClient.h | 129 +++++++------- .../storage/src/TestStorageClientTest.cxx | 20 +-- .../modules/storage/src/WebStorageClient.cxx | 100 +++++------ .../modules/storage/src/WebStorageClient.h | 157 +++++++++--------- .../storage/src/WebStorageClientTest.cxx | 61 ++++--- .../src/AddAudioClipToPlaylistMethod.cxx | 14 +- .../src/AddAudioClipToPlaylistMethodTest.cxx | 12 +- .../scheduler/src/CreatePlaylistMethod.cxx | 19 ++- .../scheduler/src/CreatePlaylistMethod.h | 8 +- .../src/CreatePlaylistMethodTest.cxx | 11 +- .../scheduler/src/DeletePlaylistMethod.cxx | 16 +- .../src/DeletePlaylistMethodTest.cxx | 11 +- .../scheduler/src/DisplayAudioClipMethod.cxx | 9 +- .../src/DisplayAudioClipMethodTest.cxx | 11 +- .../scheduler/src/DisplayAudioClipsMethod.cxx | 14 +- .../scheduler/src/DisplayAudioClipsMethod.h | 6 +- .../src/DisplayAudioClipsMethodTest.cxx | 11 +- .../scheduler/src/DisplayPlaylistMethod.cxx | 9 +- .../src/DisplayPlaylistMethodTest.cxx | 11 +- .../scheduler/src/DisplayPlaylistsMethod.cxx | 16 +- .../scheduler/src/DisplayPlaylistsMethod.h | 6 +- .../src/DisplayPlaylistsMethodTest.cxx | 11 +- .../src/DisplayScheduleMethodTest.cxx | 17 +- .../src/GeneratePlayReportMethodTest.cxx | 11 +- .../src/OpenPlaylistForEditingMethod.cxx | 9 +- .../src/OpenPlaylistForEditingMethodTest.cxx | 11 +- .../src/RemoveAudioClipFromPlaylistMethod.cxx | 9 +- .../RemoveAudioClipFromPlaylistMethodTest.cxx | 11 +- .../src/RemoveFromScheduleMethodTest.cxx | 11 +- .../scheduler/src/RescheduleMethodTest.cxx | 11 +- .../src/RevertEditedPlaylistMethod.cxx | 9 +- .../src/RevertEditedPlaylistMethodTest.cxx | 11 +- .../src/RpcAddAudioClipToPlaylistTest.cxx | 11 +- .../scheduler/src/RpcDisplayAudioClipTest.cxx | 11 +- .../scheduler/src/RpcDisplayPlaylistTest.cxx | 16 +- .../scheduler/src/RpcDisplayPlaylistsTest.cxx | 11 +- .../scheduler/src/RpcDisplayScheduleTest.cxx | 16 +- .../src/RpcRemoveFromScheduleTest.cxx | 16 +- .../scheduler/src/RpcRescheduleTest.cxx | 16 +- .../scheduler/src/RpcUploadPlaylistTest.cxx | 16 +- .../scheduler/src/SavePlaylistMethod.cxx | 9 +- .../scheduler/src/SavePlaylistMethodTest.cxx | 11 +- .../src/UpdateFadeInFadeOutMethod.cxx | 9 +- .../src/UpdateFadeInFadeOutMethodTest.cxx | 11 +- .../scheduler/src/UploadPlaylistMethod.cxx | 9 +- .../src/UploadPlaylistMethodTest.cxx | 11 +- .../scheduler/src/ValidatePlaylistMethod.cxx | 9 +- .../src/ValidatePlaylistMethodTest.cxx | 11 +- 61 files changed, 1121 insertions(+), 539 deletions(-) create mode 100644 livesupport/modules/authentication/include/LiveSupport/Authentication/AuthenticationException.h create mode 100644 livesupport/modules/storage/include/LiveSupport/Storage/StorageException.h diff --git a/livesupport/modules/authentication/include/LiveSupport/Authentication/AuthenticationClientInterface.h b/livesupport/modules/authentication/include/LiveSupport/Authentication/AuthenticationClientInterface.h index ebce1550c..ac59e4448 100644 --- a/livesupport/modules/authentication/include/LiveSupport/Authentication/AuthenticationClientInterface.h +++ b/livesupport/modules/authentication/include/LiveSupport/Authentication/AuthenticationClientInterface.h @@ -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 + * @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::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::Ref sessionId) - throw () + throw (AuthenticationException) = 0; }; diff --git a/livesupport/modules/authentication/include/LiveSupport/Authentication/AuthenticationException.h b/livesupport/modules/authentication/include/LiveSupport/Authentication/AuthenticationException.h new file mode 100644 index 000000000..bdefefe8b --- /dev/null +++ b/livesupport/modules/authentication/include/LiveSupport/Authentication/AuthenticationException.h @@ -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 + +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 + diff --git a/livesupport/modules/authentication/src/AuthenticationClientFactoryTest.cxx b/livesupport/modules/authentication/src/AuthenticationClientFactoryTest.cxx index 945cb0d79..33eab930d 100644 --- a/livesupport/modules/authentication/src/AuthenticationClientFactoryTest.cxx +++ b/livesupport/modules/authentication/src/AuthenticationClientFactoryTest.cxx @@ -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::Ref sessionId; - sessionId = authentication->login("root", "q"); + try { + sessionId = authentication->login("root", "q"); + } + catch (AuthenticationException &e) { + CPPUNIT_FAIL(e.what()); + } + CPPUNIT_ASSERT(sessionId); - CPPUNIT_ASSERT(authentication->logout(sessionId)); + + try { + authentication->logout(sessionId); + } + catch (AuthenticationException &e) { + CPPUNIT_FAIL(e.what()); + } } diff --git a/livesupport/modules/authentication/src/TestAuthenticationClient.cxx b/livesupport/modules/authentication/src/TestAuthenticationClient.cxx index 88ba4a39e..d04c10957 100644 --- a/livesupport/modules/authentication/src/TestAuthenticationClient.cxx +++ b/livesupport/modules/authentication/src/TestAuthenticationClient.cxx @@ -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 "; @@ -155,10 +154,10 @@ TestAuthenticationClient :: configure(const xmlpp::Element & element) *----------------------------------------------------------------------------*/ Ptr::Ref TestAuthenticationClient :: login(const std::string & login, - const std::string & password) - throw () + const std::string & password) + throw (AuthenticationException) { - Ptr::Ref sessionId; // initialized to 0 + Ptr::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."); } - return sessionId; } /*------------------------------------------------------------------------------ * Logout from the authentication server. *----------------------------------------------------------------------------*/ -const bool +void TestAuthenticationClient :: logout(Ptr::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."); } } diff --git a/livesupport/modules/authentication/src/TestAuthenticationClient.h b/livesupport/modules/authentication/src/TestAuthenticationClient.h index becac1aab..800409266 100644 --- a/livesupport/modules/authentication/src/TestAuthenticationClient.h +++ b/livesupport/modules/authentication/src/TestAuthenticationClient.h @@ -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; * * * @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::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::Ref sessionId) - throw (); + throw (AuthenticationException); }; diff --git a/livesupport/modules/authentication/src/TestAuthenticationClientTest.cxx b/livesupport/modules/authentication/src/TestAuthenticationClientTest.cxx index 31e1253fd..b992855b6 100644 --- a/livesupport/modules/authentication/src/TestAuthenticationClientTest.cxx +++ b/livesupport/modules/authentication/src/TestAuthenticationClientTest.cxx @@ -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::Ref sessionId; - CPPUNIT_ASSERT(!(sessionId = tac->login("Piszkos Fred", "malnaszor"))); + 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")); - CPPUNIT_ASSERT(!tac->logout(sessionId)); + try { + tac->logout(sessionId); + CPPUNIT_FAIL("Allowed logout without previous login."); + } + catch (AuthenticationException &e) { + } - CPPUNIT_ASSERT( sessionId = tac->login("root", "q")); - CPPUNIT_ASSERT( tac->logout(sessionId)); - CPPUNIT_ASSERT(!tac->logout(sessionId)); + 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) { + } } diff --git a/livesupport/modules/authentication/src/WebAuthenticationClient.cxx b/livesupport/modules/authentication/src/WebAuthenticationClient.cxx index 812e39c61..c513ca7f6 100644 --- a/livesupport/modules/authentication/src/WebAuthenticationClient.cxx +++ b/livesupport/modules/authentication/src/WebAuthenticationClient.cxx @@ -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::Ref WebAuthenticationClient :: login(const std::string & login, const std::string & password) - throw () + throw (AuthenticationException) { XmlRpcValue parameters; XmlRpcValue result; - Ptr::Ref sessionId; // initialized to 0 + Ptr::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::Ref sessionId) - throw () + throw (AuthenticationException) { XmlRpcValue parameters; XmlRpcValue result; @@ -245,28 +259,28 @@ WebAuthenticationClient :: logout(Ptr::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; - } - - if (! result.hasMember(statusParamName)) { - return sessionId; + std::stringstream eMsg; + eMsg << "Logout method returned fault response:\n" + << result; + throw Authentication::XmlRpcMethodFaultException(eMsg.str()); } - if (result[statusParamName].getType() != XmlRpcValue::TypeBoolean) { - return sessionId; + 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()); } - - if (!(bool(result[statusParamName]))) { - return sessionId; - } - - return true; } diff --git a/livesupport/modules/authentication/src/WebAuthenticationClient.h b/livesupport/modules/authentication/src/WebAuthenticationClient.h index a802456f5..356edab58 100644 --- a/livesupport/modules/authentication/src/WebAuthenticationClient.h +++ b/livesupport/modules/authentication/src/WebAuthenticationClient.h @@ -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; * * * @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::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::Ref sessionId) - throw (); + throw (AuthenticationException); }; diff --git a/livesupport/modules/authentication/src/WebAuthenticationClientTest.cxx b/livesupport/modules/authentication/src/WebAuthenticationClientTest.cxx index 628f1fb8d..ebcaf92c6 100644 --- a/livesupport/modules/authentication/src/WebAuthenticationClientTest.cxx +++ b/livesupport/modules/authentication/src/WebAuthenticationClientTest.cxx @@ -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::Ref sessionId; - CPPUNIT_ASSERT(!(sessionId = wac->login("Piszkos Fred", "malnaszor"))); + try { + sessionId = wac->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")); - 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)); + 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) { + } } diff --git a/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h b/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h index 8df3fd24f..681e71989 100644 --- a/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h +++ b/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h @@ -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::Ref sessionId, Ptr::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 - * id exists. + * @exception StorageException if there is a problem with the XML-RPC + * call or no playlist with the specified + * id exists. */ virtual Ptr::Ref getPlaylist(Ptr::Ref sessionId, Ptr::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 - * id exists. + * @exception StorageException if there is a problem with the XML-RPC + * call or no playlist with the specified + * id exists. */ virtual Ptr::Ref editPlaylist(Ptr::Ref sessionId, Ptr::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::Ref sessionId, Ptr::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 - * specified id exists. + * @exception StorageException if there is a problem with the XML-RPC + * call or no playlist with the specified + * specified id exists. */ virtual Ptr::Ref acquirePlaylist(Ptr::Ref sessionId, Ptr::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, - * or the file does not exist, etc. + * @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::Ref sessionId, Ptr::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 - * id exists. + * @exception StorageException if there is a problem with the XML-RPC + * call or no playlist with the specified + * id exists. */ virtual void deletePlaylist(Ptr::Ref sessionId, Ptr::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::Ref> >::Ref getAllPlaylists(Ptr::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::Ref createPlaylist(Ptr::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::Ref sessionId, Ptr::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 - * specified id exists. + * @exception StorageException if there is a problem with the XML-RPC + * call or no audio clip with the + * specified id exists. */ virtual Ptr::Ref getAudioClip(Ptr::Ref sessionId, Ptr::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::Ref sessionId, Ptr::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 - * specified id exists. + * @exception StorageException if there is a problem with the XML-RPC + * call or if no audio clip with the + * specified id exists. */ virtual Ptr::Ref acquireAudioClip(Ptr::Ref sessionId, Ptr::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, - * or the file does not exist, etc. + * @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::Ref sessionId, Ptr::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 - * specified id exists. + * @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::Ref sessionId, Ptr::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::Ref> >::Ref getAllAudioClips(Ptr::Ref sessionId) const - throw (std::logic_error) + throw (StorageException) = 0; }; diff --git a/livesupport/modules/storage/include/LiveSupport/Storage/StorageException.h b/livesupport/modules/storage/include/LiveSupport/Storage/StorageException.h new file mode 100644 index 000000000..86b31b55a --- /dev/null +++ b/livesupport/modules/storage/include/LiveSupport/Storage/StorageException.h @@ -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 + +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 + diff --git a/livesupport/modules/storage/src/StorageClientFactoryTest.cxx b/livesupport/modules/storage/src/StorageClientFactoryTest.cxx index dc4935b0b..a6eca0b1c 100644 --- a/livesupport/modules/storage/src/StorageClientFactoryTest.cxx +++ b/livesupport/modules/storage/src/StorageClientFactoryTest.cxx @@ -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::Ref id01(new UniqueId(1)); Ptr::Ref id77(new UniqueId(77)); - CPPUNIT_ASSERT( storage->existsPlaylist(sessionId, id01)); - CPPUNIT_ASSERT(!storage->existsPlaylist(sessionId, id77)); + try { + CPPUNIT_ASSERT( storage->existsPlaylist(sessionId, id01)); + } + 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); + } - Ptr::Ref playlist = storage->getPlaylist(sessionId, id01); - CPPUNIT_ASSERT(playlist->getId()->getId() == id01->getId()); + try { + Ptr::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); + } } diff --git a/livesupport/modules/storage/src/TestStorageClient.cxx b/livesupport/modules/storage/src/TestStorageClient.cxx index f24df5bbe..57b8ee84b 100644 --- a/livesupport/modules/storage/src/TestStorageClient.cxx +++ b/livesupport/modules/storage/src/TestStorageClient.cxx @@ -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::Ref sessionId, Ptr::Ref TestStorageClient :: getPlaylist(Ptr::Ref sessionId, Ptr::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::Ref sessionId, Ptr::Ref TestStorageClient :: editPlaylist(Ptr::Ref sessionId, Ptr::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::Ref sessionId, void TestStorageClient :: savePlaylist(Ptr::Ref sessionId, Ptr::Ref playlist) const - throw (std::logic_error) + throw () { } @@ -253,12 +252,12 @@ TestStorageClient :: savePlaylist(Ptr::Ref sessionId, Ptr::Ref TestStorageClient :: acquirePlaylist(Ptr::Ref sessionId, Ptr::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::Ref oldPlaylist = playlistMapIt->second; @@ -342,16 +341,16 @@ TestStorageClient :: acquirePlaylist(Ptr::Ref sessionId, void TestStorageClient :: releasePlaylist(Ptr::Ref sessionId, Ptr::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::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::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::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::Ref sessionId, void TestStorageClient :: deletePlaylist(Ptr::Ref sessionId, Ptr::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::Ref sessionId, Ptr::Ref TestStorageClient :: getAudioClip(Ptr::Ref sessionId, Ptr::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::Ref sessionId, bool TestStorageClient :: storeAudioClip(Ptr::Ref sessionId, Ptr::Ref audioClip) - throw (std::invalid_argument) + throw (StorageException) { audioClipMap[audioClip->getId()->getId()] = audioClip; return true; @@ -505,18 +504,18 @@ TestStorageClient :: storeAudioClip(Ptr::Ref sessionId, Ptr::Ref TestStorageClient :: acquireAudioClip(Ptr::Ref sessionId, Ptr::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::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::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::Ref sessionId, void TestStorageClient :: releaseAudioClip(Ptr::Ref sessionId, Ptr::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::Ref nullPointer; @@ -563,11 +562,11 @@ TestStorageClient :: releaseAudioClip(Ptr::Ref sessionId, void TestStorageClient :: deleteAudioClip(Ptr::Ref sessionId, Ptr::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"); } } diff --git a/livesupport/modules/storage/src/TestStorageClient.h b/livesupport/modules/storage/src/TestStorageClient.h index 2e64c30c2..c98575230 100644 --- a/livesupport/modules/storage/src/TestStorageClient.h +++ b/livesupport/modules/storage/src/TestStorageClient.h @@ -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; * * * @author $Author: fgerlits $ - * @version $Revision: 1.19 $ + * @version $Revision: 1.20 $ */ class TestStorageClient : virtual public Configurable, @@ -157,14 +157,12 @@ 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. * @@ -174,9 +172,10 @@ class TestStorageClient : * false otherwise. */ virtual const bool - existsPlaylist(Ptr::Ref sessionId, - Ptr::Ref id) const - throw (); + existsPlaylist(Ptr::Ref sessionId, + Ptr::Ref id) const + throw (); + /** * Return a playlist with the specified id, to be displayed. @@ -184,13 +183,14 @@ 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 - * id exists. + * @exception StorageException if no playlist with the specified + * id exists. */ virtual Ptr::Ref getPlaylist(Ptr::Ref sessionId, Ptr::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 - * id exists. + * @exception StorageException if no playlist with the specified + * id exists. */ virtual Ptr::Ref editPlaylist(Ptr::Ref sessionId, Ptr::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::Ref sessionId, Ptr::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 - * specified id exists. + * @exception StorageException if no playlist with the specified + * specified id exists. */ virtual Ptr::Ref acquirePlaylist(Ptr::Ref sessionId, Ptr::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, - * or the file does not exist, etc. + * @exception StorageException if the playlist has no uri field, + * or the file does not exist, etc. */ virtual void - releasePlaylist(Ptr::Ref sessionId, - Ptr::Ref playlist) const - throw (std::logic_error); + releasePlaylist(Ptr::Ref sessionId, + Ptr::Ref playlist) const + 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 - * id exists. + * @exception StorageException if no playlist with the specified + * id exists. */ virtual void - deletePlaylist(Ptr::Ref sessionId, - Ptr::Ref id) - throw (std::invalid_argument); + deletePlaylist(Ptr::Ref sessionId, + Ptr::Ref id) + throw (StorageException); + /** * Return a list of all playlists in the playlist store. @@ -275,7 +277,8 @@ class TestStorageClient : */ virtual Ptr::Ref> >::Ref getAllPlaylists(Ptr::Ref sessionId) const - throw (); + throw (); + /** * Create a new playlist. @@ -285,7 +288,8 @@ class TestStorageClient : */ virtual Ptr::Ref createPlaylist(Ptr::Ref sessionId) - throw (); + throw (); + /** * Tell if an audio clip with a given id exists. @@ -298,7 +302,7 @@ class TestStorageClient : virtual const bool existsAudioClip(Ptr::Ref sessionId, Ptr::Ref id) const - throw (); + throw (); /** * Return an audio clip with the specified id. @@ -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 - * specified id exists. + * @exception StorageException if no audio clip with the + * specified id exists. */ virtual Ptr::Ref - getAudioClip(Ptr::Ref sessionId, - Ptr::Ref id) const - throw (std::invalid_argument); + getAudioClip(Ptr::Ref sessionId, + Ptr::Ref id) const + 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::Ref sessionId, Ptr::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 - * specified id exists. + * @exception StorageException if no audio clip with the + * specified id exists. */ virtual Ptr::Ref - acquireAudioClip(Ptr::Ref sessionId, - Ptr::Ref id) const - throw (std::logic_error); + acquireAudioClip(Ptr::Ref sessionId, + Ptr::Ref id) const + 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, - * or the file does not exist, etc. + * @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::Ref sessionId, Ptr::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 - * specified id exists. + * @exception StorageException if no audio clip with the + * specified id exists. */ virtual void - deleteAudioClip(Ptr::Ref sessionId, - Ptr::Ref id) - throw (std::invalid_argument); + deleteAudioClip(Ptr::Ref sessionId, + Ptr::Ref id) + 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::Ref> >::Ref getAllAudioClips(Ptr::Ref sessionId) const - throw (); - + throw (); }; diff --git a/livesupport/modules/storage/src/TestStorageClientTest.cxx b/livesupport/modules/storage/src/TestStorageClientTest.cxx index 05ca8af79..f6c34d580 100644 --- a/livesupport/modules/storage/src/TestStorageClientTest.cxx +++ b/livesupport/modules/storage/src/TestStorageClientTest.cxx @@ -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) { } } diff --git a/livesupport/modules/storage/src/WebStorageClient.cxx b/livesupport/modules/storage/src/WebStorageClient.cxx index 7968a41e4..351ca95f8 100644 --- a/livesupport/modules/storage/src/WebStorageClient.cxx +++ b/livesupport/modules/storage/src/WebStorageClient.cxx @@ -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::Ref sessionId, Ptr::Ref id) const - throw (std::logic_error) + throw (StorageException) { return false; } @@ -361,7 +360,7 @@ WebStorageClient :: existsPlaylist(Ptr::Ref sessionId, Ptr::Ref WebStorageClient :: getPlaylist(Ptr::Ref sessionId, Ptr::Ref id) const - throw (std::logic_error) + throw (StorageException) { Ptr::Ref playlist(new Playlist); return playlist; @@ -374,7 +373,7 @@ WebStorageClient :: getPlaylist(Ptr::Ref sessionId, Ptr::Ref WebStorageClient :: editPlaylist(Ptr::Ref sessionId, Ptr::Ref id) const - throw (std::logic_error) + throw (StorageException) { Ptr::Ref playlist(new Playlist); return playlist; @@ -387,7 +386,7 @@ WebStorageClient :: editPlaylist(Ptr::Ref sessionId, void WebStorageClient :: savePlaylist(Ptr::Ref sessionId, Ptr::Ref playlist) const - throw (std::logic_error) + throw (StorageException) { } @@ -398,7 +397,7 @@ WebStorageClient :: savePlaylist(Ptr::Ref sessionId, Ptr::Ref WebStorageClient :: acquirePlaylist(Ptr::Ref sessionId, Ptr::Ref id) const - throw (std::logic_error) + throw (StorageException) { Ptr::Ref playlist(new Playlist); return playlist; @@ -411,7 +410,7 @@ WebStorageClient :: acquirePlaylist(Ptr::Ref sessionId, void WebStorageClient :: releasePlaylist(Ptr::Ref sessionId, Ptr::Ref playlist) const - throw (std::logic_error) + throw (StorageException) { } @@ -423,7 +422,7 @@ WebStorageClient :: releasePlaylist(Ptr::Ref sessionId, void WebStorageClient :: deletePlaylist(Ptr::Ref sessionId, Ptr::Ref id) - throw (std::logic_error) + throw (StorageException) { } @@ -434,7 +433,7 @@ WebStorageClient :: deletePlaylist(Ptr::Ref sessionId, *----------------------------------------------------------------------------*/ Ptr::Ref> >::Ref WebStorageClient :: getAllPlaylists(Ptr::Ref sessionId) const - throw (std::logic_error) + throw (StorageException) { Ptr::Ref> >::Ref playlistVector( new std::vector::Ref>); @@ -447,7 +446,7 @@ WebStorageClient :: getAllPlaylists(Ptr::Ref sessionId) const *----------------------------------------------------------------------------*/ Ptr::Ref WebStorageClient :: createPlaylist(Ptr::Ref sessionId) - throw (std::logic_error) + throw (StorageException) { Ptr::Ref playlist(new Playlist); return playlist; @@ -460,7 +459,7 @@ WebStorageClient :: createPlaylist(Ptr::Ref sessionId) const bool WebStorageClient :: existsAudioClip(Ptr::Ref sessionId, Ptr::Ref id) const - throw (std::logic_error) + throw (StorageException) { XmlRpcValue parameters; XmlRpcValue result; @@ -480,7 +479,7 @@ WebStorageClient :: existsAudioClip(Ptr::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::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::Ref sessionId, Ptr::Ref WebStorageClient :: getAudioClip(Ptr::Ref sessionId, Ptr::Ref id) const - throw (std::logic_error) + throw (StorageException) { XmlRpcValue parameters; XmlRpcValue result; @@ -525,7 +524,7 @@ WebStorageClient :: getAudioClip(Ptr::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::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::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::Ref sessionId, Ptr::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::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::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::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::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::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::Ref sessionId, Ptr::Ref WebStorageClient :: acquireAudioClip(Ptr::Ref sessionId, Ptr::Ref id) const - throw (std::logic_error) + throw (StorageException) { Ptr::Ref playlist(new AudioClip); return playlist; @@ -712,7 +688,7 @@ WebStorageClient :: acquireAudioClip(Ptr::Ref sessionId, void WebStorageClient :: releaseAudioClip(Ptr::Ref sessionId, Ptr::Ref audioClip) const - throw (std::logic_error) + throw (StorageException) { } @@ -724,7 +700,7 @@ WebStorageClient :: releaseAudioClip(Ptr::Ref sessionId, void WebStorageClient :: deleteAudioClip(Ptr::Ref sessionId, Ptr::Ref id) - throw (std::logic_error) + throw (StorageException) { } @@ -736,7 +712,7 @@ WebStorageClient :: deleteAudioClip(Ptr::Ref sessionId, Ptr::Ref> >::Ref WebStorageClient :: getAllAudioClips(Ptr::Ref sessionId) const - throw (std::logic_error) + throw (StorageException) { Ptr::Ref> >::Ref audioClipVector( new std::vector::Ref>); @@ -749,7 +725,7 @@ WebStorageClient :: getAllAudioClips(Ptr::Ref sessionId) *----------------------------------------------------------------------------*/ Ptr::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::Ref uniqueId(new UniqueId(std::string(uniqueIdArray[i]))); returnValue->push_back(uniqueId); diff --git a/livesupport/modules/storage/src/WebStorageClient.h b/livesupport/modules/storage/src/WebStorageClient.h index a537350e8..999ba7005 100644 --- a/livesupport/modules/storage/src/WebStorageClient.h +++ b/livesupport/modules/storage/src/WebStorageClient.h @@ -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; * * * @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::Ref sessionId, - Ptr::Ref id) const - throw (std::logic_error); + existsPlaylist(Ptr::Ref sessionId, + Ptr::Ref id) const + 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 - * id exists. - * @exception std::logic_error if we have not logged in yet. + * @exception StorageException if there is a problem with the XML-RPC + * call or no playlist with the specified + * id exists. */ virtual Ptr::Ref getPlaylist(Ptr::Ref sessionId, Ptr::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 - * id exists. - * @exception std::logic_error if we have not logged in yet. + * @exception StorageException if there is a problem with the XML-RPC + * call or no playlist with the specified + * id exists. */ virtual Ptr::Ref editPlaylist(Ptr::Ref sessionId, Ptr::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::Ref sessionId, Ptr::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 - * specified id exists. - * @exception std::logic_error if we have not logged in yet. + * @exception StorageException if there is a problem with the XML-RPC + * call or no playlist with the specified + * specified id exists. */ virtual Ptr::Ref acquirePlaylist(Ptr::Ref sessionId, Ptr::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, - * or the file does not exist, etc. - * @exception std::logic_error if we have not logged in yet. + * @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::Ref sessionId, - Ptr::Ref playlist) const - throw (std::logic_error); + releasePlaylist(Ptr::Ref sessionId, + Ptr::Ref playlist) const + 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 - * id exists. - * @exception std::logic_error if we have not logged in yet. + * @exception StorageException if there is a problem with the XML-RPC + * call or no playlist with the specified + * id exists. */ virtual void - deletePlaylist(Ptr::Ref sessionId, - Ptr::Ref id) - throw (std::logic_error); + deletePlaylist(Ptr::Ref sessionId, + Ptr::Ref id) + 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::Ref> >::Ref getAllPlaylists(Ptr::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::Ref createPlaylist(Ptr::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::Ref sessionId, Ptr::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 - * specified id exists. - * @exception std::logic_error if we have not logged in yet. + * @exception StorageException if there is a problem with the XML-RPC + * call or no audio clip with the + * specified id exists. */ virtual Ptr::Ref - getAudioClip(Ptr::Ref sessionId, - Ptr::Ref id) const - throw (std::logic_error); + getAudioClip(Ptr::Ref sessionId, + Ptr::Ref id) const + throw (StorageException); /** * Store an audio clip. The uri 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::Ref sessionId, Ptr::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 - * specified id exists. - * @exception std::logic_error if we have not logged in yet. + * @exception StorageException if there is a problem with the XML-RPC + * call or if no audio clip with the + * specified id exists. */ virtual Ptr::Ref - acquireAudioClip(Ptr::Ref sessionId, - Ptr::Ref id) const - throw (std::logic_error); + acquireAudioClip(Ptr::Ref sessionId, + Ptr::Ref id) const + 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, - * or the file does not exist, etc. - * @exception std::logic_error if we have not logged in yet. + * @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. */ virtual void releaseAudioClip(Ptr::Ref sessionId, Ptr::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 - * specified id exists. - * @exception std::logic_error if we have not logged in yet. + * @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::Ref sessionId, - Ptr::Ref id) - throw (std::logic_error); + deleteAudioClip(Ptr::Ref sessionId, + Ptr::Ref id) + 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::Ref> >::Ref getAllAudioClips(Ptr::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::Ref> >::Ref reset(void) - throw (std::logic_error); + throw (StorageException); }; diff --git a/livesupport/modules/storage/src/WebStorageClientTest.cxx b/livesupport/modules/storage/src/WebStorageClientTest.cxx index 9bf891089..ac93dbc75 100644 --- a/livesupport/modules/storage/src/WebStorageClientTest.cxx +++ b/livesupport/modules/storage/src/WebStorageClientTest.cxx @@ -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::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::Ref playlength(new time_duration(0,0,11,0)); Ptr::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::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::Ref> >::Ref audioClipVector = wsc->getAllAudioClips(); diff --git a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx index 1aa64e0b8..685549f6b 100644 --- a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx @@ -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; diff --git a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.cxx b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.cxx index 216b63256..f2ddc296f 100644 --- a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.cxx @@ -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; diff --git a/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx b/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx index ced1488d3..92642e564 100644 --- a/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx @@ -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 $ ------------------------------------------------------------------------------*/ @@ -122,11 +122,22 @@ CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, scf = StorageClientFactory::getInstance(); storage = scf->getStorageClient(); - - Ptr::Ref playlist = storage->createPlaylist(sessionId); + + Ptr::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; diff --git a/livesupport/products/scheduler/src/CreatePlaylistMethod.h b/livesupport/products/scheduler/src/CreatePlaylistMethod.h index 8cf7b089f..c0aaa8bcc 100644 --- a/livesupport/products/scheduler/src/CreatePlaylistMethod.h +++ b/livesupport/products/scheduler/src/CreatePlaylistMethod.h @@ -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 { faultCode, faultString } structure is returned. The * possible errors are: *
    - *
  • 201 - could not open new playlist for editing
  • + *
  • 201 - invalid argument format
  • + *
  • 202 - could not create playlist
  • + *
  • 203 - could not open new playlist for editing
  • *
  • 220 - missing session ID argument
  • *
* * @author $Author: fgerlits $ - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx b/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx index 0ac56213c..9f8b0c1c3 100644 --- a/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/DeletePlaylistMethod.cxx b/livesupport/products/scheduler/src/DeletePlaylistMethod.cxx index a198116ab..c8fcf6ad4 100644 --- a/livesupport/products/scheduler/src/DeletePlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/DeletePlaylistMethod.cxx @@ -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; } } diff --git a/livesupport/products/scheduler/src/DeletePlaylistMethodTest.cxx b/livesupport/products/scheduler/src/DeletePlaylistMethodTest.cxx index ec581e605..341b5f28f 100644 --- a/livesupport/products/scheduler/src/DeletePlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/DeletePlaylistMethodTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/DisplayAudioClipMethod.cxx b/livesupport/products/scheduler/src/DisplayAudioClipMethod.cxx index c3d984404..6664bfae8 100644 --- a/livesupport/products/scheduler/src/DisplayAudioClipMethod.cxx +++ b/livesupport/products/scheduler/src/DisplayAudioClipMethod.cxx @@ -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; } diff --git a/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.cxx b/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.cxx index fcd670c5c..0107a94f8 100644 --- a/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.cxx +++ b/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/DisplayAudioClipsMethod.cxx b/livesupport/products/scheduler/src/DisplayAudioClipsMethod.cxx index d91c0cb8b..92dd16bfc 100644 --- a/livesupport/products/scheduler/src/DisplayAudioClipsMethod.cxx +++ b/livesupport/products/scheduler/src/DisplayAudioClipsMethod.cxx @@ -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::Ref> >::Ref audioClipVector = - storage->getAllAudioClips(sessionId); + Ptr::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); } diff --git a/livesupport/products/scheduler/src/DisplayAudioClipsMethod.h b/livesupport/products/scheduler/src/DisplayAudioClipsMethod.h index 2c86203ad..ae6cd366a 100644 --- a/livesupport/products/scheduler/src/DisplayAudioClipsMethod.h +++ b/livesupport/products/scheduler/src/DisplayAudioClipsMethod.h @@ -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 { faultCode, faultString } structure is returned. The * possible errors are: *
    + *
  • 1801 - invalid argument format
  • + *
  • 1802 - XML-RPC error
  • *
  • 1820 - missing session ID argument
  • *
* * @author $Author: fgerlits $ - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ class DisplayAudioClipsMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.cxx b/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.cxx index 347cf75f1..49696bc9a 100644 --- a/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.cxx +++ b/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx b/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx index 273bceb70..23fafc886 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx @@ -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; } diff --git a/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx b/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx index a67b69aa1..9fc994819 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx b/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx index 021e4fccf..778b1b5f1 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx +++ b/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx @@ -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,9 +114,17 @@ DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, scf = StorageClientFactory::getInstance(); storage = scf->getStorageClient(); - Ptr::Ref> >::Ref playlistVector = - storage->getAllPlaylists(sessionId); - + Ptr::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); } diff --git a/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h b/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h index a74f4b8ba..2f50fc38a 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h +++ b/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h @@ -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 { faultCode, faultString } structure is returned. The * possible errors are: *
    + *
  • 1701 - invalid argument format
  • + *
  • 1702 - XML-RPC error
  • *
  • 1720 - missing session ID argument
  • *
* * @author $Author: fgerlits $ - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx b/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx index 1a25a8c65..e75ffc1d7 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx +++ b/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx b/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx index 8e323eca4..d2e80f66e 100644 --- a/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx +++ b/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx @@ -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::Ref acf; try { Ptr::Ref scf = StorageClientFactory::getInstance(); @@ -137,10 +138,8 @@ DisplayScheduleMethodTest :: setUp(void) throw () schedule = sf->getSchedule(); schedule->install(); - Ptr::Ref - acf = AuthenticationClientFactory::getInstance(); + 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 diff --git a/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.cxx b/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.cxx index c637ca05e..e1cb0a695 100644 --- a/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.cxx +++ b/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx index a0d75565f..8d3c37425 100644 --- a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx +++ b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx @@ -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; } diff --git a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx index 07225c7b2..a1d2406b5 100644 --- a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx +++ b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx index 750f4f577..0b6607b14 100644 --- a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx @@ -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; } diff --git a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.cxx b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.cxx index 326c78ebd..9e9eb486a 100644 --- a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.cxx b/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.cxx index 44a05fd6f..cd626cea4 100644 --- a/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.cxx +++ b/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/RescheduleMethodTest.cxx b/livesupport/products/scheduler/src/RescheduleMethodTest.cxx index 140aa0280..13df6e575 100644 --- a/livesupport/products/scheduler/src/RescheduleMethodTest.cxx +++ b/livesupport/products/scheduler/src/RescheduleMethodTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.cxx b/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.cxx index 4724482dc..a204d09f3 100644 --- a/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.cxx @@ -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; } diff --git a/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.cxx b/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.cxx index f8c4cedc9..a5b05acc9 100644 --- a/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/RpcAddAudioClipToPlaylistTest.cxx b/livesupport/products/scheduler/src/RpcAddAudioClipToPlaylistTest.cxx index 43443836d..3639ba373 100644 --- a/livesupport/products/scheduler/src/RpcAddAudioClipToPlaylistTest.cxx +++ b/livesupport/products/scheduler/src/RpcAddAudioClipToPlaylistTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/RpcDisplayAudioClipTest.cxx b/livesupport/products/scheduler/src/RpcDisplayAudioClipTest.cxx index 54d0a54c6..ddde7878e 100644 --- a/livesupport/products/scheduler/src/RpcDisplayAudioClipTest.cxx +++ b/livesupport/products/scheduler/src/RpcDisplayAudioClipTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/RpcDisplayPlaylistTest.cxx b/livesupport/products/scheduler/src/RpcDisplayPlaylistTest.cxx index 12ba49a5e..d37fa0e75 100644 --- a/livesupport/products/scheduler/src/RpcDisplayPlaylistTest.cxx +++ b/livesupport/products/scheduler/src/RpcDisplayPlaylistTest.cxx @@ -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::Ref acf; try { Ptr::Ref scf = StorageClientFactory::getInstance(); configure(scf, storageClientConfig); - Ptr::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); } } diff --git a/livesupport/products/scheduler/src/RpcDisplayPlaylistsTest.cxx b/livesupport/products/scheduler/src/RpcDisplayPlaylistsTest.cxx index 8656278c2..8aeafdfbf 100644 --- a/livesupport/products/scheduler/src/RpcDisplayPlaylistsTest.cxx +++ b/livesupport/products/scheduler/src/RpcDisplayPlaylistsTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/RpcDisplayScheduleTest.cxx b/livesupport/products/scheduler/src/RpcDisplayScheduleTest.cxx index 9f8cf045d..6f1e70271 100644 --- a/livesupport/products/scheduler/src/RpcDisplayScheduleTest.cxx +++ b/livesupport/products/scheduler/src/RpcDisplayScheduleTest.cxx @@ -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); + Ptr::Ref acf; try { - Ptr::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"); @@ -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); } } diff --git a/livesupport/products/scheduler/src/RpcRemoveFromScheduleTest.cxx b/livesupport/products/scheduler/src/RpcRemoveFromScheduleTest.cxx index ecc27db50..7ca6a4865 100644 --- a/livesupport/products/scheduler/src/RpcRemoveFromScheduleTest.cxx +++ b/livesupport/products/scheduler/src/RpcRemoveFromScheduleTest.cxx @@ -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); + Ptr::Ref acf; try { - Ptr::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"); @@ -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); } } diff --git a/livesupport/products/scheduler/src/RpcRescheduleTest.cxx b/livesupport/products/scheduler/src/RpcRescheduleTest.cxx index 11fef47ce..183678b3b 100644 --- a/livesupport/products/scheduler/src/RpcRescheduleTest.cxx +++ b/livesupport/products/scheduler/src/RpcRescheduleTest.cxx @@ -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); + Ptr::Ref acf; try { - Ptr::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"); @@ -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); } } diff --git a/livesupport/products/scheduler/src/RpcUploadPlaylistTest.cxx b/livesupport/products/scheduler/src/RpcUploadPlaylistTest.cxx index fca2574b5..717da93f8 100644 --- a/livesupport/products/scheduler/src/RpcUploadPlaylistTest.cxx +++ b/livesupport/products/scheduler/src/RpcUploadPlaylistTest.cxx @@ -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); + Ptr::Ref acf; try { - Ptr::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"); @@ -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); } } diff --git a/livesupport/products/scheduler/src/SavePlaylistMethod.cxx b/livesupport/products/scheduler/src/SavePlaylistMethod.cxx index 96a8b9a48..c74e20391 100644 --- a/livesupport/products/scheduler/src/SavePlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/SavePlaylistMethod.cxx @@ -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; } diff --git a/livesupport/products/scheduler/src/SavePlaylistMethodTest.cxx b/livesupport/products/scheduler/src/SavePlaylistMethodTest.cxx index 747965ec9..fc56ab850 100644 --- a/livesupport/products/scheduler/src/SavePlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/SavePlaylistMethodTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx index dc0f84a06..7b4e98f66 100644 --- a/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx +++ b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx @@ -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; } diff --git a/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.cxx b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.cxx index ac666d2c8..12f80a399 100644 --- a/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.cxx +++ b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx b/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx index dbc6c059d..7ce507362 100644 --- a/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx @@ -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; } diff --git a/livesupport/products/scheduler/src/UploadPlaylistMethodTest.cxx b/livesupport/products/scheduler/src/UploadPlaylistMethodTest.cxx index 2235c8276..03b32d42e 100644 --- a/livesupport/products/scheduler/src/UploadPlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/UploadPlaylistMethodTest.cxx @@ -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); } } diff --git a/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx b/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx index 99634583e..04272e8c9 100644 --- a/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx @@ -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; } diff --git a/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.cxx b/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.cxx index 47fb2a6cc..bcb152097 100644 --- a/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.cxx @@ -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); } }