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
#
#
# Author : $Author: maroy $
# Version : $Revision: 1.28 $
# Author : $Author: fgerlits $
# Version : $Revision: 1.29 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
#
# @configure_input@
@ -186,11 +186,11 @@ SCHEDULER_EXE_LIBS = -l${EVENT_SCHEDULER_LIB} -l${PLAYLIST_EXECUTOR_LIB} \
TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \
${TMP_DIR}/TestRunner.o \
${TMP_DIR}/SchedulerDaemonTest.o \
${TMP_DIR}/SchedulerDaemonUploadTest.o \
${TMP_DIR}/SchedulerDaemonDisplayScheduleTest.o \
${TMP_DIR}/SchedulerDaemonDisplayPlaylistTest.o \
${TMP_DIR}/SchedulerDaemonRemoveFromScheduleTest.o \
${TMP_DIR}/SchedulerDaemonRescheduleTest.o \
${TMP_DIR}/RpcUploadPlaylistTest.o \
${TMP_DIR}/RpcDisplayScheduleTest.o \
${TMP_DIR}/RpcDisplayPlaylistTest.o \
${TMP_DIR}/RpcRemoveFromScheduleTest.o \
${TMP_DIR}/RpcRescheduleTest.o \
${TMP_DIR}/XmlRpcToolsTest.o \
${TMP_DIR}/UploadPlaylistMethodTest.o \
${TMP_DIR}/DisplayScheduleMethodTest.o \

View File

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

View File

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

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.8 $
Version : $Revision: 1.9 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.h,v $
------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#include <string>
#include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/Playlist.h"
@ -82,13 +83,9 @@ using namespace LiveSupport::Core;
* start of the playlist and the start of the audio clip.</li>
* </ul>
*
* In case of an error, an XML-RPC structure is returned, with the following
* fields:
* <ul>
* <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:
* In case of an error, a standard XML-RPC fault response is generated,
* and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* possible errors are:
* <ul>
* <li>301 - invalid argument format </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>307 - audio clip does not exist </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>
*
* @author $Author: fgerlits $
* @version $Revision: 1.8 $
* @version $Revision: 1.9 $
*/
class AddAudioClipToPlaylistMethod : public XmlRpc::XmlRpcServerMethod
{
@ -145,7 +142,8 @@ class AddAudioClipToPlaylistMethod : public XmlRpc::XmlRpcServerMethod
*/
void
execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw ();
XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
};

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.6 $
Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -178,13 +178,25 @@ AddAudioClipToPlaylistMethodTest :: firstTest(void)
rootParameter[0] = parameters;
result.clear();
openPlaylistMethod->execute(rootParameter, result);
CPPUNIT_ASSERT(!result.hasMember("errorCode"));
result.clear();
addAudioClipMethod->execute(rootParameter, result);
CPPUNIT_ASSERT(result.hasMember("errorCode"));
CPPUNIT_ASSERT((int)(result["errorCode"]) == 308);
try {
openPlaylistMethod->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
result.clear();
try {
addAudioClipMethod->execute(rootParameter, result);
CPPUNIT_FAIL("allowed to add overlapping audio clip");
}
catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 308);
}
parameters.clear();
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = 1;
@ -193,6 +205,13 @@ AddAudioClipToPlaylistMethodTest :: firstTest(void)
rootParameter[0] = parameters;
result.clear();
addAudioClipMethod->execute(rootParameter, result);
CPPUNIT_ASSERT(!result.hasMember("errorCode"));
try {
addAudioClipMethod->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
}

View File

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

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.h,v $
------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#include <string>
#include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.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>
* </ul>
* If there is an error, an XML-RPC structure is returned, with the following
* fields:
* <ul>
* <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:
*
* In case of an error, a standard XML-RPC fault response is generated,
* and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* possible errors are:
* <ul>
* <li>201 - could not open new playlist for editing</li>
* <li>222 - missing session ID argument </li>
* <li>220 - missing session ID argument </li>
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.5 $
* @version $Revision: 1.6 $
*/
class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
{
@ -138,7 +136,8 @@ class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
*/
void
execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw ();
XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
};

View File

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

View File

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

View File

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

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -180,21 +180,46 @@ DeletePlaylistMethodTest :: firstTest(void)
rootParameter[0] = parameter;
result.clear();
openMethod->execute(rootParameter, result);
CPPUNIT_ASSERT(!result.hasMember("errorCode"));
try {
openMethod->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
result.clear();
deleteMethod->execute(rootParameter, result);
CPPUNIT_ASSERT(result.hasMember("errorCode"));
CPPUNIT_ASSERT(int(result["errorCode"]) == 904); // playlist is locked
try {
deleteMethod->execute(rootParameter, result);
CPPUNIT_FAIL("allowed to delete locked playlist");
}
catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 904); // playlist is locked
}
result.clear();
saveMethod->execute(rootParameter, result);
CPPUNIT_ASSERT(!result.hasMember("errorCode"));
try {
saveMethod->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
result.clear();
deleteMethod->execute(rootParameter, result);
CPPUNIT_ASSERT(!result.hasMember("errorCode")); // OK
try {
deleteMethod->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
}
@ -217,8 +242,12 @@ DeletePlaylistMethodTest :: negativeTest(void)
rootParameter[0] = parameter;
result.clear();
method->execute(rootParameter, result);
CPPUNIT_ASSERT(result.hasMember("errorCode"));
CPPUNIT_ASSERT(int(result["errorCode"]) == 903); // playlist not found
try {
method->execute(rootParameter, result);
CPPUNIT_FAIL("allowed to delete non-existent playlist");
}
catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 903); // playlist not found
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipsMethod.h,v $
------------------------------------------------------------------------------*/
@ -45,6 +45,7 @@
#include <vector>
#include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/AudioClip.h"
@ -88,19 +89,15 @@ using namespace LiveSupport::Core;
* </li>
* </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,
* and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* possible errors are:
* <ul>
* <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>
* <li>1822 - missing session ID argument </li>
* <li>1820 - missing session ID argument </li>
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.3 $
* @version $Revision: 1.4 $
*/
class DisplayAudioClipsMethod : public XmlRpc::XmlRpcServerMethod
{
@ -143,7 +140,8 @@ class DisplayAudioClipsMethod : public XmlRpc::XmlRpcServerMethod
*/
void
execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw ();
XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
};

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -171,7 +171,15 @@ DisplayAudioClipsMethodTest :: firstTest(void)
result.clear();
parameter["sessionId"] = sessionId->getId();
rootParameter[0] = parameter;
method->execute(rootParameter, result);
try {
method->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
CPPUNIT_ASSERT(result.size() == 2);
audioClip = result[0];

View File

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

View File

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

View File

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

View File

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

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h,v $
------------------------------------------------------------------------------*/
@ -45,6 +45,7 @@
#include <vector>
#include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/Playlist.h"
@ -88,19 +89,15 @@ using namespace LiveSupport::Core;
* </li>
* </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,
* and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* possible errors are:
* <ul>
* <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>
* <li>1722 - missing session ID argument </li>
* <li>1720 - missing session ID argument </li>
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.5 $
* @version $Revision: 1.6 $
*/
class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod
{
@ -143,7 +140,8 @@ class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod
*/
void
execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw ();
XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
};

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -171,7 +171,15 @@ DisplayPlaylistsMethodTest :: firstTest(void)
result.clear();
parameters["sessionId"] = sessionId->getId();
rootParameter[0] = parameters;
method->execute(rootParameter, result);
try {
method->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
CPPUNIT_ASSERT(result.size() == 1);
playlist = result[0];

View File

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

View File

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

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -205,7 +205,15 @@ DisplayScheduleMethodTest :: firstTest(void)
rootParameter[0] = parameters;
result.clear();
method->execute(rootParameter, result);
try {
method->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
CPPUNIT_ASSERT(result.size() == 0);
}
@ -237,7 +245,15 @@ DisplayScheduleMethodTest :: insertEntries(void)
rootParameter[0] = parameters;
result.clear();
method->execute(rootParameter, result);
try {
method->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
// insert a playlist for 2004-07-31, at 12 o'clock
parameters["sessionId"] = sessionId->getId();
@ -252,7 +268,15 @@ DisplayScheduleMethodTest :: insertEntries(void)
rootParameter[0] = parameters;
result.clear();
method->execute(rootParameter, result);
try {
method->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
// insert a playlist for 2004-07-31, at 14 o'clock
parameters["sessionId"] = sessionId->getId();
@ -267,7 +291,15 @@ DisplayScheduleMethodTest :: insertEntries(void)
rootParameter[0] = parameters;
result.clear();
method->execute(rootParameter, result);
try {
method->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
}
@ -304,7 +336,15 @@ DisplayScheduleMethodTest :: intervalTest(void)
rootParameter[0] = parameters;
result.clear();
method->execute(rootParameter, result);
try {
method->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
// check the returned values
CPPUNIT_ASSERT(result.size() == 1);
@ -343,7 +383,15 @@ DisplayScheduleMethodTest :: intervalTest(void)
rootParameter[0] = parameters;
result.clear();
method->execute(rootParameter, result);
try {
method->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
// check the returned values
CPPUNIT_ASSERT(result.size() == 2);
@ -398,7 +446,15 @@ DisplayScheduleMethodTest :: intervalTest(void)
rootParameter[0] = parameters;
result.clear();
method->execute(rootParameter, result);
try {
method->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
// check the returned values
CPPUNIT_ASSERT(result.size() == 0);

View File

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

View File

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

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -205,7 +205,15 @@ GeneratePlayReportMethodTest :: firstTest(void)
rootParameter[0] = parameters;
result.clear();
method->execute(rootParameter, result);
try {
method->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
CPPUNIT_ASSERT(result.size() == 0);
}
@ -265,7 +273,15 @@ GeneratePlayReportMethodTest :: intervalTest(void)
rootParameter[0] = parameters;
result.clear();
method->execute(rootParameter, result);
try {
method->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
// check the returned values
CPPUNIT_ASSERT(result.size() == 1);
@ -298,7 +314,15 @@ GeneratePlayReportMethodTest :: intervalTest(void)
rootParameter[0] = parameters;
result.clear();
method->execute(rootParameter, result);
try {
method->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
// check the returned values
CPPUNIT_ASSERT(result.size() == 1);
@ -331,7 +355,15 @@ GeneratePlayReportMethodTest :: intervalTest(void)
rootParameter[0] = parameters;
result.clear();
method->execute(rootParameter, result);
try {
method->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
// check the returned values
CPPUNIT_ASSERT(result.size() == 2);
@ -373,7 +405,15 @@ GeneratePlayReportMethodTest :: intervalTest(void)
rootParameter[0] = parameters;
result.clear();
method->execute(rootParameter, result);
try {
method->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
// check the returned values
CPPUNIT_ASSERT(result.size() == 0);

View File

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

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.7 $
Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h,v $
------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#include <string>
#include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.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>
* </ul>
* In case of an error, an XML-RPC structure is returned, with the following
* fields:
* <ul>
* <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:
*
* In case of an error, a standard XML-RPC fault response is generated,
* and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* possible errors are:
* <ul>
* <li>101 - invalid argument format </li>
* <li>102 - argument is not a playlist ID </li>
* <li>104 - playlist not found </li>
* <li>105 - could not open playlist </li>
* <li>122 - missing session ID argument </li>
* <li>120 - missing session ID argument </li>
* </ul>
* @author $Author: fgerlits $
* @version $Revision: 1.7 $
* @version $Revision: 1.8 $
*/
class OpenPlaylistForEditingMethod : public XmlRpc::XmlRpcServerMethod
{
@ -143,7 +141,8 @@ class OpenPlaylistForEditingMethod : public XmlRpc::XmlRpcServerMethod
*/
void
execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw ();
XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -176,7 +176,15 @@ RemoveFromScheduleMethodTest :: firstTest(void)
rootParameter[0] = parameters;
result.clear();
uploadMethod->execute(rootParameter, result);
try {
uploadMethod->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
CPPUNIT_ASSERT(result.hasMember("scheduleEntryId"));
entryId.reset(new UniqueId(int(result["scheduleEntryId"])));
@ -186,8 +194,15 @@ RemoveFromScheduleMethodTest :: firstTest(void)
rootParameter[0] = parameters;
result.clear();
removeMethod->execute(rootParameter, result);
CPPUNIT_ASSERT(!result.hasMember("errorCode"));
try {
removeMethod->execute(rootParameter, result);
}
catch (XmlRpc::XmlRpcException &e) {
std::stringstream eMsg;
eMsg << "XML-RPC method returned error: " << e.getCode()
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
}
@ -211,7 +226,11 @@ RemoveFromScheduleMethodTest :: negativeTest(void)
rootParameter[0] = parameters;
result.clear();
removeMethod->execute(rootParameter, result);
CPPUNIT_ASSERT(result.hasMember("errorCode"));
try {
removeMethod->execute(rootParameter, result);
CPPUNIT_FAIL("allowed to remove non-existent schedule entry");
}
catch (XmlRpc::XmlRpcException &e) {
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.h,v $
------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#include <string>
#include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h>
#include <XmlRpcException.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>
* </ul>
*
* In case of an error, an XML-RPC structure is returned, with the following
* fields:
* <ul>
* <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:
* In case of an error, a standard XML-RPC fault response is generated,
* and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* possible errors are:
* <ul>
* <li>1601 - invalid argument format </li>
* <li>1602 - missing playlist ID argument </li>
@ -99,10 +96,10 @@ using namespace LiveSupport::Core;
* <li>1606 - playlist does not exist </li>
* <li>1607 - playlist has not been opened for editing </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>
* @author $Author: fgerlits $
* @version $Revision: 1.3 $
* @version $Revision: 1.4 $
*/
class UpdateFadeInFadeOutMethod : public XmlRpc::XmlRpcServerMethod
{
@ -145,7 +142,8 @@ class UpdateFadeInFadeOutMethod : public XmlRpc::XmlRpcServerMethod
*/
void
execute(XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue) throw ();
XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.10 $
Version : $Revision: 1.11 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/XmlRpcTools.cxx,v $
------------------------------------------------------------------------------*/
@ -270,15 +270,14 @@ XmlRpcTools :: audioClipVectorToXmlRpcValue(
/*------------------------------------------------------------------------------
* Convert an error code, error message pair to an XmlRpcValue
* Convert an error code, error message pair to an XML-RPC fault response
*----------------------------------------------------------------------------*/
void
XmlRpcTools :: markError(int errorCode, const std::string errorMessage,
XmlRpc::XmlRpcValue & xmlRpcValue)
throw ()
throw (XmlRpc::XmlRpcException)
{
xmlRpcValue["errorCode"] = errorCode;
xmlRpcValue["errorMessage"] = errorMessage;
throw XmlRpc::XmlRpcException(errorMessage, errorCode);
}

View File

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