added new removeAudioClipFromPlaylist and validatePlaylist
modified the contract for removeAudioClipFromPlaylist to take a relative offset as argument instead of an audio clip id (makes more sense this way, also implements more neatly :-)
This commit is contained in:
parent
cad97c0806
commit
a5b4dd625e
File diff suppressed because it is too large
Load Diff
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.5 $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playlist.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -71,7 +71,7 @@ using namespace boost::posix_time;
|
|||
* the playlist.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.5 $
|
||||
* @version $Revision: 1.6 $
|
||||
*/
|
||||
class Playlist : public Configurable
|
||||
{
|
||||
|
@ -166,7 +166,7 @@ class Playlist : public Configurable
|
|||
* @return the name of the expected XML configuration element.
|
||||
*/
|
||||
static const std::string
|
||||
getConfigElementName(void) throw ()
|
||||
getConfigElementName(void) throw ()
|
||||
{
|
||||
return configElementNameStr;
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ class Playlist : public Configurable
|
|||
*/
|
||||
virtual void
|
||||
configure(const xmlpp::Element & element)
|
||||
throw (std::invalid_argument);
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Return the id of the playlist.
|
||||
|
@ -190,7 +190,7 @@ class Playlist : public Configurable
|
|||
* @return the unique id of the playlist.
|
||||
*/
|
||||
Ptr<const UniqueId>::Ref
|
||||
getId(void) const throw ()
|
||||
getId(void) const throw ()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ class Playlist : public Configurable
|
|||
* @return the playling length of this playlist, in milliseconds.
|
||||
*/
|
||||
Ptr<const time_duration>::Ref
|
||||
getPlaylength(void) const throw ()
|
||||
getPlaylength(void) const throw ()
|
||||
{
|
||||
return playlength;
|
||||
}
|
||||
|
@ -209,12 +209,14 @@ class Playlist : public Configurable
|
|||
/**
|
||||
* Test whether the playlist is locked for editing.
|
||||
*
|
||||
* @return true if playlist is locked, false if not
|
||||
* @return true if playlist is currently being edited;
|
||||
* false if not, or if the editing has been suspended
|
||||
* because the playlist is being played
|
||||
*/
|
||||
bool
|
||||
getIsLockedForEditing() throw ()
|
||||
getIsLockedForEditing() const throw ()
|
||||
{
|
||||
return isLockedForEditing;
|
||||
return isLockedForEditing && !isLockedForPlaying;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -223,7 +225,7 @@ class Playlist : public Configurable
|
|||
* @return true if playlist is locked, false if not
|
||||
*/
|
||||
bool
|
||||
getIsLockedForPlaying() throw ()
|
||||
getIsLockedForPlaying() const throw ()
|
||||
{
|
||||
return isLockedForPlaying;
|
||||
}
|
||||
|
@ -235,7 +237,7 @@ class Playlist : public Configurable
|
|||
* false otherwise.
|
||||
*/
|
||||
bool
|
||||
setLockedForEditing(bool lockStatus)
|
||||
setLockedForEditing(const bool lockStatus)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
@ -245,7 +247,7 @@ class Playlist : public Configurable
|
|||
* false otherwise.
|
||||
*/
|
||||
bool
|
||||
setLockedForPlaying(bool lockStatus)
|
||||
setLockedForPlaying(const bool lockStatus)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
@ -256,7 +258,6 @@ class Playlist : public Configurable
|
|||
|
||||
/**
|
||||
* Get an iterator pointing to the first playlist element.
|
||||
*
|
||||
*/
|
||||
const_iterator
|
||||
begin() const throw ()
|
||||
|
@ -266,7 +267,6 @@ class Playlist : public Configurable
|
|||
|
||||
/**
|
||||
* Get an iterator pointing to one after the last playlist element.
|
||||
*
|
||||
*/
|
||||
const_iterator
|
||||
end() const throw ()
|
||||
|
@ -287,6 +287,27 @@ class Playlist : public Configurable
|
|||
addAudioClip(Ptr<AudioClip>::Ref audioClip,
|
||||
Ptr<time_duration>::Ref relativeOffset)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Remove an audio clip from the playlist.
|
||||
*
|
||||
* @param relativeOffset the start of the audio clip, relative
|
||||
* to the start of the playlist
|
||||
* @exception std::invalid_argument if the playlist does not contain
|
||||
* an audio clip with the specified relative offset
|
||||
*/
|
||||
void
|
||||
removeAudioClip(Ptr<const time_duration>::Ref relativeOffset)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Validate the playlist: check that there are no overlaps or gaps.
|
||||
* If the playlength is the only thing amiss, playlist is considered
|
||||
* valid, and the playlength is fixed. (Hence no 'const'.)
|
||||
*/
|
||||
bool
|
||||
valid(void) throw ();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.5 $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -153,7 +153,7 @@ Playlist::addAudioClip(Ptr<AudioClip>::Ref audioClip,
|
|||
throw (std::invalid_argument)
|
||||
{
|
||||
if (elementList->find(*relativeOffset) != elementList->end()) {
|
||||
std::string eMsg = "two playlist elements at the same relative offset";
|
||||
std::string eMsg = "two audio clips at the same relative offset";
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
|
||||
|
@ -164,11 +164,26 @@ Playlist::addAudioClip(Ptr<AudioClip>::Ref audioClip,
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Remove an audio clip from the playlist.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Playlist::removeAudioClip(Ptr<const time_duration>::Ref relativeOffset)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
// this returns the number of elements found and erased
|
||||
if (!elementList->erase(*relativeOffset)) {
|
||||
std::string eMsg = "no audio clip at the specified relative offset";
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Lock or unlock the playlist for editing.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
Playlist::setLockedForEditing(bool lockStatus)
|
||||
Playlist::setLockedForEditing(const bool lockStatus)
|
||||
throw ()
|
||||
{
|
||||
if (lockStatus == true) {
|
||||
|
@ -196,7 +211,7 @@ Playlist::setLockedForEditing(bool lockStatus)
|
|||
* Lock or unlock the playlist for playing.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
Playlist::setLockedForPlaying(bool lockStatus)
|
||||
Playlist::setLockedForPlaying(const bool lockStatus)
|
||||
throw ()
|
||||
{
|
||||
if (lockStatus == true) {
|
||||
|
@ -214,3 +229,27 @@ Playlist::setLockedForPlaying(bool lockStatus)
|
|||
} // was already unlocked!
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Validate the playlist.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
Playlist::valid(void) throw ()
|
||||
{
|
||||
Ptr<time_duration>::Ref runningTime(new time_duration(0,0,0,0));
|
||||
Ptr<const PlaylistElement>::Ref playlistElement;
|
||||
Ptr<const AudioClip>::Ref audioClip;
|
||||
|
||||
PlaylistElementListType::const_iterator it = elementList->begin();
|
||||
while (it != elementList->end()) {
|
||||
playlistElement = it->second;
|
||||
if (*runningTime != *(playlistElement->getRelativeOffset())) {
|
||||
return false;
|
||||
}
|
||||
audioClip = playlistElement->getAudioClip();
|
||||
*runningTime += *(audioClip->getPlaylength());
|
||||
++it;
|
||||
}
|
||||
playlength = runningTime; // fix playlength, if everything else is OK
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.5 $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -90,6 +90,9 @@ PlaylistTest :: setUp(void) throw ()
|
|||
CPPUNIT_ASSERT(duration->hours() == 1);
|
||||
CPPUNIT_ASSERT(duration->minutes() == 30);
|
||||
CPPUNIT_ASSERT(duration->seconds() == 0);
|
||||
|
||||
CPPUNIT_ASSERT(playlist->valid());
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -162,10 +165,10 @@ PlaylistTest :: lockTest(void)
|
|||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test to see if we can add a new audio clip
|
||||
* Test to see if we can add or remove an audio clip
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PlaylistTest :: addAudioClipTest(void)
|
||||
PlaylistTest :: audioClipTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<UniqueId>::Ref clipId(new UniqueId(20001));
|
||||
|
@ -183,6 +186,8 @@ PlaylistTest :: addAudioClipTest(void)
|
|||
CPPUNIT_FAIL(eMsg);
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT(!playlist->valid()); // overlapping audio clips
|
||||
|
||||
Playlist::const_iterator it = playlist->begin();
|
||||
CPPUNIT_ASSERT(it != playlist->end());
|
||||
|
||||
|
@ -200,4 +205,31 @@ PlaylistTest :: addAudioClipTest(void)
|
|||
|
||||
++it;
|
||||
CPPUNIT_ASSERT(it == playlist->end());
|
||||
|
||||
try {
|
||||
playlist->removeAudioClip(relativeOffset);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
string eMsg = "removeAudioClip returned with error: ";
|
||||
eMsg += e.what();
|
||||
CPPUNIT_FAIL(eMsg);
|
||||
}
|
||||
|
||||
it = playlist->begin();
|
||||
CPPUNIT_ASSERT(it != playlist->end());
|
||||
++it;
|
||||
CPPUNIT_ASSERT(it != playlist->end());
|
||||
++it;
|
||||
CPPUNIT_ASSERT(it == playlist->end());
|
||||
|
||||
Ptr<const time_duration>::Ref phonyRelativeOffset(
|
||||
new time_duration(0,0,1,0));
|
||||
try {
|
||||
playlist->removeAudioClip(phonyRelativeOffset);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
return;
|
||||
}
|
||||
CPPUNIT_FAIL("removeAudioClip allowed to remove "
|
||||
"non-existent audio clip");
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -58,7 +58,7 @@ namespace Core {
|
|||
* Unit test for the UploadPlaylistMetohd class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.3 $
|
||||
* @version $Revision: 1.4 $
|
||||
* @see Playlist
|
||||
*/
|
||||
class PlaylistTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -66,7 +66,7 @@ class PlaylistTest : public CPPUNIT_NS::TestFixture
|
|||
CPPUNIT_TEST_SUITE(PlaylistTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST(lockTest);
|
||||
CPPUNIT_TEST(addAudioClipTest);
|
||||
CPPUNIT_TEST(audioClipTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
@ -100,7 +100,7 @@ class PlaylistTest : public CPPUNIT_NS::TestFixture
|
|||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
addAudioClipTest(void) throw (CPPUNIT_NS::Exception);
|
||||
audioClipTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
public:
|
||||
|
|
Binary file not shown.
|
@ -21,7 +21,7 @@
|
|||
#
|
||||
#
|
||||
# Author : $Author: fgerlits $
|
||||
# Version : $Revision: 1.13 $
|
||||
# Version : $Revision: 1.14 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
|
||||
#
|
||||
# @configure_input@
|
||||
|
@ -123,7 +123,9 @@ SCHEDULER_OBJS = ${TMP_DIR}/SignalDispatcher.o \
|
|||
${TMP_DIR}/DisplayPlaylistsMethod.o \
|
||||
${TMP_DIR}/OpenPlaylistForEditingMethod.o \
|
||||
${TMP_DIR}/CreatePlaylistMethod.o \
|
||||
${TMP_DIR}/AddAudioClipToPlaylistMethod.o
|
||||
${TMP_DIR}/AddAudioClipToPlaylistMethod.o \
|
||||
${TMP_DIR}/RemoveAudioClipFromPlaylistMethod.o \
|
||||
${TMP_DIR}/ValidatePlaylistMethod.o
|
||||
|
||||
SCHEDULER_EXE_OBJS = ${SCHEDULER_OBJS} \
|
||||
${TMP_DIR}/main.o
|
||||
|
@ -150,6 +152,8 @@ TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \
|
|||
${TMP_DIR}/OpenPlaylistForEditingMethodTest.o \
|
||||
${TMP_DIR}/CreatePlaylistMethodTest.o \
|
||||
${TMP_DIR}/AddAudioClipToPlaylistMethodTest.o \
|
||||
${TMP_DIR}/RemoveAudioClipFromPlaylistMethodTest.o \
|
||||
${TMP_DIR}/ValidatePlaylistMethodTest.o \
|
||||
${TMP_DIR}/TestRunner.o
|
||||
TEST_RUNNER_LIBS = ${SCHEDULER_EXE_LIBS} -lcppunit -ldl
|
||||
|
||||
|
|
|
@ -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/AddAudioClipToPlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -107,18 +107,32 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
|||
}
|
||||
|
||||
Ptr<UniqueId>::Ref playlistId;
|
||||
Ptr<UniqueId>::Ref audioClipId;
|
||||
Ptr<time_duration>::Ref relativeOffset;
|
||||
try{
|
||||
playlistId = XmlRpcTools::extractPlaylistId(parameters);
|
||||
audioClipId = XmlRpcTools::extractAudioClipId(parameters);
|
||||
relativeOffset = XmlRpcTools::extractRelativeOffset(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+2, e.what(), returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref audioClipId;
|
||||
try{
|
||||
audioClipId = XmlRpcTools::extractAudioClipId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+3, e.what(), returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<time_duration>::Ref relativeOffset;
|
||||
try{
|
||||
relativeOffset = XmlRpcTools::extractRelativeOffset(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+4, e.what(), returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
scf = StorageClientFactory::getInstance();
|
||||
|
@ -129,13 +143,13 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
|||
playlist = storage->getPlaylist(playlistId);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+3, "playlist does not exist",
|
||||
XmlRpcTools::markError(errorId+5, "playlist does not exist",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playlist->getIsLockedForEditing()) {
|
||||
XmlRpcTools::markError(errorId+4,
|
||||
XmlRpcTools::markError(errorId+6,
|
||||
"playlist has not been opened for editing",
|
||||
returnValue);
|
||||
return;
|
||||
|
@ -146,7 +160,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
|||
audioClip = storage->getAudioClip(audioClipId);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+5, "audio clip does not exist",
|
||||
XmlRpcTools::markError(errorId+7, "audio clip does not exist",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
@ -155,7 +169,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
|||
playlist->addAudioClip(audioClip, relativeOffset);
|
||||
}
|
||||
catch(std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+6,
|
||||
XmlRpcTools::markError(errorId+8,
|
||||
"two audio clips at the same relative offset",
|
||||
returnValue);
|
||||
return;
|
||||
|
|
|
@ -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/AddAudioClipToPlaylistMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -88,14 +88,16 @@ using namespace LiveSupport::Core;
|
|||
* The possible error codes are:
|
||||
* <ul>
|
||||
* <li>301 - invalid argument format </li>
|
||||
* <li>302 - missing ... argument </li>
|
||||
* <li>303 - playlist does not exist </li>
|
||||
* <li>304 - playlist has not been opened for editing </li>
|
||||
* <li>305 - audio clip does not exist </li>
|
||||
* <li>306 - two audio clips at the same relative offset</li>
|
||||
* <li>302 - missing playlist ID argument </li>
|
||||
* <li>303 - missing audio clip ID argument </li>
|
||||
* <li>304 - missing relative offset argument </li>
|
||||
* <li>305 - playlist does not exist </li>
|
||||
* <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>
|
||||
* </ul>
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class AddAudioClipToPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -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/AddAudioClipToPlaylistMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -157,7 +157,7 @@ AddAudioClipToPlaylistMethodTest :: firstTest(void)
|
|||
openPlaylistMethod->execute(parameter, result);
|
||||
addAudioClipMethod->execute(parameter, result);
|
||||
CPPUNIT_ASSERT(result.hasMember("errorCode"));
|
||||
CPPUNIT_ASSERT((int)(result["errorCode"]) == 306);
|
||||
CPPUNIT_ASSERT((int)(result["errorCode"]) == 308);
|
||||
|
||||
parameter.clear();
|
||||
result.clear();
|
||||
|
|
|
@ -0,0 +1,163 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#else
|
||||
#error need time.h
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "LiveSupport/Core/StorageClientInterface.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "ScheduleInterface.h"
|
||||
#include "ScheduleFactory.h"
|
||||
#include "XmlRpcTools.h"
|
||||
|
||||
#include "RemoveAudioClipFromPlaylistMethod.h"
|
||||
|
||||
|
||||
using namespace boost;
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Storage;
|
||||
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of this XML-RPC method.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string RemoveAudioClipFromPlaylistMethod::methodName
|
||||
= "removeAudioClipFromPlaylist";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The ID of this method for error reporting purposes.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const int RemoveAudioClipFromPlaylistMethod::errorId = 400;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the method and register it right away.
|
||||
*----------------------------------------------------------------------------*/
|
||||
RemoveAudioClipFromPlaylistMethod :: RemoveAudioClipFromPlaylistMethod (
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) throw()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Execute the stop XML-RPC function call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RemoveAudioClipFromPlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ()
|
||||
{
|
||||
if (!parameters.valid()) {
|
||||
XmlRpcTools::markError(errorId+1, "invalid argument format",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref playlistId;
|
||||
try{
|
||||
playlistId = XmlRpcTools::extractPlaylistId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+2,
|
||||
"missing playlist ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<time_duration>::Ref relativeOffset;
|
||||
try{
|
||||
relativeOffset = XmlRpcTools::extractRelativeOffset(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+3,
|
||||
"missing relative offset argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
scf = StorageClientFactory::getInstance();
|
||||
storage = scf->getStorageClient();
|
||||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->getPlaylist(playlistId);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+4, "playlist does not exist",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playlist->getIsLockedForEditing()) {
|
||||
XmlRpcTools::markError(errorId+5,
|
||||
"playlist has not been opened for editing",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
try { // and finally, the beef
|
||||
playlist->removeAudioClip(relativeOffset);
|
||||
}
|
||||
catch(std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+6,
|
||||
"no audio clip at the specified "
|
||||
"relative offset",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef RemoveAudioClipFromPlaylistMethod_h
|
||||
#define RemoveAudioClipFromPlaylistMethod_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <XmlRpcServerMethod.h>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An XML-RPC method object to remove an audio clip (specified by its relative
|
||||
* offset) from a playlist (specified by its ID).
|
||||
*
|
||||
* The name of the method when called through XML-RPC is
|
||||
* "removeAudioClipFromPlaylist".
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>playlistId - int - the unique id of the playlist.</li>
|
||||
* <li>relativeOffset - int - the number of seconds between the
|
||||
* start of the playlist and the start of the audio clip
|
||||
* 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:
|
||||
* <ul>
|
||||
* <li>401 - invalid argument format </li>
|
||||
* <li>402 - missing playlist ID argument </li>
|
||||
* <li>403 - missing relative offset argument </li>
|
||||
* <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>
|
||||
* </ul>
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
class RemoveAudioClipFromPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The name of this method, as it will be registered into the
|
||||
* XML-RPC server.
|
||||
*/
|
||||
static const std::string methodName;
|
||||
|
||||
/**
|
||||
* The ID of this method for error reporting purposes.
|
||||
*/
|
||||
static const int errorId;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* A default constructor, for testing purposes.
|
||||
*/
|
||||
RemoveAudioClipFromPlaylistMethod(void) throw ()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constuctor that registers the method with the server right away.
|
||||
*
|
||||
* @param xmlRpcServer the XML-RPC server to register with.
|
||||
*/
|
||||
RemoveAudioClipFromPlaylistMethod(
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Execute the display schedule command on the Scheduler daemon.
|
||||
*
|
||||
* @param parameters XML-RPC function call parameters
|
||||
* @param returnValue the return value of the call (out parameter)
|
||||
*/
|
||||
void
|
||||
execute( XmlRpc::XmlRpcValue & parameters,
|
||||
XmlRpc::XmlRpcValue & returnValue) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // RemoveAudioClipFromPlaylistMethod_h
|
||||
|
|
@ -0,0 +1,175 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "XmlRpcTools.h"
|
||||
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
#include "AddAudioClipToPlaylistMethod.h"
|
||||
#include "RemoveAudioClipFromPlaylistMethod.h"
|
||||
|
||||
#include "RemoveAudioClipFromPlaylistMethodTest.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(RemoveAudioClipFromPlaylistMethodTest);
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the storage client factory.
|
||||
*/
|
||||
const std::string RemoveAudioClipFromPlaylistMethodTest::storageClientConfig =
|
||||
"etc/storageClient.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the connection manager factory.
|
||||
*/
|
||||
const std::string RemoveAudioClipFromPlaylistMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Configure a Configurable with an XML file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RemoveAudioClipFromPlaylistMethodTest :: configure(
|
||||
Ptr<Configurable>::Ref configurable,
|
||||
const std::string fileName)
|
||||
throw (std::invalid_argument,
|
||||
xmlpp::exception)
|
||||
{
|
||||
Ptr<xmlpp::DomParser>::Ref parser(new xmlpp::DomParser(fileName, true));
|
||||
const xmlpp::Document * document = parser->get_document();
|
||||
const xmlpp::Element * root = document->get_root_node();
|
||||
|
||||
configurable->configure(*root);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RemoveAudioClipFromPlaylistMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
configure(scf, storageClientConfig);
|
||||
|
||||
Ptr<ConnectionManagerFactory>::Ref cmf
|
||||
= ConnectionManagerFactory::getInstance();
|
||||
configure(cmf, connectionManagerConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RemoveAudioClipFromPlaylistMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Just a very simple smoke test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RemoveAudioClipFromPlaylistMethodTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<OpenPlaylistForEditingMethod>::Ref
|
||||
openPlaylistMethod(new OpenPlaylistForEditingMethod());
|
||||
Ptr<AddAudioClipToPlaylistMethod>::Ref
|
||||
addAudioClipMethod(new AddAudioClipToPlaylistMethod());
|
||||
Ptr<RemoveAudioClipFromPlaylistMethod>::Ref
|
||||
removeAudioClipMethod(new RemoveAudioClipFromPlaylistMethod());
|
||||
XmlRpc::XmlRpcValue parameter;
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
parameter["playlistId"] = 1;
|
||||
parameter["audioClipId"] = 20002;
|
||||
parameter["relativeOffset"] = 90*60;
|
||||
|
||||
removeAudioClipMethod->execute(parameter, result);
|
||||
CPPUNIT_ASSERT(result.hasMember("errorCode"));
|
||||
CPPUNIT_ASSERT((int)(result["errorCode"]) == 405); // not open for editing
|
||||
|
||||
result.clear();
|
||||
openPlaylistMethod->execute(parameter, result);
|
||||
removeAudioClipMethod->execute(parameter, result);
|
||||
CPPUNIT_ASSERT(result.hasMember("errorCode"));
|
||||
CPPUNIT_ASSERT((int)(result["errorCode"]) == 406); // no such audio clip
|
||||
|
||||
result.clear();
|
||||
addAudioClipMethod->execute(parameter, result);
|
||||
removeAudioClipMethod->execute(parameter, result);
|
||||
CPPUNIT_ASSERT(!result.hasMember("errorCode"));
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef RemoveAudioClipFromPlaylistMethodTest_h
|
||||
#define RemoveAudioClipFromPlaylistMethodTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the RemoveAudioClipFromPlaylistMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see RemoveAudioClipFromPlaylistMethod
|
||||
*/
|
||||
class RemoveAudioClipFromPlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(RemoveAudioClipFromPlaylistMethodTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the storage client factory.
|
||||
*/
|
||||
static const std::string storageClientConfig;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the connection manager
|
||||
* factory.
|
||||
*/
|
||||
static const std::string connectionManagerConfig;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
* @param configurable configure this
|
||||
* @param fileName the name of the XML file to configure with.
|
||||
* @exception std::invalid_argument on configuration errors.
|
||||
* @exception xmlpp::exception on XML parsing errors.
|
||||
*/
|
||||
void
|
||||
configure(Ptr<Configurable>::Ref configurable,
|
||||
std::string fileName)
|
||||
throw (std::invalid_argument,
|
||||
xmlpp::exception);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // RemoveAudioClipFromPlaylistMethodTest_h
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#else
|
||||
#error need time.h
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "LiveSupport/Core/StorageClientInterface.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "ScheduleInterface.h"
|
||||
#include "ScheduleFactory.h"
|
||||
#include "XmlRpcTools.h"
|
||||
|
||||
#include "ValidatePlaylistMethod.h"
|
||||
|
||||
|
||||
using namespace boost;
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Storage;
|
||||
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of this XML-RPC method.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string ValidatePlaylistMethod::methodName
|
||||
= "validatePlaylist";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The ID of this method for error reporting purposes.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const int ValidatePlaylistMethod::errorId = 500;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the method and register it right away.
|
||||
*----------------------------------------------------------------------------*/
|
||||
ValidatePlaylistMethod :: ValidatePlaylistMethod (
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) throw()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Execute the stop XML-RPC function call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ValidatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ()
|
||||
{
|
||||
if (!parameters.valid()) {
|
||||
XmlRpcTools::markError(errorId+1, "invalid argument format",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref playlistId;
|
||||
try{
|
||||
playlistId = XmlRpcTools::extractPlaylistId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+2,
|
||||
"missing playlist ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
scf = StorageClientFactory::getInstance();
|
||||
storage = scf->getStorageClient();
|
||||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->getPlaylist(playlistId);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+3, "playlist does not exist",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playlist->getIsLockedForEditing()) {
|
||||
XmlRpcTools::markError(errorId+4,
|
||||
"playlist has not been opened for editing",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
bool valid = playlist->valid(); // and finally, the beef
|
||||
|
||||
XmlRpcTools::validStatusToXmlRpcValue(valid, returnValue);
|
||||
}
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef ValidatePlaylistMethod_h
|
||||
#define ValidatePlaylistMethod_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <XmlRpcServerMethod.h>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An XML-RPC method object to validate a playlist (specified by its ID).
|
||||
*
|
||||
* The name of the method when called through XML-RPC is
|
||||
* "validatePlaylist".
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* member:
|
||||
* <ul>
|
||||
* <li>playlistId - int - the unique id of the playlist.</li>
|
||||
* </ul>
|
||||
*
|
||||
* The XML-RPC function returns an XML-RPC structure, containing the following
|
||||
* fields:
|
||||
* <ul>
|
||||
* <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:
|
||||
* <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>
|
||||
* </ul>
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
class ValidatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The name of this method, as it will be registered into the
|
||||
* XML-RPC server.
|
||||
*/
|
||||
static const std::string methodName;
|
||||
|
||||
/**
|
||||
* The ID of this method for error reporting purposes.
|
||||
*/
|
||||
static const int errorId;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* A default constructor, for testing purposes.
|
||||
*/
|
||||
ValidatePlaylistMethod(void) throw ()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constuctor that registers the method with the server right away.
|
||||
*
|
||||
* @param xmlRpcServer the XML-RPC server to register with.
|
||||
*/
|
||||
ValidatePlaylistMethod(
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Execute the display schedule command on the Scheduler daemon.
|
||||
*
|
||||
* @param parameters XML-RPC function call parameters
|
||||
* @param returnValue the return value of the call (out parameter)
|
||||
*/
|
||||
void
|
||||
execute( XmlRpc::XmlRpcValue & parameters,
|
||||
XmlRpc::XmlRpcValue & returnValue) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // ValidatePlaylistMethod_h
|
||||
|
|
@ -0,0 +1,180 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "XmlRpcTools.h"
|
||||
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
#include "RemoveAudioClipFromPlaylistMethod.h"
|
||||
#include "ValidatePlaylistMethod.h"
|
||||
|
||||
#include "ValidatePlaylistMethodTest.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(ValidatePlaylistMethodTest);
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the storage client factory.
|
||||
*/
|
||||
const std::string ValidatePlaylistMethodTest::storageClientConfig =
|
||||
"etc/storageClient.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the connection manager factory.
|
||||
*/
|
||||
const std::string ValidatePlaylistMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Configure a Configurable with an XML file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ValidatePlaylistMethodTest :: configure(
|
||||
Ptr<Configurable>::Ref configurable,
|
||||
const std::string fileName)
|
||||
throw (std::invalid_argument,
|
||||
xmlpp::exception)
|
||||
{
|
||||
Ptr<xmlpp::DomParser>::Ref parser(new xmlpp::DomParser(fileName, true));
|
||||
const xmlpp::Document * document = parser->get_document();
|
||||
const xmlpp::Element * root = document->get_root_node();
|
||||
|
||||
configurable->configure(*root);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ValidatePlaylistMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
configure(scf, storageClientConfig);
|
||||
|
||||
Ptr<ConnectionManagerFactory>::Ref cmf
|
||||
= ConnectionManagerFactory::getInstance();
|
||||
configure(cmf, connectionManagerConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ValidatePlaylistMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Just a very simple smoke test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ValidatePlaylistMethodTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<OpenPlaylistForEditingMethod>::Ref
|
||||
openPlaylistMethod(new OpenPlaylistForEditingMethod());
|
||||
Ptr<RemoveAudioClipFromPlaylistMethod>::Ref
|
||||
removeAudioClipMethod(new RemoveAudioClipFromPlaylistMethod());
|
||||
Ptr<ValidatePlaylistMethod>::Ref
|
||||
validatePlaylistMethod(new ValidatePlaylistMethod());
|
||||
XmlRpc::XmlRpcValue parameter;
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
parameter["playlistId"] = 275;
|
||||
validatePlaylistMethod->execute(parameter, result);
|
||||
CPPUNIT_ASSERT(result.hasMember("errorCode"));
|
||||
CPPUNIT_ASSERT(int(result["errorCode"]) == 503); // no such playlist
|
||||
|
||||
result.clear();
|
||||
parameter.clear();
|
||||
parameter["playlistId"] = 1;
|
||||
openPlaylistMethod->execute(parameter, result);
|
||||
CPPUNIT_ASSERT(!result.hasMember("errorCode"));
|
||||
result.clear();
|
||||
validatePlaylistMethod->execute(parameter, result);
|
||||
CPPUNIT_ASSERT(result.hasMember("valid"));
|
||||
CPPUNIT_ASSERT(bool(result["valid"]));
|
||||
|
||||
result.clear();
|
||||
parameter["relativeOffset"] = 0;
|
||||
removeAudioClipMethod->execute(parameter, result);
|
||||
CPPUNIT_ASSERT(!result.hasMember("errorCode"));
|
||||
result.clear();
|
||||
validatePlaylistMethod->execute(parameter, result);
|
||||
CPPUNIT_ASSERT(result.hasMember("valid"));
|
||||
CPPUNIT_ASSERT(!bool(result["valid"])); // has a gap at the beginning
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef ValidatePlaylistMethodTest_h
|
||||
#define ValidatePlaylistMethodTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the ValidatePlaylistMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see ValidatePlaylistMethod
|
||||
*/
|
||||
class ValidatePlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(ValidatePlaylistMethodTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the storage client factory.
|
||||
*/
|
||||
static const std::string storageClientConfig;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the connection manager
|
||||
* factory.
|
||||
*/
|
||||
static const std::string connectionManagerConfig;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
* @param configurable configure this
|
||||
* @param fileName the name of the XML file to configure with.
|
||||
* @exception std::invalid_argument on configuration errors.
|
||||
* @exception xmlpp::exception on XML parsing errors.
|
||||
*/
|
||||
void
|
||||
configure(Ptr<Configurable>::Ref configurable,
|
||||
std::string fileName)
|
||||
throw (std::invalid_argument,
|
||||
xmlpp::exception);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // ValidatePlaylistMethodTest_h
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/XmlRpcTools.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -87,7 +87,7 @@ XmlRpcTools :: extractPlaylistId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
|||
throw (std::invalid_argument)
|
||||
{
|
||||
if (!xmlRpcValue.hasMember(playlistIdName)) {
|
||||
throw std::invalid_argument("missing playlist ID");
|
||||
throw std::invalid_argument("missing playlist ID argument");
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref id(new UniqueId((int) xmlRpcValue[playlistIdName]));
|
||||
|
@ -103,7 +103,7 @@ XmlRpcTools :: extractAudioClipId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
|||
throw (std::invalid_argument)
|
||||
{
|
||||
if (!xmlRpcValue.hasMember(audioClipIdName)) {
|
||||
throw std::invalid_argument("missing audio clip ID");
|
||||
throw std::invalid_argument("missing audio clip ID argument");
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref id(new UniqueId((int) xmlRpcValue[audioClipIdName]));
|
||||
|
@ -119,7 +119,7 @@ XmlRpcTools :: extractRelativeOffset(XmlRpc::XmlRpcValue & xmlRpcValue)
|
|||
throw (std::invalid_argument)
|
||||
{
|
||||
if (!xmlRpcValue.hasMember(relativeOffsetName)) {
|
||||
throw std::invalid_argument("missing relative offset");
|
||||
throw std::invalid_argument("missing relative offset argument");
|
||||
}
|
||||
|
||||
Ptr<time_duration>::Ref relativeOffset(new time_duration(0,0,
|
||||
|
@ -153,3 +153,17 @@ XmlRpcTools :: markError(int errorCode, const std::string errorMessage,
|
|||
xmlRpcValue["errorCode"] = errorCode;
|
||||
xmlRpcValue["errorMessage"] = errorMessage;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert the valid status of a playlist to an XmlRpcValue
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcTools :: validStatusToXmlRpcValue(
|
||||
bool validStatus,
|
||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw ()
|
||||
{
|
||||
xmlRpcValue["valid"] = XmlRpc::XmlRpcValue(validStatus);
|
||||
}
|
||||
|
||||
|
|
|
@ -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/Attic/XmlRpcTools.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -68,7 +68,7 @@ using namespace LiveSupport::Core;
|
|||
* in the Scheduler.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class XmlRpcTools
|
||||
{
|
||||
|
@ -131,7 +131,7 @@ class XmlRpcTools
|
|||
* Convert a Playlist to an XmlRpcValue
|
||||
*
|
||||
* @param playlist the Playlist to convert.
|
||||
* @param xmlRpcValue the output parameter holding the value of
|
||||
* @param xmlRpcValue the output parameter holding the result of
|
||||
* the conversion.
|
||||
*/
|
||||
static void
|
||||
|
@ -143,7 +143,7 @@ class XmlRpcTools
|
|||
* Convert an error code, message pair to an XmlRpcValue
|
||||
*
|
||||
* @param playlist the Playlist to convert.
|
||||
* @param xmlRpcValue the output parameter holding the value of
|
||||
* @param xmlRpcValue the output parameter holding the result of
|
||||
* the conversion.
|
||||
*/
|
||||
static void
|
||||
|
@ -151,6 +151,17 @@ class XmlRpcTools
|
|||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Convert the valid status of a playlist to an XmlRpcValue
|
||||
*
|
||||
* @param validStatus true if the playlist is valid, false otherwise.
|
||||
* @param xmlRpcValue the output parameter holding the result of
|
||||
* the conversion.
|
||||
*/
|
||||
static void
|
||||
validStatusToXmlRpcValue(bool validStatus,
|
||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw ();
|
||||
};
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
|
Loading…
Reference in New Issue