From 7b591bbaa1efb7d04a0545a9b58a0ff731015c1f Mon Sep 17 00:00:00 2001 From: fgerlits Date: Wed, 1 Dec 2004 15:59:59 +0000 Subject: [PATCH] changed error reporting in the XML-RPC methods from ad-hoc to standard XML-RPC fault responses --- .../products/scheduler/etc/Makefile.in | 14 +-- .../products/scheduler/etc/storageClient.xml | 4 +- .../src/AddAudioClipToPlaylistMethod.cxx | 6 +- .../src/AddAudioClipToPlaylistMethod.h | 20 ++-- .../src/AddAudioClipToPlaylistMethodTest.cxx | 37 ++++++-- .../scheduler/src/CreatePlaylistMethod.cxx | 6 +- .../scheduler/src/CreatePlaylistMethod.h | 21 ++--- .../src/CreatePlaylistMethodTest.cxx | 23 +++-- .../scheduler/src/DeletePlaylistMethod.cxx | 6 +- .../scheduler/src/DeletePlaylistMethod.h | 20 ++-- .../src/DeletePlaylistMethodTest.cxx | 55 ++++++++--- .../scheduler/src/DisplayAudioClipMethod.cxx | 6 +- .../scheduler/src/DisplayAudioClipMethod.h | 20 ++-- .../src/DisplayAudioClipMethodTest.cxx | 22 ++++- .../scheduler/src/DisplayAudioClipsMethod.cxx | 6 +- .../scheduler/src/DisplayAudioClipsMethod.h | 20 ++-- .../src/DisplayAudioClipsMethodTest.cxx | 12 ++- .../scheduler/src/DisplayPlaylistMethod.cxx | 6 +- .../scheduler/src/DisplayPlaylistMethod.h | 20 ++-- .../src/DisplayPlaylistMethodTest.cxx | 22 ++++- .../scheduler/src/DisplayPlaylistsMethod.cxx | 6 +- .../scheduler/src/DisplayPlaylistsMethod.h | 20 ++-- .../src/DisplayPlaylistsMethodTest.cxx | 12 ++- .../scheduler/src/DisplayScheduleMethod.cxx | 6 +- .../scheduler/src/DisplayScheduleMethod.h | 20 ++-- .../src/DisplayScheduleMethodTest.cxx | 72 ++++++++++++-- .../src/GeneratePlayReportMethod.cxx | 6 +- .../scheduler/src/GeneratePlayReportMethod.h | 24 +++-- .../src/GeneratePlayReportMethodTest.cxx | 52 +++++++++-- .../src/OpenPlaylistForEditingMethod.cxx | 6 +- .../src/OpenPlaylistForEditingMethod.h | 21 ++--- .../src/OpenPlaylistForEditingMethodTest.cxx | 38 +++++--- .../src/RemoveAudioClipFromPlaylistMethod.cxx | 6 +- .../src/RemoveAudioClipFromPlaylistMethod.h | 22 ++--- .../RemoveAudioClipFromPlaylistMethodTest.cxx | 63 +++++++++---- .../src/RemoveFromScheduleMethod.cxx | 6 +- .../scheduler/src/RemoveFromScheduleMethod.h | 24 +++-- .../src/RemoveFromScheduleMethodTest.cxx | 31 +++++-- .../scheduler/src/RescheduleMethod.cxx | 6 +- .../products/scheduler/src/RescheduleMethod.h | 24 +++-- .../scheduler/src/RescheduleMethodTest.cxx | 35 +++++-- .../src/RevertEditedPlaylistMethod.cxx | 6 +- .../src/RevertEditedPlaylistMethod.h | 20 ++-- .../src/RevertEditedPlaylistMethodTest.cxx | 93 ++++++++++++++----- .../scheduler/src/SavePlaylistMethod.cxx | 6 +- .../scheduler/src/SavePlaylistMethod.h | 24 +++-- .../scheduler/src/SavePlaylistMethodTest.cxx | 49 +++++++--- .../scheduler/src/SchedulerDaemon.cxx | 8 +- .../products/scheduler/src/SchedulerDaemon.h | 30 ++++-- .../src/UpdateFadeInFadeOutMethod.cxx | 6 +- .../scheduler/src/UpdateFadeInFadeOutMethod.h | 20 ++-- .../src/UpdateFadeInFadeOutMethodTest.cxx | 57 +++++++++--- .../scheduler/src/UploadPlaylistMethod.cxx | 6 +- .../scheduler/src/UploadPlaylistMethod.h | 24 +++-- .../src/UploadPlaylistMethodTest.cxx | 52 +++++++++-- .../scheduler/src/ValidatePlaylistMethod.cxx | 6 +- .../scheduler/src/ValidatePlaylistMethod.h | 24 +++-- .../src/ValidatePlaylistMethodTest.cxx | 58 +++++++++--- .../products/scheduler/src/XmlRpcTools.cxx | 9 +- .../products/scheduler/src/XmlRpcTools.h | 7 +- 60 files changed, 890 insertions(+), 461 deletions(-) diff --git a/livesupport/products/scheduler/etc/Makefile.in b/livesupport/products/scheduler/etc/Makefile.in index 2d6f3e71a..693aa70b4 100644 --- a/livesupport/products/scheduler/etc/Makefile.in +++ b/livesupport/products/scheduler/etc/Makefile.in @@ -20,8 +20,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # -# Author : $Author: maroy $ -# Version : $Revision: 1.28 $ +# Author : $Author: fgerlits $ +# Version : $Revision: 1.29 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $ # # @configure_input@ @@ -186,11 +186,11 @@ SCHEDULER_EXE_LIBS = -l${EVENT_SCHEDULER_LIB} -l${PLAYLIST_EXECUTOR_LIB} \ TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \ ${TMP_DIR}/TestRunner.o \ ${TMP_DIR}/SchedulerDaemonTest.o \ - ${TMP_DIR}/SchedulerDaemonUploadTest.o \ - ${TMP_DIR}/SchedulerDaemonDisplayScheduleTest.o \ - ${TMP_DIR}/SchedulerDaemonDisplayPlaylistTest.o \ - ${TMP_DIR}/SchedulerDaemonRemoveFromScheduleTest.o \ - ${TMP_DIR}/SchedulerDaemonRescheduleTest.o \ + ${TMP_DIR}/RpcUploadPlaylistTest.o \ + ${TMP_DIR}/RpcDisplayScheduleTest.o \ + ${TMP_DIR}/RpcDisplayPlaylistTest.o \ + ${TMP_DIR}/RpcRemoveFromScheduleTest.o \ + ${TMP_DIR}/RpcRescheduleTest.o \ ${TMP_DIR}/XmlRpcToolsTest.o \ ${TMP_DIR}/UploadPlaylistMethodTest.o \ ${TMP_DIR}/DisplayScheduleMethodTest.o \ diff --git a/livesupport/products/scheduler/etc/storageClient.xml b/livesupport/products/scheduler/etc/storageClient.xml index 819dd2abb..612142b2f 100644 --- a/livesupport/products/scheduler/etc/storageClient.xml +++ b/livesupport/products/scheduler/etc/storageClient.xml @@ -1,7 +1,7 @@ + @@ -10,7 +10,7 @@ - + diff --git a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx index 61593776e..6a126b978 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.8 $ + Version : $Revision: 1.9 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -98,7 +98,7 @@ AddAudioClipToPlaylistMethod :: AddAudioClipToPlaylistMethod ( void AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -112,7 +112,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.h b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.h index c6aa69898..50740d71f 100644 --- a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.h +++ b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.8 $ + Version : $Revision: 1.9 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -44,6 +44,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Playlist.h" @@ -82,13 +83,9 @@ using namespace LiveSupport::Core; * start of the playlist and the start of the audio clip. * * - * In case of an error, an XML-RPC structure is returned, with the following - * fields: - *
    - *
  • errorCode - int - the id of the error condition
  • - *
  • errorMessage - string - a description of the error
  • - *
- * The possible error codes are: + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
    *
  • 301 - invalid argument format
  • *
  • 302 - missing playlist ID argument
  • @@ -98,11 +95,11 @@ using namespace LiveSupport::Core; *
  • 306 - playlist has not been opened for editing
  • *
  • 307 - audio clip does not exist
  • *
  • 308 - two audio clips at the same relative offset
  • - *
  • 322 - missing session ID argument
  • + *
  • 320 - missing session ID argument
  • *
* * @author $Author: fgerlits $ - * @version $Revision: 1.8 $ + * @version $Revision: 1.9 $ */ class AddAudioClipToPlaylistMethod : public XmlRpc::XmlRpcServerMethod { @@ -145,7 +142,8 @@ class AddAudioClipToPlaylistMethod : public XmlRpc::XmlRpcServerMethod */ void execute( XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.cxx b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.cxx index 30787f0e0..216b63256 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.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -178,13 +178,25 @@ AddAudioClipToPlaylistMethodTest :: firstTest(void) rootParameter[0] = parameters; result.clear(); - openPlaylistMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); - result.clear(); - addAudioClipMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); - CPPUNIT_ASSERT((int)(result["errorCode"]) == 308); + try { + openPlaylistMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } + result.clear(); + try { + addAudioClipMethod->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to add overlapping audio clip"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 308); + } + parameters.clear(); parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; @@ -193,6 +205,13 @@ AddAudioClipToPlaylistMethodTest :: firstTest(void) rootParameter[0] = parameters; result.clear(); - addAudioClipMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); + try { + addAudioClipMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } } diff --git a/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx b/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx index abec21fd9..bc8f6e95f 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.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -97,7 +97,7 @@ CreatePlaylistMethod :: CreatePlaylistMethod ( void CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -111,7 +111,7 @@ CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/CreatePlaylistMethod.h b/livesupport/products/scheduler/src/CreatePlaylistMethod.h index 702029fc9..8cf7b089f 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.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -44,6 +44,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Playlist.h" @@ -82,20 +83,17 @@ using namespace LiveSupport::Core; *
  • playlength - int - the playlist length of the playlist, in seconds *
  • * - * If there is an error, an XML-RPC structure is returned, with the following - * fields: - *
      - *
    • errorCode - int - a numerical code for the error
    • - *
    • errorMessage - string - a description of the error
    • - *
    - * The possible error codes are: + * + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
      *
    • 201 - could not open new playlist for editing
    • - *
    • 222 - missing session ID argument
    • + *
    • 220 - missing session ID argument
    • *
    * * @author $Author: fgerlits $ - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod { @@ -138,7 +136,8 @@ class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod */ void execute( XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx b/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx index 0eda6b5de..0ac56213c 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.8 $ + Version : $Revision: 1.9 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -171,7 +171,15 @@ CreatePlaylistMethodTest :: firstTest(void) result.clear(); parameter["sessionId"] = sessionId->getId(); rootParameter[0] = parameter; - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } CPPUNIT_ASSERT(result.hasMember("id")); CPPUNIT_ASSERT(((int) result["playlength"]) == 0); @@ -182,9 +190,12 @@ CreatePlaylistMethodTest :: firstTest(void) parameter["playlistId"] = playlistId; rootParameter[0] = parameter; - // should not allow to open the same playlist for editing again result.clear(); - method->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); - CPPUNIT_ASSERT((int) result["errorCode"] == 105); + try { + method->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to open playlist twice"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 105); + } } diff --git a/livesupport/products/scheduler/src/DeletePlaylistMethod.cxx b/livesupport/products/scheduler/src/DeletePlaylistMethod.cxx index 0df1ebf0b..262b32f33 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.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -88,7 +88,7 @@ DeletePlaylistMethod :: DeletePlaylistMethod ( void DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -102,7 +102,7 @@ DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/DeletePlaylistMethod.h b/livesupport/products/scheduler/src/DeletePlaylistMethod.h index 2293150a5..27a32b40d 100644 --- a/livesupport/products/scheduler/src/DeletePlaylistMethod.h +++ b/livesupport/products/scheduler/src/DeletePlaylistMethod.h @@ -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/Attic/DeletePlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -44,6 +44,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Playlist.h" @@ -77,24 +78,20 @@ using namespace LiveSupport::Core; * to be deleted. * * - * If there is an error, an XML-RPC structure is returned, with the following - * fields: - *
      - *
    • errorCode - int - a numerical code for the error
    • - *
    • errorMessage - string - a description of the error
    • - *
    - * The possible error codes are: + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
      *
    • 901 - invalid argument format
    • *
    • 902 - missing playlist ID argument
    • *
    • 903 - playlist not found
    • *
    • 904 - playlist is locked
    • *
    • 905 - playlist could not be deleted
    • - *
    • 922 - missing session ID argument
    • + *
    • 920- missing session ID argument
    • *
    * * @author $Author: fgerlits $ - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ class DeletePlaylistMethod : public XmlRpc::XmlRpcServerMethod { @@ -137,7 +134,8 @@ class DeletePlaylistMethod : public XmlRpc::XmlRpcServerMethod */ void execute( XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/DeletePlaylistMethodTest.cxx b/livesupport/products/scheduler/src/DeletePlaylistMethodTest.cxx index 38385d7ec..ec581e605 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.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -180,21 +180,46 @@ DeletePlaylistMethodTest :: firstTest(void) rootParameter[0] = parameter; result.clear(); - openMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); + try { + openMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } result.clear(); - deleteMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); - CPPUNIT_ASSERT(int(result["errorCode"]) == 904); // playlist is locked + try { + deleteMethod->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to delete locked playlist"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 904); // playlist is locked + } result.clear(); - saveMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); + try { + saveMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } result.clear(); - deleteMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); // OK + try { + deleteMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } } @@ -217,8 +242,12 @@ DeletePlaylistMethodTest :: negativeTest(void) rootParameter[0] = parameter; result.clear(); - method->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); - CPPUNIT_ASSERT(int(result["errorCode"]) == 903); // playlist not found + try { + method->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to delete non-existent playlist"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 903); // playlist not found + } } diff --git a/livesupport/products/scheduler/src/DisplayAudioClipMethod.cxx b/livesupport/products/scheduler/src/DisplayAudioClipMethod.cxx index 8de0b2cb5..f71c847a5 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.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -97,7 +97,7 @@ DisplayAudioClipMethod :: DisplayAudioClipMethod ( void DisplayAudioClipMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -111,7 +111,7 @@ DisplayAudioClipMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/DisplayAudioClipMethod.h b/livesupport/products/scheduler/src/DisplayAudioClipMethod.h index d51eab268..214300813 100644 --- a/livesupport/products/scheduler/src/DisplayAudioClipMethod.h +++ b/livesupport/products/scheduler/src/DisplayAudioClipMethod.h @@ -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/DisplayAudioClipMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -44,6 +44,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/AudioClip.h" @@ -85,22 +86,18 @@ using namespace LiveSupport::Core; * * * - * If there is an error, an XML-RPC structure is returned, with the following - * fields: - *
      - *
    • errorCode - int - a numerical code for the error
    • - *
    • errorMessage - string - a description of the error
    • - *
    - * The possible error codes are: + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
      *
    • 601 - invalid argument format
    • *
    • 602 - argument is not an audio clip ID
    • *
    • 603 - audio clip not found
    • - *
    • 622 - missing session ID argument
    • + *
    • 620 - missing session ID argument
    • *
    * * @author $Author: fgerlits $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ class DisplayAudioClipMethod : public XmlRpc::XmlRpcServerMethod { @@ -143,7 +140,8 @@ class DisplayAudioClipMethod : public XmlRpc::XmlRpcServerMethod */ void execute( XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.cxx b/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.cxx index deb6af902..fcd670c5c 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.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -172,7 +172,15 @@ DisplayAudioClipMethodTest :: firstTest(void) rootParameter[0] = parameter; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } CPPUNIT_ASSERT(int(result["id"]) == 10001); CPPUNIT_ASSERT(int(result["playlength"]) == (60 * 60)); } @@ -197,7 +205,11 @@ DisplayAudioClipMethodTest :: negativeTest(void) rootParameter[0] = parameter; result.clear(); - method->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); - CPPUNIT_ASSERT(int(result["errorCode"]) == 603); // audio clip not found + try { + method->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to display non-existent audio clip"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 603); // audio clip not found + } } diff --git a/livesupport/products/scheduler/src/DisplayAudioClipsMethod.cxx b/livesupport/products/scheduler/src/DisplayAudioClipsMethod.cxx index 3ba897fdc..388d341fb 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.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipsMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -87,7 +87,7 @@ DisplayAudioClipsMethod :: DisplayAudioClipsMethod ( void DisplayAudioClipsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -101,7 +101,7 @@ DisplayAudioClipsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/DisplayAudioClipsMethod.h b/livesupport/products/scheduler/src/DisplayAudioClipsMethod.h index 97086098b..2c86203ad 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.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipsMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -45,6 +45,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/AudioClip.h" @@ -88,19 +89,15 @@ using namespace LiveSupport::Core; * * * - * In case of an error, an XML-RPC structure is returned, with the following - * fields: + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
      - *
    • errorCode - int - the id of the error condition
    • - *
    • errorMessage - string - a description of the error
    • - *
    - * The possible error codes are: - *
      - *
    • 1822 - missing session ID argument
    • + *
    • 1820 - missing session ID argument
    • *
    * * @author $Author: fgerlits $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ class DisplayAudioClipsMethod : public XmlRpc::XmlRpcServerMethod { @@ -143,7 +140,8 @@ class DisplayAudioClipsMethod : public XmlRpc::XmlRpcServerMethod */ void execute( XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.cxx b/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.cxx index 5147b8072..347cf75f1 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.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -171,7 +171,15 @@ DisplayAudioClipsMethodTest :: firstTest(void) result.clear(); parameter["sessionId"] = sessionId->getId(); rootParameter[0] = parameter; - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } CPPUNIT_ASSERT(result.size() == 2); audioClip = result[0]; diff --git a/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx b/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx index ff0cd8342..6babbc0f6 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.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -97,7 +97,7 @@ DisplayPlaylistMethod :: DisplayPlaylistMethod ( void DisplayPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -111,7 +111,7 @@ DisplayPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/DisplayPlaylistMethod.h b/livesupport/products/scheduler/src/DisplayPlaylistMethod.h index 2993f9340..034ce0949 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistMethod.h +++ b/livesupport/products/scheduler/src/DisplayPlaylistMethod.h @@ -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/DisplayPlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -44,6 +44,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Playlist.h" @@ -85,22 +86,18 @@ using namespace LiveSupport::Core; * * * - * If there is an error, an XML-RPC structure is returned, with the following - * fields: - *
      - *
    • errorCode - int - a numerical code for the error
    • - *
    • errorMessage - string - a description of the error
    • - *
    - * The possible error codes are: + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
      *
    • 1001 - invalid argument format
    • *
    • 1002 - argument is not a playlist ID
    • *
    • 1003 - playlist not found
    • - *
    • 1022 - missing session ID argument
    • + *
    • 1020 - missing session ID argument
    • *
    * * @author $Author: fgerlits $ - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ class DisplayPlaylistMethod : public XmlRpc::XmlRpcServerMethod { @@ -143,7 +140,8 @@ class DisplayPlaylistMethod : public XmlRpc::XmlRpcServerMethod */ void execute( XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx b/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx index c93d3bcf0..a67b69aa1 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.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -172,7 +172,15 @@ DisplayPlaylistMethodTest :: firstTest(void) rootParameter[0] = parameter; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } CPPUNIT_ASSERT(int(result["id"]) == 1); CPPUNIT_ASSERT(int(result["playlength"]) == 90 * 60); } @@ -197,8 +205,12 @@ DisplayPlaylistMethodTest :: negativeTest(void) rootParameter[0] = parameter; result.clear(); - method->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); - CPPUNIT_ASSERT(int(result["errorCode"]) == 1003); // playlist not found + try { + method->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to display non-existent playlist"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 1003); // playlist not found + } } diff --git a/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx b/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx index 66927ad68..0cdc84199 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.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -88,7 +88,7 @@ DisplayPlaylistsMethod :: DisplayPlaylistsMethod ( void DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -102,7 +102,7 @@ DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h b/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h index 69a64a249..a74f4b8ba 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.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -45,6 +45,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Playlist.h" @@ -88,19 +89,15 @@ using namespace LiveSupport::Core; * * * - * In case of an error, an XML-RPC structure is returned, with the following - * fields: + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
      - *
    • errorCode - int - the id of the error condition
    • - *
    • errorMessage - string - a description of the error
    • - *
    - * The possible error codes are: - *
      - *
    • 1722 - missing session ID argument
    • + *
    • 1720 - missing session ID argument
    • *
    * * @author $Author: fgerlits $ - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod { @@ -143,7 +140,8 @@ class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod */ void execute( XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx b/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx index b7a18fcaf..1a25a8c65 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.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -171,7 +171,15 @@ DisplayPlaylistsMethodTest :: firstTest(void) result.clear(); parameters["sessionId"] = sessionId->getId(); rootParameter[0] = parameters; - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } CPPUNIT_ASSERT(result.size() == 1); playlist = result[0]; diff --git a/livesupport/products/scheduler/src/DisplayScheduleMethod.cxx b/livesupport/products/scheduler/src/DisplayScheduleMethod.cxx index 2119e6f13..b5ef71a53 100644 --- a/livesupport/products/scheduler/src/DisplayScheduleMethod.cxx +++ b/livesupport/products/scheduler/src/DisplayScheduleMethod.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/DisplayScheduleMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -94,7 +94,7 @@ DisplayScheduleMethod :: DisplayScheduleMethod ( void DisplayScheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -108,7 +108,7 @@ DisplayScheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/DisplayScheduleMethod.h b/livesupport/products/scheduler/src/DisplayScheduleMethod.h index 84b17ead8..3231a468d 100644 --- a/livesupport/products/scheduler/src/DisplayScheduleMethod.h +++ b/livesupport/products/scheduler/src/DisplayScheduleMethod.h @@ -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/DisplayScheduleMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -46,6 +46,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" #include "ScheduleEntry.h" @@ -95,22 +96,18 @@ using namespace LiveSupport::Core; *
  • end - datetime - the end of the scheduled item
  • * * - * If there is an error, an XML-RPC structure is returned, with the following - * fields: - *
      - *
    • errorCode - int - a numerical code for the error
    • - *
    • errorMessage - string - a description of the error
    • - *
    - * The possible error codes are: + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
      *
    • 1101 - invalid argument format
    • *
    • 1102 - missing or invalid 'from' argument
    • *
    • 1103 - missing or invalid 'to' argument
    • - *
    • 1122 - missing session ID argument
    • + *
    • 1120 - missing session ID argument
    • *
    * * @author $Author: fgerlits $ - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ class DisplayScheduleMethod : public XmlRpc::XmlRpcServerMethod { @@ -153,7 +150,8 @@ class DisplayScheduleMethod : public XmlRpc::XmlRpcServerMethod */ void execute( XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx b/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx index 81828e1d1..8e323eca4 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.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -205,7 +205,15 @@ DisplayScheduleMethodTest :: firstTest(void) rootParameter[0] = parameters; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } CPPUNIT_ASSERT(result.size() == 0); } @@ -237,7 +245,15 @@ DisplayScheduleMethodTest :: insertEntries(void) rootParameter[0] = parameters; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } // insert a playlist for 2004-07-31, at 12 o'clock parameters["sessionId"] = sessionId->getId(); @@ -252,7 +268,15 @@ DisplayScheduleMethodTest :: insertEntries(void) rootParameter[0] = parameters; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } // insert a playlist for 2004-07-31, at 14 o'clock parameters["sessionId"] = sessionId->getId(); @@ -267,7 +291,15 @@ DisplayScheduleMethodTest :: insertEntries(void) rootParameter[0] = parameters; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } } @@ -304,7 +336,15 @@ DisplayScheduleMethodTest :: intervalTest(void) rootParameter[0] = parameters; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } // check the returned values CPPUNIT_ASSERT(result.size() == 1); @@ -343,7 +383,15 @@ DisplayScheduleMethodTest :: intervalTest(void) rootParameter[0] = parameters; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } // check the returned values CPPUNIT_ASSERT(result.size() == 2); @@ -398,7 +446,15 @@ DisplayScheduleMethodTest :: intervalTest(void) rootParameter[0] = parameters; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } // check the returned values CPPUNIT_ASSERT(result.size() == 0); diff --git a/livesupport/products/scheduler/src/GeneratePlayReportMethod.cxx b/livesupport/products/scheduler/src/GeneratePlayReportMethod.cxx index f171a7aeb..2bacec29e 100644 --- a/livesupport/products/scheduler/src/GeneratePlayReportMethod.cxx +++ b/livesupport/products/scheduler/src/GeneratePlayReportMethod.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/GeneratePlayReportMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -94,7 +94,7 @@ GeneratePlayReportMethod :: GeneratePlayReportMethod ( void GeneratePlayReportMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -108,7 +108,7 @@ GeneratePlayReportMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/GeneratePlayReportMethod.h b/livesupport/products/scheduler/src/GeneratePlayReportMethod.h index 6e1f45269..0b2f1d7e4 100644 --- a/livesupport/products/scheduler/src/GeneratePlayReportMethod.h +++ b/livesupport/products/scheduler/src/GeneratePlayReportMethod.h @@ -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/GeneratePlayReportMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -46,6 +46,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" #include "PlayLogEntry.h" @@ -92,22 +93,18 @@ using namespace LiveSupport::Core; *
  • timestamp - datetime - the time the clip was played (started)
  • * * - * If there is an error, an XML-RPC structure is returned, with the following - * fields: - *
      - *
    • errorCode - int - a numerical code for the error
    • - *
    • errorMessage - string - a description of the error
    • - *
    - * The possible error codes are: + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
      *
    • 1501 - invalid argument format
    • *
    • 1502 - missing or invalid 'from' argument
    • *
    • 1503 - missing or invalid 'to' argument
    • - *
    • 1522 - missing session ID argument
    • + *
    • 1520 - missing session ID argument
    • *
    * * @author $Author: fgerlits $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ class GeneratePlayReportMethod : public XmlRpc::XmlRpcServerMethod { @@ -128,7 +125,7 @@ class GeneratePlayReportMethod : public XmlRpc::XmlRpcServerMethod /** * A default constructor, for testing purposes. */ - GeneratePlayReportMethod(void) throw () + GeneratePlayReportMethod(void) throw () : XmlRpc::XmlRpcServerMethod(methodName) { } @@ -140,7 +137,7 @@ class GeneratePlayReportMethod : public XmlRpc::XmlRpcServerMethod */ GeneratePlayReportMethod( Ptr::Ref xmlRpcServer) - throw (); + throw (); /** * Execute the generatePlayReport command on the Scheduler daemon. @@ -150,7 +147,8 @@ class GeneratePlayReportMethod : public XmlRpc::XmlRpcServerMethod */ void execute(XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.cxx b/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.cxx index 360ec2b98..c637ca05e 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.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -205,7 +205,15 @@ GeneratePlayReportMethodTest :: firstTest(void) rootParameter[0] = parameters; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } CPPUNIT_ASSERT(result.size() == 0); } @@ -265,7 +273,15 @@ GeneratePlayReportMethodTest :: intervalTest(void) rootParameter[0] = parameters; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } // check the returned values CPPUNIT_ASSERT(result.size() == 1); @@ -298,7 +314,15 @@ GeneratePlayReportMethodTest :: intervalTest(void) rootParameter[0] = parameters; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } // check the returned values CPPUNIT_ASSERT(result.size() == 1); @@ -331,7 +355,15 @@ GeneratePlayReportMethodTest :: intervalTest(void) rootParameter[0] = parameters; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } // check the returned values CPPUNIT_ASSERT(result.size() == 2); @@ -373,7 +405,15 @@ GeneratePlayReportMethodTest :: intervalTest(void) rootParameter[0] = parameters; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } // check the returned values CPPUNIT_ASSERT(result.size() == 0); diff --git a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx index 10307d058..cccc1e474 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.9 $ + Version : $Revision: 1.10 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -98,7 +98,7 @@ OpenPlaylistForEditingMethod :: OpenPlaylistForEditingMethod ( void OpenPlaylistForEditingMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -112,7 +112,7 @@ OpenPlaylistForEditingMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h index cefc97109..36f87f2ba 100644 --- a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h +++ b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h @@ -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/OpenPlaylistForEditingMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -44,6 +44,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Playlist.h" @@ -85,22 +86,19 @@ using namespace LiveSupport::Core; *
  • playlength - int - the playlist length of the playlist, in seconds *
  • * - * In case of an error, an XML-RPC structure is returned, with the following - * fields: - *
      - *
    • errorCode - int - the id of the error condition
    • - *
    • errorMessage - string - a description of the error
    • - *
    - * The possible error codes are: + * + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
      *
    • 101 - invalid argument format
    • *
    • 102 - argument is not a playlist ID
    • *
    • 104 - playlist not found
    • *
    • 105 - could not open playlist
    • - *
    • 122 - missing session ID argument
    • + *
    • 120 - missing session ID argument
    • *
    * @author $Author: fgerlits $ - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ */ class OpenPlaylistForEditingMethod : public XmlRpc::XmlRpcServerMethod { @@ -143,7 +141,8 @@ class OpenPlaylistForEditingMethod : public XmlRpc::XmlRpcServerMethod */ void execute( XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx index 53192e031..07225c7b2 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.8 $ + Version : $Revision: 1.9 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -173,7 +173,15 @@ OpenPlaylistForEditingMethodTest :: firstTest(void) rootParameter[0] = parameter; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } CPPUNIT_ASSERT((int) result["id"] == 1); CPPUNIT_ASSERT((int) result["playlength"] == (90 * 60)); @@ -182,22 +190,26 @@ OpenPlaylistForEditingMethodTest :: firstTest(void) parameter["playlistId"] = 6376; rootParameter[0] = parameter; - // no such playlist result.clear(); - method->execute(rootParameter, result); - CPPUNIT_ASSERT((int) result["errorCode"] == 104); - CPPUNIT_ASSERT((const std::string) result["errorMessage"] == - "playlist not found"); + try { + method->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to open non-existent playlist"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 104); // playlist not found + } + parameter.clear(); parameter["sessionId"] = sessionId->getId(); parameter["playlistId"] = 1; rootParameter[0] = parameter; - // should not allow to open the same playlist for editing again result.clear(); - method->execute(rootParameter, result); - CPPUNIT_ASSERT((int) result["errorCode"] == 105); - CPPUNIT_ASSERT((const std::string) result["errorMessage"] == - "could not open playlist"); - + try { + method->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to open the same playlist twice"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 105); // could not open playlist + } } diff --git a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx index 9e6c0ec14..baf58c5bc 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.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -99,7 +99,7 @@ void RemoveAudioClipFromPlaylistMethod :: execute( XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -113,7 +113,7 @@ RemoveAudioClipFromPlaylistMethod :: execute( sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.h b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.h index af7bab612..68e5034f7 100644 --- a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.h +++ b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.h @@ -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/RemoveAudioClipFromPlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -44,6 +44,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Playlist.h" @@ -81,13 +82,9 @@ using namespace LiveSupport::Core; * to be removed. * * - * In case of an error, an XML-RPC structure is returned, with the following - * fields: - *
      - *
    • errorCode - int - the id of the error condition
    • - *
    • errorMessage - string - a description of the error
    • - *
    - * The possible error codes are: + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
      *
    • 401 - invalid argument format
    • *
    • 402 - missing playlist ID argument
    • @@ -95,10 +92,10 @@ using namespace LiveSupport::Core; *
    • 404 - playlist does not exist
    • *
    • 405 - playlist has not been opened for editing
    • *
    • 406 - no audio clip at the specified relative offset
    • - *
    • 422 - missing session ID argument
    • + *
    • 420 - missing session ID argument
    • *
    * @author $Author: fgerlits $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ class RemoveAudioClipFromPlaylistMethod : public XmlRpc::XmlRpcServerMethod { @@ -119,7 +116,7 @@ class RemoveAudioClipFromPlaylistMethod : public XmlRpc::XmlRpcServerMethod /** * A default constructor, for testing purposes. */ - RemoveAudioClipFromPlaylistMethod(void) throw () + RemoveAudioClipFromPlaylistMethod(void) throw () : XmlRpc::XmlRpcServerMethod(methodName) { } @@ -141,7 +138,8 @@ class RemoveAudioClipFromPlaylistMethod : public XmlRpc::XmlRpcServerMethod */ void execute( XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.cxx b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.cxx index 3ca9e9022..326c78ebd 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.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -184,22 +184,53 @@ RemoveAudioClipFromPlaylistMethodTest :: firstTest(void) rootParameter[0] = parameters; result.clear(); - removeAudioClipMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); - CPPUNIT_ASSERT((int)(result["errorCode"]) == 405); // not open for editing + try { + removeAudioClipMethod->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to edit playlist without opening it first"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 405); // not open for editing + } + + result.clear(); + try { + openPlaylistMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } + + result.clear(); + try { + removeAudioClipMethod->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to remove non-existent audio clip from playlist"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 406); // no audio clip at this rel offset + } result.clear(); - openPlaylistMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); + try { + addAudioClipMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } + result.clear(); - removeAudioClipMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); - CPPUNIT_ASSERT((int)(result["errorCode"]) == 406); // no audio clip at - // this rel offset - result.clear(); - addAudioClipMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); - result.clear(); - removeAudioClipMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); + try { + removeAudioClipMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } } diff --git a/livesupport/products/scheduler/src/RemoveFromScheduleMethod.cxx b/livesupport/products/scheduler/src/RemoveFromScheduleMethod.cxx index 287c9f6c0..711e77c97 100644 --- a/livesupport/products/scheduler/src/RemoveFromScheduleMethod.cxx +++ b/livesupport/products/scheduler/src/RemoveFromScheduleMethod.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/RemoveFromScheduleMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -91,7 +91,7 @@ RemoveFromScheduleMethod :: RemoveFromScheduleMethod ( void RemoveFromScheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -105,7 +105,7 @@ RemoveFromScheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h b/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h index 60642efaf..abd734d97 100644 --- a/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h +++ b/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h @@ -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/RemoveFromScheduleMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -45,6 +45,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/UniqueId.h" @@ -77,22 +78,18 @@ using namespace LiveSupport::Core; *
  • scheduleEntryId - int - the id of the scheduled entry to remove
  • * * - * In case of an error, an XML-RPC structure is returned, with the following - * fields: - *
      - *
    • errorCode - int - the id of the error condition
    • - *
    • errorMessage - string - a description of the error
    • - *
    - * The possible error codes are: + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
      *
    • 1201 - invalid argument format
    • *
    • 1202 - missing schedule entry ID argument
    • *
    • 1203 - schedule entry not found
    • - *
    • 1222 - missing session ID argument
    • + *
    • 1220 - missing session ID argument
    • *
    * * @author $Author: fgerlits $ - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ class RemoveFromScheduleMethod : public XmlRpc::XmlRpcServerMethod { @@ -113,7 +110,7 @@ class RemoveFromScheduleMethod : public XmlRpc::XmlRpcServerMethod /** * A default constructor, for testing purposes. */ - RemoveFromScheduleMethod(void) throw () + RemoveFromScheduleMethod(void) throw () : XmlRpc::XmlRpcServerMethod(methodName) { } @@ -125,7 +122,7 @@ class RemoveFromScheduleMethod : public XmlRpc::XmlRpcServerMethod */ RemoveFromScheduleMethod( Ptr::Ref xmlRpcServer) - throw (); + throw (); /** * Execute the remove from schedule command on the Scheduler daemon. @@ -135,7 +132,8 @@ class RemoveFromScheduleMethod : public XmlRpc::XmlRpcServerMethod */ void execute( XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.cxx b/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.cxx index 166c4f717..44a05fd6f 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.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -176,7 +176,15 @@ RemoveFromScheduleMethodTest :: firstTest(void) rootParameter[0] = parameters; result.clear(); - uploadMethod->execute(rootParameter, result); + try { + uploadMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } CPPUNIT_ASSERT(result.hasMember("scheduleEntryId")); entryId.reset(new UniqueId(int(result["scheduleEntryId"]))); @@ -186,8 +194,15 @@ RemoveFromScheduleMethodTest :: firstTest(void) rootParameter[0] = parameters; result.clear(); - removeMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); + try { + removeMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } } @@ -211,7 +226,11 @@ RemoveFromScheduleMethodTest :: negativeTest(void) rootParameter[0] = parameters; result.clear(); - removeMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); + try { + removeMethod->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to remove non-existent schedule entry"); + } + catch (XmlRpc::XmlRpcException &e) { + } } diff --git a/livesupport/products/scheduler/src/RescheduleMethod.cxx b/livesupport/products/scheduler/src/RescheduleMethod.cxx index 060aa2106..95499308e 100644 --- a/livesupport/products/scheduler/src/RescheduleMethod.cxx +++ b/livesupport/products/scheduler/src/RescheduleMethod.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/RescheduleMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -94,7 +94,7 @@ RescheduleMethod :: RescheduleMethod ( void RescheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -108,7 +108,7 @@ RescheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/RescheduleMethod.h b/livesupport/products/scheduler/src/RescheduleMethod.h index 6bbe6b1de..910e03192 100644 --- a/livesupport/products/scheduler/src/RescheduleMethod.h +++ b/livesupport/products/scheduler/src/RescheduleMethod.h @@ -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/RescheduleMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -45,6 +45,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/UniqueId.h" @@ -79,24 +80,20 @@ using namespace LiveSupport::Core; *
  • playtime - datetime - the new playing time for the entry
  • * * - * In case of an error, an XML-RPC structure is returned, with the following - * fields: - *
      - *
    • errorCode - int - the id of the error condition
    • - *
    • errorMessage - string - a description of the error
    • - *
    - * The possible error codes are: + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
      *
    • 1301 - invalid argument format
    • *
    • 1302 - missing schedule entry ID argument
    • *
    • 1303 - missing playtime argument
    • *
    • 1304 - schedule entry not found
    • *
    • 1305 - could not reschedule entry
    • - *
    • 1322 - missing session ID argument
    • + *
    • 1320 - missing session ID argument
    • *
    * * @author $Author: fgerlits $ - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ class RescheduleMethod : public XmlRpc::XmlRpcServerMethod { @@ -117,7 +114,7 @@ class RescheduleMethod : public XmlRpc::XmlRpcServerMethod /** * A default constructor, for testing purposes. */ - RescheduleMethod(void) throw () + RescheduleMethod(void) throw () : XmlRpc::XmlRpcServerMethod(methodName) { } @@ -129,7 +126,7 @@ class RescheduleMethod : public XmlRpc::XmlRpcServerMethod */ RescheduleMethod( Ptr::Ref xmlRpcServer) - throw (); + throw (); /** * Execute the upload playlist command on the Scheduler daemon. @@ -139,7 +136,8 @@ class RescheduleMethod : public XmlRpc::XmlRpcServerMethod */ void execute( XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/RescheduleMethodTest.cxx b/livesupport/products/scheduler/src/RescheduleMethodTest.cxx index 114c0e305..140aa0280 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.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RescheduleMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -176,8 +176,15 @@ RescheduleMethodTest :: firstTest(void) rootParameter[0] = parameters; result.clear(); - uploadMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); + try { + uploadMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } CPPUNIT_ASSERT(result.hasMember("scheduleEntryId")); entryId.reset(new UniqueId(int(result["scheduleEntryId"]))); @@ -195,8 +202,15 @@ RescheduleMethodTest :: firstTest(void) rootParameter[0] = parameters; result.clear(); - rescheduleMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); + try { + rescheduleMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } // now let's reschedule unto itself, should fail parameters.clear(); @@ -212,9 +226,12 @@ RescheduleMethodTest :: firstTest(void) rootParameter[0] = parameters; result.clear(); - rescheduleMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); - - CPPUNIT_ASSERT(int(result["errorCode"]) == 1305); + try { + rescheduleMethod->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to schedule playlist onto itself"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 1305); + } } diff --git a/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.cxx b/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.cxx index 243665187..c135d7a35 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.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -93,7 +93,7 @@ RevertEditedPlaylistMethod :: RevertEditedPlaylistMethod ( void RevertEditedPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -107,7 +107,7 @@ RevertEditedPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.h b/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.h index 8cf99329d..e167df2eb 100644 --- a/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.h +++ b/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.h @@ -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/RevertEditedPlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -44,6 +44,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Playlist.h" @@ -78,22 +79,18 @@ using namespace LiveSupport::Core; *
  • playlistId - int - the unique id of the playlist requested.
  • * * - * In case of an error, an XML-RPC structure is returned, with the following - * fields: - *
      - *
    • errorCode - int - the id of the error condition
    • - *
    • errorMessage - string - a description of the error
    • - *
    - * The possible error codes are: + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
      *
    • 801 - invalid argument format
    • *
    • 802 - argument is not a playlist ID
    • *
    • 803 - playlist not found
    • *
    • 804 - could not revert playlist
    • - *
    • 822 - missing session ID argument
    • + *
    • 820 - missing session ID argument
    • *
    * @author $Author: fgerlits $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ class RevertEditedPlaylistMethod : public XmlRpc::XmlRpcServerMethod { @@ -136,7 +133,8 @@ class RevertEditedPlaylistMethod : public XmlRpc::XmlRpcServerMethod */ void execute(XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.cxx b/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.cxx index 7ee5f58e9..f8c4cedc9 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.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -183,32 +183,83 @@ RevertEditedPlaylistMethodTest :: firstTest(void) rootParameter[0] = parameters; result.clear(); - revertMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); - CPPUNIT_ASSERT(int(result["errorCode"]) == 804); // no saved copy yet + try { + revertMethod->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to revert playlist without saving it first"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 804); // no saved copy + } result.clear(); - openMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); + try { + openMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } + result.clear(); - removeMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); - result.clear(); - removeMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); // can't remove it twice + try { + removeMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } result.clear(); - revertMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); - result.clear(); - removeMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); // but now we can again + try { + removeMethod->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to remove the same playlist element twice"); + } + catch (XmlRpc::XmlRpcException &e) { + } result.clear(); - saveMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); + try { + revertMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } + result.clear(); - revertMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); // saved copy has been - CPPUNIT_ASSERT(int(result["errorCode"]) == 804); // discarded + try { // but now we can again + removeMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } + + result.clear(); + try { + saveMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } + + result.clear(); + try { + revertMethod->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to revert playlist after discarding saved copy"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 804); // no saved copy + } } diff --git a/livesupport/products/scheduler/src/SavePlaylistMethod.cxx b/livesupport/products/scheduler/src/SavePlaylistMethod.cxx index d5ebf27c1..a5031a217 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.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SavePlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -93,7 +93,7 @@ SavePlaylistMethod :: SavePlaylistMethod ( void SavePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -107,7 +107,7 @@ SavePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/SavePlaylistMethod.h b/livesupport/products/scheduler/src/SavePlaylistMethod.h index 181645dbf..7dfca32f6 100644 --- a/livesupport/products/scheduler/src/SavePlaylistMethod.h +++ b/livesupport/products/scheduler/src/SavePlaylistMethod.h @@ -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/SavePlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -44,6 +44,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Playlist.h" @@ -79,22 +80,18 @@ using namespace LiveSupport::Core; *
  • playlistId - int - the unique id of the playlist to save.
  • * * - * In case of an error, an XML-RPC structure is returned, with the following - * fields: - *
      - *
    • errorCode - int - the id of the error condition
    • - *
    • errorMessage - string - a description of the error
    • - *
    - * The possible error codes are: + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
      *
    • 701 - invalid argument format
    • *
    • 702 - argument is not a playlist ID
    • *
    • 703 - playlist not found
    • *
    • 704 - could not save playlist
    • - *
    • 722 - missing session ID argument
    • + *
    • 720 - missing session ID argument
    • *
    * @author $Author: fgerlits $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ class SavePlaylistMethod : public XmlRpc::XmlRpcServerMethod { @@ -115,7 +112,7 @@ class SavePlaylistMethod : public XmlRpc::XmlRpcServerMethod /** * A default constructor, for testing purposes. */ - SavePlaylistMethod(void) throw () + SavePlaylistMethod(void) throw () : XmlRpc::XmlRpcServerMethod(methodName) { } @@ -127,7 +124,7 @@ class SavePlaylistMethod : public XmlRpc::XmlRpcServerMethod */ SavePlaylistMethod( Ptr::Ref xmlRpcServer) - throw (); + throw (); /** * Execute the display schedule command on the Scheduler daemon. @@ -137,7 +134,8 @@ class SavePlaylistMethod : public XmlRpc::XmlRpcServerMethod */ void execute(XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/SavePlaylistMethodTest.cxx b/livesupport/products/scheduler/src/SavePlaylistMethodTest.cxx index 61af6a756..747965ec9 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.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SavePlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -174,20 +174,47 @@ SavePlaylistMethodTest :: firstTest(void) rootParameter[0] = parameter; result.clear(); - saveMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); - CPPUNIT_ASSERT(int(result["errorCode"]) == 703); // playlist not found + try { + saveMethod->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to save non-existent playlist"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 703); // playlist not found + } parameter["playlistId"] = 1; rootParameter[0] = parameter; result.clear(); - openMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); - result.clear(); - saveMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); // open then save OK + try { + openMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } result.clear(); - openMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); // save then open OK + try { // open then save OK + saveMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } + + + result.clear(); + try { // save then open OK + saveMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } } diff --git a/livesupport/products/scheduler/src/SchedulerDaemon.cxx b/livesupport/products/scheduler/src/SchedulerDaemon.cxx index 731b288e9..e3a1e7709 100644 --- a/livesupport/products/scheduler/src/SchedulerDaemon.cxx +++ b/livesupport/products/scheduler/src/SchedulerDaemon.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.9 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.10 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.cxx,v $ ------------------------------------------------------------------------------*/ @@ -106,6 +106,8 @@ SchedulerDaemon :: SchedulerDaemon (void) throw () displayPlaylistMethod.reset(new DisplayPlaylistMethod()); removeFromScheduleMethod.reset(new RemoveFromScheduleMethod()); rescheduleMethod.reset(new RescheduleMethod()); + openPlaylistForEditingMethod.reset(new OpenPlaylistForEditingMethod()); + addAudioClipToPlaylistMethod.reset(new AddAudioClipToPlaylistMethod()); } @@ -211,6 +213,8 @@ SchedulerDaemon :: registerXmlRpcFunctions( xmlRpcServer->addMethod(displayPlaylistMethod.get()); xmlRpcServer->addMethod(removeFromScheduleMethod.get()); xmlRpcServer->addMethod(rescheduleMethod.get()); + xmlRpcServer->addMethod(addAudioClipToPlaylistMethod.get()); + xmlRpcServer->addMethod(openPlaylistForEditingMethod.get()); } diff --git a/livesupport/products/scheduler/src/SchedulerDaemon.h b/livesupport/products/scheduler/src/SchedulerDaemon.h index b28cfaa86..4194f5355 100644 --- a/livesupport/products/scheduler/src/SchedulerDaemon.h +++ b/livesupport/products/scheduler/src/SchedulerDaemon.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.8 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.9 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.h,v $ ------------------------------------------------------------------------------*/ @@ -67,6 +67,8 @@ #include "DisplayPlaylistMethod.h" #include "RemoveFromScheduleMethod.h" #include "RescheduleMethod.h" +#include "AddAudioClipToPlaylistMethod.h" +#include "OpenPlaylistForEditingMethod.h" #include "XmlRpcDaemon.h" @@ -123,8 +125,8 @@ using namespace LiveSupport::PlaylistExecutor; * scheduleFactory,xmlRpcDaemon) > * * - * @author $Author: maroy $ - * @version $Revision: 1.8 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.9 $ * @see ConnectionManagerFactory * @see StorageClientFactory * @see ScheduleFactory @@ -152,30 +154,40 @@ class SchedulerDaemon : public Installable, Ptr::Ref audioPlayer; /** - * The UploadPlaylistMethod the daemon is providing. + * The uploadPlaylistMethod the daemon is providing. */ Ptr::Ref uploadPlaylistMethod; /** - * The DisplayScheduleMethod the daemon is providing. + * The displayScheduleMethod the daemon is providing. */ Ptr::Ref displayScheduleMethod; /** - * The DisplayPlaylistMethod the daemon is providing. + * The displayPlaylistMethod the daemon is providing. */ Ptr::Ref displayPlaylistMethod; /** - * The RemoveFromScheduleMethod the daemon is providing. + * The removeFromScheduleMethod the daemon is providing. */ Ptr::Ref removeFromScheduleMethod; /** - * The RescheduleMethod the daemon is providing. + * The rescheduleMethod the daemon is providing. */ Ptr::Ref rescheduleMethod; + /** + * The addAudioClipToPlaylistMethod the daemon is providing. + */ + Ptr::Ref addAudioClipToPlaylistMethod; + + /** + * The openPlaylistForEditingMethod the daemon is providing. + */ + Ptr::Ref openPlaylistForEditingMethod; + /** * Default constructor. */ diff --git a/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx index b5705c946..7619dfa94 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.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -101,7 +101,7 @@ void UpdateFadeInFadeOutMethod :: execute( XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -115,7 +115,7 @@ UpdateFadeInFadeOutMethod :: execute( sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.h b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.h index 2ebbae7f4..4c2fd2fac 100644 --- a/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.h +++ b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.h @@ -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/UpdateFadeInFadeOutMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -44,6 +44,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" @@ -83,13 +84,9 @@ using namespace LiveSupport::Core; *
  • fadeOut - int - the length (in milliseconds) of the fade out.
  • * * - * In case of an error, an XML-RPC structure is returned, with the following - * fields: - *
      - *
    • errorCode - int - the id of the error condition
    • - *
    • errorMessage - string - a description of the error
    • - *
    - * The possible error codes are: + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
      *
    • 1601 - invalid argument format
    • *
    • 1602 - missing playlist ID argument
    • @@ -99,10 +96,10 @@ using namespace LiveSupport::Core; *
    • 1606 - playlist does not exist
    • *
    • 1607 - playlist has not been opened for editing
    • *
    • 1608 - no audio clip at the specified relative offset
    • - *
    • 1622 - missing session ID argument
    • + *
    • 1620 - missing session ID argument
    • *
    * @author $Author: fgerlits $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ class UpdateFadeInFadeOutMethod : public XmlRpc::XmlRpcServerMethod { @@ -145,7 +142,8 @@ class UpdateFadeInFadeOutMethod : public XmlRpc::XmlRpcServerMethod */ void execute(XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.cxx b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.cxx index d83327cb4..ac666d2c8 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.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -180,30 +180,57 @@ UpdateFadeInFadeOutMethodTest :: firstTest(void) rootParameter[0] = parameters; result.clear(); - updateFadeMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); - CPPUNIT_ASSERT((int)(result["errorCode"]) == 1605); // missing fade out + try { + updateFadeMethod->execute(rootParameter, result); + CPPUNIT_FAIL("did not notice missing fade out parameter"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 1605); // missing fade out + } parameters["fadeOut"] = 2100; rootParameter[0] = parameters; result.clear(); - updateFadeMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); - CPPUNIT_ASSERT((int)(result["errorCode"]) == 1607); // not open for editing + try { + updateFadeMethod->execute(rootParameter, result); + CPPUNIT_FAIL("allowed update fade info without opening playlist first"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 1607); // not open for editing + } result.clear(); - openPlaylistMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); + try { + openPlaylistMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } + result.clear(); - updateFadeMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); - CPPUNIT_ASSERT((int)(result["errorCode"]) == 1608); // no audio clip at - // this rel offset + try { + updateFadeMethod->execute(rootParameter, result); + CPPUNIT_FAIL("allowed update fade info for non-existent p.l. element"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 1608);// no audio clip at this rel offset + } + parameters["relativeOffset"] = 0; rootParameter[0] = parameters; result.clear(); - updateFadeMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); + try { + updateFadeMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } } diff --git a/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx b/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx index 44d468bef..b5cb45696 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.7 $ + Version : $Revision: 1.8 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -97,7 +97,7 @@ UploadPlaylistMethod :: UploadPlaylistMethod ( void UploadPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -111,7 +111,7 @@ UploadPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/UploadPlaylistMethod.h b/livesupport/products/scheduler/src/UploadPlaylistMethod.h index b0e50f56c..89663e08b 100644 --- a/livesupport/products/scheduler/src/UploadPlaylistMethod.h +++ b/livesupport/products/scheduler/src/UploadPlaylistMethod.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.8 $ + Version : $Revision: 1.9 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -45,6 +45,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/UniqueId.h" @@ -87,13 +88,9 @@ using namespace LiveSupport::Core; * by the upload * * - * In case of an error, an XML-RPC structure is returned with the following - * members: - *
      - *
    • errorCode - int - the id of the error condition
    • - *
    • errorMessage - string - a description of the error
    • - *
    - * The possible error codes are: + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
      *
    • 1401 - invalid argument format
    • *
    • 1402 - missing playlist ID argument
    • @@ -101,11 +98,11 @@ using namespace LiveSupport::Core; *
    • 1404 - playlist not found
    • *
    • 1405 - timeframe not available
    • *
    • 1406 - could not schedule playlist
    • - *
    • 1422 - missing session ID argument
    • + *
    • 1420 - missing session ID argument
    • *
    * * @author $Author: fgerlits $ - * @version $Revision: 1.8 $ + * @version $Revision: 1.9 $ */ class UploadPlaylistMethod : public XmlRpc::XmlRpcServerMethod { @@ -126,7 +123,7 @@ class UploadPlaylistMethod : public XmlRpc::XmlRpcServerMethod /** * A default constructor, for testing purposes. */ - UploadPlaylistMethod(void) throw () + UploadPlaylistMethod(void) throw () : XmlRpc::XmlRpcServerMethod(methodName) { } @@ -138,7 +135,7 @@ class UploadPlaylistMethod : public XmlRpc::XmlRpcServerMethod */ UploadPlaylistMethod( Ptr::Ref xmlRpcServer) - throw (); + throw (); /** * Execute the upload playlist command on the Scheduler daemon. @@ -148,7 +145,8 @@ class UploadPlaylistMethod : public XmlRpc::XmlRpcServerMethod */ void execute( XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/UploadPlaylistMethodTest.cxx b/livesupport/products/scheduler/src/UploadPlaylistMethodTest.cxx index d4e79e2c0..2235c8276 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.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -194,7 +194,15 @@ UploadPlaylistMethodTest :: firstTest(void) rootParameter[0] = parameters; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } CPPUNIT_ASSERT(result.hasMember("scheduleEntryId")); } @@ -226,7 +234,15 @@ UploadPlaylistMethodTest :: overlappingPlaylists(void) rootParameter[0] = parameters; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } CPPUNIT_ASSERT(result.hasMember("scheduleEntryId")); // try to load the same one, but in an overlapping time region @@ -243,9 +259,13 @@ UploadPlaylistMethodTest :: overlappingPlaylists(void) rootParameter[0] = parameters; result.clear(); - method->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); - CPPUNIT_ASSERT(int(result["errorCode"]) == 1405); // timeframe not available + try { + method->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to schedule overlapping playlist"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 1405); // timeframe not available + } // try to load the same one, but now in good timing parameters["sessionId"] = sessionId->getId(); @@ -260,7 +280,15 @@ UploadPlaylistMethodTest :: overlappingPlaylists(void) rootParameter[0] = parameters; result.clear(); - method->execute(rootParameter, result); + try { + method->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } CPPUNIT_ASSERT(result.hasMember("scheduleEntryId")); // try to load the same one, this time overlapping both previos instances @@ -276,7 +304,11 @@ UploadPlaylistMethodTest :: overlappingPlaylists(void) rootParameter[0] = parameters; result.clear(); - method->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); - CPPUNIT_ASSERT(int(result["errorCode"]) == 1405); // timeframe not available + try { + method->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to schedule doubly overlapping playlist"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 1405); // timeframe not available + } } diff --git a/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx b/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx index 21788e54f..2c4541696 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.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -98,7 +98,7 @@ ValidatePlaylistMethod :: ValidatePlaylistMethod ( void ValidatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) - throw () + throw (XmlRpc::XmlRpcException) { if (!rootParameter.valid() || rootParameter.size() != 1) { XmlRpcTools::markError(errorId+1, "invalid argument format", @@ -112,7 +112,7 @@ ValidatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, sessionId = XmlRpcTools::extractSessionId(parameters); } catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+22, + XmlRpcTools::markError(errorId+20, "missing session ID argument", returnValue); return; diff --git a/livesupport/products/scheduler/src/ValidatePlaylistMethod.h b/livesupport/products/scheduler/src/ValidatePlaylistMethod.h index c0a1975c2..5e9d9b0bc 100644 --- a/livesupport/products/scheduler/src/ValidatePlaylistMethod.h +++ b/livesupport/products/scheduler/src/ValidatePlaylistMethod.h @@ -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/ValidatePlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -44,6 +44,7 @@ #include #include #include +#include #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Playlist.h" @@ -83,22 +84,18 @@ using namespace LiveSupport::Core; *
  • valid - bool - true if the playlist is valid, false otherwise
  • * * - * In case of an error, an XML-RPC structure is returned, with the following - * fields: - *
      - *
    • errorCode - int - the id of the error condition
    • - *
    • errorMessage - string - a description of the error
    • - *
    - * The possible error codes are: + * In case of an error, a standard XML-RPC fault response is generated, + * and a { faultCode, faultString } structure is returned. The + * possible errors are: *
      *
    • 501 - invalid argument format
    • *
    • 502 - missing playlist ID argument
    • *
    • 503 - playlist does not exist
    • *
    • 504 - playlist has not been opened for editing
    • - *
    • 522 - missing session ID argument
    • + *
    • 520 - missing session ID argument
    • *
    * @author $Author: fgerlits $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ class ValidatePlaylistMethod : public XmlRpc::XmlRpcServerMethod { @@ -119,7 +116,7 @@ class ValidatePlaylistMethod : public XmlRpc::XmlRpcServerMethod /** * A default constructor, for testing purposes. */ - ValidatePlaylistMethod(void) throw () + ValidatePlaylistMethod(void) throw () : XmlRpc::XmlRpcServerMethod(methodName) { } @@ -131,7 +128,7 @@ class ValidatePlaylistMethod : public XmlRpc::XmlRpcServerMethod */ ValidatePlaylistMethod( Ptr::Ref xmlRpcServer) - throw (); + throw (); /** * Execute the display schedule command on the Scheduler daemon. @@ -141,7 +138,8 @@ class ValidatePlaylistMethod : public XmlRpc::XmlRpcServerMethod */ void execute( XmlRpc::XmlRpcValue & parameters, - XmlRpc::XmlRpcValue & returnValue) throw (); + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); }; diff --git a/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.cxx b/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.cxx index 35b664f1c..47fb2a6cc 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.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -178,30 +178,66 @@ ValidatePlaylistMethodTest :: firstTest(void) result.clear(); parameter["sessionId"] = sessionId->getId(); parameter["playlistId"] = 275; - rootParameter[0] = parameter; - validatePlaylistMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(result.hasMember("errorCode")); - CPPUNIT_ASSERT(int(result["errorCode"]) == 503); // no such playlist + rootParameter[0] = parameter; + try { + validatePlaylistMethod->execute(rootParameter, result); + CPPUNIT_FAIL("allowed to validate non-existent playlist"); + } + catch (XmlRpc::XmlRpcException &e) { + CPPUNIT_ASSERT(e.getCode() == 503); // no such playlist + } result.clear(); parameter.clear(); parameter["sessionId"] = sessionId->getId(); parameter["playlistId"] = 1; rootParameter[0] = parameter; - openPlaylistMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); + try { + openPlaylistMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } + result.clear(); - validatePlaylistMethod->execute(rootParameter, result); + try { + validatePlaylistMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } CPPUNIT_ASSERT(result.hasMember("valid")); CPPUNIT_ASSERT(bool(result["valid"])); result.clear(); parameter["relativeOffset"] = 0; rootParameter[0] = parameter; - removeAudioClipMethod->execute(rootParameter, result); - CPPUNIT_ASSERT(!result.hasMember("errorCode")); + try { + removeAudioClipMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } + result.clear(); - validatePlaylistMethod->execute(rootParameter, result); + try { + validatePlaylistMethod->execute(rootParameter, result); + } + catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } CPPUNIT_ASSERT(result.hasMember("valid")); CPPUNIT_ASSERT(!bool(result["valid"])); // has a gap at the beginning } diff --git a/livesupport/products/scheduler/src/XmlRpcTools.cxx b/livesupport/products/scheduler/src/XmlRpcTools.cxx index 57ce2de36..dc2126a8b 100644 --- a/livesupport/products/scheduler/src/XmlRpcTools.cxx +++ b/livesupport/products/scheduler/src/XmlRpcTools.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/Attic/XmlRpcTools.cxx,v $ ------------------------------------------------------------------------------*/ @@ -270,15 +270,14 @@ XmlRpcTools :: audioClipVectorToXmlRpcValue( /*------------------------------------------------------------------------------ - * Convert an error code, error message pair to an XmlRpcValue + * Convert an error code, error message pair to an XML-RPC fault response *----------------------------------------------------------------------------*/ void XmlRpcTools :: markError(int errorCode, const std::string errorMessage, XmlRpc::XmlRpcValue & xmlRpcValue) - throw () + throw (XmlRpc::XmlRpcException) { - xmlRpcValue["errorCode"] = errorCode; - xmlRpcValue["errorMessage"] = errorMessage; + throw XmlRpc::XmlRpcException(errorMessage, errorCode); } diff --git a/livesupport/products/scheduler/src/XmlRpcTools.h b/livesupport/products/scheduler/src/XmlRpcTools.h index fb32d4e3f..d18877ffd 100644 --- a/livesupport/products/scheduler/src/XmlRpcTools.h +++ b/livesupport/products/scheduler/src/XmlRpcTools.h @@ -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/Attic/XmlRpcTools.h,v $ ------------------------------------------------------------------------------*/ @@ -44,6 +44,7 @@ #include #include #include +#include #include #include "LiveSupport/Core/Ptr.h" @@ -73,7 +74,7 @@ using namespace LiveSupport::Core; * in the Scheduler. * * @author $Author: fgerlits $ - * @version $Revision: 1.10 $ + * @version $Revision: 1.11 $ */ class XmlRpcTools { @@ -272,7 +273,7 @@ class XmlRpcTools static void markError(int errorCode, const std::string errorMessage, XmlRpc::XmlRpcValue & xmlRpcValue) - throw (); + throw (XmlRpc::XmlRpcException); /** * Convert the valid status of a playlist to an XmlRpcValue