added XmlRpcTools to uml model

modified createPlaylist to lock playlist for editing (forgot earlier)
This commit is contained in:
fgerlits 2004-10-09 14:41:04 +00:00
parent a815a437d9
commit 8837f77e65
4 changed files with 41 additions and 5 deletions

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -70,6 +70,11 @@ using namespace LiveSupport::Scheduler;
*----------------------------------------------------------------------------*/
const std::string CreatePlaylistMethod::methodName = "createPlaylist";
/*------------------------------------------------------------------------------
* The ID of this method for error reporting purposes.
*----------------------------------------------------------------------------*/
const int CreatePlaylistMethod::errorId = 2000;
/* =============================================== local function prototypes */
@ -102,5 +107,11 @@ CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
Ptr<Playlist>::Ref playlist = storage->createPlaylist();
if (!playlist->setLockedForEditing(true)) { // this should never happen
XmlRpcTools :: markError(errorId+1,
"could not open new playlist for editing",
returnValue);
return;
}
XmlRpcTools :: playlistToXmlRpcValue(playlist, returnValue);
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.h,v $
------------------------------------------------------------------------------*/
@ -75,9 +75,15 @@ 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>
*
* @author $Author: fgerlits $
* @version $Revision: 1.1 $
* @version $Revision: 1.2 $
*/
class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
{
@ -88,6 +94,11 @@ class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
*/
static const std::string methodName;
/**
* The ID of this method for error reporting purposes.
*/
static const int errorId;
public:
/**

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -47,8 +47,10 @@
#include "LiveSupport/Db/ConnectionManagerFactory.h"
#include "LiveSupport/Storage/StorageClientFactory.h"
#include "CreatePlaylistMethod.h"
#include "OpenPlaylistForEditingMethod.h"
#include "CreatePlaylistMethodTest.h"
using namespace XmlRpc;
using namespace LiveSupport::Db;
using namespace LiveSupport::Storage;
@ -138,11 +140,23 @@ void
CreatePlaylistMethodTest :: firstTest(void)
throw (CPPUNIT_NS::Exception)
{
Ptr<CreatePlaylistMethod>::Ref method(new CreatePlaylistMethod());
Ptr<XmlRpcServerMethod>::Ref method(new CreatePlaylistMethod());
XmlRpc::XmlRpcValue parameter;
XmlRpc::XmlRpcValue result;
method->execute(parameter, result);
CPPUNIT_ASSERT(result.hasMember("id"));
CPPUNIT_ASSERT(((int) result["playlength"]) == 0);
int playlistId = (int) result["id"];
method.reset(new OpenPlaylistForEditingMethod());
parameter.clear();
result.clear();
parameter["playlistId"] = playlistId;
// should not allow to open the same playlist for editing again
method->execute(parameter, result);
CPPUNIT_ASSERT((int) result["errorCode"] == 1005);
CPPUNIT_ASSERT((const std::string) result["errorMessage"] ==
"playlist cannot be edited");
}