added conversion to/from XmlRpcValue to AudioClip and Playlist;

modified Scheduler methods to use these conversions;
fixed bug in Scheduler: some methods caught wrong kind of exception;
modified Playlist to accept several PlaylistElements at the same
  relative offset;
modified methods for deleting playlist elements and updating fade info
  to refer to playlist elements by ID, not relative offset
This commit is contained in:
fgerlits 2005-02-05 08:12:37 +00:00
parent aca8977831
commit e85731b8e6
70 changed files with 849 additions and 518 deletions

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.21 $
Version : $Revision: 1.22 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/AudioClip.h,v $
------------------------------------------------------------------------------*/
@ -43,6 +43,7 @@
#include <stdexcept>
#include <string>
#include <libxml++/libxml++.h>
#include <XmlRpcValue.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include "LiveSupport/Core/Ptr.h"
@ -96,17 +97,22 @@ using namespace boost::posix_time;
* The metadata element is optional. The <code>configure()</code> method
* sets only those fields which had not been set previously: e.g., if we set
* some or all fields of the AudioClip in the constructor, then these fields
* in the XML element will be ignored by <code>configure()</code>. If both the
* <code>playlength</code> attribute and the
* <code>&lt;dcterms:extent&gt;</code>
* element are present, then the playlength is set from the attribute and
* <code>&lt;dcterms:extent&gt;</code> is ignored. Embedded XML elements are
* currently ignored: e.g., <pre><code> &lt;group&gt;
* in the XML element will be ignored by <code>configure()</code>.
* The <code>title</code> attribute and the <code>&lt;dc:title&gt;</code>
* element set the same field; if both are present, the title is set from
* the attribute and the element is ignored..
* The same is true for the <code>playlength</code> attribute and the
* <code>&lt;dcterms:extent&gt;</code> element.
* It is required that by the end of the configure() method, the playlength
* is set somehow (from a constructor, the attribute or the element).
* If the title is not set by the end of the configure() method, it is then
* set to the empty string.
* Embedded XML elements are currently ignored: e.g.,
* <pre><code> &lt;group&gt;
* &lt;member1&gt;value1&lt;/member1&gt;
* &lt;member2&gt;value2&lt;/member2&gt;
* &lt;/group&gt;</code></pre> produces a single metadata field
* <code>group</code>
* with an empty value,
* &lt;/group&gt;</code></pre>
* produces a single metadata field <code>group</code> with an empty value,
* and ignores <code>member1</code> and <code>member2</code>.
* TODO: fix this?
*
@ -124,7 +130,7 @@ using namespace boost::posix_time;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.21 $
* @version $Revision: 1.22 $
*/
class AudioClip : public Configurable,
public Playable
@ -291,6 +297,30 @@ class AudioClip : public Configurable,
Ptr<const std::string>::Ref uri)
throw ();
/**
* Convert the audio clip to an XmlRpcValue (marshalling).
*
* @return an XmlRpcValue struct, containing a
* field named <i>audioClip</i>, with value of type string,
* which contains an XML document representing the audio clip.
*/
operator XmlRpc::XmlRpcValue() const
throw ();
/**
* Construct an audio clip from an XmlRpcValue (demarshalling).
*
* @param xmlRpcValue an XmlRpcValue struct, containing a
* field named <i>audioClip</i>, with value of type string,
* which contains an XML document, the root node of which
* can be passed to the configure() method.
* @exception std::invalid_argument if the argument is invalid
*/
AudioClip(XmlRpc::XmlRpcValue & xmlRpcValue)
throw (std::invalid_argument);
/**
* A virtual destructor, as this class has virtual functions.
*/
@ -299,6 +329,7 @@ class AudioClip : public Configurable,
{
}
/**
* Return the name of the XML element this object expects
* to be sent to a call to configure().
@ -469,7 +500,7 @@ class AudioClip : public Configurable,
* @return a string representation of the audio clip as an XML element
*/
virtual Ptr<Glib::ustring>::Ref
getXmlElementString(void) throw ();
getXmlElementString(void) const throw ();
/**
@ -512,7 +543,7 @@ class AudioClip : public Configurable,
* @return a string representation of the audio clip as an XML document
*/
virtual Ptr<Glib::ustring>::Ref
getXmlDocumentString(void) throw ();
getXmlDocumentString(void) const throw ();
/**

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/modules/core/include/LiveSupport/Core/Playable.h,v $
------------------------------------------------------------------------------*/
@ -73,7 +73,7 @@ using namespace boost::posix_time;
* It contains the methods which are common to these classes.
*
* @author $Author: fgerlits $
* @version $Revision: 1.8 $
* @version $Revision: 1.9 $
*/
class Playable : public boost::enable_shared_from_this<Playable>
{
@ -225,7 +225,7 @@ class Playable : public boost::enable_shared_from_this<Playable>
* @return a string representation of the audio clip as an XML element
*/
virtual Ptr<Glib::ustring>::Ref
getXmlElementString(void) throw () = 0;
getXmlElementString(void) const throw () = 0;
/**
@ -256,7 +256,7 @@ class Playable : public boost::enable_shared_from_this<Playable>
* @return a string representation of the audio clip as an XML document
*/
virtual Ptr<Glib::ustring>::Ref
getXmlDocumentString(void) throw () = 0;
getXmlDocumentString(void) const throw () = 0;
/**
@ -265,7 +265,7 @@ class Playable : public boost::enable_shared_from_this<Playable>
* @return either AudioClipType or PlaylistType.
*/
Type
getType(void) const throw ()
getType(void) const throw ()
{
return type;
}
@ -278,7 +278,7 @@ class Playable : public boost::enable_shared_from_this<Playable>
* @return an audio clip pointer to this object.
*/
Ptr<AudioClip>::Ref
getAudioClip(void) throw ();
getAudioClip(void) throw ();
/**
* Return a playlist pointer to this object. If the object's
@ -288,7 +288,7 @@ class Playable : public boost::enable_shared_from_this<Playable>
* @return a playlist pointer to this object.
*/
Ptr<Playlist>::Ref
getPlaylist(void) throw ();
getPlaylist(void) throw ();
};

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.30 $
Version : $Revision: 1.31 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playlist.h,v $
------------------------------------------------------------------------------*/
@ -43,6 +43,7 @@
#include <map>
#include <stdexcept>
#include <libxml++/libxml++.h>
#include <XmlRpcValue.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include "LiveSupport/Core/Ptr.h"
@ -75,25 +76,59 @@ using namespace boost::posix_time;
* called playlist. This may look like the following:
*
* <pre><code>
* &lt;playlist id="1" playlength="00:18:30.000000" &gt;
* &lt;playlist id="1" title="My Playlist" playlength="00:18:30.000000" &gt;
* &lt;playlistElement&gt; ... &lt;/playlistElement&gt;
* ...
* &lt;playlistElement&gt; ... &lt;/playlistElement&gt;
* &lt;metadata
* xmlns="http://www.streamonthefly.org/"
* xmlns:dc="http://purl.org/dc/elements/1.1/"
* xmlns:dcterms="http://purl.org/dc/terms/"
* xmlns:xbmf="http://www.streamonthefly.org/xbmf"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" &gt;
* &lt;dc:title &gt;File Title txt&lt;/dc:title&gt;
* &lt;dcterms:extent &gt;00:02:30.000000&lt;/dcterms:extent&gt;
* ...
* &lt;/metadata&gt;
* &lt;/playlist&gt;
* </code></pre>
*
* For detais of the playlistElement element, see the documentation
* for the PlaylistElement class.
*
* The metadata element is optional. The <code>configure()</code> method
* sets only those fields which had not been set previously: e.g., if we set
* some or all fields of the Playlist in the constructor, then these fields
* in the XML element will be ignored by <code>configure()</code>.
* The <code>title</code> attribute and the <code>&lt;dc:title&gt;</code>
* element set the same field; if both are present, the title is set from
* the attribute and the element is ignored..
* The same is true for the <code>playlength</code> attribute and the
* <code>&lt;dcterms:extent&gt;</code> element.
* It is required that by the end of the configure() method, the playlength
* is set somehow (from a constructor, the attribute or the element).
* If the title is not set by the end of the configure() method, it is then
* set to the empty string.
* Embedded XML elements are currently ignored: e.g.,
* <pre><code> &lt;group&gt;
* &lt;member1&gt;value1&lt;/member1&gt;
* &lt;member2&gt;value2&lt;/member2&gt;
* &lt;/group&gt;</code></pre>
* produces a single metadata field <code>group</code> with an empty value,
* and ignores <code>member1</code> and <code>member2</code>.
* TODO: fix this?
*
* The DTD for the above element is:
*
* <pre><code>
* &lt;!ELEMENT playlist (playlistElement*) &gt;
* &lt;!ATTLIST playlist id NMTOKEN #REQUIRED &gt;
* &lt;!ATTLIST playlist playlength NMTOKEN #REQUIRED &gt;
* &lt;!ELEMENT playlist (playlistElement*, metadata?) &gt;
* &lt;!ATTLIST playlist id NMTOKEN #REQUIRED &gt;
* &lt;!ATTLIST playlist title CDATA "" &gt;
* &lt;!ATTLIST playlist playlength NMTOKEN #IMPLIED &gt;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.30 $
* @version $Revision: 1.31 $
*/
class Playlist : public Configurable,
public Playable
@ -133,7 +168,7 @@ class Playlist : public Configurable,
* A map type for storing the playlist elements associated with
* this playlist, indexed by their relative offsets.
*/
typedef std::map<time_duration, Ptr<PlaylistElement>::Ref>
typedef std::multimap<time_duration, Ptr<PlaylistElement>::Ref>
PlaylistElementListType;
/**
@ -184,6 +219,24 @@ class Playlist : public Configurable,
setPlaylength(Ptr<time_duration>::Ref playlength)
throw ();
/**
* A private iterator type for internal use. It is non-constant;
* otherwise it is the same as Playlist::const_iterator.
*/
typedef PlaylistElementListType::iterator iterator;
/**
* Get an iterator pointing to a playlist element with a given ID.
*
* @param playlistElementId (a pointer to) the ID of the
* playlist element.
* @return an iterator to the playlist element if it exists,
* or <code>this->end()</code> if it does not.
*/
iterator
find(Ptr<UniqueId>::Ref playlistElementId)
throw ();
public:
/**
@ -274,6 +327,29 @@ class Playlist : public Configurable,
Ptr<const std::string>::Ref uri = Ptr<std::string>::Ref())
throw ();
/**
* Convert the playlist to an XmlRpcValue (marshalling).
*
* @return an XmlRpcValue struct, containing a
* field named <i>playlist</i>, with value of type string,
* which contains an XML document representing the playlist.
*/
operator XmlRpc::XmlRpcValue() const
throw ();
/**
* Construct a playlist from an XmlRpcValue (demarshalling).
*
* @param xmlRpcValue an XmlRpcValue struct, containing a
* field named <i>playlist</i>, with value of type string,
* which contains an XML document, the root node of which
* can be passed to the configure() method.
* @exception std::invalid_argument if the argument is invalid
*/
Playlist(XmlRpc::XmlRpcValue & xmlRpcValue)
throw (std::invalid_argument);
/**
* A virtual destructor, as this class has virtual functions.
*/
@ -282,6 +358,7 @@ class Playlist : public Configurable,
{
}
/**
* Return the name of the XML element this object expects
* to be sent to a call to configure().
@ -445,8 +522,9 @@ class Playlist : public Configurable,
}
/**
* Get an iterator pointing to a playlist element at a given
* Get an iterator pointing to the first playlist element at a given
* relative offset.
*
* @param relativeOffset (a pointer to) the relative offset where
* the playlist element is.
* @return a constant iterator to the playlist element if it exists,
@ -470,10 +548,11 @@ class Playlist : public Configurable,
* @param relativeOffset the start of the audio clip, relative
* to the start of the playlist
* @param fadeInfo the fade in / fade out info (optional)
* @return the ID of the new PlaylistElement
* @exception std::invalid_argument if the playlist already contains
* a playlist element with the same relative offset
*/
void
Ptr<UniqueId>::Ref
addAudioClip(Ptr<AudioClip>::Ref audioClip,
Ptr<time_duration>::Ref relativeOffset,
Ptr<FadeInfo>::Ref fadeInfo
@ -491,10 +570,11 @@ class Playlist : public Configurable,
* @param relativeOffset the start of the sub-playlist, relative
* to the start of the containing playlist
* @param fadeInfo the fade in / fade out info (optional)
* @return the ID of the new PlaylistElement
* @exception std::invalid_argument if the playlist already contains
* a playlist element with the same relative offset
*/
void
Ptr<UniqueId>::Ref
addPlaylist(Ptr<Playlist>::Ref playlist,
Ptr<time_duration>::Ref relativeOffset,
Ptr<FadeInfo>::Ref fadeInfo
@ -504,27 +584,25 @@ class Playlist : public Configurable,
/**
* Set the fade in / fade out info for a playlist element.
*
* @param relativeOffset the start of the playlist element, relative
* to the start of the playlist
* @param playlistElementId the ID of the playlist element
* @param fadeInfo the new fade in / fade out info
* @exception std::invalid_argument if there is no playlist element
* at the given relative offset
*/
void
setFadeInfo(Ptr<time_duration>::Ref relativeOffset,
Ptr<FadeInfo>::Ref fadeInfo)
setFadeInfo(Ptr<UniqueId>::Ref playlistElementId,
Ptr<FadeInfo>::Ref fadeInfo)
throw (std::invalid_argument);
/**
* Remove a playlist element from the playlist.
*
* @param relativeOffset the start of the playlist element, relative
* to the start of the playlist
* @exception std::invalid_argument if the playlist does not contain
* a playlist element at the specified relative offset
* @param playlistElementId the ID of the playlist element
* @exception std::invalid_argument if the playlist element does not
* exist
*/
void
removePlaylistElement(Ptr<const time_duration>::Ref relativeOffset)
removePlaylistElement(Ptr<UniqueId>::Ref playlistElementId)
throw (std::invalid_argument);
/**
@ -596,7 +674,7 @@ class Playlist : public Configurable,
* @return a string representation of the playlist as an XML element
*/
virtual Ptr<Glib::ustring>::Ref
getXmlElementString(void) throw ();
getXmlElementString(void) const throw ();
/**
@ -632,7 +710,7 @@ class Playlist : public Configurable,
* @return a string representation of the playlist as an XML document
*/
virtual Ptr<Glib::ustring>::Ref
getXmlDocumentString(void) throw ();
getXmlDocumentString(void) const throw ();
};

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/modules/core/include/LiveSupport/Core/XmlRpcTools.h,v $
------------------------------------------------------------------------------*/
@ -74,7 +74,7 @@ using namespace LiveSupport::Core;
* in the Scheduler.
*
* @author $Author: fgerlits $
* @version $Revision: 1.3 $
* @version $Revision: 1.4 $
*/
class XmlRpcTools
{
@ -130,7 +130,7 @@ class XmlRpcTools
throw (std::invalid_argument);
/**
* Extract the playlist id from the XML-RPC parameters.
* Extract the playlist ID from the XML-RPC parameters.
*
* @param xmlRpcValue the XML-RPC parameter to extract from.
* @return a UniqueId that was found in the XML-RPC parameter.
@ -141,6 +141,18 @@ class XmlRpcTools
extractPlaylistId(XmlRpc::XmlRpcValue & xmlRpcValue)
throw (std::invalid_argument);
/**
* Extract the playlist element ID from the XML-RPC parameters.
*
* @param xmlRpcValue the XML-RPC parameter to extract from.
* @return a UniqueId that was found in the XML-RPC parameter.
* @exception std::invalid_argument if there was no playlistElementId
* member in xmlRpcValue
*/
static Ptr<UniqueId>::Ref
extractPlaylistElementId(XmlRpc::XmlRpcValue & xmlRpcValue)
throw (std::invalid_argument);
/**
* Extract the audio clip id from the XML-RPC parameters.
*
@ -407,15 +419,28 @@ class XmlRpcTools
/**
* Add a playlist id to an XmlRpcValue
*
* @param playlist the playlist idt o add to the XmlRpcValue
* @param playlistId the playlist ID to add to the XmlRpcValue
* @param returnValue an output parameter, which has the
* playlist id added after the function returns.
* playlist ID added after the function returns.
*/
static void
playlistIdToXmlRpcValue(
Ptr<const UniqueId>::Ref playlistId,
XmlRpc::XmlRpcValue & returnValue) throw ();
/**
* Add a playlist element id to an XmlRpcValue
*
* @param playlistElementId the playlist element ID
* to add to the XmlRpcValue
* @param returnValue an output parameter, which has the
* playlist element ID added after the function returns.
*/
static void
playlistElementIdToXmlRpcValue(
Ptr<const UniqueId>::Ref playlistElementId,
XmlRpc::XmlRpcValue & returnValue) throw ();
/**
* Add a playtime value to an XmlRpcValue.
*

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.20 $
Version : $Revision: 1.21 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/AudioClip.cxx,v $
------------------------------------------------------------------------------*/
@ -189,7 +189,8 @@ AudioClip :: AudioClip(Ptr<UniqueId>::Ref id,
}
/*------------------------------------------------------------------------------ * Constructor without ID.
/*------------------------------------------------------------------------------
* Constructor without ID.
*----------------------------------------------------------------------------*/AudioClip :: AudioClip(Ptr<const Glib::ustring>::Ref title,
Ptr<time_duration>::Ref playlength,
Ptr<const std::string>::Ref uri)
@ -208,6 +209,41 @@ AudioClip :: AudioClip(Ptr<UniqueId>::Ref id,
}
/*------------------------------------------------------------------------------
* Convert to an XmlRpcValue.
*----------------------------------------------------------------------------*/
AudioClip :: operator XmlRpc::XmlRpcValue() const
throw()
{
XmlRpc::XmlRpcValue xmlRpcValue;
xmlRpcValue[configElementNameStr] = std::string(*getXmlDocumentString());
return xmlRpcValue;
}
/*------------------------------------------------------------------------------
* Construct from an XmlRpcValue.
*----------------------------------------------------------------------------*/
AudioClip :: AudioClip(XmlRpc::XmlRpcValue & xmlRpcValue)
throw (std::invalid_argument)
: Playable(AudioClipType)
{
if (!xmlRpcValue.hasMember(configElementNameStr)) {
throw std::invalid_argument("no audio clip data found in XmlRpcValue");
}
xmlpp::DomParser parser;
try {
parser.parse_memory(std::string(xmlRpcValue[configElementNameStr]));
} catch (xmlpp::exception &e) {
throw std::invalid_argument("error parsing XML document");
}
configure(*parser.get_document()->get_root_node()); // may throw
}
/*------------------------------------------------------------------------------
* Set the value of the title field.
*----------------------------------------------------------------------------*/
@ -338,11 +374,7 @@ AudioClip :: configure(const xmlpp::Element & element)
}
if (!title) {
std::string eMsg = "missing attribute ";
eMsg += titleAttrName;
eMsg += " or metadata element ";
eMsg += titleElementPrefix + ":" + titleElementName;
throw std::invalid_argument(eMsg);
title.reset(new const Glib::ustring(""));
}
}
@ -480,7 +512,7 @@ AudioClip :: setMetadata(Ptr<const Glib::ustring>::Ref value,
* Return a string containing the essential fields of this object, in XML.
*----------------------------------------------------------------------------*/
Ptr<Glib::ustring>::Ref
AudioClip :: getXmlElementString(void) throw ()
AudioClip :: getXmlElementString(void) const throw ()
{
Ptr<Glib::ustring>::Ref xmlString(new Glib::ustring);
@ -503,7 +535,7 @@ AudioClip :: getXmlElementString(void) throw ()
* Return a string containing an XML representation of this audio clip.
*----------------------------------------------------------------------------*/
Ptr<Glib::ustring>::Ref
AudioClip :: getXmlDocumentString() throw ()
AudioClip :: getXmlDocumentString() const throw ()
{
Ptr<xmlpp::Document>::Ref localDocument;

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/modules/core/src/AudioClipTest.cxx,v $
------------------------------------------------------------------------------*/
@ -219,3 +219,39 @@ AudioClipTest :: tagTest(void)
CPPUNIT_ASSERT(*artist == "The Muppets");
}
/*------------------------------------------------------------------------------
* Marshalling test
*----------------------------------------------------------------------------*/
void
AudioClipTest :: marshallingTest(void)
throw (CPPUNIT_NS::Exception)
{
Ptr<AudioClip>::Ref audioClip(new AudioClip());
try {
Ptr<xmlpp::DomParser>::Ref parser(
new xmlpp::DomParser(configFileName, false));
const xmlpp::Document * document = parser->get_document();
const xmlpp::Element * root = document->get_root_node();
audioClip->configure(*root);
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL(e.what());
} catch (xmlpp::exception &e) {
CPPUNIT_FAIL(e.what());
}
XmlRpc::XmlRpcValue xmlRpcValue = *audioClip;
CPPUNIT_ASSERT(xmlRpcValue.hasMember("audioClip"));
Ptr<AudioClip>::Ref otherAudioClip;
CPPUNIT_ASSERT_NO_THROW(otherAudioClip.reset(new AudioClip(xmlRpcValue)));
CPPUNIT_ASSERT(*audioClip->getId() == *otherAudioClip->getId());
CPPUNIT_ASSERT(*audioClip->getTitle()
== *otherAudioClip->getTitle());
CPPUNIT_ASSERT(*audioClip->getPlaylength()
== *otherAudioClip->getPlaylength());
}

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/modules/core/src/AudioClipTest.h,v $
------------------------------------------------------------------------------*/
@ -58,7 +58,7 @@ namespace Core {
* Unit test for the AudioClip class.
*
* @author $Author: fgerlits $
* @version $Revision: 1.3 $
* @version $Revision: 1.4 $
* @see AudioClip
*/
class AudioClipTest : public CPPUNIT_NS::TestFixture
@ -67,6 +67,7 @@ class AudioClipTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST(firstTest);
CPPUNIT_TEST(conversionTest);
CPPUNIT_TEST(tagTest);
CPPUNIT_TEST(marshallingTest);
CPPUNIT_TEST_SUITE_END();
protected:
@ -95,6 +96,14 @@ class AudioClipTest : public CPPUNIT_NS::TestFixture
void
tagTest(void) throw (CPPUNIT_NS::Exception);
/**
* Testing conversion to and from XmlRpcValue.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
marshallingTest(void) throw (CPPUNIT_NS::Exception);
public:

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.29 $
Version : $Revision: 1.30 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $
------------------------------------------------------------------------------*/
@ -188,6 +188,43 @@ Playlist :: Playlist(Ptr<UniqueId>::Ref id,
}
/*------------------------------------------------------------------------------
* Convert to an XmlRpcValue.
*----------------------------------------------------------------------------*/
Playlist :: operator XmlRpc::XmlRpcValue() const
throw()
{
XmlRpc::XmlRpcValue xmlRpcValue;
xmlRpcValue[configElementNameStr] = std::string(*getXmlDocumentString());
return xmlRpcValue;
}
/*------------------------------------------------------------------------------
* Construct from an XmlRpcValue.
*----------------------------------------------------------------------------*/
Playlist :: Playlist(XmlRpc::XmlRpcValue & xmlRpcValue)
throw (std::invalid_argument)
: Playable(PlaylistType)
{
elementList.reset(new PlaylistElementListType);
if (!xmlRpcValue.hasMember(configElementNameStr)) {
throw std::invalid_argument("no playlist data found in XmlRpcValue");
}
xmlpp::DomParser parser;
try {
parser.parse_memory(std::string(xmlRpcValue[configElementNameStr]));
} catch (xmlpp::exception &e) {
throw std::invalid_argument("error parsing XML document");
}
configure(*parser.get_document()->get_root_node()); // may throw
}
/*------------------------------------------------------------------------------
* Set the value of the title field.
*----------------------------------------------------------------------------*/
@ -217,7 +254,7 @@ Playlist :: setPlaylength(Ptr<time_duration>::Ref playlength)
*----------------------------------------------------------------------------*/
void
Playlist :: configure(const xmlpp::Element & element)
throw (std::invalid_argument)
throw (std::invalid_argument)
{
if (element.get_name() != configElementNameStr) {
std::string eMsg = "bad configuration element ";
@ -347,37 +384,26 @@ Playlist :: configure(const xmlpp::Element & element)
*----------------------------------------------------------------------------*/
void
Playlist::addPlaylistElement(Ptr<PlaylistElement>::Ref playlistElement)
throw (std::invalid_argument)
throw (std::invalid_argument)
{
Ptr<const time_duration>::Ref relativeOffset
= playlistElement->getRelativeOffset();
if (elementList->find(*relativeOffset) != elementList->end()) {
std::string eMsg = "two playlist elements at the same relative offset";
throw std::invalid_argument(eMsg);
}
(*elementList)[*relativeOffset] = playlistElement;
elementList->insert(std::make_pair(*relativeOffset, playlistElement));
}
/*------------------------------------------------------------------------------
* Add a new audio clip to the playlist.
*----------------------------------------------------------------------------*/
void
Ptr<UniqueId>::Ref
Playlist::addAudioClip(Ptr<AudioClip>::Ref audioClip,
Ptr<time_duration>::Ref relativeOffset,
Ptr<FadeInfo>::Ref fadeInfo)
throw (std::invalid_argument)
throw (std::invalid_argument)
{
if (elementList->find(*relativeOffset) != elementList->end()) {
std::string eMsg = "two playlist elements at the same relative offset";
throw std::invalid_argument(eMsg);
}
Ptr<PlaylistElement>::Ref playlistElement(new PlaylistElement(
relativeOffset, audioClip, fadeInfo));
(*elementList)[*relativeOffset] = playlistElement;
elementList->insert(std::make_pair(*relativeOffset, playlistElement));
Ptr<time_duration>::Ref endOffset(new time_duration(
*relativeOffset
@ -385,26 +411,23 @@ Playlist::addAudioClip(Ptr<AudioClip>::Ref audioClip,
if (*endOffset > *playlength) {
setPlaylength(endOffset);
}
return playlistElement->getId();
}
/*------------------------------------------------------------------------------
* Add a new sub-playlist to the playlist.
*----------------------------------------------------------------------------*/
void
Ptr<UniqueId>::Ref
Playlist::addPlaylist(Ptr<Playlist>::Ref playlist,
Ptr<time_duration>::Ref relativeOffset,
Ptr<FadeInfo>::Ref fadeInfo)
throw (std::invalid_argument)
throw (std::invalid_argument)
{
if (elementList->find(*relativeOffset) != elementList->end()) {
std::string eMsg = "two playlist elements at the same relative offset";
throw std::invalid_argument(eMsg);
}
Ptr<PlaylistElement>::Ref playlistElement(new PlaylistElement(
relativeOffset, playlist, fadeInfo));
(*elementList)[*relativeOffset] = playlistElement;
elementList->insert(std::make_pair(*relativeOffset, playlistElement));
Ptr<time_duration>::Ref endOffset(new time_duration(
*relativeOffset
@ -412,6 +435,24 @@ Playlist::addPlaylist(Ptr<Playlist>::Ref playlist,
if (*endOffset > *playlength) {
setPlaylength(endOffset);
}
return playlistElement->getId();
}
/*------------------------------------------------------------------------------
* Get an iterator pointing to a playlist element with a given ID.
*----------------------------------------------------------------------------*/
Playlist::iterator
Playlist::find(Ptr<UniqueId>::Ref playlistElementId)
throw ()
{
Playlist::iterator it = elementList->begin();
while (it != elementList->end()
&& *(it->second->getId()) != *playlistElementId) {
++it;
}
return it;
}
@ -419,15 +460,14 @@ Playlist::addPlaylist(Ptr<Playlist>::Ref playlist,
* Change the fade in / fade out info of a playlist element.
*----------------------------------------------------------------------------*/
void
Playlist::setFadeInfo(Ptr<time_duration>::Ref relativeOffset,
Ptr<FadeInfo>::Ref fadeInfo)
throw (std::invalid_argument)
Playlist::setFadeInfo(Ptr<UniqueId>::Ref playlistElementId,
Ptr<FadeInfo>::Ref fadeInfo)
throw (std::invalid_argument)
{
PlaylistElementListType::iterator it = elementList->find(*relativeOffset);
Playlist::iterator it = this->find(playlistElementId);
if (it == elementList->end()) {
std::string eMsg = "no playlist element at this relative offset";
throw std::invalid_argument(eMsg);
if (it == this->end()) {
throw std::invalid_argument("no playlist element with this ID");
}
it->second->setFadeInfo(fadeInfo);
@ -438,15 +478,16 @@ Playlist::setFadeInfo(Ptr<time_duration>::Ref relativeOffset,
* Remove a playlist element from the playlist.
*----------------------------------------------------------------------------*/
void
Playlist::removePlaylistElement(Ptr<const time_duration>::Ref relativeOffset)
throw (std::invalid_argument)
Playlist::removePlaylistElement(Ptr<UniqueId>::Ref playlistElementId)
throw (std::invalid_argument)
{
// this returns the number of elements found and erased
if (!elementList->erase(*relativeOffset)) {
std::string eMsg = "no playlist element found "
"at the specified relative offset";
throw std::invalid_argument(eMsg);
Playlist::iterator it = this->find(playlistElementId);
if (it == this->end()) {
throw std::invalid_argument("no playlist element with this ID");
}
elementList->erase(it);
}
@ -454,7 +495,7 @@ Playlist::removePlaylistElement(Ptr<const time_duration>::Ref relativeOffset)
* Validate the playlist.
*----------------------------------------------------------------------------*/
bool
Playlist::valid(void) throw ()
Playlist::valid(void) throw ()
{
Ptr<time_duration>::Ref runningTime(new time_duration(0,0,0,0));
Ptr<PlaylistElement>::Ref playlistElement;
@ -491,7 +532,7 @@ Playlist::valid(void) throw ()
* Create a saved copy of the playlist.
*----------------------------------------------------------------------------*/
void
Playlist::createSavedCopy(void) throw ()
Playlist::createSavedCopy(void) throw ()
{
savedCopy = Ptr<Playlist>::Ref(new Playlist(*this));
}
@ -501,7 +542,7 @@ Playlist::createSavedCopy(void) throw ()
* Revert to a saved copy of the playlist.
*----------------------------------------------------------------------------*/
void
Playlist::revertToSavedCopy(void) throw (std::invalid_argument)
Playlist::revertToSavedCopy(void) throw (std::invalid_argument)
{
if (savedCopy == 0) {
throw (std::invalid_argument("playlist has no saved copy"));
@ -652,7 +693,7 @@ Playlist :: setMetadata(Ptr<const Glib::ustring>::Ref value,
* Return a string containing the essential fields of this object, in XML.
*----------------------------------------------------------------------------*/
Ptr<Glib::ustring>::Ref
Playlist :: getXmlElementString(void) throw ()
Playlist :: getXmlElementString(void) const throw ()
{
Ptr<Glib::ustring>::Ref xmlString(new Glib::ustring);
@ -685,7 +726,7 @@ Playlist :: getXmlElementString(void) throw ()
* Return a string containing an XML representation of this playlist.
*----------------------------------------------------------------------------*/
Ptr<Glib::ustring>::Ref
Playlist :: getXmlDocumentString() throw ()
Playlist :: getXmlDocumentString() const throw ()
{
Ptr<xmlpp::Document>::Ref localDocument;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.21 $
Version : $Revision: 1.22 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.cxx,v $
------------------------------------------------------------------------------*/
@ -212,7 +212,7 @@ PlaylistTest :: audioClipTest(void)
CPPUNIT_ASSERT(it == playlist->end());
try {
playlist->removePlaylistElement(relativeOffset);
playlist->removePlaylistElement(playlistElement->getId());
} catch (std::invalid_argument &e) {
string eMsg = "removePlaylistElement returned with error: ";
eMsg += e.what();
@ -228,10 +228,9 @@ PlaylistTest :: audioClipTest(void)
++it;
CPPUNIT_ASSERT(it == playlist->end());
Ptr<const time_duration>::Ref phonyRelativeOffset(
new time_duration(0,0,1,0));
Ptr<UniqueId>::Ref phonyPlaylistElementId(new UniqueId(9999));
try {
playlist->removePlaylistElement(phonyRelativeOffset);
playlist->removePlaylistElement(phonyPlaylistElementId);
CPPUNIT_FAIL("removePlaylistElement allowed to remove "
"non-existent audio clip");
} catch (std::invalid_argument &e) {
@ -253,12 +252,9 @@ PlaylistTest :: savedCopyTest(void)
}
playlist->createSavedCopy();
playlist->removePlaylistElement(Ptr<time_duration>::Ref(
new time_duration(0,0,0,0)));
playlist->removePlaylistElement(Ptr<time_duration>::Ref(
new time_duration(0,0,11,0)));
playlist->removePlaylistElement(Ptr<time_duration>::Ref(
new time_duration(0,0,23,0)));
playlist->removePlaylistElement(playlist->begin()->second->getId());
playlist->removePlaylistElement(playlist->begin()->second->getId());
playlist->removePlaylistElement(playlist->begin()->second->getId());
CPPUNIT_ASSERT(playlist->begin() == playlist->end());
try {
@ -297,18 +293,21 @@ void
PlaylistTest :: fadeInfoTest(void)
throw (CPPUNIT_NS::Exception)
{
Playlist::const_iterator it = playlist->begin();
Ptr<PlaylistElement>::Ref playlistElementOne,
playlistElementTwo;
Playlist::const_iterator it = playlist->begin();
CPPUNIT_ASSERT(it != playlist->end());
Ptr<PlaylistElement>::Ref playlistElement = it->second;
CPPUNIT_ASSERT(playlistElement->getFadeInfo().get() == 0);
playlistElementOne = it->second;
CPPUNIT_ASSERT(playlistElementOne->getFadeInfo().get() == 0);
++it;
CPPUNIT_ASSERT(it != playlist->end());
playlistElement = it->second;
CPPUNIT_ASSERT(playlistElement->getFadeInfo()->getFadeIn()
->total_milliseconds() == 2000);
CPPUNIT_ASSERT(playlistElement->getFadeInfo()->getFadeOut()
->total_milliseconds() == 1500);
playlistElementTwo = it->second;
CPPUNIT_ASSERT(playlistElementTwo->getFadeInfo()->getFadeIn()
->total_milliseconds() == 2000);
CPPUNIT_ASSERT(playlistElementTwo->getFadeInfo()->getFadeOut()
->total_milliseconds() == 1500);
++it;
CPPUNIT_ASSERT(it != playlist->end());
@ -319,37 +318,34 @@ PlaylistTest :: fadeInfoTest(void)
Ptr<time_duration>::Ref fadeOut(new time_duration(0,0,4,0));
Ptr<FadeInfo>::Ref fadeInfo(new FadeInfo(fadeIn, fadeOut));
Ptr<time_duration>::Ref relativeOffset (new time_duration(0,0,0,0));
try {
playlist->setFadeInfo(relativeOffset, fadeInfo);
playlist->setFadeInfo(playlistElementOne->getId(), fadeInfo);
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL("could not add new fade info");
}
relativeOffset.reset(new time_duration(0,0,11,0));
try {
playlist->setFadeInfo(relativeOffset, fadeInfo);
playlist->setFadeInfo(playlistElementTwo->getId(), fadeInfo);
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL("could not update fade info");
}
it = playlist->begin();
playlistElement = it->second;
CPPUNIT_ASSERT(playlistElement->getFadeInfo()->getFadeIn()
->total_milliseconds() == 3200);
CPPUNIT_ASSERT(playlistElement->getFadeInfo()->getFadeOut()
->total_milliseconds() == 4000);
playlistElementOne = it->second;
CPPUNIT_ASSERT(playlistElementOne->getFadeInfo()->getFadeIn()
->total_milliseconds() == 3200);
CPPUNIT_ASSERT(playlistElementOne->getFadeInfo()->getFadeOut()
->total_milliseconds() == 4000);
++it;
playlistElement = it->second;
CPPUNIT_ASSERT(playlistElement->getFadeInfo()->getFadeIn()
->total_milliseconds() == 3200);
CPPUNIT_ASSERT(playlistElement->getFadeInfo()->getFadeOut()
->total_milliseconds() == 4000);
relativeOffset.reset(new time_duration(0,0,7,0));
playlistElementTwo = it->second;
CPPUNIT_ASSERT(playlistElementTwo->getFadeInfo()->getFadeIn()
->total_milliseconds() == 3200);
CPPUNIT_ASSERT(playlistElementTwo->getFadeInfo()->getFadeOut()
->total_milliseconds() == 4000);
Ptr<UniqueId>::Ref phonyPlaylistElementId(new UniqueId(9999));
try {
playlist->setFadeInfo(relativeOffset, fadeInfo);
playlist->setFadeInfo(phonyPlaylistElementId, fadeInfo);
CPPUNIT_FAIL("allowed to set fade info for non-existent element");
} catch (std::invalid_argument &e) {
}
@ -377,3 +373,39 @@ PlaylistTest :: conversionTest(void)
CPPUNIT_ASSERT(!audioClip);
}
/*------------------------------------------------------------------------------
* Marshalling test
*----------------------------------------------------------------------------*/
void
PlaylistTest :: marshallingTest(void)
throw (CPPUNIT_NS::Exception)
{
Ptr<Playlist>::Ref playlist(new Playlist());
try {
Ptr<xmlpp::DomParser>::Ref parser(
new xmlpp::DomParser(configFileName, false));
const xmlpp::Document * document = parser->get_document();
const xmlpp::Element * root = document->get_root_node();
playlist->configure(*root);
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL(e.what());
} catch (xmlpp::exception &e) {
CPPUNIT_FAIL(e.what());
}
XmlRpc::XmlRpcValue xmlRpcValue = *playlist;
CPPUNIT_ASSERT(xmlRpcValue.hasMember("playlist"));
Ptr<Playlist>::Ref otherPlaylist;
CPPUNIT_ASSERT_NO_THROW(otherPlaylist.reset(new Playlist(xmlRpcValue)));
CPPUNIT_ASSERT(*playlist->getId() == *otherPlaylist->getId());
CPPUNIT_ASSERT(*playlist->getTitle()
== *otherPlaylist->getTitle());
CPPUNIT_ASSERT(*playlist->getPlaylength()
== *otherPlaylist->getPlaylength());
}

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/modules/core/src/PlaylistTest.h,v $
------------------------------------------------------------------------------*/
@ -58,7 +58,7 @@ namespace Core {
* Unit test for the UploadPlaylistMetohd class.
*
* @author $Author: fgerlits $
* @version $Revision: 1.10 $
* @version $Revision: 1.11 $
* @see Playlist
*/
class PlaylistTest : public CPPUNIT_NS::TestFixture
@ -69,6 +69,7 @@ class PlaylistTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST(savedCopyTest);
CPPUNIT_TEST(fadeInfoTest);
CPPUNIT_TEST(conversionTest);
CPPUNIT_TEST(marshallingTest);
CPPUNIT_TEST_SUITE_END();
private:
@ -120,6 +121,14 @@ class PlaylistTest : public CPPUNIT_NS::TestFixture
void
conversionTest(void) throw (CPPUNIT_NS::Exception);
/**
* Testing conversion to and from XmlRpcValue.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
marshallingTest(void) throw (CPPUNIT_NS::Exception);
public:

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/modules/core/src/XmlRpcTools.cxx,v $
------------------------------------------------------------------------------*/
@ -64,6 +64,11 @@ static const std::string idName = "id";
*----------------------------------------------------------------------------*/
static const std::string playlistIdName = "playlistId";
/*------------------------------------------------------------------------------
* The name of the playlist element ID member in the XML-RPC param structure
*----------------------------------------------------------------------------*/
static const std::string playlistElementIdName = "playlistElementId";
/*------------------------------------------------------------------------------
* The name of the audio clip ID member in the XML-RPC parameter structure
*----------------------------------------------------------------------------*/
@ -196,6 +201,26 @@ XmlRpcTools :: extractPlaylistId(XmlRpc::XmlRpcValue & xmlRpcValue)
}
/*------------------------------------------------------------------------------
* Extract the playlist element ID from an XML-RPC function call parameter
*----------------------------------------------------------------------------*/
Ptr<UniqueId>::Ref
XmlRpcTools :: extractPlaylistElementId(XmlRpc::XmlRpcValue & xmlRpcValue)
throw (std::invalid_argument)
{
if (!xmlRpcValue.hasMember(playlistElementIdName)
|| xmlRpcValue[playlistElementIdName].getType()
!= XmlRpc::XmlRpcValue::TypeString) {
throw std::invalid_argument("missing or bad playlist element ID "
"argument");
}
Ptr<UniqueId>::Ref id(new UniqueId(std::string(
xmlRpcValue[playlistElementIdName] )));
return id;
}
/*------------------------------------------------------------------------------
* Extract the audio clip ID from an XML-RPC function call parameter
*----------------------------------------------------------------------------*/
@ -243,8 +268,7 @@ XmlRpcTools :: playlistToXmlRpcValue(
XmlRpc::XmlRpcValue & xmlRpcValue)
throw ()
{
xmlRpcValue["id"] = std::string(*playlist->getId());
xmlRpcValue["playlength"] = int(playlist->getPlaylength()->total_seconds());
xmlRpcValue["playlist"] = std::string(*playlist->getXmlDocumentString());
}
@ -284,9 +308,7 @@ XmlRpcTools :: audioClipToXmlRpcValue(
XmlRpc::XmlRpcValue & xmlRpcValue)
throw ()
{
xmlRpcValue["id"] = std::string(*audioClip->getId());
xmlRpcValue["playlength"] = int(audioClip->getPlaylength()
->total_seconds());
xmlRpcValue["audioClip"] = std::string(*audioClip->getXmlDocumentString());
}
@ -605,6 +627,19 @@ XmlRpcTools :: playlistIdToXmlRpcValue(
}
/*------------------------------------------------------------------------------
* Add a playlist element ID to an XmlRpcValue
*----------------------------------------------------------------------------*/
void
XmlRpcTools :: playlistElementIdToXmlRpcValue(
Ptr<const UniqueId>::Ref playlistElementId,
XmlRpc::XmlRpcValue & returnValue)
throw ()
{
returnValue[playlistElementIdName] = std::string(*playlistElementId);
}
/*------------------------------------------------------------------------------
* Add a playtime value to an XmlRpcValue
*----------------------------------------------------------------------------*/

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/modules/core/src/XmlRpcToolsTest.cxx,v $
------------------------------------------------------------------------------*/
@ -122,7 +122,7 @@ XmlRpcToolsTest :: firstTest(void)
{
XmlRpcValue xmlRpcPlaylist;
XmlRpcValue xmlRpcAudioClip;
Ptr<Playlist>::Ref playlist = Ptr<Playlist>::Ref(new Playlist);
Ptr<Playlist>::Ref playlist = Ptr<Playlist>::Ref(new Playlist());
Ptr<const AudioClip>::Ref audioClip;
// set up a playlist instance
@ -133,23 +133,39 @@ XmlRpcToolsTest :: firstTest(void)
XmlRpcTools :: playlistToXmlRpcValue(playlist, xmlRpcPlaylist);
XmlRpcTools :: audioClipToXmlRpcValue(audioClip, xmlRpcAudioClip);
CPPUNIT_ASSERT(xmlRpcPlaylist.hasMember("id"));
CPPUNIT_ASSERT(xmlRpcPlaylist["id"].getType() == XmlRpcValue::TypeString);
CPPUNIT_ASSERT(std::string(xmlRpcPlaylist["id"]) == "0000000000000001");
CPPUNIT_ASSERT(xmlRpcPlaylist.hasMember("playlist"));
CPPUNIT_ASSERT(xmlRpcPlaylist["playlist"].getType()
== XmlRpcValue::TypeString);
CPPUNIT_ASSERT(xmlRpcPlaylist.hasMember("playlength"));
CPPUNIT_ASSERT(xmlRpcPlaylist["playlength"].getType()
== XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(int(xmlRpcPlaylist["playlength"]) == 34);
Ptr<Playlist>::Ref copyOfPlaylist(new Playlist());
xmlpp::DomParser parser;
CPPUNIT_ASSERT_NO_THROW(parser.parse_memory(std::string(
xmlRpcPlaylist["playlist"] )));
xmlpp::Element* configElement;
CPPUNIT_ASSERT_NO_THROW(configElement = parser.get_document()
->get_root_node());
CPPUNIT_ASSERT_NO_THROW(copyOfPlaylist->configure(*configElement));
CPPUNIT_ASSERT(xmlRpcAudioClip.hasMember("id"));
CPPUNIT_ASSERT(xmlRpcAudioClip["id"].getType() == XmlRpcValue::TypeString);
CPPUNIT_ASSERT(std::string(xmlRpcAudioClip["id"]) == "0000000000010001");
CPPUNIT_ASSERT(*copyOfPlaylist->getId() == *playlist->getId());
CPPUNIT_ASSERT(*copyOfPlaylist->getTitle() == *playlist->getTitle());
CPPUNIT_ASSERT(*copyOfPlaylist->getPlaylength()
== *playlist->getPlaylength());
CPPUNIT_ASSERT(xmlRpcAudioClip.hasMember("playlength"));
CPPUNIT_ASSERT(xmlRpcAudioClip["playlength"].getType()
== XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(int(xmlRpcAudioClip["playlength"]) == 11);
CPPUNIT_ASSERT(xmlRpcAudioClip.hasMember("audioClip"));
CPPUNIT_ASSERT(xmlRpcAudioClip["audioClip"].getType()
== XmlRpcValue::TypeString);
Ptr<AudioClip>::Ref copyOfAudioClip(new AudioClip());
CPPUNIT_ASSERT_NO_THROW(parser.parse_memory(std::string(
xmlRpcAudioClip["audioClip"] )));
CPPUNIT_ASSERT_NO_THROW(configElement = parser.get_document()
->get_root_node());
CPPUNIT_ASSERT_NO_THROW(copyOfAudioClip->configure(*configElement));
CPPUNIT_ASSERT(*copyOfAudioClip->getId() == *audioClip->getId());
CPPUNIT_ASSERT(*copyOfAudioClip->getTitle() == *audioClip->getTitle());
CPPUNIT_ASSERT(*copyOfAudioClip->getPlaylength()
== *audioClip->getPlaylength());
XmlRpcValue xmlRpcPlaylistId;
Ptr<UniqueId>::Ref playlistId(new UniqueId(rand()));

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.15 $
Version : $Revision: 1.16 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -110,7 +110,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<SessionId>::Ref sessionId;
try{
sessionId = XmlRpcTools::extractSessionId(parameters);
} catch (XmlRpcException &e) {
} catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+20,
"missing session ID argument",
returnValue);
@ -120,7 +120,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<UniqueId>::Ref playlistId;
try{
playlistId = XmlRpcTools::extractPlaylistId(parameters);
} catch (XmlRpcException &e) {
} catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+2, "missing playlist ID argument",
returnValue);
return;
@ -129,7 +129,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<UniqueId>::Ref audioClipId;
try{
audioClipId = XmlRpcTools::extractAudioClipId(parameters);
} catch (XmlRpcException &e) {
} catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+3, "missing audio clip ID argument",
returnValue);
return;
@ -138,7 +138,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<time_duration>::Ref relativeOffset;
try{
relativeOffset = XmlRpcTools::extractRelativeOffset(parameters);
} catch (XmlRpcException &e) {
} catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+4, "missing relative offset argument",
returnValue);
return;
@ -152,7 +152,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<Playlist>::Ref playlist;
try {
playlist = storage->getPlaylist(sessionId, playlistId);
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
XmlRpcTools::markError(errorId+5, "playlist not found",
returnValue);
return;
@ -168,18 +168,21 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<AudioClip>::Ref audioClip;
try {
audioClip = storage->getAudioClip(sessionId, audioClipId);
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
XmlRpcTools::markError(errorId+7, "audio clip does not exist",
returnValue);
return;
}
Ptr<UniqueId>::Ref playlistElementId;
try { // and finally, the beef
playlist->addAudioClip(audioClip, relativeOffset);
playlistElementId = playlist->addAudioClip(audioClip, relativeOffset);
} catch(std::invalid_argument &e) {
XmlRpcTools::markError(errorId+8,
"two audio clips at the same relative offset",
returnValue);
return;
}
XmlRpcTools::playlistElementIdToXmlRpcValue(playlistElementId, returnValue);
}

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/AddAudioClipToPlaylistMethod.h,v $
------------------------------------------------------------------------------*/
@ -76,13 +76,20 @@ using namespace LiveSupport::Core;
* <ul>
* <li>sessionId - string - the session ID obtained via the login()
* method of the authentication client </li>
* <li>playlistId - int - the unique id of the playlist.</li>
* <li>audioClipId - int - the unique id of the audio clip to
* <li>playlistId - string - the unique id of the playlist.</li>
* <li>audioClipId - string - the unique id of the audio clip to
* be added.</li>
* <li>relativeOffset - int - the number of seconds between the
* start of the playlist and the start of the audio clip.</li>
* </ul>
*
* The XML-RPC function returns an XML-RPC structure, containing the following
* fields:
* <ul>
* <li>playlistElementId - string - the unique id of the newly created
* playlist element</li>
* </ul>
*
* 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:
@ -99,7 +106,7 @@ using namespace LiveSupport::Core;
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.9 $
* @version $Revision: 1.10 $
*/
class AddAudioClipToPlaylistMethod : public XmlRpc::XmlRpcServerMethod
{

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.14 $
Version : $Revision: 1.15 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -194,14 +194,6 @@ AddAudioClipToPlaylistMethodTest :: firstTest(void)
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"] = "0000000000000001";
@ -218,4 +210,7 @@ AddAudioClipToPlaylistMethodTest :: firstTest(void)
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
CPPUNIT_ASSERT(result.hasMember("playlistElementId"));
CPPUNIT_ASSERT(result["playlistElementId"].getType()
== XmlRpc::XmlRpcValue::TypeString);
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.13 $
Version : $Revision: 1.14 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -125,7 +125,7 @@ CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<UniqueId>::Ref playlistId;
try {
playlistId = storage->createPlaylist(sessionId);
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "could not create playlist:\n";
eMsg += e.what();
XmlRpcTools :: markError(errorId+2,
@ -137,7 +137,7 @@ CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<Playlist>::Ref playlist;
try {
playlist = storage->editPlaylist(sessionId, playlistId);
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "could not create playlist:\n";
eMsg += e.what();
XmlRpcTools :: markError(errorId+2,

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/CreatePlaylistMethod.h,v $
------------------------------------------------------------------------------*/
@ -79,9 +79,8 @@ using namespace LiveSupport::Core;
* The XML-RPC function returns an XML-RPC structure, containing the following
* fields:
* <ul>
* <li>id - int - the unique id of the new playlist</li>
* <li>playlength - int - the playlist length of the playlist, in seconds
* </li>
* <li>playlist - string - an XML representation of the playlist; this
* XML element can be used as argument to Playlist::configure()</li>
* </ul>
*
* In case of an error, a standard XML-RPC fault response is generated,
@ -94,7 +93,7 @@ using namespace LiveSupport::Core;
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.8 $
* @version $Revision: 1.9 $
*/
class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
{

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.14 $
Version : $Revision: 1.15 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -185,12 +185,13 @@ CreatePlaylistMethodTest :: firstTest(void)
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
CPPUNIT_ASSERT(result.hasMember("id"));
CPPUNIT_ASSERT(result["id"].getType() == XmlRpc::XmlRpcValue::TypeString);
CPPUNIT_ASSERT(result.hasMember("playlength"));
CPPUNIT_ASSERT(result["playlength"].getType()
== XmlRpc::XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(int(result["playlength"]) == 0);
CPPUNIT_ASSERT(result.hasMember("playlist"));
CPPUNIT_ASSERT(result["playlist"].getType()
== XmlRpc::XmlRpcValue::TypeString);
Ptr<Playlist>::Ref playlist;
CPPUNIT_ASSERT_NO_THROW(playlist.reset(new Playlist(result)));
CPPUNIT_ASSERT(playlist->getId()->getId() >= 0);
CPPUNIT_ASSERT(playlist->getPlaylength()->total_seconds() == 0);
method.reset(new OpenPlaylistForEditingMethod());
parameter.clear();

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.11 $
Version : $Revision: 1.12 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -123,7 +123,7 @@ DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<Playlist>::Ref playlist;
try {
playlist = storage->getPlaylist(sessionId, playlistId);
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "playlist not found:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+3, eMsg, returnValue);
@ -138,7 +138,7 @@ DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try {
storage->deletePlaylist(sessionId, playlistId);
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "playlist could not be deleted:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+5, eMsg, returnValue);

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/Attic/DeletePlaylistMethod.h,v $
------------------------------------------------------------------------------*/
@ -74,7 +74,7 @@ using namespace LiveSupport::Core;
* <ul>
* <li>sessionId - string - the session ID obtained via the login()
* method of the authentication client </li>
* <li>playlistId - int - the unique id of the playlist
* <li>playlistId - string - the unique id of the playlist
* to be deleted.</li>
* </ul>
*
@ -91,7 +91,7 @@ using namespace LiveSupport::Core;
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.6 $
* @version $Revision: 1.7 $
*/
class DeletePlaylistMethod : public XmlRpc::XmlRpcServerMethod
{

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/DisplayAudioClipMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -134,7 +134,7 @@ DisplayAudioClipMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<AudioClip>::Ref audioClip;
try {
audioClip = storage->getAudioClip(sessionId, id);
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "audio clip not found:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+3, eMsg, returnValue);

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/DisplayAudioClipMethod.h,v $
------------------------------------------------------------------------------*/
@ -75,15 +75,14 @@ using namespace LiveSupport::Core;
* <ul>
* <li>sessionId - string - the session ID obtained via the login()
* method of the authentication client </li>
* <li>audioClipId - int - the unique id of the audio clip requested.</li>
* <li>audioClipId - string - the unique id of the audio clip requested.</li>
* </ul>
*
* The XML-RPC function returns an XML-RPC structure, containing the following
* fields:
* <ul>
* <li>id - int - the unique id of the audio clip</li>
* <li>playlength - int - the length of the audio clip, in seconds
* </li>
* <li>audioClip - string - an XML representation of the audio clip; this
* XML element can be used as argument to AudioClip::configure()</li>
* </ul>
*
* In case of an error, a standard XML-RPC fault response is generated,
@ -97,7 +96,7 @@ using namespace LiveSupport::Core;
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.4 $
* @version $Revision: 1.5 $
*/
class DisplayAudioClipMethod : public XmlRpc::XmlRpcServerMethod
{

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/DisplayAudioClipMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -186,14 +186,13 @@ DisplayAudioClipMethodTest :: firstTest(void)
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
CPPUNIT_ASSERT(result.hasMember("id"));
CPPUNIT_ASSERT(result["id"].getType() == XmlRpc::XmlRpcValue::TypeString);
CPPUNIT_ASSERT(std::string(result["id"]) == "0000000000010001");
CPPUNIT_ASSERT(result.hasMember("playlength"));
CPPUNIT_ASSERT(result["playlength"].getType()
== XmlRpc::XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(int(result["playlength"]) == 60 * 60);
CPPUNIT_ASSERT(result.hasMember("audioClip"));
CPPUNIT_ASSERT(result["audioClip"].getType()
== XmlRpc::XmlRpcValue::TypeString);
Ptr<AudioClip>::Ref audioClip;
CPPUNIT_ASSERT_NO_THROW(audioClip.reset(new AudioClip(result)));
CPPUNIT_ASSERT(audioClip->getId()->getId() == 0x10001);
CPPUNIT_ASSERT(audioClip->getPlaylength()->total_seconds() == 60 * 60);
}

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/DisplayAudioClipsMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -115,7 +115,7 @@ DisplayAudioClipsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<std::vector<Ptr<UniqueId>::Ref> >::Ref audioClipIds;
try {
audioClipIds = storage->getAudioClipIds();
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "getAudioClipIds returned error:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+2, eMsg, returnValue);
@ -128,7 +128,7 @@ DisplayAudioClipsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
while (it != audioClipIds->end()) {
try {
audioClips->push_back(storage->getAudioClip(sessionId, *it));
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "audio clip not found:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+3, eMsg, returnValue);

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/DisplayAudioClipsMethod.h,v $
------------------------------------------------------------------------------*/
@ -84,9 +84,8 @@ using namespace LiveSupport::Core;
* for each audio clip in the audio clip store. An array of size 0 means the
* audio clip store is empty. Each structure is as follows:
* <ul>
* <li>id - int - the unique id of the audio clip</li>
* <li>playlength - int - the length of the audio clip, in seconds
* </li>
* <li>audioClip - string - an XML representation of the audio clip; this
* XML element can be used as argument to AudioClip::configure()</li>
* </ul>
*
* In case of an error, a standard XML-RPC fault response is generated,
@ -99,7 +98,7 @@ using namespace LiveSupport::Core;
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.5 $
* @version $Revision: 1.6 $
*/
class DisplayAudioClipsMethod : public XmlRpc::XmlRpcServerMethod
{

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/DisplayAudioClipsMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -172,7 +172,6 @@ DisplayAudioClipsMethodTest :: firstTest(void)
XmlRpc::XmlRpcValue rootParameter;
rootParameter.setSize(1);
XmlRpc::XmlRpcValue result;
XmlRpc::XmlRpcValue audioClip;
result.clear();
parameter["sessionId"] = sessionId->getId();
@ -187,26 +186,21 @@ DisplayAudioClipsMethodTest :: firstTest(void)
}
CPPUNIT_ASSERT(result.size() >= 2);
audioClip = result[0];
CPPUNIT_ASSERT(audioClip.hasMember("id"));
CPPUNIT_ASSERT(audioClip["id"].getType()
XmlRpc::XmlRpcValue result0 = result[0];
CPPUNIT_ASSERT(result0.hasMember("audioClip"));
CPPUNIT_ASSERT(result0["audioClip"].getType()
== XmlRpc::XmlRpcValue::TypeString);
CPPUNIT_ASSERT(std::string(audioClip["id"]) == "0000000000010001");
Ptr<AudioClip>::Ref audioClip;
CPPUNIT_ASSERT_NO_THROW(audioClip.reset(new AudioClip(result0)));
CPPUNIT_ASSERT(audioClip->getId()->getId() == 0x10001);
CPPUNIT_ASSERT(audioClip->getPlaylength()->total_seconds() == 60 * 60);
CPPUNIT_ASSERT(audioClip.hasMember("playlength"));
CPPUNIT_ASSERT(audioClip["playlength"].getType()
== XmlRpc::XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(int(audioClip["playlength"]) == 60 * 60);
audioClip = result[1];
CPPUNIT_ASSERT(audioClip.hasMember("id"));
CPPUNIT_ASSERT(audioClip["id"].getType()
XmlRpc::XmlRpcValue result1 = result[1];
CPPUNIT_ASSERT(result1.hasMember("audioClip"));
CPPUNIT_ASSERT(result1["audioClip"].getType()
== XmlRpc::XmlRpcValue::TypeString);
CPPUNIT_ASSERT(std::string(audioClip["id"]) == "0000000000010002");
CPPUNIT_ASSERT(audioClip.hasMember("playlength"));
CPPUNIT_ASSERT(audioClip["playlength"].getType()
== XmlRpc::XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(int(audioClip["playlength"]) == 30 * 60);
CPPUNIT_ASSERT_NO_THROW(audioClip.reset(new AudioClip(result1)));
CPPUNIT_ASSERT(audioClip->getId()->getId() == 0x10002);
CPPUNIT_ASSERT(audioClip->getPlaylength()->total_seconds() == 30 * 60);
}

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/DisplayPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -134,7 +134,7 @@ DisplayPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<Playlist>::Ref playlist;
try {
playlist = storage->getPlaylist(sessionId, id);
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "playlist not found:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+3, eMsg, returnValue);

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/DisplayPlaylistMethod.h,v $
------------------------------------------------------------------------------*/
@ -75,15 +75,14 @@ using namespace LiveSupport::Core;
* <ul>
* <li>sessionId - string - the session ID obtained via the login()
* method of the authentication client </li>
* <li>playlistId - int - the unique id of the playlist requested.</li>
* <li>playlistId - string - the unique id of the playlist requested.</li>
* </ul>
*
* The XML-RPC function returns an XML-RPC structure, containing the following
* fields:
* <ul>
* <li>id - int - the unique id of the playlist</li>
* <li>playlength - int - the playlist length of the playlist, in seconds
* </li>
* <li>playlist - string - an XML representation of the playlist; this
* XML element can be used as argument to Playlist::configure()</li>
* </ul>
*
* In case of an error, a standard XML-RPC fault response is generated,
@ -97,7 +96,7 @@ using namespace LiveSupport::Core;
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.6 $
* @version $Revision: 1.7 $
*/
class DisplayPlaylistMethod : public XmlRpc::XmlRpcServerMethod
{

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/DisplayPlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -186,13 +186,13 @@ DisplayPlaylistMethodTest :: firstTest(void)
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
CPPUNIT_ASSERT(result.hasMember("id"));
CPPUNIT_ASSERT(result["id"].getType() == XmlRpc::XmlRpcValue::TypeString);
CPPUNIT_ASSERT(std::string(result["id"]) == "0000000000000001");
CPPUNIT_ASSERT(result.hasMember("playlength"));
CPPUNIT_ASSERT(result["playlength"].getType()
== XmlRpc::XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(int(result["playlength"]) == 90 * 60);
CPPUNIT_ASSERT(result.hasMember("playlist"));
CPPUNIT_ASSERT(result["playlist"].getType()
== XmlRpc::XmlRpcValue::TypeString);
Ptr<Playlist>::Ref playlist;
CPPUNIT_ASSERT_NO_THROW(playlist.reset(new Playlist(result)));
CPPUNIT_ASSERT(playlist->getId()->getId() == 1);
CPPUNIT_ASSERT(playlist->getPlaylength()->total_seconds() == 90 * 60);
}

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/DisplayPlaylistsMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -118,7 +118,7 @@ DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
playlistIds = storage->getPlaylistIds();
//std::cerr << "\nplaylistIds: " << playlistIds << "\n"
// << "size: " << playlistIds->size() << "n";
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "getPlaylistsIds() returned error:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+2, eMsg, returnValue);
@ -131,7 +131,7 @@ DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
while (it != playlistIds->end()) {
try {
playlists->push_back(storage->getPlaylist(sessionId, *it));
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "audio clip not found:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+3, eMsg, returnValue);

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/DisplayPlaylistsMethod.h,v $
------------------------------------------------------------------------------*/
@ -84,9 +84,8 @@ using namespace LiveSupport::Core;
* for each playlist in the playlist store. An array of size 0 means the
* playlist store is empty. Each structure is as follows:
* <ul>
* <li>id - int - the unique id of the playlist</li>
* <li>playlength - int - the playlist length of the playlist, in seconds
* </li>
* <li>playlist - string - an XML representation of the playlist; this
* XML element can be used as argument to Playlist::configure()</li>
* </ul>
*
* In case of an error, a standard XML-RPC fault response is generated,
@ -99,7 +98,7 @@ using namespace LiveSupport::Core;
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.7 $
* @version $Revision: 1.8 $
*/
class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod
{

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/DisplayPlaylistsMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -185,14 +185,13 @@ DisplayPlaylistsMethodTest :: firstTest(void)
CPPUNIT_FAIL(eMsg.str());
}
CPPUNIT_ASSERT(result.size() == 1);
XmlRpc::XmlRpcValue playlist = result[0];
XmlRpc::XmlRpcValue result0 = result[0];
CPPUNIT_ASSERT(playlist.hasMember("id"));
CPPUNIT_ASSERT(playlist["id"].getType() == XmlRpc::XmlRpcValue::TypeString);
CPPUNIT_ASSERT(std::string(playlist["id"]) == "0000000000000001");
CPPUNIT_ASSERT(playlist.hasMember("playlength"));
CPPUNIT_ASSERT(playlist["playlength"].getType()
== XmlRpc::XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(int(playlist["playlength"]) == 90 * 60);
CPPUNIT_ASSERT(result0.hasMember("playlist"));
CPPUNIT_ASSERT(result0["playlist"].getType()
== XmlRpc::XmlRpcValue::TypeString);
Ptr<Playlist>::Ref playlist;
CPPUNIT_ASSERT_NO_THROW(playlist.reset(new Playlist(result0)));
CPPUNIT_ASSERT(playlist->getId()->getId() == 1);
CPPUNIT_ASSERT(playlist->getPlaylength()->total_seconds() == 90 * 60);
}

View File

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.7 $
Author : $Author: fgerlits $
Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethod.h,v $
------------------------------------------------------------------------------*/
@ -90,7 +90,7 @@ using namespace LiveSupport::Core;
* are not scheduled entries. Each structure is as follows:
* <ul>
* <li>id - int - the id of the scheduled entry</li>
* <li>playlistId - int - the id of the playlist associated with the entry
* <li>playlistId - string - the id of the playlist associated with the entry
* </li>
* <li>start - datetime - the start of the scheduled item</li>
* <li>end - datetime - the end of the scheduled item</li>
@ -106,8 +106,8 @@ using namespace LiveSupport::Core;
* <li>1120 - missing session ID argument </li>
* </ul>
*
* @author $Author: maroy $
* @version $Revision: 1.7 $
* @author $Author: fgerlits $
* @version $Revision: 1.8 $
*/
class DisplayScheduleMethod : public XmlRpc::XmlRpcServerMethod
{

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/GeneratePlayReportMethod.h,v $
------------------------------------------------------------------------------*/
@ -89,8 +89,8 @@ using namespace LiveSupport::Core;
* for each play log item in the interval. An array of size 0 means there
* are no play log entries. Each structure is as follows:
* <ul>
* <li>audioClipId - int - the id of the audio clip played </li>
* <li>timestamp - datetime - the time the clip was played (started) </li>
* <li>audioClipId - string - the id of the audio clip played </li>
* <li>timestamp - datetime - the time the clip was played (started)</li>
* </ul>
*
* In case of an error, a standard XML-RPC fault response is generated,
@ -104,7 +104,7 @@ using namespace LiveSupport::Core;
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.5 $
* @version $Revision: 1.6 $
*/
class GeneratePlayReportMethod : public XmlRpc::XmlRpcServerMethod
{

View File

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.1 $
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GetVersionMethod.h,v $
------------------------------------------------------------------------------*/
@ -74,14 +74,13 @@ using namespace LiveSupport::Core;
* The XML-RPC function returns an XML-RPC structure, containing the following
* fields:
* <ul>
* <li>version - string - the version string of the Scheduler Daemon
* </li>
* <li>version - string - the version string of the Scheduler Daemon </li>
* </ul>
*
* There are no possible internal error condititons for this function.
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
*/
class GetVersionMethod : public XmlRpc::XmlRpcServerMethod
{

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/LoginMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -89,7 +89,7 @@ LoginMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<std::string>::Ref loginName;
try{
loginName = XmlRpcTools::extractLoginName(parameters);
} catch (XmlRpcException &e) {
} catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+2, "missing login argument",
returnValue);
return;
@ -98,7 +98,7 @@ LoginMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<std::string>::Ref password;
try{
password = XmlRpcTools::extractPassword(parameters);
} catch (XmlRpcException &e) {
} catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+3, "missing password argument",
returnValue);
return;
@ -112,7 +112,7 @@ LoginMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<SessionId>::Ref sessionId;
try {
sessionId = authentication->login(*loginName, *password);
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "authentication login() returned error:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+4, eMsg, 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/LogoutMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -89,7 +89,7 @@ LogoutMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<SessionId>::Ref sessionId;
try{
sessionId = XmlRpcTools::extractSessionId(parameters);
} catch (XmlRpcException &e) {
} catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+20, "missing logout argument",
returnValue);
return;
@ -102,7 +102,7 @@ LogoutMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try {
authentication->logout(sessionId);
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "authentication logout() returned error:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+4, eMsg, returnValue);

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.16 $
Version : $Revision: 1.17 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -135,7 +135,7 @@ OpenPlaylistForEditingMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<Playlist>::Ref playlist;
try {
playlist = storage->editPlaylist(sessionId, id);
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "could not open playlist for editing:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+4, eMsg, returnValue);

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/OpenPlaylistForEditingMethod.h,v $
------------------------------------------------------------------------------*/
@ -76,15 +76,14 @@ using namespace LiveSupport::Core;
* <ul>
* <li>sessionId - string - the session ID obtained via the login()
* method of the authentication client </li>
* <li>playlistId - int - the unique id of the playlist requested.</li>
* <li>playlistId - string - the unique id of the playlist requested.</li>
* </ul>
*
* The XML-RPC function returns an XML-RPC structure, containing the following
* fields:
* <ul>
* <li>id - int - the unique id of the playlist</li>
* <li>playlength - int - the playlist length of the playlist, in seconds
* </li>
* <li>playlist - string - an XML representation of the playlist; this
* XML element can be used as argument to Playlist::configure()</li>
* </ul>
*
* In case of an error, a standard XML-RPC fault response is generated,
@ -97,7 +96,7 @@ using namespace LiveSupport::Core;
* <li>120 - missing session ID argument </li>
* </ul>
* @author $Author: fgerlits $
* @version $Revision: 1.10 $
* @version $Revision: 1.11 $
*/
class OpenPlaylistForEditingMethod : public XmlRpc::XmlRpcServerMethod
{

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.15 $
Version : $Revision: 1.16 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -187,14 +187,13 @@ OpenPlaylistForEditingMethodTest :: firstTest(void)
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
CPPUNIT_ASSERT(result.hasMember("id"));
CPPUNIT_ASSERT(result["id"].getType() == XmlRpc::XmlRpcValue::TypeString);
CPPUNIT_ASSERT(std::string(result["id"]) == "0000000000000001");
CPPUNIT_ASSERT(result.hasMember("playlength"));
CPPUNIT_ASSERT(result["playlength"].getType()
== XmlRpc::XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(int(result["playlength"]) == 90 * 60);
CPPUNIT_ASSERT(result.hasMember("playlist"));
CPPUNIT_ASSERT(result["playlist"].getType()
== XmlRpc::XmlRpcValue::TypeString);
Ptr<Playlist>::Ref playlist;
CPPUNIT_ASSERT_NO_THROW(playlist.reset(new Playlist(result)));
CPPUNIT_ASSERT(playlist->getId()->getId() == 1);
CPPUNIT_ASSERT(playlist->getPlaylength()->total_seconds() == 90 * 60);
parameter.clear();
parameter["sessionId"] = sessionId->getId();

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.12 $
Version : $Revision: 1.13 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -106,9 +106,9 @@ RemoveAudioClipFromPlaylistMethod :: execute(
returnValue);
return;
}
XmlRpc::XmlRpcValue parameters = rootParameter[0];
XmlRpc::XmlRpcValue parameters = rootParameter[0];
Ptr<SessionId>::Ref sessionId;
Ptr<SessionId>::Ref sessionId;
try{
sessionId = XmlRpcTools::extractSessionId(parameters);
} catch (std::invalid_argument &e) {
@ -118,7 +118,7 @@ RemoveAudioClipFromPlaylistMethod :: execute(
return;
}
Ptr<UniqueId>::Ref playlistId;
Ptr<UniqueId>::Ref playlistId;
try{
playlistId = XmlRpcTools::extractPlaylistId(parameters);
} catch (std::invalid_argument &e) {
@ -128,12 +128,12 @@ RemoveAudioClipFromPlaylistMethod :: execute(
return;
}
Ptr<time_duration>::Ref relativeOffset;
Ptr<UniqueId>::Ref playlistElementId;
try{
relativeOffset = XmlRpcTools::extractRelativeOffset(parameters);
playlistElementId = XmlRpcTools::extractPlaylistElementId(parameters);
} catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+3,
"missing relative offset argument",
"missing playlist element ID argument",
returnValue);
return;
}
@ -146,7 +146,7 @@ RemoveAudioClipFromPlaylistMethod :: execute(
Ptr<Playlist>::Ref playlist;
try {
playlist = storage->getPlaylist(sessionId, playlistId);
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "playlist does not exist:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+4, eMsg, returnValue);
@ -161,7 +161,7 @@ RemoveAudioClipFromPlaylistMethod :: execute(
}
try { // and finally, the beef
playlist->removePlaylistElement(relativeOffset);
playlist->removePlaylistElement(playlistElementId);
} catch(std::invalid_argument &e) {
XmlRpcTools::markError(errorId+6,
"no audio clip at the specified "

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.h,v $
------------------------------------------------------------------------------*/
@ -76,10 +76,9 @@ using namespace LiveSupport::Core;
* <ul>
* <li>sessionId - string - the session ID obtained via the login()
* method of the authentication client </li>
* <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>
* <li>playlistId - string - the unique id of the playlist.</li>
* <li>playlistElementId - string - the unique id of the playlist element
* to be removed.</li>
* </ul>
*
* In case of an error, a standard XML-RPC fault response is generated,
@ -95,7 +94,7 @@ using namespace LiveSupport::Core;
* <li>420 - missing session ID argument </li>
* </ul>
* @author $Author: fgerlits $
* @version $Revision: 1.4 $
* @version $Revision: 1.5 $
*/
class RemoveAudioClipFromPlaylistMethod : public XmlRpc::XmlRpcServerMethod
{

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.12 $
Version : $Revision: 1.13 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -183,11 +183,12 @@ RemoveAudioClipFromPlaylistMethodTest :: firstTest(void)
rootParameter.setSize(1);
XmlRpc::XmlRpcValue result;
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = "0000000000000001";
parameters["audioClipId"] = "0000000000010001";
parameters["relativeOffset"] = 90*60;
rootParameter[0] = parameters;
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = "0000000000000001";
parameters["audioClipId"] = "0000000000010001";
parameters["relativeOffset"] = 60*60;
parameters["playlistElementId"] = "0000000000009999";
rootParameter[0] = parameters;
result.clear();
try {
@ -212,7 +213,7 @@ RemoveAudioClipFromPlaylistMethodTest :: firstTest(void)
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
CPPUNIT_ASSERT(e.getCode() == 406); // no such playlist element
}
result.clear();
@ -224,6 +225,16 @@ RemoveAudioClipFromPlaylistMethodTest :: firstTest(void)
<< " - " << e.getMessage();
CPPUNIT_FAIL(eMsg.str());
}
CPPUNIT_ASSERT(result.hasMember("playlistElementId"));
CPPUNIT_ASSERT(result["playlistElementId"].getType()
== XmlRpc::XmlRpcValue::TypeString);
std::string playlistElementId(result["playlistElementId"]);
parameters.clear();
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = "0000000000000001";
parameters["playlistElementId"] = playlistElementId;
rootParameter[0] = parameters;
result.clear();
try {

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/RemoveFromScheduleMethod.h,v $
------------------------------------------------------------------------------*/
@ -75,7 +75,8 @@ using namespace LiveSupport::Core;
* <ul>
* <li>sessionId - string - the session ID obtained via the login()
* method of the authentication client </li>
* <li>scheduleEntryId - int - the id of the scheduled entry to remove</li>
* <li>scheduleEntryId - string - the id of the scheduled entry
* to remove</li>
* </ul>
*
* In case of an error, a standard XML-RPC fault response is generated,
@ -89,7 +90,7 @@ using namespace LiveSupport::Core;
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.6 $
* @version $Revision: 1.7 $
*/
class RemoveFromScheduleMethod : public XmlRpc::XmlRpcServerMethod
{

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/RescheduleMethod.h,v $
------------------------------------------------------------------------------*/
@ -75,8 +75,8 @@ using namespace LiveSupport::Core;
* <ul>
* <li>sessionId - string - the session ID obtained via the login()
* method of the authentication client </li>
* <li>scheduleEntryId - int - the id of the schedule entry to reschedule
* </li>
* <li>scheduleEntryId - string - the id of the schedule entry
* to reschedule </li>
* <li>playtime - datetime - the new playing time for the entry</li>
* </ul>
*
@ -93,7 +93,7 @@ using namespace LiveSupport::Core;
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.6 $
* @version $Revision: 1.7 $
*/
class RescheduleMethod : public XmlRpc::XmlRpcServerMethod
{

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/ResetStorageMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -90,7 +90,7 @@ ResetStorageMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try {
storage->reset();
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "storage reset() returned error:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+1, eMsg, 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/ResetStorageMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -67,7 +67,6 @@ ResetStorageMethodTest :: tearDown(void) throw ()
{
}
#include <iostream>
/*------------------------------------------------------------------------------
* Just a very simple smoke test
*----------------------------------------------------------------------------*/
@ -99,7 +98,7 @@ ResetStorageMethodTest :: firstTest(void)
result.clear();
CPPUNIT_ASSERT(xmlRpcClient.execute("displayPlaylist", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("id"));
CPPUNIT_ASSERT(result.hasMember("playlist"));
parameters.clear();
parameters["sessionId"] = sessionId;
@ -135,7 +134,7 @@ ResetStorageMethodTest :: firstTest(void)
result.clear();
CPPUNIT_ASSERT(xmlRpcClient.execute("displayPlaylist", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("id"));
CPPUNIT_ASSERT(result.hasMember("playlist"));
parameters.clear();
parameters["sessionId"] = sessionId;

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/RevertEditedPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -130,7 +130,7 @@ RevertEditedPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<Playlist>::Ref playlist;
try {
playlist = storage->getPlaylist(sessionId, id);
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "playlist not found:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+3, eMsg, returnValue);
@ -139,7 +139,7 @@ RevertEditedPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try {
playlist->revertToSavedCopy();
} catch (std::logic_error) {
} catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+4, "could not revert playlist",
returnValue);
return;

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/RevertEditedPlaylistMethod.h,v $
------------------------------------------------------------------------------*/
@ -76,7 +76,7 @@ using namespace LiveSupport::Core;
* <ul>
* <li>sessionId - string - the session ID obtained via the login()
* method of the authentication client </li>
* <li>playlistId - int - the unique id of the playlist requested.</li>
* <li>playlistId - string - the unique id of the playlist to revert.</li>
* </ul>
*
* In case of an error, a standard XML-RPC fault response is generated,
@ -90,7 +90,7 @@ using namespace LiveSupport::Core;
* <li>820 - missing session ID argument </li>
* </ul>
* @author $Author: fgerlits $
* @version $Revision: 1.4 $
* @version $Revision: 1.5 $
*/
class RevertEditedPlaylistMethod : public XmlRpc::XmlRpcServerMethod
{

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/RevertEditedPlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -183,10 +183,10 @@ RevertEditedPlaylistMethodTest :: firstTest(void)
rootParameter.setSize(1);
XmlRpc::XmlRpcValue result;
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = "0000000000000001";
parameters["relativeOffset"] = 0;
rootParameter[0] = parameters;
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = "0000000000000001";
parameters["playlistElementId"] = "0000000000000101";
rootParameter[0] = parameters;
result.clear();
try {

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.12 $
Version : $Revision: 1.13 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcAddAudioClipToPlaylistTest.cxx,v $
------------------------------------------------------------------------------*/
@ -119,14 +119,7 @@ RpcAddAudioClipToPlaylistTest :: firstTest(void)
result.clear();
xmlRpcClient.execute("openPlaylistForEditing", parameters, result);
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("id"));
CPPUNIT_ASSERT(result["id"].getType() == XmlRpcValue::TypeString);
CPPUNIT_ASSERT(std::string(result["id"]) == "0000000000000001");
result.clear();
xmlRpcClient.execute("addAudioClipToPlaylist", parameters, result);
CPPUNIT_ASSERT(xmlRpcClient.isFault());
parameters.clear();
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = "0000000000000001";

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/RpcCreatePlaylistTest.cxx,v $
------------------------------------------------------------------------------*/
@ -115,12 +115,13 @@ RpcCreatePlaylistTest :: firstTest(void)
result.clear();
xmlRpcClient.execute("createPlaylist", parameters, result);
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("id"));
CPPUNIT_ASSERT(result["id"].getType() == XmlRpc::XmlRpcValue::TypeString);
CPPUNIT_ASSERT(result.hasMember("playlength"));
CPPUNIT_ASSERT(result["playlength"].getType()
== XmlRpc::XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(int(result["playlength"]) == 0);
CPPUNIT_ASSERT(result.hasMember("playlist"));
CPPUNIT_ASSERT(result["playlist"].getType()
== XmlRpc::XmlRpcValue::TypeString);
Ptr<Playlist>::Ref playlist;
CPPUNIT_ASSERT_NO_THROW(playlist.reset(new Playlist(result)));
CPPUNIT_ASSERT(playlist->getId()->getId() >= 0);
CPPUNIT_ASSERT(playlist->getPlaylength()->total_seconds() == 0);
parameters.clear();
parameters["sessionId"] = sessionId->getId();

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/RpcDisplayAudioClipTest.cxx,v $
------------------------------------------------------------------------------*/
@ -117,13 +117,13 @@ RpcDisplayAudioClipTest :: firstTest(void)
xmlRpcClient.execute("displayAudioClip", parameters, result);
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("id"));
CPPUNIT_ASSERT(result["id"].getType() == XmlRpcValue::TypeString);
CPPUNIT_ASSERT(std::string(result["id"]) == "0000000000010001");
CPPUNIT_ASSERT(result.hasMember("playlength"));
CPPUNIT_ASSERT(result["playlength"].getType() == XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(int(result["playlength"]) == 60 * 60);
CPPUNIT_ASSERT(result.hasMember("audioClip"));
CPPUNIT_ASSERT(result["audioClip"].getType()
== XmlRpc::XmlRpcValue::TypeString);
Ptr<AudioClip>::Ref audioClip;
CPPUNIT_ASSERT_NO_THROW(audioClip.reset(new AudioClip(result)));
CPPUNIT_ASSERT(audioClip->getId()->getId() == 0x10001);
CPPUNIT_ASSERT(audioClip->getPlaylength()->total_seconds() == 60 * 60);
xmlRpcClient.close();
}

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/RpcDisplayAudioClipsTest.cxx,v $
------------------------------------------------------------------------------*/
@ -116,23 +116,22 @@ RpcDisplayAudioClipsTest :: firstTest(void)
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.size() >= 2);
XmlRpc::XmlRpcValue audioClip = result[0];
CPPUNIT_ASSERT(audioClip.hasMember("id"));
CPPUNIT_ASSERT(audioClip["id"].getType() == XmlRpcValue::TypeString);
CPPUNIT_ASSERT(std::string(audioClip["id"]) == "0000000000010001");
XmlRpc::XmlRpcValue result0 = result[0];
CPPUNIT_ASSERT(result0.hasMember("audioClip"));
CPPUNIT_ASSERT(result0["audioClip"].getType()
== XmlRpc::XmlRpcValue::TypeString);
Ptr<AudioClip>::Ref audioClip;
CPPUNIT_ASSERT_NO_THROW(audioClip.reset(new AudioClip(result0)));
CPPUNIT_ASSERT(audioClip->getId()->getId() == 0x10001);
CPPUNIT_ASSERT(audioClip->getPlaylength()->total_seconds() == 60 * 60);
CPPUNIT_ASSERT(audioClip.hasMember("playlength"));
CPPUNIT_ASSERT(audioClip["playlength"].getType() == XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(int(audioClip["playlength"]) == 60 * 60);
audioClip = result[1];
CPPUNIT_ASSERT(audioClip.hasMember("id"));
CPPUNIT_ASSERT(audioClip["id"].getType() == XmlRpcValue::TypeString);
CPPUNIT_ASSERT(std::string(audioClip["id"]) == "0000000000010002");
CPPUNIT_ASSERT(audioClip.hasMember("playlength"));
CPPUNIT_ASSERT(audioClip["playlength"].getType() == XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(int(audioClip["playlength"]) == 30 * 60);
XmlRpc::XmlRpcValue result1 = result[1];
CPPUNIT_ASSERT(result1.hasMember("audioClip"));
CPPUNIT_ASSERT(result1["audioClip"].getType()
== XmlRpc::XmlRpcValue::TypeString);
CPPUNIT_ASSERT_NO_THROW(audioClip.reset(new AudioClip(result1)));
CPPUNIT_ASSERT(audioClip->getId()->getId() == 0x10002);
CPPUNIT_ASSERT(audioClip->getPlaylength()->total_seconds() == 30 * 60);
xmlRpcClient.close();
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.11 $
Version : $Revision: 1.12 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcDisplayPlaylistTest.cxx,v $
------------------------------------------------------------------------------*/
@ -117,13 +117,14 @@ RpcDisplayPlaylistTest :: simpleTest(void)
result.clear();
xmlRpcClient.execute("displayPlaylist", parameters, result);
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("id"));
CPPUNIT_ASSERT(result["id"].getType() == XmlRpcValue::TypeString);
CPPUNIT_ASSERT(result.hasMember("playlength"));
CPPUNIT_ASSERT(result["playlength"].getType() == XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(std::string(result["id"]) == "0000000000000001");
CPPUNIT_ASSERT(int(result["playlength"]) == 90 * 60);
CPPUNIT_ASSERT(result.hasMember("playlist"));
CPPUNIT_ASSERT(result["playlist"].getType()
== XmlRpc::XmlRpcValue::TypeString);
Ptr<Playlist>::Ref playlist;
CPPUNIT_ASSERT_NO_THROW(playlist.reset(new Playlist(result)));
CPPUNIT_ASSERT(playlist->getId()->getId() == 1);
CPPUNIT_ASSERT(playlist->getPlaylength()->total_seconds() == 90 * 60);
xmlRpcClient.close();
}

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/RpcDisplayPlaylistsTest.cxx,v $
------------------------------------------------------------------------------*/
@ -116,14 +116,14 @@ RpcDisplayPlaylistsTest :: firstTest(void)
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.size() == 1);
XmlRpc::XmlRpcValue playlist = result[0];
CPPUNIT_ASSERT(playlist.hasMember("id"));
CPPUNIT_ASSERT(playlist["id"].getType() == XmlRpcValue::TypeString);
CPPUNIT_ASSERT(std::string(playlist["id"]) == "0000000000000001");
CPPUNIT_ASSERT(playlist.hasMember("playlength"));
CPPUNIT_ASSERT(playlist["playlength"].getType() == XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(int(playlist["playlength"]) == 90 * 60);
XmlRpc::XmlRpcValue result0 = result[0];
CPPUNIT_ASSERT(result0.hasMember("playlist"));
CPPUNIT_ASSERT(result0["playlist"].getType()
== XmlRpc::XmlRpcValue::TypeString);
Ptr<Playlist>::Ref playlist;
CPPUNIT_ASSERT_NO_THROW(playlist.reset(new Playlist(result0)));
CPPUNIT_ASSERT(playlist->getId()->getId() == 1);
CPPUNIT_ASSERT(playlist->getPlaylength()->total_seconds() == 90 * 60);
xmlRpcClient.close();
}

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/RpcOpenPlaylistForEditingTest.cxx,v $
------------------------------------------------------------------------------*/
@ -118,14 +118,13 @@ RpcOpenPlaylistForEditingTest :: firstTest(void)
CPPUNIT_ASSERT(xmlRpcClient.execute("openPlaylistForEditing",
parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("id"));
CPPUNIT_ASSERT(result["id"].getType() == XmlRpc::XmlRpcValue::TypeString);
CPPUNIT_ASSERT(std::string(result["id"]) == "0000000000000001");
CPPUNIT_ASSERT(result.hasMember("playlength"));
CPPUNIT_ASSERT(result["playlength"].getType()
== XmlRpc::XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(int(result["playlength"]) == 90 * 60);
CPPUNIT_ASSERT(result.hasMember("playlist"));
CPPUNIT_ASSERT(result["playlist"].getType()
== XmlRpc::XmlRpcValue::TypeString);
Ptr<Playlist>::Ref playlist;
CPPUNIT_ASSERT_NO_THROW(playlist.reset(new Playlist(result)));
CPPUNIT_ASSERT(playlist->getId()->getId() == 1);
CPPUNIT_ASSERT(playlist->getPlaylength()->total_seconds() == 90 * 60);
parameters.clear();
parameters["sessionId"] = sessionId->getId();

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/RpcRemoveAudioClipFromPlaylistTest.cxx,v $
------------------------------------------------------------------------------*/
@ -111,10 +111,11 @@ RpcRemoveAudioClipFromPlaylistTest :: firstTest(void)
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = "0000000000000001";
parameters["audioClipId"] = "0000000000010001";
parameters["relativeOffset"] = 90*60;
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = "0000000000000001";
parameters["audioClipId"] = "0000000000010001";
parameters["relativeOffset"] = 60*60;
parameters["playlistElementId"] = "0000000000009999";
result.clear();
CPPUNIT_ASSERT(xmlRpcClient.execute("removeAudioClipFromPlaylist",
@ -143,6 +144,15 @@ RpcRemoveAudioClipFromPlaylistTest :: firstTest(void)
CPPUNIT_ASSERT(xmlRpcClient.execute("addAudioClipToPlaylist",
parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("playlistElementId"));
CPPUNIT_ASSERT(result["playlistElementId"].getType()
== XmlRpc::XmlRpcValue::TypeString);
std::string playlistElementId = std::string(result["playlistElementId"]);
parameters.clear();
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = "0000000000000001";
parameters["playlistElementId"] = playlistElementId;
result.clear();
CPPUNIT_ASSERT(xmlRpcClient.execute("removeAudioClipFromPlaylist",

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/RpcRevertEditedPlaylistTest.cxx,v $
------------------------------------------------------------------------------*/
@ -111,9 +111,9 @@ RpcRevertEditedPlaylistTest :: firstTest(void)
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = "0000000000000001";
parameters["relativeOffset"] = 0;
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = "0000000000000001";
parameters["playlistElementId"] = "0000000000000101";
CPPUNIT_ASSERT(xmlRpcClient.execute("revertEditedPlaylist",
parameters, result));

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/RpcUpdateFadeInFadeOutTest.cxx,v $
------------------------------------------------------------------------------*/
@ -109,10 +109,10 @@ RpcUpdateFadeInFadeOutTest :: firstTest(void)
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = "0000000000000001";
parameters["relativeOffset"] = 90*60;
parameters["fadeIn"] = 0;
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = "0000000000000001";
parameters["playlistElementId"] = "0000000000009999";
parameters["fadeIn"] = 0;
result.clear();
CPPUNIT_ASSERT(xmlRpcClient.execute("updateFadeInFadeOut",
@ -146,9 +146,9 @@ RpcUpdateFadeInFadeOutTest :: firstTest(void)
xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("faultCode"));
CPPUNIT_ASSERT(int(result["faultCode"]) == 1608);
// no audio clip at this rel offset
// no such playlist element
parameters["relativeOffset"] = 0;
parameters["playlistElementId"] = "0000000000000101";
result.clear();
CPPUNIT_ASSERT(xmlRpcClient.execute("updateFadeInFadeOut",

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/RpcValidatePlaylistTest.cxx,v $
------------------------------------------------------------------------------*/
@ -136,7 +136,7 @@ RpcValidatePlaylistTest :: firstTest(void)
CPPUNIT_ASSERT(bool(result["valid"]));
result.clear();
parameters["relativeOffset"] = 0;
parameters["playlistElementId"] = "0000000000000101";
CPPUNIT_ASSERT(xmlRpcClient.execute("removeAudioClipFromPlaylist",
parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());

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/SavePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -130,7 +130,7 @@ SavePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<Playlist>::Ref playlist;
try {
playlist = storage->getPlaylist(sessionId, id);
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "playlist not found:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+3, eMsg, returnValue);
@ -141,7 +141,7 @@ SavePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
try {
storage->savePlaylist(sessionId, playlist);
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "could not save playlist:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+5, eMsg, returnValue);

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/SavePlaylistMethod.h,v $
------------------------------------------------------------------------------*/
@ -77,7 +77,7 @@ using namespace LiveSupport::Core;
* <ul>
* <li>sessionId - string - the session ID obtained via the login()
* method of the authentication client </li>
* <li>playlistId - int - the unique id of the playlist to save.</li>
* <li>playlistId - string - the unique id of the playlist to save.</li>
* </ul>
*
* In case of an error, a standard XML-RPC fault response is generated,
@ -91,7 +91,7 @@ using namespace LiveSupport::Core;
* <li>720 - missing session ID argument </li>
* </ul>
* @author $Author: fgerlits $
* @version $Revision: 1.6 $
* @version $Revision: 1.7 $
*/
class SavePlaylistMethod : public XmlRpc::XmlRpcServerMethod
{

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/UpdateFadeInFadeOutMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -108,35 +108,29 @@ UpdateFadeInFadeOutMethod :: execute(
returnValue);
return;
}
XmlRpc::XmlRpcValue parameters = rootParameter[0];
XmlRpc::XmlRpcValue parameters = rootParameter[0];
Ptr<SessionId>::Ref sessionId;
Ptr<SessionId>::Ref sessionId;
try{
sessionId = XmlRpcTools::extractSessionId(parameters);
} catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+20,
"missing session ID argument",
returnValue);
XmlRpcTools::markError(errorId+20, e.what(), returnValue);
return;
}
Ptr<UniqueId>::Ref playlistId;
Ptr<UniqueId>::Ref playlistId;
try{
playlistId = XmlRpcTools::extractPlaylistId(parameters);
} catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+2,
"missing playlist ID argument",
returnValue);
XmlRpcTools::markError(errorId+2, e.what(), returnValue);
return;
}
Ptr<time_duration>::Ref relativeOffset;
Ptr<UniqueId>::Ref playlistElementId;
try{
relativeOffset = XmlRpcTools::extractRelativeOffset(parameters);
playlistElementId = XmlRpcTools::extractPlaylistElementId(parameters);
} catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+3,
"missing relative offset argument",
returnValue);
XmlRpcTools::markError(errorId+3, e.what(), returnValue);
return;
}
@ -144,9 +138,7 @@ UpdateFadeInFadeOutMethod :: execute(
try{
fadeIn = XmlRpcTools::extractFadeIn(parameters);
} catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+4,
"missing fade in argument",
returnValue);
XmlRpcTools::markError(errorId+4, e.what(), returnValue);
return;
}
@ -154,9 +146,7 @@ UpdateFadeInFadeOutMethod :: execute(
try{
fadeOut = XmlRpcTools::extractFadeOut(parameters);
} catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+5,
"missing fade out argument",
returnValue);
XmlRpcTools::markError(errorId+5, e.what(), returnValue);
return;
}
@ -168,28 +158,23 @@ UpdateFadeInFadeOutMethod :: execute(
Ptr<Playlist>::Ref playlist;
try {
playlist = storage->getPlaylist(sessionId, playlistId);
} catch (XmlRpcException &e) {
std::string eMsg = "playlist does not exist:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+6, eMsg, returnValue);
} catch (Core::XmlRpcException &e) {
XmlRpcTools::markError(errorId+6, e.what(), returnValue);
return;
}
if (!playlist->isLocked()) {
XmlRpcTools::markError(errorId+7,
"playlist has not been opened for editing",
"playlist has not been opened for editing",
returnValue);
return;
}
Ptr<FadeInfo>::Ref fadeInfo(new FadeInfo(fadeIn, fadeOut));
try { // and finally, the beef
playlist->setFadeInfo(relativeOffset, fadeInfo);
playlist->setFadeInfo(playlistElementId, fadeInfo);
} catch(std::invalid_argument &e) {
XmlRpcTools::markError(errorId+8,
"no audio clip at the specified "
"relative offset",
returnValue);
XmlRpcTools::markError(errorId+8, e.what(), returnValue);
return;
}
}

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/UpdateFadeInFadeOutMethod.h,v $
------------------------------------------------------------------------------*/
@ -76,10 +76,9 @@ using namespace LiveSupport::Core;
* <ul>
* <li>sessionId - string - the session ID obtained via the login()
* method of the authentication client </li>
* <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>
* <li>playlistId - string - the unique ID of the playlist.</li>
* <li>playlistElementId - string - the unique ID of the playlist element
* to be removed.</li>
* <li>fadeIn - int - the length (in milliseconds) of the fade in. </li>
* <li>fadeOut - int - the length (in milliseconds) of the fade out. </li>
* </ul>
@ -90,16 +89,16 @@ using namespace LiveSupport::Core;
* <ul>
* <li>1601 - invalid argument format </li>
* <li>1602 - missing playlist ID argument </li>
* <li>1603 - missing relative offset argument </li>
* <li>1603 - missing playlist element ID argument </li>
* <li>1604 - missing fade in argument </li>
* <li>1605 - missing fade out argument </li>
* <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>1608 - error executing setFadeInfo() method </li>
* <li>1620 - missing session ID argument </li>
* </ul>
* @author $Author: fgerlits $
* @version $Revision: 1.4 $
* @version $Revision: 1.5 $
*/
class UpdateFadeInFadeOutMethod : public XmlRpc::XmlRpcServerMethod
{

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/UpdateFadeInFadeOutMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -179,11 +179,11 @@ UpdateFadeInFadeOutMethodTest :: firstTest(void)
rootParameter.setSize(1);
XmlRpc::XmlRpcValue result;
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = "0000000000000001";
parameters["relativeOffset"] = 90*60;
parameters["fadeIn"] = 0;
rootParameter[0] = parameters;
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = "0000000000000001";
parameters["playlistElementId"] = "0000000000009999";
parameters["fadeIn"] = 0;
rootParameter[0] = parameters;
result.clear();
try {
@ -220,11 +220,11 @@ UpdateFadeInFadeOutMethodTest :: firstTest(void)
CPPUNIT_FAIL("allowed update fade info for non-existent "
"playlist element");
} catch (XmlRpc::XmlRpcException &e) {
CPPUNIT_ASSERT(e.getCode() == 1608);// no audio clip at this rel offset
CPPUNIT_ASSERT(e.getCode() == 1608);// no such playlist element
}
parameters["relativeOffset"] = 0;
rootParameter[0] = parameters;
parameters["playlistElementId"] = "0000000000000101";
rootParameter[0] = parameters;
result.clear();
try {

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/UploadPlaylistMethod.h,v $
------------------------------------------------------------------------------*/
@ -84,7 +84,7 @@ using namespace LiveSupport::Core;
* If the upload is successful, the method returns an XML-RPC structure with
* the following members:
* <ul>
* <li>scheduleEntryId - int - the id of the schedule entry created
* <li>scheduleEntryId - string - the id of the schedule entry created
* by the upload </li>
* </ul>
*
@ -102,7 +102,7 @@ using namespace LiveSupport::Core;
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.9 $
* @version $Revision: 1.10 $
*/
class UploadPlaylistMethod : public XmlRpc::XmlRpcServerMethod
{

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.11 $
Version : $Revision: 1.12 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -135,7 +135,7 @@ ValidatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
Ptr<Playlist>::Ref playlist;
try {
playlist = storage->getPlaylist(sessionId, playlistId);
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
std::string eMsg = "playlist does not exist:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+3, eMsg, returnValue);

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.h,v $
------------------------------------------------------------------------------*/
@ -75,7 +75,7 @@ using namespace LiveSupport::Core;
* <ul>
* <li>sessionId - string - the session ID obtained via the login()
* method of the authentication client </li>
* <li>playlistId - int - the unique id of the playlist.</li>
* <li>playlistId - string - the unique id of the playlist.</li>
* </ul>
*
* The XML-RPC function returns an XML-RPC structure, containing the following
@ -95,7 +95,7 @@ using namespace LiveSupport::Core;
* <li>520 - missing session ID argument </li>
* </ul>
* @author $Author: fgerlits $
* @version $Revision: 1.4 $
* @version $Revision: 1.5 $
*/
class ValidatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
{

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/ValidatePlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -219,8 +219,8 @@ ValidatePlaylistMethodTest :: firstTest(void)
CPPUNIT_ASSERT(bool(result["valid"]));
result.clear();
parameter["relativeOffset"] = 0;
rootParameter[0] = parameter;
parameter["playlistElementId"] = "0000000000000101";
rootParameter[0] = parameter;
try {
removeAudioClipMethod->execute(rootParameter, result);
} catch (XmlRpc::XmlRpcException &e) {