added 7 scheduler methods to schedulerClient

This commit is contained in:
fgerlits 2005-02-07 21:35:21 +00:00
parent 3a71d1a29e
commit 892d7d132f
11 changed files with 859 additions and 134 deletions

View file

@ -20,8 +20,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# Author : $Author: maroy $
# Version : $Revision: 1.5 $
# Author : $Author: fgerlits $
# Version : $Revision: 1.6 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/schedulerClient/etc/Makefile.in,v $
#
# @configure_input@
@ -79,6 +79,11 @@ VPATH = ${SRC_DIR}
LIBXMLPP_CFLAGS=@LIBXMLPP_CFLAGS@
LIBXMLPP_LIBS=@LIBXMLPP_LIBS@
# TODO: move ICU flag determination to configure script
ICU_LIBS=`${USR_DIR}/bin/icu-config --ldflags --ldflags-toolutil --ldflags-icuio`
TAGLIB_LIBS =`${USR_DIR}/bin/taglib-config --libs`
TEST_RESULTS = ${DOC_DIR}/testResults.xml
# the text result XSLT has to be relative to the test result file, e.g. TMP_DIR
TEST_XSLT = ../etc/testResultToHtml.xsl
@ -106,6 +111,8 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
-I${INCLUDE_DIR} -I${TMP_DIR}
LDFLAGS = @LDFLAGS@ -pthread \
${LIBXMLPP_LIBS} \
${ICU_LIBS} \
${TAGLIB_LIBS} \
-L${USR_LIB_DIR} \
-L${CORE_LIB_DIR} \
-L${AUTHENTICATION_LIB_DIR} \

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.4 $
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/schedulerClient/include/LiveSupport/SchedulerClient/SchedulerClientInterface.h,v $
------------------------------------------------------------------------------*/
@ -41,6 +41,7 @@
#endif
#include <stdexcept>
#include <vector>
#include "boost/date_time/posix_time/posix_time.hpp"
#include "LiveSupport/Core/Ptr.h"
@ -48,10 +49,13 @@
#include "LiveSupport/Core/SessionId.h"
#include "LiveSupport/Core/ScheduleEntry.h"
#include "LiveSupport/Core/XmlRpcException.h"
#include "LiveSupport/Core/Playlist.h"
#include "LiveSupport/Core/AudioClip.h"
namespace LiveSupport {
namespace SchedulerClient {
using namespace boost::posix_time;
using namespace LiveSupport::Core;
@ -66,8 +70,8 @@ using namespace LiveSupport::Core;
/**
* An interface to access the scheduler daemon as a client.
*
* @author $Author: maroy $
* @version $Revision: 1.4 $
* @author $Author: fgerlits $
* @version $Revision: 1.5 $
*/
class SchedulerClientInterface
{
@ -89,7 +93,7 @@ class SchedulerClientInterface
* @return the current time at the scheduler server.
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual Ptr<const boost::posix_time::ptime>::Ref
virtual Ptr<const ptime>::Ref
getSchedulerTime(void) throw (XmlRpcException)
= 0;
@ -104,9 +108,9 @@ class SchedulerClientInterface
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual Ptr<UniqueId>::Ref
uploadPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref playlistId,
Ptr<boost::posix_time::ptime>::Ref playtime)
uploadPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref playlistId,
Ptr<ptime>::Ref playtime)
throw (XmlRpcException)
= 0;
@ -120,9 +124,9 @@ class SchedulerClientInterface
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref
displaySchedule(Ptr<SessionId>::Ref sessionId,
Ptr<boost::posix_time::ptime>::Ref from,
Ptr<boost::posix_time::ptime>::Ref to)
displaySchedule(Ptr<SessionId>::Ref sessionId,
Ptr<ptime>::Ref from,
Ptr<ptime>::Ref to)
throw (XmlRpcException)
= 0;
@ -139,6 +143,104 @@ class SchedulerClientInterface
throw (XmlRpcException)
= 0;
/**
* Add an audio clip to a playlist.
*
* @param sessionId a valid, authenticated session id.
* @param playlistId the id of the playlist.
* @param audioClipId the id of the audio clip.
* @param relativeOffset the number of seconds between the start
* of the playlist and the start of the audio clip.
* @return the unique ID of the newly created playlist element.
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual Ptr<UniqueId>::Ref
addAudioClipToPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref playlistId,
Ptr<UniqueId>::Ref audioClipId,
Ptr<time_duration>::Ref relativeOffset)
throw (XmlRpcException)
= 0;
/**
* Create a new playlist.
*
* @param sessionId a valid, authenticated session id.
* @return the newly created playlist.
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual Ptr<Playlist>::Ref
createPlaylist(Ptr<SessionId>::Ref sessionId)
throw (XmlRpcException)
= 0;
/**
* Delete a playlist.
*
* @param sessionId a valid, authenticated session id.
* @param playlistId the id of the playlist.
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual void
deletePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref playlistId)
throw (XmlRpcException)
= 0;
/**
* Return an audio clip.
*
* @param sessionId a valid, authenticated session id.
* @param audioClipId the id of the audio clip.
* @return the audio clip.
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual Ptr<AudioClip>::Ref
displayAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref audioClipId)
throw (XmlRpcException)
= 0;
/**
* Return a list of audio clips. This method returns the audio
* clips found by the latest search() on the storage client.
*
* @param sessionId a valid, authenticated session id.
* @return a std::vector of audio clips.
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref
displayAudioClips(Ptr<SessionId>::Ref sessionId)
throw (XmlRpcException)
= 0;
/**
* Return a playlist.
*
* @param sessionId a valid, authenticated session id.
* @param playlistId the id of the playlist.
* @return the playlist.
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual Ptr<Playlist>::Ref
displayPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref playlistId)
throw (XmlRpcException)
= 0;
/**
* Return a list of playlists. This method returns the playlists
* found by the latest search() on the storage client.
*
* @param sessionId a valid, authenticated session id.
* @return a std::vector of playlists.
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
displayPlaylists(Ptr<SessionId>::Ref sessionId)
throw (XmlRpcException)
= 0;
};

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.5 $
Author : $Author: fgerlits $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/schedulerClient/src/SchedulerDaemonXmlRpcClient.cxx,v $
------------------------------------------------------------------------------*/
@ -149,7 +149,7 @@ SchedulerDaemonXmlRpcClient :: getVersion(void)
xmlRpcResult.clear();
if (!xmlRpcClient.execute("getVersion", xmlRpcParams, xmlRpcResult)) {
throw XmlRpcCommunicationException(
throw Core::XmlRpcCommunicationException(
"cannot execute XML-RPC method 'getVersion'");
}
@ -157,21 +157,21 @@ SchedulerDaemonXmlRpcClient :: getVersion(void)
std::stringstream eMsg;
eMsg << "XML-RPC method 'getVersion' returned error message:\n"
<< xmlRpcResult;
throw XmlRpcMethodFaultException(eMsg.str());
throw Core::XmlRpcMethodFaultException(eMsg.str());
}
xmlRpcClient.close();
if (!xmlRpcResult.hasMember("version")
|| xmlRpcResult["version"].getType() != XmlRpcValue::TypeString) {
std::stringstream eMsg;
eMsg << "XML-RPC method 'getVersion' returned unexpected value:\n"
<< xmlRpcResult;
throw XmlRpcMethodResponseException(eMsg.str());
throw Core::XmlRpcMethodResponseException(eMsg.str());
}
result.reset(new std::string(xmlRpcResult["version"]));
xmlRpcClient.close();
return result;
}
@ -194,7 +194,7 @@ SchedulerDaemonXmlRpcClient :: getSchedulerTime(void)
xmlRpcResult.clear();
if (!xmlRpcClient.execute("getSchedulerTime", xmlRpcParams, xmlRpcResult)) {
throw XmlRpcCommunicationException(
throw Core::XmlRpcCommunicationException(
"cannot execute XML-RPC method 'getSchedulerTime'");
}
@ -202,15 +202,17 @@ SchedulerDaemonXmlRpcClient :: getSchedulerTime(void)
std::stringstream eMsg;
eMsg << "XML-RPC method 'getSchedulerTime' returned error message:\n"
<< xmlRpcResult;
throw XmlRpcMethodFaultException(eMsg.str());
throw Core::XmlRpcMethodFaultException(eMsg.str());
}
xmlRpcClient.close();
if (!xmlRpcResult.hasMember("schedulerTime")
|| xmlRpcResult["schedulerTime"].getType() != XmlRpcValue::TypeDateTime) {
std::stringstream eMsg;
eMsg << "XML-RPC method 'getSchedulerTime' returned unexpected value:\n"
<< xmlRpcResult;
throw XmlRpcMethodResponseException(eMsg.str());
throw Core::XmlRpcMethodResponseException(eMsg.str());
}
struct tm time = xmlRpcResult["schedulerTime"];
@ -218,11 +220,9 @@ SchedulerDaemonXmlRpcClient :: getSchedulerTime(void)
try {
result = TimeConversion::tmToPtime(&time);
} catch (std::out_of_range &e) {
throw XmlRpcException("time conversion error", e);
throw Core::XmlRpcException("time conversion error", e);
}
xmlRpcClient.close();
return result;
}
@ -254,7 +254,7 @@ SchedulerDaemonXmlRpcClient :: uploadPlaylist(
xmlRpcResult.clear();
if (!xmlRpcClient.execute("uploadPlaylist", xmlRpcParams, xmlRpcResult)) {
throw XmlRpcCommunicationException(
throw Core::XmlRpcCommunicationException(
"cannot execute XML-RPC method 'uploadPlaylist'");
}
@ -262,17 +262,17 @@ SchedulerDaemonXmlRpcClient :: uploadPlaylist(
std::stringstream eMsg;
eMsg << "XML-RPC method 'uploadPlaylist' returned error message:\n"
<< xmlRpcResult;
throw XmlRpcMethodFaultException(eMsg.str());
throw Core::XmlRpcMethodFaultException(eMsg.str());
}
xmlRpcClient.close();
try {
scheduleEntryId = XmlRpcTools::extractScheduleEntryId(xmlRpcResult);
} catch (std::invalid_argument &e) {
throw XmlRpcInvalidArgumentException(e);
throw Core::XmlRpcInvalidArgumentException(e);
}
xmlRpcClient.close();
return scheduleEntryId;
}
@ -304,7 +304,7 @@ SchedulerDaemonXmlRpcClient :: displaySchedule(
xmlRpcResult.clear();
if (!xmlRpcClient.execute("displaySchedule", xmlRpcParams, xmlRpcResult)) {
throw XmlRpcCommunicationException(
throw Core::XmlRpcCommunicationException(
"cannot execute XML-RPC method 'displaySchedule'");
}
@ -312,17 +312,17 @@ SchedulerDaemonXmlRpcClient :: displaySchedule(
std::stringstream eMsg;
eMsg << "XML-RPC method 'displaySchedule' returned error message:\n"
<< xmlRpcResult;
throw XmlRpcMethodFaultException(eMsg.str());
throw Core::XmlRpcMethodFaultException(eMsg.str());
}
xmlRpcClient.close();
try {
entries = XmlRpcTools::extractScheduleEntries(xmlRpcResult);
} catch (std::invalid_argument &e) {
throw XmlRpcInvalidArgumentException(e);
throw Core::XmlRpcInvalidArgumentException(e);
}
xmlRpcClient.close();
return entries;
}
@ -352,7 +352,7 @@ SchedulerDaemonXmlRpcClient :: removeFromSchedule(
if (!xmlRpcClient.execute("removeFromSchedule",
xmlRpcParams,
xmlRpcResult)) {
throw XmlRpcCommunicationException(
throw Core::XmlRpcCommunicationException(
"cannot execute XML-RPC method 'removeFromSchedule'");
}
@ -360,7 +360,340 @@ SchedulerDaemonXmlRpcClient :: removeFromSchedule(
std::stringstream eMsg;
eMsg << "XML-RPC method 'removeFromSchedule' returned error message:\n"
<< xmlRpcResult;
throw XmlRpcMethodFaultException(eMsg.str());
throw Core::XmlRpcMethodFaultException(eMsg.str());
}
xmlRpcClient.close();
}
/*------------------------------------------------------------------------------
* Add an audio clip to a playlist.
*----------------------------------------------------------------------------*/
Ptr<UniqueId>::Ref
SchedulerDaemonXmlRpcClient :: addAudioClipToPlaylist(
Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref playlistId,
Ptr<UniqueId>::Ref audioClipId,
Ptr<time_duration>::Ref relativeOffset)
throw (Core::XmlRpcException)
{
XmlRpcValue xmlRpcParams;
XmlRpcValue xmlRpcResult;
Ptr<const ptime>::Ref result;
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
xmlRpcPort,
xmlRpcUri->c_str(),
false);
XmlRpcTools::sessionIdToXmlRpcValue(sessionId, xmlRpcParams);
XmlRpcTools::playlistIdToXmlRpcValue(playlistId, xmlRpcParams);
XmlRpcTools::audioClipIdToXmlRpcValue(audioClipId, xmlRpcParams);
xmlRpcResult.clear();
if (!xmlRpcClient.execute("addAudioClipToPlaylist",
xmlRpcParams,
xmlRpcResult)) {
throw Core::XmlRpcCommunicationException(
"cannot execute XML-RPC method 'addAudioClipToPlaylist'");
}
if (xmlRpcClient.isFault()) {
std::stringstream eMsg;
eMsg << "XML-RPC method 'addAudioClipToPlaylist' returned "
"error message:\n"
<< xmlRpcResult;
throw Core::XmlRpcMethodFaultException(eMsg.str());
}
xmlRpcClient.close();
Ptr<UniqueId>::Ref playlistElementId;
try {
playlistElementId = XmlRpcTools::extractPlaylistElementId(xmlRpcResult);
} catch (std::invalid_argument &e) {
throw Core::XmlRpcInvalidArgumentException(e);
}
return playlistElementId;
}
/*------------------------------------------------------------------------------
* Create a new playlist.
*----------------------------------------------------------------------------*/
Ptr<Playlist>::Ref
SchedulerDaemonXmlRpcClient :: createPlaylist(
Ptr<SessionId>::Ref sessionId)
throw (Core::XmlRpcException)
{
XmlRpcValue xmlRpcParams;
XmlRpcValue xmlRpcResult;
Ptr<const ptime>::Ref result;
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
xmlRpcPort,
xmlRpcUri->c_str(),
false);
XmlRpcTools::sessionIdToXmlRpcValue(sessionId, xmlRpcParams);
xmlRpcResult.clear();
if (!xmlRpcClient.execute("createPlaylist",
xmlRpcParams,
xmlRpcResult)) {
throw Core::XmlRpcCommunicationException(
"cannot execute XML-RPC method 'createPlaylist'");
}
if (xmlRpcClient.isFault()) {
std::stringstream eMsg;
eMsg << "XML-RPC method 'createPlaylist' returned "
"error message:\n"
<< xmlRpcResult;
throw Core::XmlRpcMethodFaultException(eMsg.str());
}
xmlRpcClient.close();
Ptr<Playlist>::Ref playlist;
try {
playlist = XmlRpcTools::extractPlaylist(xmlRpcResult);
} catch (std::invalid_argument &e) {
throw Core::XmlRpcInvalidArgumentException(e);
}
return playlist;
}
/*------------------------------------------------------------------------------
* Delete a playlist.
*----------------------------------------------------------------------------*/
void
SchedulerDaemonXmlRpcClient :: deletePlaylist(
Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref playlistId)
throw (Core::XmlRpcException)
{
XmlRpcValue xmlRpcParams;
XmlRpcValue xmlRpcResult;
Ptr<const ptime>::Ref result;
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
xmlRpcPort,
xmlRpcUri->c_str(),
false);
XmlRpcTools::sessionIdToXmlRpcValue(sessionId, xmlRpcParams);
XmlRpcTools::playlistIdToXmlRpcValue(playlistId, xmlRpcParams);
xmlRpcResult.clear();
if (!xmlRpcClient.execute("deletePlaylist",
xmlRpcParams,
xmlRpcResult)) {
throw Core::XmlRpcCommunicationException(
"cannot execute XML-RPC method 'deletePlaylist'");
}
if (xmlRpcClient.isFault()) {
std::stringstream eMsg;
eMsg << "XML-RPC method 'deletePlaylist' returned error message:\n"
<< xmlRpcResult;
throw Core::XmlRpcMethodFaultException(eMsg.str());
}
}
/*------------------------------------------------------------------------------
* Return an audio clip.
*----------------------------------------------------------------------------*/
Ptr<AudioClip>::Ref
SchedulerDaemonXmlRpcClient :: displayAudioClip(
Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref audioClipId)
throw (Core::XmlRpcException)
{
XmlRpcValue xmlRpcParams;
XmlRpcValue xmlRpcResult;
Ptr<const ptime>::Ref result;
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
xmlRpcPort,
xmlRpcUri->c_str(),
false);
XmlRpcTools::sessionIdToXmlRpcValue(sessionId, xmlRpcParams);
XmlRpcTools::audioClipIdToXmlRpcValue(audioClipId, xmlRpcParams);
xmlRpcResult.clear();
if (!xmlRpcClient.execute("displayAudioClip",
xmlRpcParams,
xmlRpcResult)) {
throw Core::XmlRpcCommunicationException(
"cannot execute XML-RPC method 'displayAudioClip'");
}
if (xmlRpcClient.isFault()) {
std::stringstream eMsg;
eMsg << "XML-RPC method 'displayAudioClip' returned error message:\n"
<< xmlRpcResult;
throw Core::XmlRpcMethodFaultException(eMsg.str());
}
xmlRpcClient.close();
Ptr<AudioClip>::Ref audioClip;
try {
audioClip = XmlRpcTools::extractAudioClip(xmlRpcResult);
} catch (std::invalid_argument &e) {
throw Core::XmlRpcInvalidArgumentException(e);
}
return audioClip;
}
/*------------------------------------------------------------------------------
* Return a list of audio clips.
*----------------------------------------------------------------------------*/
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref
SchedulerDaemonXmlRpcClient :: displayAudioClips(
Ptr<SessionId>::Ref sessionId)
throw (Core::XmlRpcException)
{
XmlRpcValue xmlRpcParams;
XmlRpcValue xmlRpcResult;
Ptr<const ptime>::Ref result;
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
xmlRpcPort,
xmlRpcUri->c_str(),
false);
XmlRpcTools::sessionIdToXmlRpcValue(sessionId, xmlRpcParams);
xmlRpcResult.clear();
if (!xmlRpcClient.execute("displayAudioClips",
xmlRpcParams,
xmlRpcResult)) {
throw Core::XmlRpcCommunicationException(
"cannot execute XML-RPC method 'displayAudioClips'");
}
if (xmlRpcClient.isFault()) {
std::stringstream eMsg;
eMsg << "XML-RPC method 'displayAudioClips' returned error message:\n"
<< xmlRpcResult;
throw Core::XmlRpcMethodFaultException(eMsg.str());
}
xmlRpcClient.close();
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref audioClipVector;
try {
audioClipVector = XmlRpcTools::extractAudioClipVector(xmlRpcResult);
} catch (std::invalid_argument &e) {
throw Core::XmlRpcInvalidArgumentException(e);
}
return audioClipVector;
}
/*------------------------------------------------------------------------------
* Return a playlist.
*----------------------------------------------------------------------------*/
Ptr<Playlist>::Ref
SchedulerDaemonXmlRpcClient :: displayPlaylist(
Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref playlistId)
throw (Core::XmlRpcException)
{
XmlRpcValue xmlRpcParams;
XmlRpcValue xmlRpcResult;
Ptr<const ptime>::Ref result;
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
xmlRpcPort,
xmlRpcUri->c_str(),
false);
XmlRpcTools::sessionIdToXmlRpcValue(sessionId, xmlRpcParams);
XmlRpcTools::playlistIdToXmlRpcValue(playlistId, xmlRpcParams);
xmlRpcResult.clear();
if (!xmlRpcClient.execute("displayPlaylist",
xmlRpcParams,
xmlRpcResult)) {
throw Core::XmlRpcCommunicationException(
"cannot execute XML-RPC method 'displayPlaylist'");
}
if (xmlRpcClient.isFault()) {
std::stringstream eMsg;
eMsg << "XML-RPC method 'displayPlaylist' returned error message:\n"
<< xmlRpcResult;
throw Core::XmlRpcMethodFaultException(eMsg.str());
}
xmlRpcClient.close();
Ptr<Playlist>::Ref playlist;
try {
playlist = XmlRpcTools::extractPlaylist(xmlRpcResult);
} catch (std::invalid_argument &e) {
throw Core::XmlRpcInvalidArgumentException(e);
}
return playlist;
}
/*------------------------------------------------------------------------------
* Return a list of playlists.
*----------------------------------------------------------------------------*/
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
SchedulerDaemonXmlRpcClient :: displayPlaylists(
Ptr<SessionId>::Ref sessionId)
throw (Core::XmlRpcException)
{
XmlRpcValue xmlRpcParams;
XmlRpcValue xmlRpcResult;
Ptr<const ptime>::Ref result;
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
xmlRpcPort,
xmlRpcUri->c_str(),
false);
XmlRpcTools::sessionIdToXmlRpcValue(sessionId, xmlRpcParams);
xmlRpcResult.clear();
if (!xmlRpcClient.execute("displayPlaylists",
xmlRpcParams,
xmlRpcResult)) {
throw Core::XmlRpcCommunicationException(
"cannot execute XML-RPC method 'displayPlaylists'");
}
if (xmlRpcClient.isFault()) {
std::stringstream eMsg;
eMsg << "XML-RPC method 'displayPlaylists' returned error message:\n"
<< xmlRpcResult;
throw Core::XmlRpcMethodFaultException(eMsg.str());
}
xmlRpcClient.close();
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlistVector;
try {
playlistVector = XmlRpcTools::extractPlaylistVector(xmlRpcResult);
} catch (std::invalid_argument &e) {
throw Core::XmlRpcInvalidArgumentException(e);
}
return playlistVector;
}

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.4 $
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/schedulerClient/src/SchedulerDaemonXmlRpcClient.h,v $
------------------------------------------------------------------------------*/
@ -48,6 +48,9 @@
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/Configurable.h"
#include "LiveSupport/Core/Playlist.h"
#include "LiveSupport/Core/AudioClip.h"
#include "LiveSupport/SchedulerClient/SchedulerClientInterface.h"
@ -76,8 +79,8 @@ using namespace LiveSupport::Core;
*
* <pre><code>
* &lt;schedulerDaemonXmlRpcClient xmlRpcHost = "localhost"
* xmlRpcPort = "3344"
* xmlRpcUri = "/RC2"
* xmlRpcPort = "3344"
* xmlRpcUri = "/RC2"
* /&gt;
* </code></pre>
*
@ -90,8 +93,8 @@ using namespace LiveSupport::Core;
* <!ATTLIST schedulerDaemonXmlRpcClient xmlRpcUri CDATA #REQUIRED >
* </code></pre>
*
* @author $Author: maroy $
* @version $Revision: 1.4 $
* @author $Author: fgerlits $
* @version $Revision: 1.5 $
*/
class SchedulerDaemonXmlRpcClient :
virtual public Configurable,
@ -217,6 +220,97 @@ class SchedulerDaemonXmlRpcClient :
Ptr<UniqueId>::Ref scheduleEntryId)
throw (XmlRpcException);
/**
* Add an audio clip to a playlist.
*
* @param sessionId a valid, authenticated session id.
* @param playlistId the id of the playlist.
* @param audioClipId the id of the audio clip.
* @param relativeOffset the number of seconds between the start
* of the playlist and the start of the audio clip.
* @return the unique ID of the newly created playlist element.
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual Ptr<UniqueId>::Ref
addAudioClipToPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref playlistId,
Ptr<UniqueId>::Ref audioClipId,
Ptr<time_duration>::Ref relativeOffset)
throw (XmlRpcException);
/**
* Create a new playlist.
*
* @param sessionId a valid, authenticated session id.
* @return the newly created playlist.
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual Ptr<Playlist>::Ref
createPlaylist(Ptr<SessionId>::Ref sessionId)
throw (XmlRpcException);
/**
* Delete a playlist.
*
* @param sessionId a valid, authenticated session id.
* @param playlistId the id of the playlist.
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual void
deletePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref playlistId)
throw (XmlRpcException);
/**
* Return an audio clip.
*
* @param sessionId a valid, authenticated session id.
* @param audioClipId the id of the audio clip.
* @return the audio clip.
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual Ptr<AudioClip>::Ref
displayAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref audioClipId)
throw (XmlRpcException);
/**
* Return a list of audio clips. This method returns the audio
* clips found by the latest search() on the storage client.
*
* @param sessionId a valid, authenticated session id.
* @return a std::vector of audio clips.
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref
displayAudioClips(Ptr<SessionId>::Ref sessionId)
throw (XmlRpcException);
/**
* Return a playlist.
*
* @param sessionId a valid, authenticated session id.
* @param playlistId the id of the playlist.
* @return the playlist.
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual Ptr<Playlist>::Ref
displayPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref playlistId)
throw (XmlRpcException);
/**
* Return a list of playlists. This method returns the playlists
* found by the latest search() on the storage client.
*
* @param sessionId a valid, authenticated session id.
* @return a std::vector of playlists.
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
displayPlaylists(Ptr<SessionId>::Ref sessionId)
throw (XmlRpcException);
};

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.4 $
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/schedulerClient/src/SchedulerDaemonXmlRpcClientTest.cxx,v $
------------------------------------------------------------------------------*/
@ -43,6 +43,8 @@
#include <string>
#include <fstream>
#include <iostream>
#include <XmlRpcClient.h>
#include <XmlRpcValue.h>
#include "LiveSupport/Core/TimeConversion.h"
#include "LiveSupport/Core/XmlRpcMethodFaultException.h"
@ -116,23 +118,23 @@ SchedulerDaemonXmlRpcClientTest :: setUp(void) throw ()
CPPUNIT_FAIL("error parsing configuration file");
}
try {
Ptr<AuthenticationClientFactory>::Ref acf;
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfigFileName);
authentication = acf->getAuthenticationClient();
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("semantic error in authentication configuration file");
} catch (xmlpp::exception &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("error parsing authentication configuration file");
}
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
}
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
parameters["login"] = "root";
parameters["password"] = "q";
CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("sessionId"));
xmlRpcClient.close();
sessionId.reset(new SessionId(std::string(result["sessionId"])));
}
@ -142,11 +144,16 @@ SchedulerDaemonXmlRpcClientTest :: setUp(void) throw ()
void
SchedulerDaemonXmlRpcClientTest :: tearDown(void) throw ()
{
schedulerClient.reset();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
authentication->logout(sessionId);
sessionId.reset();
authentication.reset();
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
parameters["sessionId"] = sessionId->getId();
CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
xmlRpcClient.close();
}
@ -161,7 +168,7 @@ SchedulerDaemonXmlRpcClientTest :: getVersionTest(void)
Ptr<const std::string>::Ref version = schedulerClient->getVersion();
CPPUNIT_ASSERT(version.get());
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
}
@ -182,7 +189,7 @@ SchedulerDaemonXmlRpcClientTest :: getSchedulerTimeTest(void)
// assume that the scheduler and the client is in the same year
// this can break at new year's eve - so don't run the test then :)
CPPUNIT_ASSERT(time->date().year() == now->date().year());
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
}
@ -206,12 +213,66 @@ SchedulerDaemonXmlRpcClientTest :: displayScheduleEmptyTest(void)
entries = schedulerClient->displaySchedule(sessionId, from, to);
CPPUNIT_ASSERT(entries->empty());
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
}
/*------------------------------------------------------------------------------
* Test some simple playlist operations.
*----------------------------------------------------------------------------*/
void
SchedulerDaemonXmlRpcClientTest :: displayPlaylistTest(void)
throw (CPPUNIT_NS::Exception)
{
Ptr<Playlist>::Ref playlist;
Ptr<UniqueId>::Ref playlistId;
// the test assumes that
// * there is a playlist with the id of 1
// * there is no playlist with the id of 9999
// in the storage accessed by the scheduler daemon
playlistId.reset(new UniqueId(1));
CPPUNIT_ASSERT_NO_THROW(
playlist = schedulerClient->displayPlaylist(sessionId, playlistId)
);
CPPUNIT_ASSERT(playlist->getId()->getId() == 1);
playlistId.reset(new UniqueId(9999));
CPPUNIT_ASSERT_THROW(
playlist = schedulerClient->displayPlaylist(sessionId, playlistId),
Core::XmlRpcMethodFaultException
);
CPPUNIT_ASSERT_NO_THROW(
playlist = schedulerClient->createPlaylist(sessionId)
);
CPPUNIT_ASSERT(playlistId->getId() >= 0);
playlistId = playlist->getId();
CPPUNIT_ASSERT_NO_THROW(
playlist = schedulerClient->displayPlaylist(sessionId, playlistId)
);
CPPUNIT_ASSERT(*playlist->getId() == *playlistId);
CPPUNIT_ASSERT(playlist->getPlaylength()->total_seconds() == 0);
// This doesn't work yet: createPlaylist() opens the playlist for editing,
// and so far we have no way of saving it.
/*
CPPUNIT_ASSERT_NO_THROW(
schedulerClient->deletePlaylist(sessionId, playlistId)
);
CPPUNIT_ASSERT_THROW(
playlist = schedulerClient->displayPlaylist(sessionId, playlistId),
Core::XmlRpcMethodFaultException
);
*/
}
/*------------------------------------------------------------------------------
* Test playlist management functions.
*----------------------------------------------------------------------------*/
@ -261,7 +322,7 @@ SchedulerDaemonXmlRpcClientTest :: playlistMgmtTest(void)
schedulerClient->removeFromSchedule(sessionId, entryId);
entries = schedulerClient->displaySchedule(sessionId, from, to);
CPPUNIT_ASSERT(entries->empty());
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
}
@ -298,7 +359,7 @@ SchedulerDaemonXmlRpcClientTest :: xmlRpcErrorTest(void)
entryId = schedulerClient->uploadPlaylist(sessionId,
playlistId,
playtime);
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
@ -307,9 +368,9 @@ SchedulerDaemonXmlRpcClientTest :: xmlRpcErrorTest(void)
// try to upload the same entry again, for the same time
// this should result in an error
schedulerClient->uploadPlaylist(sessionId, playlistId, playtime);
} catch (LiveSupport::Core::XmlRpcMethodFaultException &e) {
} catch (Core::XmlRpcMethodFaultException &e) {
gotException = true;
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(gotException);
@ -322,7 +383,7 @@ SchedulerDaemonXmlRpcClientTest :: xmlRpcErrorTest(void)
schedulerClient->removeFromSchedule(sessionId, entryId);
entries = schedulerClient->displaySchedule(sessionId, from, to);
CPPUNIT_ASSERT(entries->empty());
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
@ -331,9 +392,9 @@ SchedulerDaemonXmlRpcClientTest :: xmlRpcErrorTest(void)
// and now, try to remove it again, which should result in an
// exception
schedulerClient->removeFromSchedule(sessionId, entryId);
} catch (LiveSupport::Core::XmlRpcMethodFaultException &e) {
} catch (Core::XmlRpcMethodFaultException &e) {
gotException = true;
} catch (XmlRpcException &e) {
} catch (Core::XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(gotException);

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.4 $
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/schedulerClient/src/SchedulerDaemonXmlRpcClientTest.h,v $
------------------------------------------------------------------------------*/
@ -62,8 +62,8 @@ using namespace LiveSupport::Authentication;
/**
* Unit test for the SchedulerDaemonXmlRpcClient class.
*
* @author $Author: maroy $
* @version $Revision: 1.4 $
* @author $Author: fgerlits $
* @version $Revision: 1.5 $
* @see SchedulerDaemonXmlRpcClient
*/
class SchedulerDaemonXmlRpcClientTest : public CPPUNIT_NS::TestFixture
@ -72,6 +72,7 @@ class SchedulerDaemonXmlRpcClientTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST(getVersionTest);
CPPUNIT_TEST(getSchedulerTimeTest);
CPPUNIT_TEST(displayScheduleEmptyTest);
CPPUNIT_TEST(displayPlaylistTest);
CPPUNIT_TEST(playlistMgmtTest);
CPPUNIT_TEST(xmlRpcErrorTest);
CPPUNIT_TEST_SUITE_END();
@ -82,11 +83,6 @@ class SchedulerDaemonXmlRpcClientTest : public CPPUNIT_NS::TestFixture
*/
Ptr<SchedulerDaemonXmlRpcClient>::Ref schedulerClient;
/**
* An authentication client.
*/
Ptr<AuthenticationClientInterface>::Ref authentication;
/**
* A session ID from the authentication client login() method.
*/
@ -134,6 +130,14 @@ class SchedulerDaemonXmlRpcClientTest : public CPPUNIT_NS::TestFixture
void
displayScheduleEmptyTest(void) throw (CPPUNIT_NS::Exception);
/**
* Test some simple playlist operations.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
displayPlaylistTest(void) throw (CPPUNIT_NS::Exception);
/**
* Test playlist management.
*