changed error reporting in the XML-RPC methods from ad-hoc to standard

XML-RPC fault responses
This commit is contained in:
fgerlits 2004-12-01 15:59:59 +00:00
parent 86beeeab01
commit 7b591bbaa1
60 changed files with 890 additions and 461 deletions

View File

@ -20,8 +20,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# #
# Author : $Author: maroy $ # Author : $Author: fgerlits $
# Version : $Revision: 1.28 $ # Version : $Revision: 1.29 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
# #
# @configure_input@ # @configure_input@
@ -186,11 +186,11 @@ SCHEDULER_EXE_LIBS = -l${EVENT_SCHEDULER_LIB} -l${PLAYLIST_EXECUTOR_LIB} \
TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \ TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \
${TMP_DIR}/TestRunner.o \ ${TMP_DIR}/TestRunner.o \
${TMP_DIR}/SchedulerDaemonTest.o \ ${TMP_DIR}/SchedulerDaemonTest.o \
${TMP_DIR}/SchedulerDaemonUploadTest.o \ ${TMP_DIR}/RpcUploadPlaylistTest.o \
${TMP_DIR}/SchedulerDaemonDisplayScheduleTest.o \ ${TMP_DIR}/RpcDisplayScheduleTest.o \
${TMP_DIR}/SchedulerDaemonDisplayPlaylistTest.o \ ${TMP_DIR}/RpcDisplayPlaylistTest.o \
${TMP_DIR}/SchedulerDaemonRemoveFromScheduleTest.o \ ${TMP_DIR}/RpcRemoveFromScheduleTest.o \
${TMP_DIR}/SchedulerDaemonRescheduleTest.o \ ${TMP_DIR}/RpcRescheduleTest.o \
${TMP_DIR}/XmlRpcToolsTest.o \ ${TMP_DIR}/XmlRpcToolsTest.o \
${TMP_DIR}/UploadPlaylistMethodTest.o \ ${TMP_DIR}/UploadPlaylistMethodTest.o \
${TMP_DIR}/DisplayScheduleMethodTest.o \ ${TMP_DIR}/DisplayScheduleMethodTest.o \

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE storageClientFactory [ <!DOCTYPE storageClientFactory [
<!ELEMENT storageClientFactory (testStorage?) > <!ELEMENT storageClientFactory (webStorage|testStorage) >
<!ELEMENT testStorage (playlist*, audioClip*) > <!ELEMENT testStorage (playlist*, audioClip*) >
<!ATTLIST testStorage tempFiles CDATA #REQUIRED > <!ATTLIST testStorage tempFiles CDATA #REQUIRED >
@ -10,7 +10,7 @@
<!ATTLIST playlist id NMTOKEN #REQUIRED > <!ATTLIST playlist id NMTOKEN #REQUIRED >
<!ATTLIST playlist playlength NMTOKEN #REQUIRED > <!ATTLIST playlist playlength NMTOKEN #REQUIRED >
<!ELEMENT playlistElement (audioClip, fadeInfo?) > <!ELEMENT playlistElement ((audioClip|playlist), fadeInfo?) >
<!ATTLIST playlistElement id NMTOKEN #REQUIRED > <!ATTLIST playlistElement id NMTOKEN #REQUIRED >
<!ATTLIST playlistElement relativeOffset NMTOKEN #REQUIRED > <!ATTLIST playlistElement relativeOffset NMTOKEN #REQUIRED >

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -98,7 +98,7 @@ AddAudioClipToPlaylistMethod :: AddAudioClipToPlaylistMethod (
void void
AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -112,7 +112,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#include <string> #include <string>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/Playlist.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.</li> * start of the playlist and the start of the audio clip.</li>
* </ul> * </ul>
* *
* In case of an error, an XML-RPC structure is returned, with the following * In case of an error, a standard XML-RPC fault response is generated,
* fields: * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* <ul> * possible errors are:
* <li>errorCode - int - the id of the error condition</li>
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul> * <ul>
* <li>301 - invalid argument format </li> * <li>301 - invalid argument format </li>
* <li>302 - missing playlist ID argument </li> * <li>302 - missing playlist ID argument </li>
@ -98,11 +95,11 @@ using namespace LiveSupport::Core;
* <li>306 - playlist has not been opened for editing </li> * <li>306 - playlist has not been opened for editing </li>
* <li>307 - audio clip does not exist </li> * <li>307 - audio clip does not exist </li>
* <li>308 - two audio clips at the same relative offset</li> * <li>308 - two audio clips at the same relative offset</li>
* <li>322 - missing session ID argument </li> * <li>320 - missing session ID argument </li>
* </ul> * </ul>
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.8 $ * @version $Revision: 1.9 $
*/ */
class AddAudioClipToPlaylistMethod : public XmlRpc::XmlRpcServerMethod class AddAudioClipToPlaylistMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -145,7 +142,8 @@ class AddAudioClipToPlaylistMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute( XmlRpc::XmlRpcValue & parameters, execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -178,13 +178,25 @@ AddAudioClipToPlaylistMethodTest :: firstTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); result.clear();
openPlaylistMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); openPlaylistMethod->execute(rootParameter, result);
result.clear(); }
addAudioClipMethod->execute(rootParameter, result); catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(result.hasMember("errorCode")); std::stringstream eMsg;
CPPUNIT_ASSERT((int)(result["errorCode"]) == 308); 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.clear();
parameters["sessionId"] = sessionId->getId(); parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = 1; parameters["playlistId"] = 1;
@ -193,6 +205,13 @@ AddAudioClipToPlaylistMethodTest :: firstTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); result.clear();
addAudioClipMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); 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());
}
} }

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -97,7 +97,7 @@ CreatePlaylistMethod :: CreatePlaylistMethod (
void void
CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -111,7 +111,7 @@ CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#include <string> #include <string>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/Playlist.h" #include "LiveSupport/Core/Playlist.h"
@ -82,20 +83,17 @@ using namespace LiveSupport::Core;
* <li>playlength - int - the playlist length of the playlist, in seconds * <li>playlength - int - the playlist length of the playlist, in seconds
* </li> * </li>
* </ul> * </ul>
* If there is 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,
* <ul> * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* <li>errorCode - int - a numerical code for the error</li> * possible errors are:
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul> * <ul>
* <li>201 - could not open new playlist for editing</li> * <li>201 - could not open new playlist for editing</li>
* <li>222 - missing session ID argument </li> * <li>220 - missing session ID argument </li>
* </ul> * </ul>
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.5 $ * @version $Revision: 1.6 $
*/ */
class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -138,7 +136,8 @@ class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute( XmlRpc::XmlRpcValue & parameters, execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -171,7 +171,15 @@ CreatePlaylistMethodTest :: firstTest(void)
result.clear(); result.clear();
parameter["sessionId"] = sessionId->getId(); parameter["sessionId"] = sessionId->getId();
rootParameter[0] = parameter; 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(result.hasMember("id"));
CPPUNIT_ASSERT(((int) result["playlength"]) == 0); CPPUNIT_ASSERT(((int) result["playlength"]) == 0);
@ -182,9 +190,12 @@ CreatePlaylistMethodTest :: firstTest(void)
parameter["playlistId"] = playlistId; parameter["playlistId"] = playlistId;
rootParameter[0] = parameter; rootParameter[0] = parameter;
// should not allow to open the same playlist for editing again
result.clear(); result.clear();
method->execute(rootParameter, result); try {
CPPUNIT_ASSERT(result.hasMember("errorCode")); method->execute(rootParameter, result);
CPPUNIT_ASSERT((int) result["errorCode"] == 105); CPPUNIT_FAIL("allowed to open playlist twice");
}
catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 105);
}
} }

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -88,7 +88,7 @@ DeletePlaylistMethod :: DeletePlaylistMethod (
void void
DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -102,7 +102,7 @@ DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#include <string> #include <string>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/Playlist.h" #include "LiveSupport/Core/Playlist.h"
@ -77,24 +78,20 @@ using namespace LiveSupport::Core;
* to be deleted.</li> * to be deleted.</li>
* </ul> * </ul>
* *
* If there is an error, an XML-RPC structure is returned, with the following * In case of an error, a standard XML-RPC fault response is generated,
* fields: * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* <ul> * possible errors are:
* <li>errorCode - int - a numerical code for the error</li>
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul> * <ul>
* <li>901 - invalid argument format </li> * <li>901 - invalid argument format </li>
* <li>902 - missing playlist ID argument </li> * <li>902 - missing playlist ID argument </li>
* <li>903 - playlist not found </li> * <li>903 - playlist not found </li>
* <li>904 - playlist is locked </li> * <li>904 - playlist is locked </li>
* <li>905 - playlist could not be deleted </li> * <li>905 - playlist could not be deleted </li>
* <li>922 - missing session ID argument </li> * <li>920- missing session ID argument </li>
* </ul> * </ul>
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.5 $ * @version $Revision: 1.6 $
*/ */
class DeletePlaylistMethod : public XmlRpc::XmlRpcServerMethod class DeletePlaylistMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -137,7 +134,8 @@ class DeletePlaylistMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute( XmlRpc::XmlRpcValue & parameters, execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ 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; rootParameter[0] = parameter;
result.clear(); result.clear();
openMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); 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(); result.clear();
deleteMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(result.hasMember("errorCode")); deleteMethod->execute(rootParameter, result);
CPPUNIT_ASSERT(int(result["errorCode"]) == 904); // playlist is locked CPPUNIT_FAIL("allowed to delete locked playlist");
}
catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 904); // playlist is locked
}
result.clear(); result.clear();
saveMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); 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(); result.clear();
deleteMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); // OK 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; rootParameter[0] = parameter;
result.clear(); result.clear();
method->execute(rootParameter, result); try {
CPPUNIT_ASSERT(result.hasMember("errorCode")); method->execute(rootParameter, result);
CPPUNIT_ASSERT(int(result["errorCode"]) == 903); // playlist not found CPPUNIT_FAIL("allowed to delete non-existent playlist");
}
catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 903); // playlist not found
}
} }

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -97,7 +97,7 @@ DisplayAudioClipMethod :: DisplayAudioClipMethod (
void void
DisplayAudioClipMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, DisplayAudioClipMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -111,7 +111,7 @@ DisplayAudioClipMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#include <string> #include <string>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/AudioClip.h" #include "LiveSupport/Core/AudioClip.h"
@ -85,22 +86,18 @@ using namespace LiveSupport::Core;
* </li> * </li>
* </ul> * </ul>
* *
* If there is an error, an XML-RPC structure is returned, with the following * In case of an error, a standard XML-RPC fault response is generated,
* fields: * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* <ul> * possible errors are:
* <li>errorCode - int - a numerical code for the error</li>
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul> * <ul>
* <li>601 - invalid argument format </li> * <li>601 - invalid argument format </li>
* <li>602 - argument is not an audio clip ID </li> * <li>602 - argument is not an audio clip ID </li>
* <li>603 - audio clip not found </li> * <li>603 - audio clip not found </li>
* <li>622 - missing session ID argument </li> * <li>620 - missing session ID argument </li>
* </ul> * </ul>
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.3 $ * @version $Revision: 1.4 $
*/ */
class DisplayAudioClipMethod : public XmlRpc::XmlRpcServerMethod class DisplayAudioClipMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -143,7 +140,8 @@ class DisplayAudioClipMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute( XmlRpc::XmlRpcValue & parameters, execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -172,7 +172,15 @@ DisplayAudioClipMethodTest :: firstTest(void)
rootParameter[0] = parameter; rootParameter[0] = parameter;
result.clear(); 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["id"]) == 10001);
CPPUNIT_ASSERT(int(result["playlength"]) == (60 * 60)); CPPUNIT_ASSERT(int(result["playlength"]) == (60 * 60));
} }
@ -197,7 +205,11 @@ DisplayAudioClipMethodTest :: negativeTest(void)
rootParameter[0] = parameter; rootParameter[0] = parameter;
result.clear(); result.clear();
method->execute(rootParameter, result); try {
CPPUNIT_ASSERT(result.hasMember("errorCode")); method->execute(rootParameter, result);
CPPUNIT_ASSERT(int(result["errorCode"]) == 603); // audio clip not found CPPUNIT_FAIL("allowed to display non-existent audio clip");
}
catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 603); // audio clip not found
}
} }

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipsMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -87,7 +87,7 @@ DisplayAudioClipsMethod :: DisplayAudioClipsMethod (
void void
DisplayAudioClipsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, DisplayAudioClipsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -101,7 +101,7 @@ DisplayAudioClipsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipsMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -45,6 +45,7 @@
#include <vector> #include <vector>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/AudioClip.h" #include "LiveSupport/Core/AudioClip.h"
@ -88,19 +89,15 @@ using namespace LiveSupport::Core;
* </li> * </li>
* </ul> * </ul>
* *
* In case of an error, an XML-RPC structure is returned, with the following * In case of an error, a standard XML-RPC fault response is generated,
* fields: * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* possible errors are:
* <ul> * <ul>
* <li>errorCode - int - the id of the error condition</li> * <li>1820 - missing session ID argument </li>
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul>
* <li>1822 - missing session ID argument </li>
* </ul> * </ul>
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.3 $ * @version $Revision: 1.4 $
*/ */
class DisplayAudioClipsMethod : public XmlRpc::XmlRpcServerMethod class DisplayAudioClipsMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -143,7 +140,8 @@ class DisplayAudioClipsMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute( XmlRpc::XmlRpcValue & parameters, execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -171,7 +171,15 @@ DisplayAudioClipsMethodTest :: firstTest(void)
result.clear(); result.clear();
parameter["sessionId"] = sessionId->getId(); parameter["sessionId"] = sessionId->getId();
rootParameter[0] = parameter; 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); CPPUNIT_ASSERT(result.size() == 2);
audioClip = result[0]; audioClip = result[0];

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -97,7 +97,7 @@ DisplayPlaylistMethod :: DisplayPlaylistMethod (
void void
DisplayPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, DisplayPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -111,7 +111,7 @@ DisplayPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#include <string> #include <string>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/Playlist.h" #include "LiveSupport/Core/Playlist.h"
@ -85,22 +86,18 @@ using namespace LiveSupport::Core;
* </li> * </li>
* </ul> * </ul>
* *
* If there is an error, an XML-RPC structure is returned, with the following * In case of an error, a standard XML-RPC fault response is generated,
* fields: * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* <ul> * possible errors are:
* <li>errorCode - int - a numerical code for the error</li>
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul> * <ul>
* <li>1001 - invalid argument format </li> * <li>1001 - invalid argument format </li>
* <li>1002 - argument is not a playlist ID </li> * <li>1002 - argument is not a playlist ID </li>
* <li>1003 - playlist not found </li> * <li>1003 - playlist not found </li>
* <li>1022 - missing session ID argument </li> * <li>1020 - missing session ID argument </li>
* </ul> * </ul>
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.5 $ * @version $Revision: 1.6 $
*/ */
class DisplayPlaylistMethod : public XmlRpc::XmlRpcServerMethod class DisplayPlaylistMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -143,7 +140,8 @@ class DisplayPlaylistMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute( XmlRpc::XmlRpcValue & parameters, execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -172,7 +172,15 @@ DisplayPlaylistMethodTest :: firstTest(void)
rootParameter[0] = parameter; rootParameter[0] = parameter;
result.clear(); 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["id"]) == 1);
CPPUNIT_ASSERT(int(result["playlength"]) == 90 * 60); CPPUNIT_ASSERT(int(result["playlength"]) == 90 * 60);
} }
@ -197,8 +205,12 @@ DisplayPlaylistMethodTest :: negativeTest(void)
rootParameter[0] = parameter; rootParameter[0] = parameter;
result.clear(); result.clear();
method->execute(rootParameter, result); try {
CPPUNIT_ASSERT(result.hasMember("errorCode")); method->execute(rootParameter, result);
CPPUNIT_ASSERT(int(result["errorCode"]) == 1003); // playlist not found CPPUNIT_FAIL("allowed to display non-existent playlist");
}
catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 1003); // playlist not found
}
} }

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -88,7 +88,7 @@ DisplayPlaylistsMethod :: DisplayPlaylistsMethod (
void void
DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -102,7 +102,7 @@ DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -45,6 +45,7 @@
#include <vector> #include <vector>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/Playlist.h" #include "LiveSupport/Core/Playlist.h"
@ -88,19 +89,15 @@ using namespace LiveSupport::Core;
* </li> * </li>
* </ul> * </ul>
* *
* In case of an error, an XML-RPC structure is returned, with the following * In case of an error, a standard XML-RPC fault response is generated,
* fields: * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* possible errors are:
* <ul> * <ul>
* <li>errorCode - int - the id of the error condition</li> * <li>1720 - missing session ID argument </li>
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul>
* <li>1722 - missing session ID argument </li>
* </ul> * </ul>
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.5 $ * @version $Revision: 1.6 $
*/ */
class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -143,7 +140,8 @@ class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute( XmlRpc::XmlRpcValue & parameters, execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -171,7 +171,15 @@ DisplayPlaylistsMethodTest :: firstTest(void)
result.clear(); result.clear();
parameters["sessionId"] = sessionId->getId(); parameters["sessionId"] = sessionId->getId();
rootParameter[0] = parameters; 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); CPPUNIT_ASSERT(result.size() == 1);
playlist = result[0]; playlist = result[0];

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -94,7 +94,7 @@ DisplayScheduleMethod :: DisplayScheduleMethod (
void void
DisplayScheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, DisplayScheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -108,7 +108,7 @@ DisplayScheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -46,6 +46,7 @@
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "ScheduleEntry.h" #include "ScheduleEntry.h"
@ -95,22 +96,18 @@ using namespace LiveSupport::Core;
* <li>end - datetime - the end of the scheduled item</li> * <li>end - datetime - the end of the scheduled item</li>
* </ul> * </ul>
* *
* If there is an error, an XML-RPC structure is returned, with the following * In case of an error, a standard XML-RPC fault response is generated,
* fields: * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* <ul> * possible errors are:
* <li>errorCode - int - a numerical code for the error</li>
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul> * <ul>
* <li>1101 - invalid argument format </li> * <li>1101 - invalid argument format </li>
* <li>1102 - missing or invalid 'from' argument </li> * <li>1102 - missing or invalid 'from' argument </li>
* <li>1103 - missing or invalid 'to' argument </li> * <li>1103 - missing or invalid 'to' argument </li>
* <li>1122 - missing session ID argument </li> * <li>1120 - missing session ID argument </li>
* </ul> * </ul>
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.5 $ * @version $Revision: 1.6 $
*/ */
class DisplayScheduleMethod : public XmlRpc::XmlRpcServerMethod class DisplayScheduleMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -153,7 +150,8 @@ class DisplayScheduleMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute( XmlRpc::XmlRpcValue & parameters, execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -205,7 +205,15 @@ DisplayScheduleMethodTest :: firstTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); 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); CPPUNIT_ASSERT(result.size() == 0);
} }
@ -237,7 +245,15 @@ DisplayScheduleMethodTest :: insertEntries(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); 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 // insert a playlist for 2004-07-31, at 12 o'clock
parameters["sessionId"] = sessionId->getId(); parameters["sessionId"] = sessionId->getId();
@ -252,7 +268,15 @@ DisplayScheduleMethodTest :: insertEntries(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); 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 // insert a playlist for 2004-07-31, at 14 o'clock
parameters["sessionId"] = sessionId->getId(); parameters["sessionId"] = sessionId->getId();
@ -267,7 +291,15 @@ DisplayScheduleMethodTest :: insertEntries(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); 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; rootParameter[0] = parameters;
result.clear(); 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 // check the returned values
CPPUNIT_ASSERT(result.size() == 1); CPPUNIT_ASSERT(result.size() == 1);
@ -343,7 +383,15 @@ DisplayScheduleMethodTest :: intervalTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); 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 // check the returned values
CPPUNIT_ASSERT(result.size() == 2); CPPUNIT_ASSERT(result.size() == 2);
@ -398,7 +446,15 @@ DisplayScheduleMethodTest :: intervalTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); 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 // check the returned values
CPPUNIT_ASSERT(result.size() == 0); CPPUNIT_ASSERT(result.size() == 0);

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GeneratePlayReportMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -94,7 +94,7 @@ GeneratePlayReportMethod :: GeneratePlayReportMethod (
void void
GeneratePlayReportMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, GeneratePlayReportMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -108,7 +108,7 @@ GeneratePlayReportMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GeneratePlayReportMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -46,6 +46,7 @@
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "PlayLogEntry.h" #include "PlayLogEntry.h"
@ -92,22 +93,18 @@ using namespace LiveSupport::Core;
* <li>timestamp - datetime - the time the clip was played (started) </li> * <li>timestamp - datetime - the time the clip was played (started) </li>
* </ul> * </ul>
* *
* If there is an error, an XML-RPC structure is returned, with the following * In case of an error, a standard XML-RPC fault response is generated,
* fields: * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* <ul> * possible errors are:
* <li>errorCode - int - a numerical code for the error</li>
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul> * <ul>
* <li>1501 - invalid argument format </li> * <li>1501 - invalid argument format </li>
* <li>1502 - missing or invalid 'from' argument </li> * <li>1502 - missing or invalid 'from' argument </li>
* <li>1503 - missing or invalid 'to' argument </li> * <li>1503 - missing or invalid 'to' argument </li>
* <li>1522 - missing session ID argument </li> * <li>1520 - missing session ID argument </li>
* </ul> * </ul>
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.3 $ * @version $Revision: 1.4 $
*/ */
class GeneratePlayReportMethod : public XmlRpc::XmlRpcServerMethod class GeneratePlayReportMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -128,7 +125,7 @@ class GeneratePlayReportMethod : public XmlRpc::XmlRpcServerMethod
/** /**
* A default constructor, for testing purposes. * A default constructor, for testing purposes.
*/ */
GeneratePlayReportMethod(void) throw () GeneratePlayReportMethod(void) throw ()
: XmlRpc::XmlRpcServerMethod(methodName) : XmlRpc::XmlRpcServerMethod(methodName)
{ {
} }
@ -140,7 +137,7 @@ class GeneratePlayReportMethod : public XmlRpc::XmlRpcServerMethod
*/ */
GeneratePlayReportMethod( GeneratePlayReportMethod(
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
throw (); throw ();
/** /**
* Execute the generatePlayReport command on the Scheduler daemon. * Execute the generatePlayReport command on the Scheduler daemon.
@ -150,7 +147,8 @@ class GeneratePlayReportMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute(XmlRpc::XmlRpcValue & parameters, execute(XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -205,7 +205,15 @@ GeneratePlayReportMethodTest :: firstTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); 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); CPPUNIT_ASSERT(result.size() == 0);
} }
@ -265,7 +273,15 @@ GeneratePlayReportMethodTest :: intervalTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); 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 // check the returned values
CPPUNIT_ASSERT(result.size() == 1); CPPUNIT_ASSERT(result.size() == 1);
@ -298,7 +314,15 @@ GeneratePlayReportMethodTest :: intervalTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); 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 // check the returned values
CPPUNIT_ASSERT(result.size() == 1); CPPUNIT_ASSERT(result.size() == 1);
@ -331,7 +355,15 @@ GeneratePlayReportMethodTest :: intervalTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); 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 // check the returned values
CPPUNIT_ASSERT(result.size() == 2); CPPUNIT_ASSERT(result.size() == 2);
@ -373,7 +405,15 @@ GeneratePlayReportMethodTest :: intervalTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); 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 // check the returned values
CPPUNIT_ASSERT(result.size() == 0); CPPUNIT_ASSERT(result.size() == 0);

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -98,7 +98,7 @@ OpenPlaylistForEditingMethod :: OpenPlaylistForEditingMethod (
void void
OpenPlaylistForEditingMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, OpenPlaylistForEditingMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -112,7 +112,7 @@ OpenPlaylistForEditingMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#include <string> #include <string>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/Playlist.h" #include "LiveSupport/Core/Playlist.h"
@ -85,22 +86,19 @@ using namespace LiveSupport::Core;
* <li>playlength - int - the playlist length of the playlist, in seconds * <li>playlength - int - the playlist length of the playlist, in seconds
* </li> * </li>
* </ul> * </ul>
* 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,
* <ul> * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* <li>errorCode - int - the id of the error condition</li> * possible errors are:
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul> * <ul>
* <li>101 - invalid argument format </li> * <li>101 - invalid argument format </li>
* <li>102 - argument is not a playlist ID </li> * <li>102 - argument is not a playlist ID </li>
* <li>104 - playlist not found </li> * <li>104 - playlist not found </li>
* <li>105 - could not open playlist </li> * <li>105 - could not open playlist </li>
* <li>122 - missing session ID argument </li> * <li>120 - missing session ID argument </li>
* </ul> * </ul>
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.7 $ * @version $Revision: 1.8 $
*/ */
class OpenPlaylistForEditingMethod : public XmlRpc::XmlRpcServerMethod class OpenPlaylistForEditingMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -143,7 +141,8 @@ class OpenPlaylistForEditingMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute( XmlRpc::XmlRpcValue & parameters, execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -173,7 +173,15 @@ OpenPlaylistForEditingMethodTest :: firstTest(void)
rootParameter[0] = parameter; rootParameter[0] = parameter;
result.clear(); 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["id"] == 1);
CPPUNIT_ASSERT((int) result["playlength"] == (90 * 60)); CPPUNIT_ASSERT((int) result["playlength"] == (90 * 60));
@ -182,22 +190,26 @@ OpenPlaylistForEditingMethodTest :: firstTest(void)
parameter["playlistId"] = 6376; parameter["playlistId"] = 6376;
rootParameter[0] = parameter; rootParameter[0] = parameter;
// no such playlist
result.clear(); result.clear();
method->execute(rootParameter, result); try {
CPPUNIT_ASSERT((int) result["errorCode"] == 104); method->execute(rootParameter, result);
CPPUNIT_ASSERT((const std::string) result["errorMessage"] == CPPUNIT_FAIL("allowed to open non-existent playlist");
"playlist not found"); }
catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 104); // playlist not found
}
parameter.clear(); parameter.clear();
parameter["sessionId"] = sessionId->getId(); parameter["sessionId"] = sessionId->getId();
parameter["playlistId"] = 1; parameter["playlistId"] = 1;
rootParameter[0] = parameter; rootParameter[0] = parameter;
// should not allow to open the same playlist for editing again
result.clear(); result.clear();
method->execute(rootParameter, result); try {
CPPUNIT_ASSERT((int) result["errorCode"] == 105); method->execute(rootParameter, result);
CPPUNIT_ASSERT((const std::string) result["errorMessage"] == CPPUNIT_FAIL("allowed to open the same playlist twice");
"could not open playlist"); }
catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 105); // could not open playlist
}
} }

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -99,7 +99,7 @@ void
RemoveAudioClipFromPlaylistMethod :: execute( RemoveAudioClipFromPlaylistMethod :: execute(
XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -113,7 +113,7 @@ RemoveAudioClipFromPlaylistMethod :: execute(
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#include <string> #include <string>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/Playlist.h" #include "LiveSupport/Core/Playlist.h"
@ -81,13 +82,9 @@ using namespace LiveSupport::Core;
* to be removed.</li> * to be removed.</li>
* </ul> * </ul>
* *
* In case of an error, an XML-RPC structure is returned, with the following * In case of an error, a standard XML-RPC fault response is generated,
* fields: * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* <ul> * possible errors are:
* <li>errorCode - int - the id of the error condition</li>
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul> * <ul>
* <li>401 - invalid argument format </li> * <li>401 - invalid argument format </li>
* <li>402 - missing playlist ID argument </li> * <li>402 - missing playlist ID argument </li>
@ -95,10 +92,10 @@ using namespace LiveSupport::Core;
* <li>404 - playlist does not exist </li> * <li>404 - playlist does not exist </li>
* <li>405 - playlist has not been opened for editing </li> * <li>405 - playlist has not been opened for editing </li>
* <li>406 - no audio clip at the specified relative offset </li> * <li>406 - no audio clip at the specified relative offset </li>
* <li>422 - missing session ID argument </li> * <li>420 - missing session ID argument </li>
* </ul> * </ul>
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.3 $ * @version $Revision: 1.4 $
*/ */
class RemoveAudioClipFromPlaylistMethod : public XmlRpc::XmlRpcServerMethod class RemoveAudioClipFromPlaylistMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -119,7 +116,7 @@ class RemoveAudioClipFromPlaylistMethod : public XmlRpc::XmlRpcServerMethod
/** /**
* A default constructor, for testing purposes. * A default constructor, for testing purposes.
*/ */
RemoveAudioClipFromPlaylistMethod(void) throw () RemoveAudioClipFromPlaylistMethod(void) throw ()
: XmlRpc::XmlRpcServerMethod(methodName) : XmlRpc::XmlRpcServerMethod(methodName)
{ {
} }
@ -141,7 +138,8 @@ class RemoveAudioClipFromPlaylistMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute( XmlRpc::XmlRpcValue & parameters, execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -184,22 +184,53 @@ RemoveAudioClipFromPlaylistMethodTest :: firstTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); result.clear();
removeAudioClipMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(result.hasMember("errorCode")); removeAudioClipMethod->execute(rootParameter, result);
CPPUNIT_ASSERT((int)(result["errorCode"]) == 405); // not open for editing 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(); result.clear();
openPlaylistMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); 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(); result.clear();
removeAudioClipMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(result.hasMember("errorCode")); removeAudioClipMethod->execute(rootParameter, result);
CPPUNIT_ASSERT((int)(result["errorCode"]) == 406); // no audio clip at }
// this rel offset catch (XmlRpc::XmlRpcException &e) {
result.clear(); std::stringstream eMsg;
addAudioClipMethod->execute(rootParameter, result); eMsg << "XML-RPC method returned error: " << e.getCode()
CPPUNIT_ASSERT(!result.hasMember("errorCode")); << " - " << e.getMessage();
result.clear(); CPPUNIT_FAIL(eMsg.str());
removeAudioClipMethod->execute(rootParameter, result); }
CPPUNIT_ASSERT(!result.hasMember("errorCode"));
} }

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -91,7 +91,7 @@ RemoveFromScheduleMethod :: RemoveFromScheduleMethod (
void void
RemoveFromScheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, RemoveFromScheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -105,7 +105,7 @@ RemoveFromScheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -45,6 +45,7 @@
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/UniqueId.h" #include "LiveSupport/Core/UniqueId.h"
@ -77,22 +78,18 @@ using namespace LiveSupport::Core;
* <li>scheduleEntryId - int - the id of the scheduled entry to remove</li> * <li>scheduleEntryId - int - the id of the scheduled entry to remove</li>
* </ul> * </ul>
* *
* In case of an error, an XML-RPC structure is returned, with the following * In case of an error, a standard XML-RPC fault response is generated,
* fields: * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* <ul> * possible errors are:
* <li>errorCode - int - the id of the error condition</li>
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul> * <ul>
* <li>1201 - invalid argument format </li> * <li>1201 - invalid argument format </li>
* <li>1202 - missing schedule entry ID argument </li> * <li>1202 - missing schedule entry ID argument </li>
* <li>1203 - schedule entry not found </li> * <li>1203 - schedule entry not found </li>
* <li>1222 - missing session ID argument </li> * <li>1220 - missing session ID argument </li>
* </ul> * </ul>
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.5 $ * @version $Revision: 1.6 $
*/ */
class RemoveFromScheduleMethod : public XmlRpc::XmlRpcServerMethod class RemoveFromScheduleMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -113,7 +110,7 @@ class RemoveFromScheduleMethod : public XmlRpc::XmlRpcServerMethod
/** /**
* A default constructor, for testing purposes. * A default constructor, for testing purposes.
*/ */
RemoveFromScheduleMethod(void) throw () RemoveFromScheduleMethod(void) throw ()
: XmlRpc::XmlRpcServerMethod(methodName) : XmlRpc::XmlRpcServerMethod(methodName)
{ {
} }
@ -125,7 +122,7 @@ class RemoveFromScheduleMethod : public XmlRpc::XmlRpcServerMethod
*/ */
RemoveFromScheduleMethod( RemoveFromScheduleMethod(
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
throw (); throw ();
/** /**
* Execute the remove from schedule command on the Scheduler daemon. * Execute the remove from schedule command on the Scheduler daemon.
@ -135,7 +132,8 @@ class RemoveFromScheduleMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute( XmlRpc::XmlRpcValue & parameters, execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -176,7 +176,15 @@ RemoveFromScheduleMethodTest :: firstTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); 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")); CPPUNIT_ASSERT(result.hasMember("scheduleEntryId"));
entryId.reset(new UniqueId(int(result["scheduleEntryId"]))); entryId.reset(new UniqueId(int(result["scheduleEntryId"])));
@ -186,8 +194,15 @@ RemoveFromScheduleMethodTest :: firstTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); result.clear();
removeMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); 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; rootParameter[0] = parameters;
result.clear(); result.clear();
removeMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(result.hasMember("errorCode")); removeMethod->execute(rootParameter, result);
CPPUNIT_FAIL("allowed to remove non-existent schedule entry");
}
catch (XmlRpc::XmlRpcException &e) {
}
} }

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RescheduleMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -94,7 +94,7 @@ RescheduleMethod :: RescheduleMethod (
void void
RescheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, RescheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -108,7 +108,7 @@ RescheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RescheduleMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -45,6 +45,7 @@
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/UniqueId.h" #include "LiveSupport/Core/UniqueId.h"
@ -79,24 +80,20 @@ using namespace LiveSupport::Core;
* <li>playtime - datetime - the new playing time for the entry</li> * <li>playtime - datetime - the new playing time for the entry</li>
* </ul> * </ul>
* *
* In case of an error, an XML-RPC structure is returned, with the following * In case of an error, a standard XML-RPC fault response is generated,
* fields: * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* <ul> * possible errors are:
* <li>errorCode - int - the id of the error condition</li>
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul> * <ul>
* <li>1301 - invalid argument format </li> * <li>1301 - invalid argument format </li>
* <li>1302 - missing schedule entry ID argument </li> * <li>1302 - missing schedule entry ID argument </li>
* <li>1303 - missing playtime argument </li> * <li>1303 - missing playtime argument </li>
* <li>1304 - schedule entry not found </li> * <li>1304 - schedule entry not found </li>
* <li>1305 - could not reschedule entry </li> * <li>1305 - could not reschedule entry </li>
* <li>1322 - missing session ID argument </li> * <li>1320 - missing session ID argument </li>
* </ul> * </ul>
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.5 $ * @version $Revision: 1.6 $
*/ */
class RescheduleMethod : public XmlRpc::XmlRpcServerMethod class RescheduleMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -117,7 +114,7 @@ class RescheduleMethod : public XmlRpc::XmlRpcServerMethod
/** /**
* A default constructor, for testing purposes. * A default constructor, for testing purposes.
*/ */
RescheduleMethod(void) throw () RescheduleMethod(void) throw ()
: XmlRpc::XmlRpcServerMethod(methodName) : XmlRpc::XmlRpcServerMethod(methodName)
{ {
} }
@ -129,7 +126,7 @@ class RescheduleMethod : public XmlRpc::XmlRpcServerMethod
*/ */
RescheduleMethod( RescheduleMethod(
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
throw (); throw ();
/** /**
* Execute the upload playlist command on the Scheduler daemon. * Execute the upload playlist command on the Scheduler daemon.
@ -139,7 +136,8 @@ class RescheduleMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute( XmlRpc::XmlRpcValue & parameters, execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RescheduleMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -176,8 +176,15 @@ RescheduleMethodTest :: firstTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); result.clear();
uploadMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); 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")); CPPUNIT_ASSERT(result.hasMember("scheduleEntryId"));
entryId.reset(new UniqueId(int(result["scheduleEntryId"]))); entryId.reset(new UniqueId(int(result["scheduleEntryId"])));
@ -195,8 +202,15 @@ RescheduleMethodTest :: firstTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); result.clear();
rescheduleMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); 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 // now let's reschedule unto itself, should fail
parameters.clear(); parameters.clear();
@ -212,9 +226,12 @@ RescheduleMethodTest :: firstTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); result.clear();
rescheduleMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(result.hasMember("errorCode")); rescheduleMethod->execute(rootParameter, result);
CPPUNIT_FAIL("allowed to schedule playlist onto itself");
CPPUNIT_ASSERT(int(result["errorCode"]) == 1305); }
catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 1305);
}
} }

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -93,7 +93,7 @@ RevertEditedPlaylistMethod :: RevertEditedPlaylistMethod (
void void
RevertEditedPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, RevertEditedPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -107,7 +107,7 @@ RevertEditedPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#include <string> #include <string>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/Playlist.h" #include "LiveSupport/Core/Playlist.h"
@ -78,22 +79,18 @@ using namespace LiveSupport::Core;
* <li>playlistId - int - the unique id of the playlist requested.</li> * <li>playlistId - int - the unique id of the playlist requested.</li>
* </ul> * </ul>
* *
* In case of an error, an XML-RPC structure is returned, with the following * In case of an error, a standard XML-RPC fault response is generated,
* fields: * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* <ul> * possible errors are:
* <li>errorCode - int - the id of the error condition</li>
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul> * <ul>
* <li>801 - invalid argument format </li> * <li>801 - invalid argument format </li>
* <li>802 - argument is not a playlist ID </li> * <li>802 - argument is not a playlist ID </li>
* <li>803 - playlist not found </li> * <li>803 - playlist not found </li>
* <li>804 - could not revert playlist </li> * <li>804 - could not revert playlist </li>
* <li>822 - missing session ID argument </li> * <li>820 - missing session ID argument </li>
* </ul> * </ul>
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.3 $ * @version $Revision: 1.4 $
*/ */
class RevertEditedPlaylistMethod : public XmlRpc::XmlRpcServerMethod class RevertEditedPlaylistMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -136,7 +133,8 @@ class RevertEditedPlaylistMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute(XmlRpc::XmlRpcValue & parameters, execute(XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -183,32 +183,83 @@ RevertEditedPlaylistMethodTest :: firstTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); result.clear();
revertMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(result.hasMember("errorCode")); revertMethod->execute(rootParameter, result);
CPPUNIT_ASSERT(int(result["errorCode"]) == 804); // no saved copy yet CPPUNIT_FAIL("allowed to revert playlist without saving it first");
}
catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 804); // no saved copy
}
result.clear(); result.clear();
openMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); 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(); result.clear();
removeMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); removeMethod->execute(rootParameter, result);
result.clear(); }
removeMethod->execute(rootParameter, result); catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(result.hasMember("errorCode")); // can't remove it twice std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
result.clear(); result.clear();
revertMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); removeMethod->execute(rootParameter, result);
result.clear(); CPPUNIT_FAIL("allowed to remove the same playlist element twice");
removeMethod->execute(rootParameter, result); }
CPPUNIT_ASSERT(!result.hasMember("errorCode")); // but now we can again catch (XmlRpc::XmlRpcException &e) {
}
result.clear(); result.clear();
saveMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); 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(); result.clear();
revertMethod->execute(rootParameter, result); try { // but now we can again
CPPUNIT_ASSERT(result.hasMember("errorCode")); // saved copy has been removeMethod->execute(rootParameter, result);
CPPUNIT_ASSERT(int(result["errorCode"]) == 804); // discarded }
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
}
} }

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SavePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -93,7 +93,7 @@ SavePlaylistMethod :: SavePlaylistMethod (
void void
SavePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, SavePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -107,7 +107,7 @@ SavePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SavePlaylistMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#include <string> #include <string>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/Playlist.h" #include "LiveSupport/Core/Playlist.h"
@ -79,22 +80,18 @@ using namespace LiveSupport::Core;
* <li>playlistId - int - the unique id of the playlist to save.</li> * <li>playlistId - int - the unique id of the playlist to save.</li>
* </ul> * </ul>
* *
* In case of an error, an XML-RPC structure is returned, with the following * In case of an error, a standard XML-RPC fault response is generated,
* fields: * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* <ul> * possible errors are:
* <li>errorCode - int - the id of the error condition</li>
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul> * <ul>
* <li>701 - invalid argument format </li> * <li>701 - invalid argument format </li>
* <li>702 - argument is not a playlist ID </li> * <li>702 - argument is not a playlist ID </li>
* <li>703 - playlist not found </li> * <li>703 - playlist not found </li>
* <li>704 - could not save playlist </li> * <li>704 - could not save playlist </li>
* <li>722 - missing session ID argument </li> * <li>720 - missing session ID argument </li>
* </ul> * </ul>
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.3 $ * @version $Revision: 1.4 $
*/ */
class SavePlaylistMethod : public XmlRpc::XmlRpcServerMethod class SavePlaylistMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -115,7 +112,7 @@ class SavePlaylistMethod : public XmlRpc::XmlRpcServerMethod
/** /**
* A default constructor, for testing purposes. * A default constructor, for testing purposes.
*/ */
SavePlaylistMethod(void) throw () SavePlaylistMethod(void) throw ()
: XmlRpc::XmlRpcServerMethod(methodName) : XmlRpc::XmlRpcServerMethod(methodName)
{ {
} }
@ -127,7 +124,7 @@ class SavePlaylistMethod : public XmlRpc::XmlRpcServerMethod
*/ */
SavePlaylistMethod( SavePlaylistMethod(
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
throw (); throw ();
/** /**
* Execute the display schedule command on the Scheduler daemon. * Execute the display schedule command on the Scheduler daemon.
@ -137,7 +134,8 @@ class SavePlaylistMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute(XmlRpc::XmlRpcValue & parameters, execute(XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SavePlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -174,20 +174,47 @@ SavePlaylistMethodTest :: firstTest(void)
rootParameter[0] = parameter; rootParameter[0] = parameter;
result.clear(); result.clear();
saveMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(result.hasMember("errorCode")); saveMethod->execute(rootParameter, result);
CPPUNIT_ASSERT(int(result["errorCode"]) == 703); // playlist not found CPPUNIT_FAIL("allowed to save non-existent playlist");
}
catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 703); // playlist not found
}
parameter["playlistId"] = 1; parameter["playlistId"] = 1;
rootParameter[0] = parameter; rootParameter[0] = parameter;
result.clear(); result.clear();
openMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); openMethod->execute(rootParameter, result);
result.clear(); }
saveMethod->execute(rootParameter, result); catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); // open then save OK std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
result.clear(); result.clear();
openMethod->execute(rootParameter, result); try { // open then save OK
CPPUNIT_ASSERT(!result.hasMember("errorCode")); // 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());
}
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());
}
} }

View File

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $ Author : $Author: fgerlits $
Version : $Revision: 1.9 $ Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.cxx,v $ 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()); displayPlaylistMethod.reset(new DisplayPlaylistMethod());
removeFromScheduleMethod.reset(new RemoveFromScheduleMethod()); removeFromScheduleMethod.reset(new RemoveFromScheduleMethod());
rescheduleMethod.reset(new RescheduleMethod()); rescheduleMethod.reset(new RescheduleMethod());
openPlaylistForEditingMethod.reset(new OpenPlaylistForEditingMethod());
addAudioClipToPlaylistMethod.reset(new AddAudioClipToPlaylistMethod());
} }
@ -211,6 +213,8 @@ SchedulerDaemon :: registerXmlRpcFunctions(
xmlRpcServer->addMethod(displayPlaylistMethod.get()); xmlRpcServer->addMethod(displayPlaylistMethod.get());
xmlRpcServer->addMethod(removeFromScheduleMethod.get()); xmlRpcServer->addMethod(removeFromScheduleMethod.get());
xmlRpcServer->addMethod(rescheduleMethod.get()); xmlRpcServer->addMethod(rescheduleMethod.get());
xmlRpcServer->addMethod(addAudioClipToPlaylistMethod.get());
xmlRpcServer->addMethod(openPlaylistForEditingMethod.get());
} }

View File

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $ Author : $Author: fgerlits $
Version : $Revision: 1.8 $ Version : $Revision: 1.9 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -67,6 +67,8 @@
#include "DisplayPlaylistMethod.h" #include "DisplayPlaylistMethod.h"
#include "RemoveFromScheduleMethod.h" #include "RemoveFromScheduleMethod.h"
#include "RescheduleMethod.h" #include "RescheduleMethod.h"
#include "AddAudioClipToPlaylistMethod.h"
#include "OpenPlaylistForEditingMethod.h"
#include "XmlRpcDaemon.h" #include "XmlRpcDaemon.h"
@ -123,8 +125,8 @@ using namespace LiveSupport::PlaylistExecutor;
* scheduleFactory,xmlRpcDaemon) &gt; * scheduleFactory,xmlRpcDaemon) &gt;
* </code></pre> * </code></pre>
* *
* @author $Author: maroy $ * @author $Author: fgerlits $
* @version $Revision: 1.8 $ * @version $Revision: 1.9 $
* @see ConnectionManagerFactory * @see ConnectionManagerFactory
* @see StorageClientFactory * @see StorageClientFactory
* @see ScheduleFactory * @see ScheduleFactory
@ -152,30 +154,40 @@ class SchedulerDaemon : public Installable,
Ptr<AudioPlayerInterface>::Ref audioPlayer; Ptr<AudioPlayerInterface>::Ref audioPlayer;
/** /**
* The UploadPlaylistMethod the daemon is providing. * The uploadPlaylistMethod the daemon is providing.
*/ */
Ptr<UploadPlaylistMethod>::Ref uploadPlaylistMethod; Ptr<UploadPlaylistMethod>::Ref uploadPlaylistMethod;
/** /**
* The DisplayScheduleMethod the daemon is providing. * The displayScheduleMethod the daemon is providing.
*/ */
Ptr<DisplayScheduleMethod>::Ref displayScheduleMethod; Ptr<DisplayScheduleMethod>::Ref displayScheduleMethod;
/** /**
* The DisplayPlaylistMethod the daemon is providing. * The displayPlaylistMethod the daemon is providing.
*/ */
Ptr<DisplayPlaylistMethod>::Ref displayPlaylistMethod; Ptr<DisplayPlaylistMethod>::Ref displayPlaylistMethod;
/** /**
* The RemoveFromScheduleMethod the daemon is providing. * The removeFromScheduleMethod the daemon is providing.
*/ */
Ptr<RemoveFromScheduleMethod>::Ref removeFromScheduleMethod; Ptr<RemoveFromScheduleMethod>::Ref removeFromScheduleMethod;
/** /**
* The RescheduleMethod the daemon is providing. * The rescheduleMethod the daemon is providing.
*/ */
Ptr<RescheduleMethod>::Ref rescheduleMethod; Ptr<RescheduleMethod>::Ref rescheduleMethod;
/**
* The addAudioClipToPlaylistMethod the daemon is providing.
*/
Ptr<AddAudioClipToPlaylistMethod>::Ref addAudioClipToPlaylistMethod;
/**
* The openPlaylistForEditingMethod the daemon is providing.
*/
Ptr<OpenPlaylistForEditingMethod>::Ref openPlaylistForEditingMethod;
/** /**
* Default constructor. * Default constructor.
*/ */

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -101,7 +101,7 @@ void
UpdateFadeInFadeOutMethod :: execute( UpdateFadeInFadeOutMethod :: execute(
XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -115,7 +115,7 @@ UpdateFadeInFadeOutMethod :: execute(
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#include <string> #include <string>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
@ -83,13 +84,9 @@ using namespace LiveSupport::Core;
* <li>fadeOut - int - the length (in milliseconds) of the fade out. </li> * <li>fadeOut - int - the length (in milliseconds) of the fade out. </li>
* </ul> * </ul>
* *
* In case of an error, an XML-RPC structure is returned, with the following * In case of an error, a standard XML-RPC fault response is generated,
* fields: * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* <ul> * possible errors are:
* <li>errorCode - int - the id of the error condition</li>
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul> * <ul>
* <li>1601 - invalid argument format </li> * <li>1601 - invalid argument format </li>
* <li>1602 - missing playlist ID argument </li> * <li>1602 - missing playlist ID argument </li>
@ -99,10 +96,10 @@ using namespace LiveSupport::Core;
* <li>1606 - playlist does not exist </li> * <li>1606 - playlist does not exist </li>
* <li>1607 - playlist has not been opened for editing </li> * <li>1607 - playlist has not been opened for editing </li>
* <li>1608 - no audio clip at the specified relative offset </li> * <li>1608 - no audio clip at the specified relative offset </li>
* <li>1622 - missing session ID argument </li> * <li>1620 - missing session ID argument </li>
* </ul> * </ul>
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.3 $ * @version $Revision: 1.4 $
*/ */
class UpdateFadeInFadeOutMethod : public XmlRpc::XmlRpcServerMethod class UpdateFadeInFadeOutMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -145,7 +142,8 @@ class UpdateFadeInFadeOutMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute(XmlRpc::XmlRpcValue & parameters, execute(XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -180,30 +180,57 @@ UpdateFadeInFadeOutMethodTest :: firstTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); result.clear();
updateFadeMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(result.hasMember("errorCode")); updateFadeMethod->execute(rootParameter, result);
CPPUNIT_ASSERT((int)(result["errorCode"]) == 1605); // missing fade out CPPUNIT_FAIL("did not notice missing fade out parameter");
}
catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 1605); // missing fade out
}
parameters["fadeOut"] = 2100; parameters["fadeOut"] = 2100;
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); result.clear();
updateFadeMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(result.hasMember("errorCode")); updateFadeMethod->execute(rootParameter, result);
CPPUNIT_ASSERT((int)(result["errorCode"]) == 1607); // not open for editing 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(); result.clear();
openPlaylistMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); 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(); result.clear();
updateFadeMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(result.hasMember("errorCode")); updateFadeMethod->execute(rootParameter, result);
CPPUNIT_ASSERT((int)(result["errorCode"]) == 1608); // no audio clip at CPPUNIT_FAIL("allowed update fade info for non-existent p.l. element");
// this rel offset }
catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 1608);// no audio clip at this rel offset
}
parameters["relativeOffset"] = 0; parameters["relativeOffset"] = 0;
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); result.clear();
updateFadeMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); 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());
}
} }

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -97,7 +97,7 @@ UploadPlaylistMethod :: UploadPlaylistMethod (
void void
UploadPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, UploadPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -111,7 +111,7 @@ UploadPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -45,6 +45,7 @@
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/UniqueId.h" #include "LiveSupport/Core/UniqueId.h"
@ -87,13 +88,9 @@ using namespace LiveSupport::Core;
* by the upload </li> * by the upload </li>
* </ul> * </ul>
* *
* In case of an error, an XML-RPC structure is returned with the following * In case of an error, a standard XML-RPC fault response is generated,
* members: * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* <ul> * possible errors are:
* <li>errorCode - int - the id of the error condition</li>
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul> * <ul>
* <li>1401 - invalid argument format </li> * <li>1401 - invalid argument format </li>
* <li>1402 - missing playlist ID argument </li> * <li>1402 - missing playlist ID argument </li>
@ -101,11 +98,11 @@ using namespace LiveSupport::Core;
* <li>1404 - playlist not found </li> * <li>1404 - playlist not found </li>
* <li>1405 - timeframe not available </li> * <li>1405 - timeframe not available </li>
* <li>1406 - could not schedule playlist </li> * <li>1406 - could not schedule playlist </li>
* <li>1422 - missing session ID argument </li> * <li>1420 - missing session ID argument </li>
* </ul> * </ul>
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.8 $ * @version $Revision: 1.9 $
*/ */
class UploadPlaylistMethod : public XmlRpc::XmlRpcServerMethod class UploadPlaylistMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -126,7 +123,7 @@ class UploadPlaylistMethod : public XmlRpc::XmlRpcServerMethod
/** /**
* A default constructor, for testing purposes. * A default constructor, for testing purposes.
*/ */
UploadPlaylistMethod(void) throw () UploadPlaylistMethod(void) throw ()
: XmlRpc::XmlRpcServerMethod(methodName) : XmlRpc::XmlRpcServerMethod(methodName)
{ {
} }
@ -138,7 +135,7 @@ class UploadPlaylistMethod : public XmlRpc::XmlRpcServerMethod
*/ */
UploadPlaylistMethod( UploadPlaylistMethod(
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
throw (); throw ();
/** /**
* Execute the upload playlist command on the Scheduler daemon. * Execute the upload playlist command on the Scheduler daemon.
@ -148,7 +145,8 @@ class UploadPlaylistMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute( XmlRpc::XmlRpcValue & parameters, execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -194,7 +194,15 @@ UploadPlaylistMethodTest :: firstTest(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); 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")); CPPUNIT_ASSERT(result.hasMember("scheduleEntryId"));
} }
@ -226,7 +234,15 @@ UploadPlaylistMethodTest :: overlappingPlaylists(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); 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")); CPPUNIT_ASSERT(result.hasMember("scheduleEntryId"));
// try to load the same one, but in an overlapping time region // try to load the same one, but in an overlapping time region
@ -243,9 +259,13 @@ UploadPlaylistMethodTest :: overlappingPlaylists(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); result.clear();
method->execute(rootParameter, result); try {
CPPUNIT_ASSERT(result.hasMember("errorCode")); method->execute(rootParameter, result);
CPPUNIT_ASSERT(int(result["errorCode"]) == 1405); // timeframe not available 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 // try to load the same one, but now in good timing
parameters["sessionId"] = sessionId->getId(); parameters["sessionId"] = sessionId->getId();
@ -260,7 +280,15 @@ UploadPlaylistMethodTest :: overlappingPlaylists(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); 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")); CPPUNIT_ASSERT(result.hasMember("scheduleEntryId"));
// try to load the same one, this time overlapping both previos instances // try to load the same one, this time overlapping both previos instances
@ -276,7 +304,11 @@ UploadPlaylistMethodTest :: overlappingPlaylists(void)
rootParameter[0] = parameters; rootParameter[0] = parameters;
result.clear(); result.clear();
method->execute(rootParameter, result); try {
CPPUNIT_ASSERT(result.hasMember("errorCode")); method->execute(rootParameter, result);
CPPUNIT_ASSERT(int(result["errorCode"]) == 1405); // timeframe not available CPPUNIT_FAIL("allowed to schedule doubly overlapping playlist");
}
catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 1405); // timeframe not available
}
} }

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -98,7 +98,7 @@ ValidatePlaylistMethod :: ValidatePlaylistMethod (
void void
ValidatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, ValidatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue) XmlRpc::XmlRpcValue & returnValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
if (!rootParameter.valid() || rootParameter.size() != 1) { if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format", XmlRpcTools::markError(errorId+1, "invalid argument format",
@ -112,7 +112,7 @@ ValidatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
sessionId = XmlRpcTools::extractSessionId(parameters); sessionId = XmlRpcTools::extractSessionId(parameters);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+22, XmlRpcTools::markError(errorId+20,
"missing session ID argument", "missing session ID argument",
returnValue); returnValue);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#include <string> #include <string>
#include <XmlRpcServerMethod.h> #include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/Playlist.h" #include "LiveSupport/Core/Playlist.h"
@ -83,22 +84,18 @@ using namespace LiveSupport::Core;
* <li>valid - bool - true if the playlist is valid, false otherwise</li> * <li>valid - bool - true if the playlist is valid, false otherwise</li>
* </ul> * </ul>
* *
* In case of an error, an XML-RPC structure is returned, with the following * In case of an error, a standard XML-RPC fault response is generated,
* fields: * and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* <ul> * possible errors are:
* <li>errorCode - int - the id of the error condition</li>
* <li>errorMessage - string - a description of the error</li>
* </ul>
* The possible error codes are:
* <ul> * <ul>
* <li>501 - invalid argument format </li> * <li>501 - invalid argument format </li>
* <li>502 - missing playlist ID argument </li> * <li>502 - missing playlist ID argument </li>
* <li>503 - playlist does not exist </li> * <li>503 - playlist does not exist </li>
* <li>504 - playlist has not been opened for editing </li> * <li>504 - playlist has not been opened for editing </li>
* <li>522 - missing session ID argument </li> * <li>520 - missing session ID argument </li>
* </ul> * </ul>
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.3 $ * @version $Revision: 1.4 $
*/ */
class ValidatePlaylistMethod : public XmlRpc::XmlRpcServerMethod class ValidatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
{ {
@ -119,7 +116,7 @@ class ValidatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
/** /**
* A default constructor, for testing purposes. * A default constructor, for testing purposes.
*/ */
ValidatePlaylistMethod(void) throw () ValidatePlaylistMethod(void) throw ()
: XmlRpc::XmlRpcServerMethod(methodName) : XmlRpc::XmlRpcServerMethod(methodName)
{ {
} }
@ -131,7 +128,7 @@ class ValidatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
*/ */
ValidatePlaylistMethod( ValidatePlaylistMethod(
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
throw (); throw ();
/** /**
* Execute the display schedule command on the Scheduler daemon. * Execute the display schedule command on the Scheduler daemon.
@ -141,7 +138,8 @@ class ValidatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
*/ */
void void
execute( XmlRpc::XmlRpcValue & parameters, execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw (); XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -178,30 +178,66 @@ ValidatePlaylistMethodTest :: firstTest(void)
result.clear(); result.clear();
parameter["sessionId"] = sessionId->getId(); parameter["sessionId"] = sessionId->getId();
parameter["playlistId"] = 275; parameter["playlistId"] = 275;
rootParameter[0] = parameter; rootParameter[0] = parameter;
validatePlaylistMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(result.hasMember("errorCode")); validatePlaylistMethod->execute(rootParameter, result);
CPPUNIT_ASSERT(int(result["errorCode"]) == 503); // no such playlist CPPUNIT_FAIL("allowed to validate non-existent playlist");
}
catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 503); // no such playlist
}
result.clear(); result.clear();
parameter.clear(); parameter.clear();
parameter["sessionId"] = sessionId->getId(); parameter["sessionId"] = sessionId->getId();
parameter["playlistId"] = 1; parameter["playlistId"] = 1;
rootParameter[0] = parameter; rootParameter[0] = parameter;
openPlaylistMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); 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(); 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(result.hasMember("valid"));
CPPUNIT_ASSERT(bool(result["valid"])); CPPUNIT_ASSERT(bool(result["valid"]));
result.clear(); result.clear();
parameter["relativeOffset"] = 0; parameter["relativeOffset"] = 0;
rootParameter[0] = parameter; rootParameter[0] = parameter;
removeAudioClipMethod->execute(rootParameter, result); try {
CPPUNIT_ASSERT(!result.hasMember("errorCode")); 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(); 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(result.hasMember("valid"));
CPPUNIT_ASSERT(!bool(result["valid"])); // has a gap at the beginning CPPUNIT_ASSERT(!bool(result["valid"])); // has a gap at the beginning
} }

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ 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 void
XmlRpcTools :: markError(int errorCode, const std::string errorMessage, XmlRpcTools :: markError(int errorCode, const std::string errorMessage,
XmlRpc::XmlRpcValue & xmlRpcValue) XmlRpc::XmlRpcValue & xmlRpcValue)
throw () throw (XmlRpc::XmlRpcException)
{ {
xmlRpcValue["errorCode"] = errorCode; throw XmlRpc::XmlRpcException(errorMessage, errorCode);
xmlRpcValue["errorMessage"] = errorMessage;
} }

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/XmlRpcTools.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <XmlRpcValue.h> #include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
@ -73,7 +74,7 @@ using namespace LiveSupport::Core;
* in the Scheduler. * in the Scheduler.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.10 $ * @version $Revision: 1.11 $
*/ */
class XmlRpcTools class XmlRpcTools
{ {
@ -272,7 +273,7 @@ class XmlRpcTools
static void static void
markError(int errorCode, const std::string errorMessage, markError(int errorCode, const std::string errorMessage,
XmlRpc::XmlRpcValue & xmlRpcValue) XmlRpc::XmlRpcValue & xmlRpcValue)
throw (); throw (XmlRpc::XmlRpcException);
/** /**
* Convert the valid status of a playlist to an XmlRpcValue * Convert the valid status of a playlist to an XmlRpcValue