merging the scheduler_export branch (2137:2153) back to the trunk
This commit is contained in:
parent
872692eb2e
commit
58ef925f57
155 changed files with 3771 additions and 10880 deletions
|
@ -140,7 +140,8 @@ CORE_LIB_OBJS = ${TMP_DIR}/UniqueId.o \
|
|||
${TMP_DIR}/MetadataType.o \
|
||||
${TMP_DIR}/MetadataTypeContainer.o \
|
||||
${TMP_DIR}/OptionsContainer.o \
|
||||
${TMP_DIR}/FileTools.o
|
||||
${TMP_DIR}/FileTools.o \
|
||||
${TMP_DIR}/AsyncState.o
|
||||
|
||||
TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \
|
||||
${TMP_DIR}/FileToolsTest.o \
|
||||
|
@ -159,7 +160,8 @@ TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \
|
|||
${TMP_DIR}/Md5Test.o \
|
||||
${TMP_DIR}/XmlRpcToolsTest.o \
|
||||
${TMP_DIR}/SearchCriteriaTest.o \
|
||||
${TMP_DIR}/MetadataTypeContainerTest.o
|
||||
${TMP_DIR}/MetadataTypeContainerTest.o \
|
||||
${TMP_DIR}/AsyncStateTest.o
|
||||
|
||||
TEST_RUNNER_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \
|
||||
${TMP_DIR}/${PACKAGE_NAME}_en.res \
|
||||
|
|
|
@ -0,0 +1,220 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef LiveSupport_Core_AsyncState_h
|
||||
#define LiveSupport_Core_AsyncState_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#include <string>
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Core {
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* A class representing the state of an asynchronous process.
|
||||
*
|
||||
* It provides some constants, plus conversion methods to and from
|
||||
* strings (used when sending through XML-RPC methods).
|
||||
*
|
||||
* There are two sets of conversion methods, because the states have
|
||||
* different names in the storage server for backup-related stuff and
|
||||
* general transport stuff.
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class AsyncState
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* The possible states of an asynchronous process.
|
||||
*/
|
||||
typedef enum { innerInitState,
|
||||
innerPendingState,
|
||||
innerFinishedState,
|
||||
innerClosedState,
|
||||
innerFailedState,
|
||||
innerInvalidState } InnerState;
|
||||
/**
|
||||
* The value of this state.
|
||||
*/
|
||||
InnerState value;
|
||||
|
||||
/**
|
||||
* A private constructor.
|
||||
*/
|
||||
AsyncState(InnerState state) throw ()
|
||||
: value(state)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor; sets the state to "invalid".
|
||||
*/
|
||||
AsyncState(void) throw ()
|
||||
: value(innerInvalidState)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constant instance: init.
|
||||
*/
|
||||
static const AsyncState initState;
|
||||
|
||||
/**
|
||||
* Constant instance: pending.
|
||||
*/
|
||||
static const AsyncState pendingState;
|
||||
|
||||
/**
|
||||
* Constant instance: finished.
|
||||
*/
|
||||
static const AsyncState finishedState;
|
||||
|
||||
/**
|
||||
* Constant instance: closed.
|
||||
*/
|
||||
static const AsyncState closedState;
|
||||
|
||||
/**
|
||||
* Constant instance: failed.
|
||||
*/
|
||||
static const AsyncState failedState;
|
||||
|
||||
/**
|
||||
* Constant instance: invalid.
|
||||
*/
|
||||
static const AsyncState invalidState;
|
||||
|
||||
/**
|
||||
* Construct from a transport string.
|
||||
*
|
||||
* @param transportString a string used by the getTransportInfo
|
||||
* method of the storage server.
|
||||
* @return an AsyncState with the corresponding value.
|
||||
*/
|
||||
static AsyncState
|
||||
fromTransportString(const std::string & transportString)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Construct from a backup string.
|
||||
*
|
||||
* @param backupString a string used by the xxxxBackupCheck
|
||||
* method of the storage server.
|
||||
* @return an AsyncState with the corresponding value.
|
||||
*/
|
||||
static AsyncState
|
||||
fromBackupString(const std::string & backupString)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Convert to a transport string.
|
||||
*
|
||||
* @return a string used by the getTransportInfo method of the
|
||||
* storage server.
|
||||
*/
|
||||
Ptr<std::string>::Ref
|
||||
toTransportString(void) const throw ();
|
||||
|
||||
/**
|
||||
* Convert to a backup string.
|
||||
*
|
||||
* @return a string used by the xxxxBackupCheck method of the
|
||||
* storage server.
|
||||
*/
|
||||
Ptr<std::string>::Ref
|
||||
toBackupString(void) const throw ();
|
||||
|
||||
/**
|
||||
* Check for equality.
|
||||
*
|
||||
* @param other the other AsyncState to compare with.
|
||||
* @return true if the two states are equal.
|
||||
*/
|
||||
bool
|
||||
operator==(const AsyncState & other) const throw ()
|
||||
{
|
||||
return (value == other.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for inequality.
|
||||
*
|
||||
* @param other the other AsyncState to compare with.
|
||||
* @return true if the two states are not equal.
|
||||
*/
|
||||
bool
|
||||
operator!=(const AsyncState & other) const throw ()
|
||||
{
|
||||
return (value != other.value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Core
|
||||
} // namespace LiveSupport
|
||||
|
||||
/**
|
||||
* Print to an ostream.
|
||||
*
|
||||
* @param ostream the ostream to print to.
|
||||
* @param state the AsyncState to print.
|
||||
* @return a reference to the same ostream object.
|
||||
*/
|
||||
std::ostream&
|
||||
operator<<(std::ostream& ostream, const LiveSupport::Core::AsyncState state)
|
||||
throw ();
|
||||
|
||||
#endif // LiveSupport_Core_AsyncState_h
|
||||
|
|
@ -52,6 +52,8 @@
|
|||
#include "LiveSupport/Core/Playlist.h"
|
||||
#include "LiveSupport/Core/ScheduleEntry.h"
|
||||
#include "LiveSupport/Core/PlayLogEntry.h"
|
||||
#include "LiveSupport/Core/SearchCriteria.h"
|
||||
#include "LiveSupport/Core/AsyncState.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
|
@ -59,6 +61,7 @@ namespace Core {
|
|||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -556,6 +559,139 @@ class XmlRpcTools
|
|||
extractPassword(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Extract the search criteria from the XML-RPC parameters.
|
||||
*
|
||||
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||
* @return a search criteria that was found in the XML-RPC parameter.
|
||||
* @exception std::invalid_argument if there was no criteria
|
||||
* member in xmlRpcValue.
|
||||
*/
|
||||
static Ptr<SearchCriteria>::Ref
|
||||
extractSearchCriteria(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Convert a SearchCriteria to an XmlRpcValue.
|
||||
*
|
||||
* @param criteria the SearchCriteria to convert.
|
||||
* @param xmlRpcValue the output parameter holding the result of
|
||||
* the conversion.
|
||||
*/
|
||||
static void
|
||||
searchCriteriaToXmlRpcValue(
|
||||
Ptr<const SearchCriteria>::Ref criteria,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Extract a token from the XML-RPC parameters.
|
||||
*
|
||||
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||
* @return a string token that was found in the XML-RPC parameter.
|
||||
* @exception std::invalid_argument if there was no token
|
||||
* member in xmlRpcValue.
|
||||
*/
|
||||
static Ptr<Glib::ustring>::Ref
|
||||
extractToken(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Convert a string token to an XmlRpcValue.
|
||||
*
|
||||
* @param criteria the string token to convert.
|
||||
* @param xmlRpcValue the output parameter holding the result of
|
||||
* the conversion.
|
||||
*/
|
||||
static void
|
||||
tokenToXmlRpcValue(Ptr<const Glib::ustring>::Ref token,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Extract the backup status from the XML-RPC parameters.
|
||||
*
|
||||
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||
* @return an AsyncState that was found in the XML-RPC parameter.
|
||||
* @exception std::invalid_argument if there was no "status"
|
||||
* member in xmlRpcValue.
|
||||
*/
|
||||
static AsyncState
|
||||
extractBackupStatus(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Convert an AsyncState returned by one
|
||||
* of the backup methods to an XmlRpcValue.
|
||||
*
|
||||
* @param status the AsyncState to convert.
|
||||
* @param xmlRpcValue the output parameter holding the result of
|
||||
* the conversion.
|
||||
*/
|
||||
static void
|
||||
backupStatusToXmlRpcValue(AsyncState status,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Extract a URL string from the XML-RPC parameters.
|
||||
*
|
||||
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||
* @return a URL string that was found in the XML-RPC parameter.
|
||||
* @exception std::invalid_argument if there was no "url"
|
||||
* member in xmlRpcValue.
|
||||
*/
|
||||
static Ptr<Glib::ustring>::Ref
|
||||
extractUrl(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Convert a URL string to an XmlRpcValue.
|
||||
*
|
||||
* @param url the URL string to convert.
|
||||
* @param xmlRpcValue the output parameter holding the result of
|
||||
* the conversion.
|
||||
*/
|
||||
static void
|
||||
urlToXmlRpcValue(Ptr<const Glib::ustring>::Ref url,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Extract a path string from the XML-RPC parameters.
|
||||
*
|
||||
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||
* @return a path string that was found in the XML-RPC parameter.
|
||||
* @exception std::invalid_argument if there was no "path"
|
||||
* member in xmlRpcValue.
|
||||
*/
|
||||
static Ptr<Glib::ustring>::Ref
|
||||
extractPath(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Convert a path string to an XmlRpcValue.
|
||||
*
|
||||
* @param path the path string to convert.
|
||||
* @param xmlRpcValue the output parameter holding the result of
|
||||
* the conversion.
|
||||
*/
|
||||
static void
|
||||
pathToXmlRpcValue(Ptr<const Glib::ustring>::Ref path,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Convert a fault string to an XmlRpcValue.
|
||||
*
|
||||
* @param path the fault string to convert.
|
||||
* @param xmlRpcValue the output parameter holding the result of
|
||||
* the conversion.
|
||||
*/
|
||||
static void
|
||||
faultStringToXmlRpcValue(Ptr<const Glib::ustring>::Ref faultString,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ();
|
||||
};
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
|
201
livesupport/src/modules/core/src/AsyncState.cxx
Normal file
201
livesupport/src/modules/core/src/AsyncState.cxx
Normal file
|
@ -0,0 +1,201 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#include "LiveSupport/Core/AsyncState.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Constant instance: init.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const AsyncState AsyncState::initState(innerInitState);
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Constant instance: pending.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const AsyncState AsyncState::pendingState(innerPendingState);
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Constant instance: finished.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const AsyncState AsyncState::finishedState(innerFinishedState);
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Constant instance: closed.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const AsyncState AsyncState::closedState(innerClosedState);
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Constant instance: failed.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const AsyncState AsyncState::failedState(innerFailedState);
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Constant instance: invalid.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const AsyncState AsyncState::invalidState(innerInvalidState);
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct from a transport string.
|
||||
*----------------------------------------------------------------------------*/
|
||||
AsyncState
|
||||
AsyncState :: fromTransportString(const std::string & transportString)
|
||||
throw ()
|
||||
{
|
||||
if (transportString == "init") {
|
||||
return initState;
|
||||
|
||||
} else if (transportString == "pending" || transportString == "waiting") {
|
||||
return pendingState;
|
||||
|
||||
} else if (transportString == "finished") {
|
||||
return finishedState;
|
||||
|
||||
} else if (transportString == "closed") {
|
||||
return closedState;
|
||||
|
||||
} else if (transportString == "failed") {
|
||||
return failedState;
|
||||
}
|
||||
|
||||
return invalidState;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct from a backup string.
|
||||
*----------------------------------------------------------------------------*/
|
||||
AsyncState
|
||||
AsyncState :: fromBackupString(const std::string & backupString)
|
||||
throw ()
|
||||
{
|
||||
if (backupString == "working") {
|
||||
return pendingState;
|
||||
|
||||
} else if (backupString == "success") {
|
||||
return finishedState;
|
||||
|
||||
} else if (backupString == "fault") {
|
||||
return failedState;
|
||||
}
|
||||
|
||||
return invalidState;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert to a transport string.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<std::string>::Ref
|
||||
AsyncState :: toTransportString(void) const throw ()
|
||||
{
|
||||
Ptr<std::string>::Ref transportString(new std::string());
|
||||
|
||||
switch (value) {
|
||||
case innerInitState: *transportString = "init";
|
||||
break;
|
||||
|
||||
case innerPendingState: *transportString = "pending";
|
||||
break;
|
||||
|
||||
case innerFinishedState: *transportString = "finished";
|
||||
break;
|
||||
|
||||
case innerClosedState: *transportString = "closed";
|
||||
break;
|
||||
|
||||
case innerFailedState: *transportString = "failed";
|
||||
break;
|
||||
|
||||
case innerInvalidState: *transportString = "(invalid)";
|
||||
break;
|
||||
}
|
||||
|
||||
return transportString;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert to a backup string.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<std::string>::Ref
|
||||
AsyncState :: toBackupString(void) const throw ()
|
||||
{
|
||||
Ptr<std::string>::Ref backupString(new std::string());
|
||||
|
||||
switch (value) {
|
||||
case innerInitState: *backupString = "(init)";
|
||||
break;
|
||||
|
||||
case innerPendingState: *backupString = "working";
|
||||
break;
|
||||
|
||||
case innerFinishedState: *backupString = "success";
|
||||
break;
|
||||
|
||||
case innerClosedState: *backupString = "(closed)";
|
||||
break;
|
||||
|
||||
case innerFailedState: *backupString = "fault";
|
||||
break;
|
||||
|
||||
case innerInvalidState: *backupString = "(invalid)";
|
||||
break;
|
||||
}
|
||||
|
||||
return backupString;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Print to an ostream.
|
||||
*----------------------------------------------------------------------------*/
|
||||
std::ostream &
|
||||
operator<<(std::ostream & ostream, const LiveSupport::Core::AsyncState state)
|
||||
throw ()
|
||||
{
|
||||
Ptr<std::string>::Ref transportState = state.toTransportString();
|
||||
ostream << *transportState;
|
||||
return ostream;
|
||||
}
|
||||
|
133
livesupport/src/modules/core/src/AsyncStateTest.cxx
Normal file
133
livesupport/src/modules/core/src/AsyncStateTest.cxx
Normal file
|
@ -0,0 +1,133 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include "LiveSupport/Core/AsyncState.h"
|
||||
#include "AsyncStateTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(AsyncStateTest);
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
AsyncStateTest :: setUp(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
AsyncStateTest :: tearDown(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test the basic conversions.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
AsyncStateTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
AsyncState state = AsyncState::invalidState;
|
||||
Ptr<std::string>::Ref transportString;
|
||||
Ptr<std::string>::Ref backupString;
|
||||
|
||||
state = AsyncState::initState;
|
||||
transportString = state.toTransportString();
|
||||
CPPUNIT_ASSERT_EQUAL(AsyncState::fromTransportString(*transportString),
|
||||
state);
|
||||
|
||||
state = AsyncState::pendingState;
|
||||
transportString = state.toTransportString();
|
||||
backupString = state.toBackupString();
|
||||
CPPUNIT_ASSERT_EQUAL(AsyncState::fromTransportString(*transportString),
|
||||
state);
|
||||
CPPUNIT_ASSERT_EQUAL(AsyncState::fromBackupString(*backupString),
|
||||
state);
|
||||
|
||||
state = AsyncState::finishedState;
|
||||
transportString = state.toTransportString();
|
||||
backupString = state.toBackupString();
|
||||
CPPUNIT_ASSERT_EQUAL(AsyncState::fromTransportString(*transportString),
|
||||
state);
|
||||
CPPUNIT_ASSERT_EQUAL(AsyncState::fromBackupString(*backupString),
|
||||
state);
|
||||
|
||||
state = AsyncState::closedState;
|
||||
transportString = state.toTransportString();
|
||||
CPPUNIT_ASSERT_EQUAL(AsyncState::fromTransportString(*transportString),
|
||||
state);
|
||||
|
||||
state = AsyncState::failedState;
|
||||
transportString = state.toTransportString();
|
||||
backupString = state.toBackupString();
|
||||
CPPUNIT_ASSERT_EQUAL(AsyncState::fromTransportString(*transportString),
|
||||
state);
|
||||
CPPUNIT_ASSERT_EQUAL(AsyncState::fromBackupString(*backupString),
|
||||
state);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test the printing to an ostream.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
AsyncStateTest :: ostreamTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
AsyncState state = AsyncState::finishedState;
|
||||
|
||||
stream << state;
|
||||
CPPUNIT_ASSERT(stream.str() == "finished");
|
||||
}
|
||||
|
|
@ -26,8 +26,8 @@
|
|||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef RpcCreatePlaylistTest_h
|
||||
#define RpcCreatePlaylistTest_h
|
||||
#ifndef AsyncStateTest_h
|
||||
#define AsyncStateTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
|
@ -36,21 +36,11 @@
|
|||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
#include "BaseTestMethod.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
namespace Core {
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -61,35 +51,37 @@ using namespace LiveSupport::Core;
|
|||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the CreatePlaylistMethod class.
|
||||
* Unit test for the AsyncState class.
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
* @see CreatePlaylistMethod
|
||||
* @see AsyncState
|
||||
*/
|
||||
class RpcCreatePlaylistTest : public BaseTestMethod
|
||||
class AsyncStateTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(RpcCreatePlaylistTest);
|
||||
CPPUNIT_TEST_SUITE(AsyncStateTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST(ostreamTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
* Test the basic conversions.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Test the printing to an ostream.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
ostreamTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
@ -113,8 +105,8 @@ class RpcCreatePlaylistTest : public BaseTestMethod
|
|||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace Core
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // RpcCreatePlaylistTest_h
|
||||
#endif // AsyncStateTest_h
|
||||
|
|
@ -54,86 +54,119 @@ using namespace LiveSupport::Core;
|
|||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
namespace {
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the generic ID member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string idName = "id";
|
||||
const std::string idName = "id";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the playlist ID member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string playlistIdName = "playlistId";
|
||||
const std::string playlistIdName = "playlistId";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the audio clip ID member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string audioClipIdName = "audioClipId";
|
||||
const std::string audioClipIdName = "audioClipId";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the playlist element ID member in the XML-RPC param structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string playlistElementIdName = "playlistElementId";
|
||||
const std::string playlistElementIdName = "playlistElementId";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the relative offset member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string relativeOffsetName = "relativeOffset";
|
||||
const std::string relativeOffsetName = "relativeOffset";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the from member in the XML-RPC parameter structure.
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string fromTimeName = "from";
|
||||
const std::string fromTimeName = "from";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the to member in the XML-RPC parameter structure.
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string toTimeName = "to";
|
||||
const std::string toTimeName = "to";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the start member in the XML-RPC parameter structure.
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string startTimeName = "start";
|
||||
const std::string startTimeName = "start";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the end member in the XML-RPC parameter structure.
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string endTimeName = "end";
|
||||
const std::string endTimeName = "end";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the schedule entry id member in the XML-RPC parameter structure.
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string scheduleEntryIdName = "scheduleEntryId";
|
||||
const std::string scheduleEntryIdName = "scheduleEntryId";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the playtime member in the XML-RPC parameter structure.
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string playtimeName = "playtime";
|
||||
const std::string playtimeName = "playtime";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the fade in member in the XML-RPC parameter structure.
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string fadeInName = "fadeIn";
|
||||
const std::string fadeInName = "fadeIn";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the fade out member in the XML-RPC parameter structure.
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string fadeOutName = "fadeOut";
|
||||
const std::string fadeOutName = "fadeOut";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the session ID member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string sessionIdName = "sessionId";
|
||||
const std::string sessionIdName = "sessionId";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the login name member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string loginName = "login";
|
||||
const std::string loginName = "login";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the password member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string passwordName = "password";
|
||||
const std::string passwordName = "password";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the search criteria member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string searchCriteriaName = "criteria";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the token member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string tokenName = "token";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the backup status member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string backupStatusName = "status";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the URL member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string urlName = "url";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the path member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string pathName = "path";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the fault string member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string faultStringName = "faultString";
|
||||
|
||||
}
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
|
@ -870,3 +903,178 @@ XmlRpcTools :: extractPassword(
|
|||
return password;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Extract the search criteria from the XML-RPC parameters.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<SearchCriteria>::Ref
|
||||
XmlRpcTools :: extractSearchCriteria(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
if (!xmlRpcValue.hasMember(searchCriteriaName)
|
||||
|| xmlRpcValue[searchCriteriaName].getType()
|
||||
!= XmlRpc::XmlRpcValue::TypeStruct) {
|
||||
throw std::invalid_argument("missing or bad criteria argument");
|
||||
}
|
||||
XmlRpc::XmlRpcValue xmlCriteria = xmlRpcValue[searchCriteriaName];
|
||||
|
||||
Ptr<SearchCriteria>::Ref criteria(new SearchCriteria(xmlCriteria));
|
||||
|
||||
return criteria;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert a SearchCriteria to an XmlRpcValue
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcTools :: searchCriteriaToXmlRpcValue(
|
||||
Ptr<const SearchCriteria>::Ref criteria,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ()
|
||||
{
|
||||
returnValue[searchCriteriaName] = *criteria;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Extract a token from the XML-RPC parameters.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Glib::ustring>::Ref
|
||||
XmlRpcTools :: extractToken(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
if (!xmlRpcValue.hasMember(tokenName)
|
||||
|| xmlRpcValue[tokenName].getType()
|
||||
!= XmlRpc::XmlRpcValue::TypeString) {
|
||||
throw std::invalid_argument("missing or bad token argument");
|
||||
}
|
||||
|
||||
Ptr<Glib::ustring>::Ref token(new Glib::ustring(
|
||||
xmlRpcValue[tokenName] ));
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert a string token to an XmlRpcValue.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcTools :: tokenToXmlRpcValue(
|
||||
Ptr<const Glib::ustring>::Ref token,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ()
|
||||
{
|
||||
returnValue[tokenName] = std::string(*token);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Extract the backup status from the XML-RPC parameters.
|
||||
*----------------------------------------------------------------------------*/
|
||||
AsyncState
|
||||
XmlRpcTools :: extractBackupStatus(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
if (!xmlRpcValue.hasMember(backupStatusName)
|
||||
|| xmlRpcValue[backupStatusName].getType()
|
||||
!= XmlRpc::XmlRpcValue::TypeString) {
|
||||
throw std::invalid_argument("missing or bad status argument");
|
||||
}
|
||||
|
||||
AsyncState status = AsyncState::fromBackupString(
|
||||
xmlRpcValue[backupStatusName]);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert a StorageClientInterface::AsyncState returned by one
|
||||
* of the backup methods to an XmlRpcValue.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcTools :: backupStatusToXmlRpcValue(AsyncState status,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ()
|
||||
{
|
||||
Ptr<const std::string>::Ref stringValue = status.toBackupString();
|
||||
returnValue[backupStatusName] = *stringValue;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Extract a URL string from the XML-RPC parameters.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Glib::ustring>::Ref
|
||||
XmlRpcTools :: extractUrl(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
if (!xmlRpcValue.hasMember(urlName)
|
||||
|| xmlRpcValue[urlName].getType()
|
||||
!= XmlRpc::XmlRpcValue::TypeString) {
|
||||
throw std::invalid_argument("missing or bad url argument");
|
||||
}
|
||||
|
||||
Ptr<Glib::ustring>::Ref url(new Glib::ustring(
|
||||
xmlRpcValue[urlName] ));
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert a string token to an XmlRpcValue.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcTools :: urlToXmlRpcValue(
|
||||
Ptr<const Glib::ustring>::Ref url,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ()
|
||||
{
|
||||
returnValue[urlName] = std::string(*url);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Extract a path string from the XML-RPC parameters.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Glib::ustring>::Ref
|
||||
XmlRpcTools :: extractPath(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
if (!xmlRpcValue.hasMember(pathName)
|
||||
|| xmlRpcValue[pathName].getType()
|
||||
!= XmlRpc::XmlRpcValue::TypeString) {
|
||||
throw std::invalid_argument("missing or bad path argument");
|
||||
}
|
||||
|
||||
Ptr<Glib::ustring>::Ref path(new Glib::ustring(
|
||||
xmlRpcValue[pathName] ));
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert a string token to an XmlRpcValue.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcTools :: pathToXmlRpcValue(
|
||||
Ptr<const Glib::ustring>::Ref path,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ()
|
||||
{
|
||||
returnValue[pathName] = std::string(*path);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert a fault string to an XmlRpcValue.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcTools :: faultStringToXmlRpcValue(
|
||||
Ptr<const Glib::ustring>::Ref faultString,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ()
|
||||
{
|
||||
returnValue[faultStringName] = std::string(*faultString);
|
||||
}
|
||||
|
||||
|
|
|
@ -184,6 +184,129 @@ XmlRpcToolsTest :: firstTest(void)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Testing the search criteria marshaling/demarshaling.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcToolsTest :: secondTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<Glib::ustring>::Ref token(new Glib::ustring("this is a token"));
|
||||
XmlRpcValue xmlRpcToken;
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
XmlRpcTools::tokenToXmlRpcValue(token, xmlRpcToken)
|
||||
);
|
||||
|
||||
Ptr<Glib::ustring>::Ref otherToken;
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
otherToken = XmlRpcTools::extractToken(xmlRpcToken)
|
||||
);
|
||||
CPPUNIT_ASSERT(otherToken);
|
||||
|
||||
CPPUNIT_ASSERT(*token == *otherToken);
|
||||
|
||||
XmlRpcValue otherXmlRpcToken;
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
XmlRpcTools::tokenToXmlRpcValue(otherToken, otherXmlRpcToken)
|
||||
);
|
||||
|
||||
CPPUNIT_ASSERT(xmlRpcToken == otherXmlRpcToken);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Testing the search criteria marshaling/demarshaling.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcToolsTest :: searchCriteriaTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
std::string xmlStringCriteria =
|
||||
"<value><struct>"
|
||||
"<member>"
|
||||
"<name>criteria</name>"
|
||||
"<value><struct>"
|
||||
" <member>"
|
||||
" <name>filetype</name>"
|
||||
" <value>audioClip</value>"
|
||||
" </member>"
|
||||
" <member>"
|
||||
" <name>operator</name>"
|
||||
" <value>or</value>"
|
||||
" </member>"
|
||||
" <member>"
|
||||
" <name>limit</name>"
|
||||
" <value><int>5</int></value>"
|
||||
" </member>"
|
||||
" <member>"
|
||||
" <name>offset</name>"
|
||||
" <value><int>100</int></value>"
|
||||
" </member>"
|
||||
" <member>"
|
||||
" <name>conditions</name>"
|
||||
" <value><array><data>"
|
||||
" <value><struct>"
|
||||
" <member>"
|
||||
" <name>cat</name>"
|
||||
" <value><string>dc:title</string></value>"
|
||||
" </member>"
|
||||
" <member>"
|
||||
" <name>op</name>"
|
||||
" <value><string>partial</string></value>"
|
||||
" </member>"
|
||||
" <member>"
|
||||
" <name>val</name>"
|
||||
" <value>abcdef</value>"
|
||||
" </member>"
|
||||
" </struct></value>"
|
||||
" <value><struct>"
|
||||
" <member>"
|
||||
" <name>cat</name>"
|
||||
" <value><string>dc:creator</string></value>"
|
||||
" </member>"
|
||||
" <member>"
|
||||
" <name>op</name>"
|
||||
" <value><string>=</string></value>"
|
||||
" </member>"
|
||||
" <member>"
|
||||
" <name>val</name>"
|
||||
" <value>ABCDEF</value>"
|
||||
" </member>"
|
||||
" </struct></value>"
|
||||
" </data></array></value>"
|
||||
" </member>"
|
||||
"</struct></value>"
|
||||
"</member>"
|
||||
"</struct></value>";
|
||||
|
||||
XmlRpcValue xmlRpcCriteria;
|
||||
int offset = 0;
|
||||
xmlRpcCriteria.fromXml(xmlStringCriteria, &offset);
|
||||
|
||||
Ptr<SearchCriteria>::Ref criteria;
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
criteria = XmlRpcTools::extractSearchCriteria(xmlRpcCriteria)
|
||||
);
|
||||
CPPUNIT_ASSERT(criteria);
|
||||
|
||||
XmlRpcValue otherXmlRpcCriteria;
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
XmlRpcTools::searchCriteriaToXmlRpcValue(criteria, otherXmlRpcCriteria)
|
||||
);
|
||||
|
||||
CPPUNIT_ASSERT(xmlRpcCriteria == otherXmlRpcCriteria);
|
||||
|
||||
Ptr<SearchCriteria>::Ref otherCriteria;
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
otherCriteria = XmlRpcTools::extractSearchCriteria(otherXmlRpcCriteria)
|
||||
);
|
||||
CPPUNIT_ASSERT(otherCriteria);
|
||||
|
||||
CPPUNIT_ASSERT(*criteria == *otherCriteria);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Testing markError()
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -68,6 +68,8 @@ class XmlRpcToolsTest : public CPPUNIT_NS::TestFixture
|
|||
{
|
||||
CPPUNIT_TEST_SUITE(XmlRpcToolsTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST(secondTest);
|
||||
CPPUNIT_TEST(searchCriteriaTest);
|
||||
CPPUNIT_TEST(errorTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
|
@ -95,6 +97,22 @@ class XmlRpcToolsTest : public CPPUNIT_NS::TestFixture
|
|||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Another simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
secondTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Testing the search criteria marshaling/demarshaling.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
searchCriteriaTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Testing the method for error message packaging.
|
||||
*
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<?php
|
||||
header('LOCATION: html/ui_browser.php');
|
||||
header('LOCATION: /livesupport/htmlUI/var/html/ui_browser.php');
|
||||
?>
|
||||
|
|
|
@ -167,104 +167,6 @@ 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;
|
||||
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
|
|
|
@ -366,334 +366,3 @@ SchedulerDaemonXmlRpcClient :: removeFromSchedule(
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -252,98 +252,6 @@ class SchedulerDaemonXmlRpcClient :
|
|||
removeFromSchedule(Ptr<SessionId>::Ref sessionId,
|
||||
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);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -205,60 +205,6 @@ SchedulerDaemonXmlRpcClientTest :: displayScheduleEmptyTest(void)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* 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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -73,7 +73,6 @@ class SchedulerDaemonXmlRpcClientTest : public BaseTestMethod
|
|||
CPPUNIT_TEST(getVersionTest);
|
||||
CPPUNIT_TEST(getSchedulerTimeTest);
|
||||
CPPUNIT_TEST(displayScheduleEmptyTest);
|
||||
CPPUNIT_TEST(displayPlaylistTest);
|
||||
CPPUNIT_TEST(playlistMgmtTest);
|
||||
CPPUNIT_TEST(xmlRpcErrorTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
@ -117,14 +116,6 @@ class SchedulerDaemonXmlRpcClientTest : public BaseTestMethod
|
|||
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.
|
||||
*
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "LiveSupport/Core/SessionId.h"
|
||||
#include "LiveSupport/Core/XmlRpcException.h"
|
||||
#include "LiveSupport/Core/SearchCriteria.h"
|
||||
#include "LiveSupport/Core/AsyncState.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
|
@ -79,18 +80,6 @@ class StorageClientInterface
|
|||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* The possible states of an asynchronous process.
|
||||
* This is used by the asynchronous (groups of) methods:
|
||||
* remoteSearch, createBackup, restoreBackup,
|
||||
* uploadToHub, downloadFromHub.
|
||||
*/
|
||||
typedef enum { initState,
|
||||
pendingState,
|
||||
finishedState,
|
||||
closedState,
|
||||
failedState } AsyncState;
|
||||
|
||||
/**
|
||||
* Return the version string from the storage.
|
||||
*
|
||||
|
|
|
@ -1032,7 +1032,7 @@ TestStorageClient :: createBackupOpen(Ptr<SessionId>::Ref sessionId,
|
|||
/*------------------------------------------------------------------------------
|
||||
* Check the status of a storage backup.
|
||||
*----------------------------------------------------------------------------*/
|
||||
TestStorageClient :: AsyncState
|
||||
AsyncState
|
||||
TestStorageClient :: createBackupCheck(
|
||||
const Glib::ustring & token,
|
||||
Ptr<const Glib::ustring>::Ref & url,
|
||||
|
@ -1040,7 +1040,7 @@ TestStorageClient :: createBackupCheck(
|
|||
Ptr<const Glib::ustring>::Ref & errorMessage) const
|
||||
throw (XmlRpcException)
|
||||
{
|
||||
return pendingState;
|
||||
return AsyncState::pendingState;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1071,13 +1071,13 @@ TestStorageClient :: restoreBackupOpen(
|
|||
/*------------------------------------------------------------------------------
|
||||
* Check the status of a backup restore.
|
||||
*----------------------------------------------------------------------------*/
|
||||
TestStorageClient :: AsyncState
|
||||
AsyncState
|
||||
TestStorageClient :: restoreBackupCheck(
|
||||
const Glib::ustring & token,
|
||||
Ptr<const Glib::ustring>::Ref & errorMessage) const
|
||||
throw (XmlRpcException)
|
||||
{
|
||||
return pendingState;
|
||||
return AsyncState::pendingState;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1134,18 +1134,18 @@ TestStorageClient :: importPlaylist(
|
|||
/*------------------------------------------------------------------------------
|
||||
* Check the status of the asynchronous network transport operation.
|
||||
*----------------------------------------------------------------------------*/
|
||||
TestStorageClient :: AsyncState
|
||||
AsyncState
|
||||
TestStorageClient :: checkTransport(Ptr<const Glib::ustring>::Ref token,
|
||||
Ptr<Glib::ustring>::Ref errorMessage)
|
||||
throw (XmlRpcException)
|
||||
{
|
||||
if (token && *token == "fake_token") {
|
||||
return pendingState;
|
||||
return AsyncState::pendingState;
|
||||
} else {
|
||||
if (errorMessage) {
|
||||
errorMessage->assign("bad token");
|
||||
}
|
||||
return failedState;
|
||||
return AsyncState::failedState;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -491,11 +491,11 @@ TestStorageClientTest :: createBackupTest(void)
|
|||
Ptr<const Glib::ustring>::Ref url;
|
||||
Ptr<const Glib::ustring>::Ref path;
|
||||
Ptr<const Glib::ustring>::Ref errorMessage;
|
||||
StorageClientInterface::AsyncState state;
|
||||
AsyncState state;
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
state = tsc->createBackupCheck(*token, url, path, errorMessage);
|
||||
);
|
||||
CPPUNIT_ASSERT_EQUAL(StorageClientInterface::pendingState, state);
|
||||
CPPUNIT_ASSERT_EQUAL(AsyncState::pendingState, state);
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
tsc->createBackupClose(*token);
|
||||
|
@ -519,11 +519,11 @@ TestStorageClientTest :: restoreBackupTest(void)
|
|||
CPPUNIT_ASSERT(token);
|
||||
|
||||
Ptr<const Glib::ustring>::Ref errorMessage;
|
||||
StorageClientInterface::AsyncState state;
|
||||
AsyncState state;
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
state = tsc->restoreBackupCheck(*token, errorMessage);
|
||||
);
|
||||
CPPUNIT_ASSERT_EQUAL(StorageClientInterface::pendingState, state);
|
||||
CPPUNIT_ASSERT_EQUAL(AsyncState::pendingState, state);
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
tsc->restoreBackupClose(*token);
|
||||
|
@ -584,11 +584,11 @@ TestStorageClientTest :: remoteSearchTest(void)
|
|||
CPPUNIT_ASSERT(token);
|
||||
|
||||
Ptr<Glib::ustring>::Ref errorMessage(new Glib::ustring);
|
||||
StorageClientInterface::AsyncState state;
|
||||
AsyncState state;
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
state = tsc->checkTransport(token, errorMessage);
|
||||
);
|
||||
CPPUNIT_ASSERT_EQUAL(StorageClientInterface::pendingState, state);
|
||||
CPPUNIT_ASSERT_EQUAL(AsyncState::pendingState, state);
|
||||
|
||||
CPPUNIT_ASSERT_THROW(
|
||||
tsc->remoteSearchClose(token), XmlRpcMethodFaultException
|
||||
|
|
|
@ -2406,7 +2406,7 @@ WebStorageClient :: createBackupOpen(Ptr<SessionId>::Ref sessionId,
|
|||
/*------------------------------------------------------------------------------
|
||||
* Check the status of a storage backup.
|
||||
*----------------------------------------------------------------------------*/
|
||||
WebStorageClient :: AsyncState
|
||||
AsyncState
|
||||
WebStorageClient :: createBackupCheck(
|
||||
const Glib::ustring & token,
|
||||
Ptr<const Glib::ustring>::Ref & url,
|
||||
|
@ -2428,13 +2428,10 @@ WebStorageClient :: createBackupCheck(
|
|||
createBackupStatusParamName,
|
||||
XmlRpcValue::TypeString);
|
||||
|
||||
Ptr<Glib::ustring>::Ref status(new Glib::ustring(
|
||||
result[createBackupStatusParamName] ));
|
||||
std::string stateString = result[createBackupStatusParamName];
|
||||
AsyncState state = AsyncState::fromBackupString(stateString);
|
||||
|
||||
if (*status == "working") {
|
||||
return pendingState;
|
||||
|
||||
} else if (*status == "success") {
|
||||
if (state == AsyncState::finishedState) {
|
||||
checkStruct(createBackupCheckMethodName,
|
||||
result,
|
||||
createBackupUrlParamName,
|
||||
|
@ -2451,9 +2448,7 @@ WebStorageClient :: createBackupCheck(
|
|||
path.reset(new const Glib::ustring(
|
||||
std::string(result[createBackupTmpFileParamName]) ));
|
||||
|
||||
return finishedState;
|
||||
|
||||
} else if (*status == "fault") {
|
||||
} else if (state == AsyncState::failedState) {
|
||||
checkStruct(createBackupCheckMethodName,
|
||||
result,
|
||||
createBackupFaultStringParamName,
|
||||
|
@ -2462,17 +2457,17 @@ WebStorageClient :: createBackupCheck(
|
|||
errorMessage.reset(new Glib::ustring(
|
||||
std::string(result[createBackupFaultStringParamName])));
|
||||
|
||||
return failedState;
|
||||
|
||||
} else {
|
||||
} else if (state == AsyncState::invalidState) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "Incorrect value '"
|
||||
<< *status
|
||||
<< stateString
|
||||
<< "' returned by the XML-RPC method '"
|
||||
<< createBackupCheckMethodName
|
||||
<< "; expected one of 'working', 'success' or 'fault'.";
|
||||
throw XmlRpcMethodResponseException(eMsg.str());
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2529,7 +2524,7 @@ WebStorageClient :: restoreBackupOpen(
|
|||
/*------------------------------------------------------------------------------
|
||||
* Check the status of a backup restore.
|
||||
*----------------------------------------------------------------------------*/
|
||||
WebStorageClient :: AsyncState
|
||||
AsyncState
|
||||
WebStorageClient :: restoreBackupCheck(
|
||||
const Glib::ustring & token,
|
||||
Ptr<const Glib::ustring>::Ref & errorMessage) const
|
||||
|
@ -2555,16 +2550,10 @@ result = oldResult["status"];
|
|||
restoreBackupStatusParamName,
|
||||
XmlRpcValue::TypeString);
|
||||
|
||||
Ptr<Glib::ustring>::Ref status(new Glib::ustring(
|
||||
result[restoreBackupStatusParamName] ));
|
||||
std::string stateString = result[restoreBackupStatusParamName];
|
||||
AsyncState state = AsyncState::fromBackupString(stateString);
|
||||
|
||||
if (*status == "working") {
|
||||
return pendingState;
|
||||
|
||||
} else if (*status == "success") {
|
||||
return finishedState;
|
||||
|
||||
} else if (*status == "fault") {
|
||||
if (state == AsyncState::failedState) {
|
||||
checkStruct(restoreBackupCheckMethodName,
|
||||
result,
|
||||
restoreBackupFaultStringParamName,
|
||||
|
@ -2573,17 +2562,17 @@ result = oldResult["status"];
|
|||
errorMessage.reset(new Glib::ustring(
|
||||
std::string(result[restoreBackupFaultStringParamName])));
|
||||
|
||||
return failedState;
|
||||
|
||||
} else {
|
||||
} else if (state == AsyncState::invalidState) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "Incorrect value '"
|
||||
<< *status
|
||||
<< stateString
|
||||
<< "' returned by the XML-RPC method '"
|
||||
<< restoreBackupCheckMethodName
|
||||
<< "; expected one of 'working', 'success' or 'fault'.";
|
||||
throw XmlRpcMethodResponseException(eMsg.str());
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2747,7 +2736,7 @@ WebStorageClient :: importPlaylist(
|
|||
/*------------------------------------------------------------------------------
|
||||
* Check the status of the asynchronous network transport operation.
|
||||
*----------------------------------------------------------------------------*/
|
||||
WebStorageClient :: AsyncState
|
||||
AsyncState
|
||||
WebStorageClient :: checkTransport(Ptr<const Glib::ustring>::Ref token,
|
||||
Ptr<Glib::ustring>::Ref errorMessage)
|
||||
throw (XmlRpcException)
|
||||
|
@ -2766,16 +2755,10 @@ WebStorageClient :: checkTransport(Ptr<const Glib::ustring>::Ref token,
|
|||
checkTransportStateParamName,
|
||||
XmlRpcValue::TypeString);
|
||||
|
||||
std::string state = result[checkTransportStateParamName];
|
||||
if (state == "init") {
|
||||
return initState;
|
||||
} else if (state == "pending" || state == "waiting") {
|
||||
return pendingState;
|
||||
} else if (state == "finished") {
|
||||
return finishedState;
|
||||
} else if (state == "closed") {
|
||||
return closedState;
|
||||
} else if (state == "failed") {
|
||||
std::string stateString = result[checkTransportStateParamName];
|
||||
AsyncState state = AsyncState::fromTransportString(stateString);
|
||||
|
||||
if (state == AsyncState::failedState) {
|
||||
if (errorMessage) {
|
||||
checkStruct(checkTransportMethodName,
|
||||
result,
|
||||
|
@ -2784,8 +2767,8 @@ WebStorageClient :: checkTransport(Ptr<const Glib::ustring>::Ref token,
|
|||
errorMessage->assign(std::string(
|
||||
result[checkTransportErrorMessageParamName]));
|
||||
}
|
||||
return failedState;
|
||||
} else {
|
||||
|
||||
} else if (state == AsyncState::invalidState) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "Unrecognized transport state returned by XML-RPC method '"
|
||||
<< checkTransportMethodName
|
||||
|
@ -2793,6 +2776,8 @@ WebStorageClient :: checkTransport(Ptr<const Glib::ustring>::Ref token,
|
|||
<< result;
|
||||
throw XmlRpcMethodResponseException(eMsg.str());
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -860,7 +860,7 @@ WebStorageClientTest :: createBackupTest(void)
|
|||
Ptr<const Glib::ustring>::Ref url;
|
||||
Ptr<const Glib::ustring>::Ref path;
|
||||
Ptr<const Glib::ustring>::Ref errorMessage;
|
||||
StorageClientInterface::AsyncState state;
|
||||
AsyncState state;
|
||||
|
||||
int iterations = 20;
|
||||
do {
|
||||
|
@ -869,12 +869,12 @@ WebStorageClientTest :: createBackupTest(void)
|
|||
CPPUNIT_ASSERT_NO_THROW(
|
||||
state = wsc->createBackupCheck(*token, url, path, errorMessage);
|
||||
);
|
||||
CPPUNIT_ASSERT(state == StorageClientInterface::pendingState
|
||||
|| state == StorageClientInterface::finishedState
|
||||
|| state == StorageClientInterface::failedState);
|
||||
} while (--iterations && state == StorageClientInterface::pendingState);
|
||||
CPPUNIT_ASSERT(state == AsyncState::pendingState
|
||||
|| state == AsyncState::finishedState
|
||||
|| state == AsyncState::failedState);
|
||||
} while (--iterations && state == AsyncState::pendingState);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(StorageClientInterface::finishedState, state);
|
||||
CPPUNIT_ASSERT_EQUAL(AsyncState::finishedState, state);
|
||||
// TODO: test accessibility of the URL?
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
|
@ -919,7 +919,7 @@ WebStorageClientTest :: restoreBackupTest(void)
|
|||
CPPUNIT_ASSERT(token);
|
||||
|
||||
Ptr<const Glib::ustring>::Ref errorMessage;
|
||||
StorageClientInterface::AsyncState state;
|
||||
AsyncState state;
|
||||
|
||||
int iterations = 20;
|
||||
do {
|
||||
|
@ -928,12 +928,12 @@ WebStorageClientTest :: restoreBackupTest(void)
|
|||
CPPUNIT_ASSERT_NO_THROW(
|
||||
state = wsc->restoreBackupCheck(*token, errorMessage);
|
||||
);
|
||||
CPPUNIT_ASSERT(state == StorageClientInterface::pendingState
|
||||
|| state == StorageClientInterface::finishedState
|
||||
|| state == StorageClientInterface::failedState);
|
||||
} while (--iterations && state == StorageClientInterface::pendingState);
|
||||
CPPUNIT_ASSERT(state == AsyncState::pendingState
|
||||
|| state == AsyncState::finishedState
|
||||
|| state == AsyncState::failedState);
|
||||
} while (--iterations && state == AsyncState::pendingState);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(StorageClientInterface::finishedState, state);
|
||||
CPPUNIT_ASSERT_EQUAL(AsyncState::finishedState, state);
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
wsc->createBackupClose(*token);
|
||||
|
@ -1077,7 +1077,7 @@ WebStorageClientTest :: remoteSearchTest(void)
|
|||
);
|
||||
|
||||
Ptr<Glib::ustring>::Ref errorMessage(new Glib::ustring);
|
||||
StorageClientInterface::AsyncState state;
|
||||
AsyncState state;
|
||||
|
||||
int iterations = 20;
|
||||
do {
|
||||
|
@ -1086,12 +1086,12 @@ WebStorageClientTest :: remoteSearchTest(void)
|
|||
CPPUNIT_ASSERT_NO_THROW(
|
||||
state = wsc->checkTransport(token, errorMessage);
|
||||
);
|
||||
CPPUNIT_ASSERT(state == StorageClientInterface::initState
|
||||
|| state == StorageClientInterface::pendingState
|
||||
|| state == StorageClientInterface::finishedState);
|
||||
} while (--iterations && state != StorageClientInterface::finishedState);
|
||||
CPPUNIT_ASSERT(state == AsyncState::initState
|
||||
|| state == AsyncState::pendingState
|
||||
|| state == AsyncState::finishedState);
|
||||
} while (--iterations && state != AsyncState::finishedState);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(StorageClientInterface::finishedState, state);
|
||||
CPPUNIT_ASSERT_EQUAL(AsyncState::finishedState, state);
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
wsc->remoteSearchClose(token);
|
||||
|
|
|
@ -153,8 +153,7 @@ BackupList :: add(const Glib::ustring & title,
|
|||
Ptr<const Glib::ustring>::Ref path;
|
||||
Ptr<const Glib::ustring>::Ref errorMessage;
|
||||
|
||||
StorageClientInterface::AsyncState status
|
||||
= storage->createBackupCheck(token,
|
||||
AsyncState status = storage->createBackupCheck(token,
|
||||
url,
|
||||
path,
|
||||
errorMessage);
|
||||
|
@ -302,7 +301,7 @@ BackupList :: update(Gtk::TreeIter iter) throw (XmlRpcException)
|
|||
Ptr<const Glib::ustring>::Ref path;
|
||||
Ptr<const Glib::ustring>::Ref errorMessage;
|
||||
|
||||
StorageClientInterface::AsyncState status = storage->createBackupCheck(
|
||||
AsyncState status = storage->createBackupCheck(
|
||||
iter->get_value(modelColumns.tokenColumn),
|
||||
url,
|
||||
path,
|
||||
|
@ -317,16 +316,15 @@ BackupList :: update(Gtk::TreeIter iter) throw (XmlRpcException)
|
|||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
BackupList :: setStatus(Gtk::TreeIter iter,
|
||||
StorageClientInterface::AsyncState status,
|
||||
AsyncState status,
|
||||
Ptr<const Glib::ustring>::Ref url,
|
||||
Ptr<const Glib::ustring>::Ref errorMessage)
|
||||
throw ()
|
||||
{
|
||||
switch (status) {
|
||||
case StorageClientInterface::pendingState:
|
||||
if (status == AsyncState::pendingState) {
|
||||
return false;
|
||||
|
||||
case StorageClientInterface::finishedState:
|
||||
} else if (status == AsyncState::finishedState) {
|
||||
iter->set_value(modelColumns.statusColumn,
|
||||
successStatusKey);
|
||||
iter->set_value(modelColumns.statusDisplayColumn,
|
||||
|
@ -335,18 +333,19 @@ BackupList :: setStatus(Gtk::TreeIter iter,
|
|||
*url);
|
||||
return true;
|
||||
|
||||
case StorageClientInterface::failedState:
|
||||
} else if (status == AsyncState::failedState) {
|
||||
iter->set_value(modelColumns.statusColumn,
|
||||
faultStatusKey);
|
||||
iter->set_value(modelColumns.statusDisplayColumn,
|
||||
*formatMessage(faultStatusKey, *errorMessage));
|
||||
return false;
|
||||
|
||||
default:
|
||||
} else {
|
||||
std::cerr << "Impossible status: '" << status
|
||||
<< "' in BackupList::setStatus()." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ class BackupList : public Gtk::VBox,
|
|||
*/
|
||||
bool
|
||||
setStatus(Gtk::TreeIter iter,
|
||||
StorageClientInterface::AsyncState status,
|
||||
AsyncState status,
|
||||
Ptr<const Glib::ustring>::Ref url,
|
||||
Ptr<const Glib::ustring>::Ref errorMessage)
|
||||
throw ();
|
||||
|
|
|
@ -66,7 +66,7 @@ RestoreBackupWindow :: RestoreBackupWindow (
|
|||
bundle,
|
||||
""),
|
||||
fileName(fileName),
|
||||
currentState(StorageClientInterface::pendingState)
|
||||
currentState(AsyncState::pendingState)
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
|
@ -183,7 +183,7 @@ inline void
|
|||
RestoreBackupWindow :: signalError(const Glib::ustring & errorMessage)
|
||||
throw ()
|
||||
{
|
||||
currentState = StorageClientInterface::failedState;
|
||||
currentState = AsyncState::failedState;
|
||||
displayMessage("errorMessage", errorMessage);
|
||||
restoreBackupClose();
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ RestoreBackupWindow :: restoreBackupOpen(void) throw ()
|
|||
return;
|
||||
}
|
||||
|
||||
currentState = StorageClientInterface::pendingState;
|
||||
currentState = AsyncState::pendingState;
|
||||
displayMessage("pendingMessage", *fileName);
|
||||
setTimer();
|
||||
}
|
||||
|
@ -232,19 +232,14 @@ RestoreBackupWindow :: restoreBackupCheck(void) throw ()
|
|||
return;
|
||||
}
|
||||
|
||||
switch (currentState) {
|
||||
case StorageClientInterface::finishedState:
|
||||
if (currentState == AsyncState::finishedState) {
|
||||
displayMessage("finishedMessage");
|
||||
restoreBackupClose();
|
||||
break;
|
||||
|
||||
case StorageClientInterface::failedState:
|
||||
} else if (currentState == AsyncState::failedState) {
|
||||
displayMessage("errorMessage",
|
||||
*errorMessage);
|
||||
restoreBackupClose();
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -280,7 +275,7 @@ RestoreBackupWindow :: restoreBackupClose(void) throw ()
|
|||
bool
|
||||
RestoreBackupWindow :: onUpdateTime(void) throw ()
|
||||
{
|
||||
if (currentState == StorageClientInterface::pendingState) {
|
||||
if (currentState == AsyncState::pendingState) {
|
||||
restoreBackupCheck();
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -92,7 +92,7 @@ class RestoreBackupWindow : public GuiWindow
|
|||
/**
|
||||
* The current state of the upload task.
|
||||
*/
|
||||
StorageClientInterface::AsyncState currentState;
|
||||
AsyncState currentState;
|
||||
|
||||
/**
|
||||
* The token of the upload task.
|
||||
|
|
|
@ -558,7 +558,7 @@ SearchWindow :: remoteSearchClose(void)
|
|||
storage = gLiveSupport->getStorageClient();
|
||||
Ptr<SessionId>::Ref sessionId = gLiveSupport->getSessionId();
|
||||
|
||||
StorageClientInterface::AsyncState state;
|
||||
AsyncState state;
|
||||
Ptr<Glib::ustring>::Ref errorMessage;
|
||||
try {
|
||||
state = storage->checkTransport(remoteSearchToken, errorMessage);
|
||||
|
@ -571,14 +571,7 @@ SearchWindow :: remoteSearchClose(void)
|
|||
|
||||
Ptr<GLiveSupport::PlayableList>::Ref results;
|
||||
|
||||
switch (state) {
|
||||
case StorageClientInterface::initState :
|
||||
break;
|
||||
|
||||
case StorageClientInterface::pendingState :
|
||||
break;
|
||||
|
||||
case StorageClientInterface::finishedState :
|
||||
if (state == AsyncState::finishedState) {
|
||||
try {
|
||||
storage->remoteSearchClose(remoteSearchToken);
|
||||
} catch (XmlRpcException &e) {
|
||||
|
@ -599,17 +592,14 @@ SearchWindow :: remoteSearchClose(void)
|
|||
}
|
||||
|
||||
displaySearchResults(results, remoteSearchResults);
|
||||
break;
|
||||
|
||||
case StorageClientInterface::closedState :
|
||||
} else if (state == AsyncState::closedState) {
|
||||
remoteSearchToken.reset();
|
||||
displayMessage("remoteSearchErrorMsg", remoteSearchResults);
|
||||
break;
|
||||
|
||||
case StorageClientInterface::failedState :
|
||||
} else if (state == AsyncState::failedState) {
|
||||
remoteSearchToken.reset();
|
||||
displayMessage(*errorMessage, remoteSearchResults);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,8 +218,7 @@ TransportList :: add(const Glib::ustring & title,
|
|||
|
||||
Ptr<Glib::ustring>::Ref tokenPtr(new Glib::ustring(token));
|
||||
Ptr<Glib::ustring>::Ref errorMsg(new Glib::ustring);
|
||||
StorageClientInterface::AsyncState
|
||||
state = storage->checkTransport(tokenPtr,
|
||||
AsyncState state = storage->checkTransport(tokenPtr,
|
||||
errorMsg);
|
||||
|
||||
Gtk::TreeRow row = *treeModel->append();
|
||||
|
@ -321,8 +320,7 @@ TransportList :: update(Gtk::TreeIter iter) throw (XmlRpcException)
|
|||
Ptr<StorageClientInterface>::Ref
|
||||
storage = gLiveSupport->getStorageClient();
|
||||
Ptr<Glib::ustring>::Ref errorMsg(new Glib::ustring);
|
||||
StorageClientInterface::AsyncState
|
||||
status = storage->checkTransport(
|
||||
AsyncState status = storage->checkTransport(
|
||||
iter->get_value(modelColumns.tokenColumn),
|
||||
errorMsg);
|
||||
|
||||
|
@ -335,41 +333,39 @@ TransportList :: update(Gtk::TreeIter iter) throw (XmlRpcException)
|
|||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
TransportList :: setStatus(Gtk::TreeIter iter,
|
||||
StorageClientInterface::AsyncState status,
|
||||
AsyncState status,
|
||||
Ptr<const Glib::ustring>::Ref errorMsg)
|
||||
throw ()
|
||||
{
|
||||
switch (status) {
|
||||
case StorageClientInterface::initState:
|
||||
|
||||
case StorageClientInterface::pendingState:
|
||||
if (status == AsyncState::pendingState) {
|
||||
iter->set_value(modelColumns.statusColumn,
|
||||
workingStatusKey);
|
||||
iter->set_value(modelColumns.statusDisplayColumn,
|
||||
*getResourceUstring(workingStatusKey));
|
||||
return false;
|
||||
|
||||
case StorageClientInterface::finishedState:
|
||||
|
||||
case StorageClientInterface::closedState:
|
||||
} else if (status == AsyncState::finishedState
|
||||
|| status == AsyncState::closedState) {
|
||||
iter->set_value(modelColumns.statusColumn,
|
||||
successStatusKey);
|
||||
iter->set_value(modelColumns.statusDisplayColumn,
|
||||
*getResourceUstring(successStatusKey));
|
||||
return true;
|
||||
|
||||
case StorageClientInterface::failedState:
|
||||
} else if (status == AsyncState::failedState) {
|
||||
iter->set_value(modelColumns.statusColumn,
|
||||
faultStatusKey);
|
||||
iter->set_value(modelColumns.statusDisplayColumn,
|
||||
*formatMessage(faultStatusKey, *errorMsg));
|
||||
return false;
|
||||
|
||||
default: std::cerr << "Impossible status: '" << status
|
||||
} else {
|
||||
std::cerr << "Impossible status: '" << status
|
||||
<< "' in TransportList::setStatus()."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ class TransportList : public Gtk::VBox,
|
|||
*/
|
||||
bool
|
||||
setStatus(Gtk::TreeIter iter,
|
||||
StorageClientInterface::AsyncState status,
|
||||
AsyncState status,
|
||||
Ptr<const Glib::ustring>::Ref errorMsg
|
||||
= Ptr<const Glib::ustring>::Ref())
|
||||
throw ();
|
||||
|
|
|
@ -198,6 +198,7 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
|
|||
${LIBODBCXX_CFLAGS} \
|
||||
${GSTREAMER_CFLAGS} \
|
||||
${TAGLIB_CFLAGS} \
|
||||
${LIBTAR_CFLAGS} \
|
||||
-I${USR_INCLUDE_DIR} \
|
||||
-I${BOOST_INCLUDE_DIR} \
|
||||
-I${CORE_INCLUDE_DIR} \
|
||||
|
@ -215,6 +216,7 @@ LDFLAGS = @LDFLAGS@ -pthread \
|
|||
${CURL_LIBS} \
|
||||
${ICU_LIBS} \
|
||||
${TAGLIB_LIBS} \
|
||||
${LIBTAR_LIBS} \
|
||||
-L${USR_LIB_DIR} \
|
||||
-L${CORE_LIB_DIR} \
|
||||
-L${AUTHENTICATION_LIB_DIR} \
|
||||
|
@ -234,31 +236,24 @@ SCHEDULER_OBJS = ${TMP_DIR}/SignalDispatcher.o \
|
|||
${TMP_DIR}/GetVersionMethod.o \
|
||||
${TMP_DIR}/UploadPlaylistMethod.o \
|
||||
${TMP_DIR}/DisplayScheduleMethod.o \
|
||||
${TMP_DIR}/DisplayPlaylistMethod.o \
|
||||
${TMP_DIR}/RemoveFromScheduleMethod.o \
|
||||
${TMP_DIR}/RescheduleMethod.o \
|
||||
${TMP_DIR}/ScheduleFactory.o \
|
||||
${TMP_DIR}/PostgresqlSchedule.o \
|
||||
${TMP_DIR}/DisplayPlaylistsMethod.o \
|
||||
${TMP_DIR}/OpenPlaylistForEditingMethod.o \
|
||||
${TMP_DIR}/CreatePlaylistMethod.o \
|
||||
${TMP_DIR}/AddAudioClipToPlaylistMethod.o \
|
||||
${TMP_DIR}/RemoveAudioClipFromPlaylistMethod.o \
|
||||
${TMP_DIR}/ValidatePlaylistMethod.o \
|
||||
${TMP_DIR}/DisplayAudioClipMethod.o \
|
||||
${TMP_DIR}/DisplayAudioClipsMethod.o \
|
||||
${TMP_DIR}/RevertEditedPlaylistMethod.o \
|
||||
${TMP_DIR}/SavePlaylistMethod.o \
|
||||
${TMP_DIR}/GetSchedulerTimeMethod.o \
|
||||
${TMP_DIR}/PlayLogFactory.o \
|
||||
${TMP_DIR}/PostgresqlPlayLog.o \
|
||||
${TMP_DIR}/GeneratePlayReportMethod.o \
|
||||
${TMP_DIR}/UpdateFadeInFadeOutMethod.o \
|
||||
${TMP_DIR}/PlaylistEventContainer.o \
|
||||
${TMP_DIR}/PlaylistEvent.o \
|
||||
${TMP_DIR}/ResetStorageMethod.o \
|
||||
${TMP_DIR}/LoginMethod.o \
|
||||
${TMP_DIR}/LogoutMethod.o
|
||||
${TMP_DIR}/LogoutMethod.o \
|
||||
${TMP_DIR}/BackupFactory.o \
|
||||
${TMP_DIR}/PostgresqlBackup.o \
|
||||
${TMP_DIR}/CreateBackupOpenMethod.o \
|
||||
${TMP_DIR}/CreateBackupCheckMethod.o \
|
||||
${TMP_DIR}/CreateBackupCloseMethod.o
|
||||
|
||||
|
||||
SCHEDULER_EXE_OBJS = ${SCHEDULER_OBJS} \
|
||||
|
@ -289,35 +284,13 @@ TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \
|
|||
${TMP_DIR}/RescheduleMethodTest.o \
|
||||
${TMP_DIR}/RpcRescheduleTest.o \
|
||||
${TMP_DIR}/PostgresqlScheduleTest.o \
|
||||
${TMP_DIR}/DisplayPlaylistMethodTest.o \
|
||||
${TMP_DIR}/RpcDisplayPlaylistTest.o \
|
||||
${TMP_DIR}/DisplayPlaylistsMethodTest.o \
|
||||
${TMP_DIR}/RpcDisplayPlaylistsTest.o \
|
||||
${TMP_DIR}/OpenPlaylistForEditingMethodTest.o \
|
||||
${TMP_DIR}/RpcOpenPlaylistForEditingTest.o \
|
||||
${TMP_DIR}/CreatePlaylistMethodTest.o \
|
||||
${TMP_DIR}/RpcCreatePlaylistTest.o \
|
||||
${TMP_DIR}/AddAudioClipToPlaylistMethodTest.o \
|
||||
${TMP_DIR}/RpcAddAudioClipToPlaylistTest.o \
|
||||
${TMP_DIR}/RemoveAudioClipFromPlaylistMethodTest.o \
|
||||
${TMP_DIR}/RpcRemoveAudioClipFromPlaylistTest.o \
|
||||
${TMP_DIR}/ValidatePlaylistMethodTest.o \
|
||||
${TMP_DIR}/RpcValidatePlaylistTest.o \
|
||||
${TMP_DIR}/DisplayAudioClipMethodTest.o \
|
||||
${TMP_DIR}/RpcDisplayAudioClipTest.o \
|
||||
${TMP_DIR}/DisplayAudioClipsMethodTest.o \
|
||||
${TMP_DIR}/RpcDisplayAudioClipsTest.o \
|
||||
${TMP_DIR}/SavePlaylistMethodTest.o \
|
||||
${TMP_DIR}/RpcSavePlaylistTest.o \
|
||||
${TMP_DIR}/RevertEditedPlaylistMethodTest.o \
|
||||
${TMP_DIR}/RpcRevertEditedPlaylistTest.o \
|
||||
${TMP_DIR}/PostgresqlPlayLogTest.o \
|
||||
${TMP_DIR}/GeneratePlayReportMethodTest.o \
|
||||
${TMP_DIR}/RpcGeneratePlayReportTest.o \
|
||||
${TMP_DIR}/UpdateFadeInFadeOutMethodTest.o \
|
||||
${TMP_DIR}/RpcUpdateFadeInFadeOutTest.o \
|
||||
${TMP_DIR}/PlaylistEventContainerTest.o \
|
||||
${TMP_DIR}/PlaylistEventTest.o
|
||||
${TMP_DIR}/PlaylistEventTest.o \
|
||||
${TMP_DIR}/PostgresqlBackupTest.o \
|
||||
${TMP_DIR}/RpcBackupTest.o
|
||||
TEST_RUNNER_LIBS = ${SCHEDULER_EXE_LIBS} -lcppunit -ldl
|
||||
|
||||
|
||||
|
@ -358,7 +331,7 @@ depclean: clean
|
|||
distclean: clean docclean
|
||||
${RMDIR} ${TMP_DIR}/config* ${TMP_DIR}/autom4te* ${TMP_DIR}/ac*.m4
|
||||
|
||||
check: all ${TEST_RUNNER} storage_server_init start run_tests stop
|
||||
check: all ${TEST_RUNNER} storage_server_init stop start run_tests stop
|
||||
|
||||
install: all copy_files create_database create_odbc_datasource init_database
|
||||
|
||||
|
@ -400,7 +373,7 @@ ifeq (@INIT_LS_DATABASE@,yes)
|
|||
endif
|
||||
|
||||
|
||||
check_local: all ${TEST_RUNNER} start_local run_tests stop_local
|
||||
check_local: all ${TEST_RUNNER} stop_local start_local run_tests stop_local
|
||||
|
||||
run_tests: ${TEST_RUNNER}
|
||||
${TEST_RUNNER_SH} -o ${TEST_RESULTS} -s ${TEST_XSLT}
|
||||
|
|
|
@ -45,6 +45,9 @@ AC_PROG_CXX()
|
|||
AC_CHECK_HEADERS(sys/types.h unistd.h getopt.h signal.h sys/stat.h time.h)
|
||||
AC_CHECK_HEADERS(stdio.h fcntl.h sys/time.h)
|
||||
|
||||
AC_CHECK_HEADERS(libtar.h)
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl specify the pkg-config path
|
||||
dnl-----------------------------------------------------------------------------
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
storageClientFactory,
|
||||
scheduleFactory,
|
||||
playLogFactory,
|
||||
backupFactory,
|
||||
audioPlayer,
|
||||
xmlRpcDaemon) >
|
||||
|
||||
|
@ -63,6 +64,9 @@
|
|||
<!ELEMENT playLogFactory (postgresqlPlayLog) >
|
||||
<!ELEMENT postgresqlPlayLog EMPTY >
|
||||
|
||||
<!ELEMENT backupFactory (postgresqlBackup) >
|
||||
<!ELEMENT postgresqlBackup EMPTY >
|
||||
|
||||
<!ELEMENT audioPlayer (gstreamerPlayer) >
|
||||
|
||||
<!ELEMENT gstreamerPlayer EMPTY >
|
||||
|
@ -125,6 +129,10 @@
|
|||
<postgresqlPlayLog/>
|
||||
</playLogFactory>
|
||||
|
||||
<backupFactory>
|
||||
<postgresqlBackup/>
|
||||
</backupFactory>
|
||||
|
||||
<audioPlayer>
|
||||
<gstreamerPlayer audioDevice = "plughw:0,0" />
|
||||
</audioPlayer>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
storageClientFactory,
|
||||
scheduleFactory,
|
||||
playLogFactory,
|
||||
backupFactory,
|
||||
audioPlayer,
|
||||
xmlRpcDaemon) >
|
||||
|
||||
|
@ -66,6 +67,9 @@
|
|||
<!ELEMENT playLogFactory (postgresqlPlayLog) >
|
||||
<!ELEMENT postgresqlPlayLog EMPTY >
|
||||
|
||||
<!ELEMENT backupFactory (postgresqlBackup) >
|
||||
<!ELEMENT postgresqlBackup EMPTY >
|
||||
|
||||
<!ELEMENT audioPlayer (gstreamerPlayer) >
|
||||
|
||||
<!ELEMENT gstreamerPlayer EMPTY >
|
||||
|
@ -110,6 +114,10 @@
|
|||
<postgresqlPlayLog/>
|
||||
</playLogFactory>
|
||||
|
||||
<backupFactory>
|
||||
<postgresqlBackup/>
|
||||
</backupFactory>
|
||||
|
||||
<audioPlayer>
|
||||
<gstreamerPlayer audioDevice = "plughw:0,0" />
|
||||
</audioPlayer>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
storageClientFactory,
|
||||
scheduleFactory,
|
||||
playLogFactory,
|
||||
backupFactory,
|
||||
audioPlayer,
|
||||
xmlRpcDaemon) >
|
||||
|
||||
|
@ -66,6 +67,9 @@
|
|||
<!ELEMENT playLogFactory (postgresqlPlayLog) >
|
||||
<!ELEMENT postgresqlPlayLog EMPTY >
|
||||
|
||||
<!ELEMENT backupFactory (postgresqlBackup) >
|
||||
<!ELEMENT postgresqlBackup EMPTY >
|
||||
|
||||
<!ELEMENT audioPlayer (gstreamerPlayer) >
|
||||
|
||||
<!ELEMENT gstreamerPlayer EMPTY >
|
||||
|
@ -110,6 +114,10 @@
|
|||
<postgresqlPlayLog/>
|
||||
</playLogFactory>
|
||||
|
||||
<backupFactory>
|
||||
<postgresqlBackup/>
|
||||
</backupFactory>
|
||||
|
||||
<audioPlayer>
|
||||
<gstreamerPlayer audioDevice = "ls_audio_output_device" />
|
||||
</audioPlayer>
|
||||
|
|
|
@ -1,189 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#else
|
||||
#error need time.h
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "LiveSupport/StorageClient/StorageClientInterface.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "ScheduleInterface.h"
|
||||
#include "ScheduleFactory.h"
|
||||
#include "LiveSupport/Core/XmlRpcTools.h"
|
||||
|
||||
#include "AddAudioClipToPlaylistMethod.h"
|
||||
|
||||
|
||||
using namespace boost;
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of this XML-RPC method.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string AddAudioClipToPlaylistMethod::methodName
|
||||
= "addAudioClipToPlaylist";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The ID of this method for error reporting purposes.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const int AddAudioClipToPlaylistMethod::errorId = 300;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the method and register it right away.
|
||||
*----------------------------------------------------------------------------*/
|
||||
AddAudioClipToPlaylistMethod :: AddAudioClipToPlaylistMethod (
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) throw()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Execute the stop XML-RPC function call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw (XmlRpc::XmlRpcException)
|
||||
{
|
||||
if (!rootParameter.valid() || rootParameter.size() != 1
|
||||
|| !rootParameter[0].valid()) {
|
||||
XmlRpcTools::markError(errorId+1, "invalid argument format",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+20,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref playlistId;
|
||||
try{
|
||||
playlistId = XmlRpcTools::extractPlaylistId(parameters);
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+2, "missing playlist ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref audioClipId;
|
||||
try{
|
||||
audioClipId = XmlRpcTools::extractAudioClipId(parameters);
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+3, "missing audio clip ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<time_duration>::Ref relativeOffset;
|
||||
try{
|
||||
relativeOffset = XmlRpcTools::extractRelativeOffset(parameters);
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+4, "missing relative offset argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
scf = StorageClientFactory::getInstance();
|
||||
storage = scf->getStorageClient();
|
||||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->getPlaylist(sessionId, playlistId);
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
XmlRpcTools::markError(errorId+5, "playlist not found",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playlist->isLocked()) {
|
||||
XmlRpcTools::markError(errorId+6,
|
||||
"playlist has not been opened for editing",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<AudioClip>::Ref audioClip;
|
||||
try {
|
||||
audioClip = storage->getAudioClip(sessionId, audioClipId);
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
XmlRpcTools::markError(errorId+7, "audio clip does not exist",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref playlistElementId;
|
||||
try { // and finally, the beef
|
||||
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);
|
||||
}
|
|
@ -1,167 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef AddAudioClipToPlaylistMethod_h
|
||||
#define AddAudioClipToPlaylistMethod_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <XmlRpcServerMethod.h>
|
||||
#include <XmlRpcValue.h>
|
||||
#include <XmlRpcException.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An XML-RPC method object to add an audio clip (specified by its ID)
|
||||
* to a playlist (also specified by its ID).
|
||||
*
|
||||
* The name of the method when called through XML-RPC is
|
||||
* "addAudioClipToPlaylist".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <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 { faultCode, faultString } structure is returned. The
|
||||
* possible errors are:
|
||||
* <ul>
|
||||
* <li>301 - invalid argument format </li>
|
||||
* <li>302 - missing playlist ID argument </li>
|
||||
* <li>303 - missing audio clip ID argument </li>
|
||||
* <li>304 - missing relative offset argument </li>
|
||||
* <li>305 - playlist not found </li>
|
||||
* <li>306 - playlist has not been opened for editing </li>
|
||||
* <li>307 - audio clip does not exist </li>
|
||||
* <li>308 - two audio clips at the same relative offset</li>
|
||||
* <li>320 - missing session ID argument </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class AddAudioClipToPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The name of this method, as it will be registered into the
|
||||
* XML-RPC server.
|
||||
*/
|
||||
static const std::string methodName;
|
||||
|
||||
/**
|
||||
* The ID of this method for error reporting purposes.
|
||||
*/
|
||||
static const int errorId;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* A default constructor, for testing purposes.
|
||||
*/
|
||||
AddAudioClipToPlaylistMethod(void) throw ()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constuctor that registers the method with the server right away.
|
||||
*
|
||||
* @param xmlRpcServer the XML-RPC server to register with.
|
||||
*/
|
||||
AddAudioClipToPlaylistMethod(
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Execute the display schedule command on the Scheduler daemon.
|
||||
*
|
||||
* @param parameters XML-RPC function call parameters
|
||||
* @param returnValue the return value of the call (out parameter)
|
||||
*/
|
||||
void
|
||||
execute( XmlRpc::XmlRpcValue & parameters,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw (XmlRpc::XmlRpcException);
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // AddAudioClipToPlaylistMethod_h
|
||||
|
|
@ -1,171 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "LiveSupport/Core/XmlRpcTools.h"
|
||||
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
#include "AddAudioClipToPlaylistMethod.h"
|
||||
#include "AddAudioClipToPlaylistMethodTest.h"
|
||||
#include "SchedulerDaemon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(AddAudioClipToPlaylistMethodTest);
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
AddAudioClipToPlaylistMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<SchedulerDaemon>::Ref scheduler = SchedulerDaemon::getInstance();
|
||||
try {
|
||||
Ptr<StorageClientInterface>::Ref storage = scheduler->getStorage();
|
||||
storage->reset();
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = scheduler->getAuthentication();
|
||||
try {
|
||||
sessionId = authentication->login("root", "q");
|
||||
} catch (XmlRpcException &e) {
|
||||
std::string eMsg = "could not log in:\n";
|
||||
eMsg += e.what();
|
||||
CPPUNIT_FAIL(eMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
AddAudioClipToPlaylistMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Just a very simple smoke test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
AddAudioClipToPlaylistMethodTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<OpenPlaylistForEditingMethod>::Ref
|
||||
openPlaylistMethod(new OpenPlaylistForEditingMethod());
|
||||
Ptr<AddAudioClipToPlaylistMethod>::Ref
|
||||
addAudioClipMethod(new AddAudioClipToPlaylistMethod());
|
||||
XmlRpc::XmlRpcValue parameters;
|
||||
XmlRpc::XmlRpcValue rootParameter;
|
||||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
parameters.clear();
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = "0000000000000001";
|
||||
parameters["audioClipId"] = "0000000000010001";
|
||||
parameters["relativeOffset"] = 60*60;
|
||||
rootParameter[0] = parameters;
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
openPlaylistMethod->execute(rootParameter, result);
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method returned error: " << e.getCode()
|
||||
<< " - " << e.getMessage();
|
||||
CPPUNIT_FAIL(eMsg.str());
|
||||
}
|
||||
|
||||
parameters.clear();
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = "0000000000000001";
|
||||
parameters["audioClipId"] = "0000000000010001";
|
||||
parameters["relativeOffset"] = 90*60;
|
||||
rootParameter[0] = parameters;
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
addAudioClipMethod->execute(rootParameter, result);
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method returned error: " << e.getCode()
|
||||
<< " - " << e.getMessage();
|
||||
CPPUNIT_FAIL(eMsg.str());
|
||||
}
|
||||
CPPUNIT_ASSERT(result.hasMember("playlistElementId"));
|
||||
CPPUNIT_ASSERT(result["playlistElementId"].getType()
|
||||
== XmlRpc::XmlRpcValue::TypeString);
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef AddAudioClipToPlaylistMethodTest_h
|
||||
#define AddAudioClipToPlaylistMethodTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
#include "BaseTestMethod.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the AddAudioClipToPlaylistMethod class.
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
* @see AddAudioClipToPlaylistMethod
|
||||
*/
|
||||
class AddAudioClipToPlaylistMethodTest : public BaseTestMethod
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(AddAudioClipToPlaylistMethodTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // AddAudioClipToPlaylistMethodTest_h
|
||||
|
169
livesupport/src/products/scheduler/src/BackupFactory.cxx
Normal file
169
livesupport/src/products/scheduler/src/BackupFactory.cxx
Normal file
|
@ -0,0 +1,169 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "ScheduleFactory.h"
|
||||
#include "PostgresqlBackup.h"
|
||||
|
||||
#include "BackupFactory.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the config element for this class
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string BackupFactory::configElementNameStr = "backupFactory";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The singleton instance of BackupFactory
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<BackupFactory>::Ref BackupFactory::singleton;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Return the singleton instance to BackupFactory
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<BackupFactory>::Ref
|
||||
BackupFactory :: getInstance(void) throw ()
|
||||
{
|
||||
if (!singleton.get()) {
|
||||
singleton.reset(new BackupFactory());
|
||||
}
|
||||
|
||||
return singleton;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Configure the backup factory.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
BackupFactory :: configure(const xmlpp::Element & element)
|
||||
throw (std::invalid_argument,
|
||||
std::logic_error)
|
||||
{
|
||||
if (element.get_name() != configElementNameStr) {
|
||||
std::string eMsg = "Bad configuration element ";
|
||||
eMsg += element.get_name();
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
|
||||
backup.reset();
|
||||
|
||||
Ptr<ConnectionManagerFactory>::Ref
|
||||
cmf = ConnectionManagerFactory::getInstance();
|
||||
Ptr<ConnectionManagerInterface>::Ref
|
||||
connection = cmf->getConnectionManager();
|
||||
|
||||
Ptr<StorageClientFactory>::Ref
|
||||
scf = StorageClientFactory::getInstance();
|
||||
Ptr<StorageClientInterface>::Ref
|
||||
storage = scf->getStorageClient();
|
||||
|
||||
Ptr<ScheduleFactory>::Ref
|
||||
sf = ScheduleFactory::getInstance();
|
||||
Ptr<ScheduleInterface>::Ref
|
||||
schedule = sf->getSchedule();
|
||||
|
||||
// try to look for a PostgresqlBackup configuration element
|
||||
xmlpp::Node::NodeList nodes =
|
||||
element.get_children(PostgresqlBackup::getConfigElementName());
|
||||
if (nodes.size() >= 1) {
|
||||
const xmlpp::Element * configElement =
|
||||
dynamic_cast<const xmlpp::Element*> (*(nodes.begin()));
|
||||
Ptr<PostgresqlBackup>::Ref pb(new PostgresqlBackup(connection,
|
||||
storage,
|
||||
schedule));
|
||||
pb->configure(*configElement);
|
||||
backup = pb;
|
||||
}
|
||||
|
||||
if (!backup) {
|
||||
throw std::invalid_argument("could not configure BackupFactory");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Install the backup factory.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
BackupFactory :: install(void) throw (std::exception)
|
||||
{
|
||||
if (!backup) {
|
||||
throw std::logic_error("BackupFactory not yet configured");
|
||||
}
|
||||
|
||||
backup->install();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check to see if the backup factory has already been installed.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
BackupFactory :: isInstalled(void) throw (std::exception)
|
||||
{
|
||||
if (!backup) {
|
||||
throw std::logic_error("BackupFactory not yet configured");
|
||||
}
|
||||
|
||||
return backup->isInstalled();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Install the backup factory.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
BackupFactory :: uninstall(void) throw (std::exception)
|
||||
{
|
||||
if (!backup) {
|
||||
throw std::logic_error("BackupFactory not yet configured");
|
||||
}
|
||||
|
||||
backup->uninstall();
|
||||
}
|
||||
|
217
livesupport/src/products/scheduler/src/BackupFactory.h
Normal file
217
livesupport/src/products/scheduler/src/BackupFactory.h
Normal file
|
@ -0,0 +1,217 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef BackupFactory_h
|
||||
#define BackupFactory_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "LiveSupport/Core/Configurable.h"
|
||||
#include "LiveSupport/Core/Installable.h"
|
||||
#include "BackupInterface.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* The factory to create backup objects.
|
||||
*
|
||||
* Backup objects are objects which implement the BackupInterface interface,
|
||||
* so they can create and restore schedule backups.
|
||||
*
|
||||
* This object has to be configured with an element that contains
|
||||
* the configuration element that the factory should build.
|
||||
* Currently only PostgresqlBackup is supported by this factory.
|
||||
*
|
||||
* An example configuration element is the following:
|
||||
*
|
||||
* <pre><code>
|
||||
* <backupFactory>
|
||||
* <postgresqlBackup/>
|
||||
* </backupFactory>
|
||||
* </code></pre>
|
||||
*
|
||||
* The DTD for the above element is:
|
||||
*
|
||||
* <pre><code>
|
||||
* <!ELEMENT backupFactory (postgresqlBackup) >
|
||||
* </code></pre>
|
||||
*
|
||||
* For details on the <postgresqlBackup> element, see the
|
||||
* PostgresqlBackup documentation.
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
* @see PostgresqlBackup
|
||||
*/
|
||||
class BackupFactory : virtual public Configurable,
|
||||
virtual public Installable
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The name of the configuration XML elmenent used by this object.
|
||||
*/
|
||||
static const std::string configElementNameStr;
|
||||
|
||||
/**
|
||||
* The singleton instance of this object.
|
||||
*/
|
||||
static Ptr<BackupFactory>::Ref singleton;
|
||||
|
||||
/**
|
||||
* The backup created by this factory.
|
||||
*/
|
||||
Ptr<BackupInterface>::Ref backup;
|
||||
|
||||
/**
|
||||
* The default constructor.
|
||||
*/
|
||||
BackupFactory(void) throw()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
virtual
|
||||
~BackupFactory(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the XML element this object expects
|
||||
* to be sent to a call to configure().
|
||||
*
|
||||
* @return the name of the expected XML configuration element.
|
||||
*/
|
||||
static const std::string
|
||||
getConfigElementName(void) throw ()
|
||||
{
|
||||
return configElementNameStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the singleton instance of this object.
|
||||
*
|
||||
* @return the singleton instance of this object.
|
||||
*/
|
||||
static Ptr<BackupFactory>::Ref
|
||||
getInstance() throw ();
|
||||
|
||||
/**
|
||||
* Configure the object based on the XML element supplied.
|
||||
*
|
||||
* @param element the XML element to configure the object from.
|
||||
* @exception std::invalid_argument if the supplied XML element
|
||||
* contains bad configuraiton information
|
||||
* @exception std::logic_error if the object has already
|
||||
* been configured, and can not be reconfigured.
|
||||
*/
|
||||
virtual void
|
||||
configure(const xmlpp::Element & element)
|
||||
throw (std::invalid_argument,
|
||||
std::logic_error);
|
||||
|
||||
/**
|
||||
* Install the component.
|
||||
* This step involves creating the environment in which the component
|
||||
* will run. This may be creation of coniguration files,
|
||||
* database tables, etc.
|
||||
*
|
||||
* @exception std::exception on installation problems,
|
||||
* especially if the BackupFactory was not yet configured.
|
||||
*/
|
||||
virtual void
|
||||
install(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Check to see if the component has already been installed.
|
||||
*
|
||||
* @return true if the component is properly installed,
|
||||
* false otherwise
|
||||
* @exception std::exception on generic problems
|
||||
*/
|
||||
virtual bool
|
||||
isInstalled(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Uninstall the component.
|
||||
* Removes all the resources created in the install step.
|
||||
*
|
||||
* @exception std::exception on unistallation problems,
|
||||
e especially if the BackupFactory was not yet configured.
|
||||
*/
|
||||
virtual void
|
||||
uninstall(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Return a backup.
|
||||
*
|
||||
* @return the appropriate backup, according to the
|
||||
* configuration of this factory.
|
||||
*/
|
||||
Ptr<BackupInterface>::Ref
|
||||
getBackup(void) throw ()
|
||||
{
|
||||
return backup;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Storage
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // BackupFactory_h
|
||||
|
166
livesupport/src/products/scheduler/src/BackupInterface.h
Normal file
166
livesupport/src/products/scheduler/src/BackupInterface.h
Normal file
|
@ -0,0 +1,166 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef BackupInterface_h
|
||||
#define BackupInterface_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#include <stdexcept>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Installable.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
#include "LiveSupport/Core/ScheduleEntry.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientInterface.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* The generic interface for creating and restoring schedule backups.
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class BackupInterface : virtual public Installable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Start to create a backup by calling the storage, and also
|
||||
* adding a backup of the schedule.
|
||||
* To check if the backup procedure is still pending, call
|
||||
* createBackupCheck() regularly.
|
||||
* Make sure to close the backup by calling createBackupClose().
|
||||
*
|
||||
* @param sessionId a valid session ID to use for accessing the
|
||||
* storage
|
||||
* @param criteria the criteria to use for backing up the storage
|
||||
* @param fromTime entries are included in the schedule export starting
|
||||
* from this time.
|
||||
* @param toTime entries as included in the schedule export
|
||||
* up to but not including this time.
|
||||
* @return a token, which can be used to query the backup process.
|
||||
* @exception XmlRpcException on XML-RPC issues.
|
||||
* @see #createBackupCheck
|
||||
* @see #createBackupClose
|
||||
*/
|
||||
virtual Ptr<Glib::ustring>::Ref
|
||||
createBackupOpen(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<SearchCriteria>::Ref criteria,
|
||||
Ptr<ptime>::Ref fromTime,
|
||||
Ptr<ptime>::Ref toTime)
|
||||
throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Check the status of a storage backup.
|
||||
*
|
||||
* @param token the identifier of this backup task.
|
||||
* @param url return parameter;
|
||||
* if the status is "success", it contains the
|
||||
* URL of the created backup file.
|
||||
* @param path return parameter;
|
||||
* if the status is "success", it contains the
|
||||
* local access path of the created backup file.
|
||||
* @param errorMessage return parameter;
|
||||
* if the status is "fault", it contains the
|
||||
* fault string.
|
||||
* @return the state of the backup process: one of pendingState,
|
||||
* finishedState, or failedState.
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
* @see #createBackupOpen
|
||||
* @see #createBackupClose
|
||||
*/
|
||||
virtual AsyncState
|
||||
createBackupCheck(const Glib::ustring & token,
|
||||
Ptr<const Glib::ustring>::Ref & url,
|
||||
Ptr<const Glib::ustring>::Ref & path,
|
||||
Ptr<const Glib::ustring>::Ref & errorMessage)
|
||||
throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Close the storage backup process.
|
||||
* Frees up all resources allocated to the backup.
|
||||
*
|
||||
* @param token the identifier of this backup task.
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
* @see #createBackupOpen
|
||||
* @see #createBackupCheck
|
||||
*/
|
||||
virtual void
|
||||
createBackupClose(const Glib::ustring & token)
|
||||
throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
virtual
|
||||
~BackupInterface(void) throw ()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // BackupInterface_h
|
||||
|
|
@ -29,34 +29,16 @@
|
|||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#else
|
||||
#error need time.h
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "LiveSupport/StorageClient/StorageClientInterface.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "ScheduleInterface.h"
|
||||
#include "ScheduleFactory.h"
|
||||
#include "LiveSupport/Core/XmlRpcTools.h"
|
||||
#include "BackupFactory.h"
|
||||
|
||||
#include "DisplayAudioClipMethod.h"
|
||||
#include "CreateBackupCheckMethod.h"
|
||||
|
||||
|
||||
using namespace boost;
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
|
@ -68,12 +50,12 @@ using namespace LiveSupport::Scheduler;
|
|||
/*------------------------------------------------------------------------------
|
||||
* The name of this XML-RPC method.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string DisplayAudioClipMethod::methodName = "displayAudioClip";
|
||||
const std::string CreateBackupCheckMethod::methodName = "createBackupCheck";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The ID of this method for error reporting purposes.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const int DisplayAudioClipMethod::errorId = 600;
|
||||
const int CreateBackupCheckMethod::errorId = 4100;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
@ -84,18 +66,19 @@ const int DisplayAudioClipMethod::errorId = 600;
|
|||
/*------------------------------------------------------------------------------
|
||||
* Construct the method and register it right away.
|
||||
*----------------------------------------------------------------------------*/
|
||||
DisplayAudioClipMethod :: DisplayAudioClipMethod (
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) throw()
|
||||
CreateBackupCheckMethod :: CreateBackupCheckMethod (
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Execute the stop XML-RPC function call.
|
||||
* Execute the upload playlist method XML-RPC function call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayAudioClipMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
||||
CreateBackupCheckMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw (XmlRpc::XmlRpcException)
|
||||
{
|
||||
|
@ -107,40 +90,54 @@ DisplayAudioClipMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
Ptr<Glib::ustring>::Ref token;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
token = XmlRpcTools::extractToken(parameters);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+20,
|
||||
"missing session ID argument",
|
||||
XmlRpcTools::markError(errorId+2,
|
||||
"missing token argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref id;
|
||||
Ptr<BackupFactory>::Ref bf = BackupFactory::getInstance();
|
||||
Ptr<BackupInterface>::Ref backup = bf->getBackup();
|
||||
|
||||
Ptr<const Glib::ustring>::Ref url;
|
||||
Ptr<const Glib::ustring>::Ref path;
|
||||
Ptr<const Glib::ustring>::Ref errorMessage;
|
||||
AsyncState state;
|
||||
try {
|
||||
id = XmlRpcTools::extractAudioClipId(parameters);
|
||||
state = backup->createBackupCheck(*token, url, path, errorMessage);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+2, "argument is not an audio clip ID",
|
||||
XmlRpcTools::markError(errorId+10, e.what(), returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
XmlRpcTools::backupStatusToXmlRpcValue(state, returnValue);
|
||||
|
||||
if (state == AsyncState::finishedState) {
|
||||
if (url && path) {
|
||||
XmlRpcTools::urlToXmlRpcValue(url, returnValue);
|
||||
XmlRpcTools::pathToXmlRpcValue(url, returnValue);
|
||||
} else {
|
||||
XmlRpcTools::markError(errorId+11,
|
||||
"missing url or path return value",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
|
||||
scf = StorageClientFactory::getInstance();
|
||||
storage = scf->getStorageClient();
|
||||
|
||||
Ptr<AudioClip>::Ref audioClip;
|
||||
try {
|
||||
audioClip = storage->getAudioClip(sessionId, id);
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
std::string eMsg = "audio clip not found:\n";
|
||||
eMsg += e.what();
|
||||
XmlRpcTools::markError(errorId+3, eMsg, returnValue);
|
||||
} else if (state == AsyncState::failedState) {
|
||||
if (errorMessage) {
|
||||
XmlRpcTools::faultStringToXmlRpcValue(errorMessage, returnValue);
|
||||
} else {
|
||||
XmlRpcTools::markError(errorId+11,
|
||||
"missing faultString return value",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
XmlRpcTools::audioClipToXmlRpcValue(audioClip, returnValue);
|
||||
}
|
||||
}
|
||||
|
|
@ -26,8 +26,8 @@
|
|||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef DisplayAudioClipMethod_h
|
||||
#define DisplayAudioClipMethod_h
|
||||
#ifndef CreateBackupCheckMethod_h
|
||||
#define CreateBackupCheckMethod_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
|
@ -42,12 +42,13 @@
|
|||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <XmlRpcServerMethod.h>
|
||||
#include <XmlRpcValue.h>
|
||||
#include <XmlRpcException.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/AudioClip.h"
|
||||
#include "LiveSupport/Core/UniqueId.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
|
@ -65,40 +66,42 @@ using namespace LiveSupport::Core;
|
|||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An XML-RPC method object to return a audio clip for a specified
|
||||
* audio clip id.
|
||||
* An XML-RPC method object to check the progress of a backup creation process.
|
||||
*
|
||||
* The name of the method when called through XML-RPC is "displayAudioClip".
|
||||
* The name of the method when called through XML-RPC is "createBackupCheck".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* The expected parameter is an XML-RPC structure with a single member:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <li>audioClipId - string - the unique id of the audio clip requested.</li>
|
||||
* <li>token - string - the token obtained from createBackupOpen </li>
|
||||
* </ul>
|
||||
*
|
||||
* The XML-RPC function returns an XML-RPC structure, containing the following
|
||||
* fields:
|
||||
* On success, returns an XML-RPC struct, with the following members:
|
||||
* <ul>
|
||||
* <li>audioClip - string - an XML representation of the audio clip; this
|
||||
* XML element can be used as argument to AudioClip::configure()</li>
|
||||
* <li>status - string - on of "success", "working" or "fault" </li>
|
||||
* <li>url - string - if the status is "success", this contains
|
||||
* a readable URL of the new backup archive </li>
|
||||
* <li>path - string - if the status is "success", this contains
|
||||
* the local access path of the new backup
|
||||
* archive </li>
|
||||
* <li>faultString - string - if the status is "fault", this contains
|
||||
* the error message. </li>
|
||||
* </ul>
|
||||
*
|
||||
* In case of an error, a standard XML-RPC fault response is generated,
|
||||
* and a { faultCode, faultString } structure is returned. The
|
||||
* possible errors are:
|
||||
* <ul>
|
||||
* <li>601 - invalid argument format </li>
|
||||
* <li>602 - argument is not an audio clip ID </li>
|
||||
* <li>603 - audio clip not found </li>
|
||||
* <li>620 - missing session ID argument </li>
|
||||
* <li>4101 - invalid argument format </li>
|
||||
* <li>4102 - missing token argument </li>
|
||||
* <li>4010 - error reported by the scheduler daemon </li>
|
||||
* <li>4011 - syntax error in the values returned by
|
||||
* the scheduler daemon </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class DisplayAudioClipMethod : public XmlRpc::XmlRpcServerMethod
|
||||
class CreateBackupCheckMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
private:
|
||||
/**
|
||||
|
@ -117,7 +120,7 @@ class DisplayAudioClipMethod : public XmlRpc::XmlRpcServerMethod
|
|||
/**
|
||||
* A default constructor, for testing purposes.
|
||||
*/
|
||||
DisplayAudioClipMethod(void) throw ()
|
||||
CreateBackupCheckMethod(void) throw ()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName)
|
||||
{
|
||||
}
|
||||
|
@ -127,12 +130,12 @@ class DisplayAudioClipMethod : public XmlRpc::XmlRpcServerMethod
|
|||
*
|
||||
* @param xmlRpcServer the XML-RPC server to register with.
|
||||
*/
|
||||
DisplayAudioClipMethod(
|
||||
CreateBackupCheckMethod(
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Execute the display schedule command on the Scheduler daemon.
|
||||
* Execute the createBackupOpen command on the Scheduler daemon.
|
||||
*
|
||||
* @param parameters XML-RPC function call parameters
|
||||
* @param returnValue the return value of the call (out parameter)
|
||||
|
@ -153,5 +156,5 @@ class DisplayAudioClipMethod : public XmlRpc::XmlRpcServerMethod
|
|||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // DisplayAudioClipMethod_h
|
||||
#endif // CreateBackupCheckMethod_h
|
||||
|
|
@ -42,21 +42,14 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "LiveSupport/StorageClient/StorageClientInterface.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "ScheduleInterface.h"
|
||||
#include "ScheduleFactory.h"
|
||||
#include "LiveSupport/Core/XmlRpcTools.h"
|
||||
#include "BackupFactory.h"
|
||||
|
||||
#include "DisplayPlaylistMethod.h"
|
||||
#include "CreateBackupCloseMethod.h"
|
||||
|
||||
|
||||
using namespace boost;
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
|
@ -68,12 +61,12 @@ using namespace LiveSupport::Scheduler;
|
|||
/*------------------------------------------------------------------------------
|
||||
* The name of this XML-RPC method.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string DisplayPlaylistMethod::methodName = "displayPlaylist";
|
||||
const std::string CreateBackupCloseMethod::methodName = "createBackupClose";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The ID of this method for error reporting purposes.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const int DisplayPlaylistMethod::errorId = 1000;
|
||||
const int CreateBackupCloseMethod::errorId = 4200;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
@ -84,18 +77,19 @@ const int DisplayPlaylistMethod::errorId = 1000;
|
|||
/*------------------------------------------------------------------------------
|
||||
* Construct the method and register it right away.
|
||||
*----------------------------------------------------------------------------*/
|
||||
DisplayPlaylistMethod :: DisplayPlaylistMethod (
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) throw()
|
||||
CreateBackupCloseMethod :: CreateBackupCloseMethod(
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Execute the stop XML-RPC function call.
|
||||
* Execute the upload playlist method XML-RPC function call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
||||
CreateBackupCloseMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw (XmlRpc::XmlRpcException)
|
||||
{
|
||||
|
@ -107,40 +101,26 @@ DisplayPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
Ptr<Glib::ustring>::Ref token;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
token = XmlRpcTools::extractToken(parameters);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+20,
|
||||
"missing session ID argument",
|
||||
XmlRpcTools::markError(errorId+2,
|
||||
"missing token argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref id;
|
||||
Ptr<BackupFactory>::Ref bf = BackupFactory::getInstance();
|
||||
Ptr<BackupInterface>::Ref backup = bf->getBackup();
|
||||
|
||||
try {
|
||||
id = XmlRpcTools::extractPlaylistId(parameters);
|
||||
backup->createBackupClose(*token);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+2, "argument is not a Playlist ID",
|
||||
returnValue);
|
||||
XmlRpcTools::markError(errorId+10, e.what(), returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
|
||||
scf = StorageClientFactory::getInstance();
|
||||
storage = scf->getStorageClient();
|
||||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->getPlaylist(sessionId, id);
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
std::string eMsg = "playlist not found:\n";
|
||||
eMsg += e.what();
|
||||
XmlRpcTools::markError(errorId+3, eMsg, returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
XmlRpcTools::playlistToXmlRpcValue(playlist, returnValue);
|
||||
}
|
|
@ -26,8 +26,8 @@
|
|||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef CreatePlaylistMethod_h
|
||||
#define CreatePlaylistMethod_h
|
||||
#ifndef CreateBackupCloseMethod_h
|
||||
#define CreateBackupCloseMethod_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
|
@ -47,7 +47,6 @@
|
|||
#include <XmlRpcException.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
|
@ -65,37 +64,28 @@ using namespace LiveSupport::Core;
|
|||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An XML-RPC method object to create a new playlist in the playlist store.
|
||||
* An XML-RPC method object to close the backup creation process.
|
||||
*
|
||||
* The name of the method when called through XML-RPC is "createPlaylist".
|
||||
* The name of the method when called through XML-RPC is "createBackupClose".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* The expected parameter is an XML-RPC structure with a single member:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* </ul>
|
||||
*
|
||||
* The XML-RPC function returns an XML-RPC structure, containing the following
|
||||
* fields:
|
||||
* <ul>
|
||||
* <li>playlist - string - an XML representation of the playlist; this
|
||||
* XML element can be used as argument to Playlist::configure()</li>
|
||||
* <li>token - string - the token obtained from createBackupOpen </li>
|
||||
* </ul>
|
||||
*
|
||||
* In case of an error, a standard XML-RPC fault response is generated,
|
||||
* and a { faultCode, faultString } structure is returned. The
|
||||
* possible errors are:
|
||||
* <ul>
|
||||
* <li>201 - invalid argument format</li>
|
||||
* <li>202 - could not create playlist</li>
|
||||
* <li>220 - missing session ID argument </li>
|
||||
* <li>4201 - invalid argument format </li>
|
||||
* <li>4202 - missing token argument </li>
|
||||
* <li>4210 - error reported by the scheduler daemon </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
class CreateBackupCloseMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
private:
|
||||
/**
|
||||
|
@ -114,7 +104,7 @@ class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
|||
/**
|
||||
* A default constructor, for testing purposes.
|
||||
*/
|
||||
CreatePlaylistMethod(void) throw ()
|
||||
CreateBackupCloseMethod(void) throw ()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName)
|
||||
{
|
||||
}
|
||||
|
@ -124,12 +114,12 @@ class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
|||
*
|
||||
* @param xmlRpcServer the XML-RPC server to register with.
|
||||
*/
|
||||
CreatePlaylistMethod(
|
||||
CreateBackupCloseMethod(
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Execute the create playlist command on the Scheduler daemon.
|
||||
* Execute the createBackupOpen command on the Scheduler daemon.
|
||||
*
|
||||
* @param parameters XML-RPC function call parameters
|
||||
* @param returnValue the return value of the call (out parameter)
|
||||
|
@ -150,5 +140,5 @@ class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
|||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // CreatePlaylistMethod_h
|
||||
#endif // CreateBackupCloseMethod_h
|
||||
|
|
@ -42,16 +42,17 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "LiveSupport/StorageClient/StorageClientInterface.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "LiveSupport/Core/XmlRpcTools.h"
|
||||
#include "BackupFactory.h"
|
||||
|
||||
#include "RevertEditedPlaylistMethod.h"
|
||||
#include "CreateBackupOpenMethod.h"
|
||||
|
||||
|
||||
using namespace boost;
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
|
@ -63,13 +64,12 @@ using namespace LiveSupport::Scheduler;
|
|||
/*------------------------------------------------------------------------------
|
||||
* The name of this XML-RPC method.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string RevertEditedPlaylistMethod::methodName
|
||||
= "revertEditedPlaylist";
|
||||
const std::string CreateBackupOpenMethod::methodName = "createBackupOpen";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The ID of this method for error reporting purposes.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const int RevertEditedPlaylistMethod::errorId = 800;
|
||||
const int CreateBackupOpenMethod::errorId = 4000;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
@ -80,18 +80,19 @@ const int RevertEditedPlaylistMethod::errorId = 800;
|
|||
/*------------------------------------------------------------------------------
|
||||
* Construct the method and register it right away.
|
||||
*----------------------------------------------------------------------------*/
|
||||
RevertEditedPlaylistMethod :: RevertEditedPlaylistMethod (
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) throw()
|
||||
CreateBackupOpenMethod :: CreateBackupOpenMethod(
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Execute the stop XML-RPC function call.
|
||||
* Execute the upload playlist method XML-RPC function call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RevertEditedPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
||||
CreateBackupOpenMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw (XmlRpc::XmlRpcException)
|
||||
{
|
||||
|
@ -113,36 +114,44 @@ RevertEditedPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref id;
|
||||
Ptr<SearchCriteria>::Ref criteria;
|
||||
try {
|
||||
id = XmlRpcTools::extractPlaylistId(parameters);
|
||||
criteria = XmlRpcTools::extractSearchCriteria(parameters);
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+2, "argument is not a playlist ID",
|
||||
returnValue);
|
||||
XmlRpcTools::markError(errorId+2, e.what(), returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
|
||||
scf = StorageClientFactory::getInstance();
|
||||
storage = scf->getStorageClient();
|
||||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
Ptr<ptime>::Ref fromTime;
|
||||
try {
|
||||
playlist = storage->getPlaylist(sessionId, id);
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
std::string eMsg = "playlist not found:\n";
|
||||
eMsg += e.what();
|
||||
XmlRpcTools::markError(errorId+3, eMsg, returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
playlist->revertToSavedCopy();
|
||||
fromTime = XmlRpcTools::extractFromTime(parameters);
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+4, "could not revert playlist",
|
||||
returnValue);
|
||||
XmlRpcTools::markError(errorId+3, e.what(), returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<ptime>::Ref toTime;
|
||||
try {
|
||||
toTime = XmlRpcTools::extractToTime(parameters);
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+4, e.what(), returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<BackupFactory>::Ref bf = BackupFactory::getInstance();
|
||||
Ptr<BackupInterface>::Ref backup = bf->getBackup();
|
||||
|
||||
Ptr<Glib::ustring>::Ref token;
|
||||
try {
|
||||
token = backup->createBackupOpen(sessionId,
|
||||
criteria,
|
||||
fromTime,
|
||||
toTime);
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+5, e.what(), returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
XmlRpcTools::tokenToXmlRpcValue(token, returnValue);
|
||||
}
|
||||
|
|
@ -26,8 +26,8 @@
|
|||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef DisplayPlaylistMethod_h
|
||||
#define DisplayPlaylistMethod_h
|
||||
#ifndef CreateBackupOpenMethod_h
|
||||
#define CreateBackupOpenMethod_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
|
@ -42,12 +42,13 @@
|
|||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <XmlRpcServerMethod.h>
|
||||
#include <XmlRpcValue.h>
|
||||
#include <XmlRpcException.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
#include "LiveSupport/Core/UniqueId.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
|
@ -65,40 +66,48 @@ using namespace LiveSupport::Core;
|
|||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An XML-RPC method object to return a playlist for a specified
|
||||
* playlist id.
|
||||
* An XML-RPC method object to start a backup creation process.
|
||||
*
|
||||
* The name of the method when called through XML-RPC is "displayPlaylist".
|
||||
* The name of the method when called through XML-RPC is "createBackupOpen".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <li>playlistId - string - the unique id of the playlist requested.</li>
|
||||
* <li>criteria - struct - the criteria to use for backing up the
|
||||
* storage </li>
|
||||
* <li>fromTime - datetime - entries are included in the schedule export
|
||||
* starting from this time </li>
|
||||
* <li>toTime - datetime - entries are included in the schedule export
|
||||
* up to but not including this time </li>
|
||||
* </ul>
|
||||
*
|
||||
* The XML-RPC function returns an XML-RPC structure, containing the following
|
||||
* fields:
|
||||
* For the format of the <code>criteria</code> parameter, see the
|
||||
* documentation of <code>XR_LocStor::xr_searchMetadata()</code>.
|
||||
*
|
||||
* On success, returns an XML-RPC struct with a single field:
|
||||
* <ul>
|
||||
* <li>playlist - string - an XML representation of the playlist; this
|
||||
* XML element can be used as argument to Playlist::configure()</li>
|
||||
* <li>token - string - a token, which can be used to query the
|
||||
* backup process </li>
|
||||
* </ul>
|
||||
*
|
||||
* In case of an error, a standard XML-RPC fault response is generated,
|
||||
* and a { faultCode, faultString } structure is returned. The
|
||||
* possible errors are:
|
||||
* <ul>
|
||||
* <li>1001 - invalid argument format </li>
|
||||
* <li>1002 - argument is not a playlist ID </li>
|
||||
* <li>1003 - playlist not found </li>
|
||||
* <li>1020 - missing session ID argument </li>
|
||||
* <li>4001 - invalid argument format </li>
|
||||
* <li>4002 - missing criteria argument </li>
|
||||
* <li>4003 - missing fromTime argument </li>
|
||||
* <li>4004 - missing toTime argument </li>
|
||||
* <li>4010 - error reported by the scheduler daemon </li>
|
||||
* <li>4020 - missing session ID argument </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class DisplayPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
class CreateBackupOpenMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
private:
|
||||
/**
|
||||
|
@ -117,7 +126,7 @@ class DisplayPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
|||
/**
|
||||
* A default constructor, for testing purposes.
|
||||
*/
|
||||
DisplayPlaylistMethod(void) throw ()
|
||||
CreateBackupOpenMethod(void) throw ()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName)
|
||||
{
|
||||
}
|
||||
|
@ -127,12 +136,12 @@ class DisplayPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
|||
*
|
||||
* @param xmlRpcServer the XML-RPC server to register with.
|
||||
*/
|
||||
DisplayPlaylistMethod(
|
||||
CreateBackupOpenMethod(
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Execute the display schedule command on the Scheduler daemon.
|
||||
* Execute the createBackupOpen command on the Scheduler daemon.
|
||||
*
|
||||
* @param parameters XML-RPC function call parameters
|
||||
* @param returnValue the return value of the call (out parameter)
|
||||
|
@ -153,5 +162,5 @@ class DisplayPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
|||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // DisplayPlaylistMethod_h
|
||||
#endif // CreateBackupOpenMethod_h
|
||||
|
|
@ -1,151 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#else
|
||||
#error need time.h
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "LiveSupport/StorageClient/StorageClientInterface.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "ScheduleInterface.h"
|
||||
#include "ScheduleFactory.h"
|
||||
#include "LiveSupport/Core/XmlRpcTools.h"
|
||||
|
||||
#include "CreatePlaylistMethod.h"
|
||||
|
||||
|
||||
using namespace boost;
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of this XML-RPC method.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string CreatePlaylistMethod::methodName = "createPlaylist";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The ID of this method for error reporting purposes.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const int CreatePlaylistMethod::errorId = 200;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the method and register it right away.
|
||||
*----------------------------------------------------------------------------*/
|
||||
CreatePlaylistMethod :: CreatePlaylistMethod (
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) throw()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Execute the stop XML-RPC function call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw (XmlRpc::XmlRpcException)
|
||||
{
|
||||
if (!rootParameter.valid() || rootParameter.size() != 1
|
||||
|| !rootParameter[0].valid()) {
|
||||
XmlRpcTools::markError(errorId+1, "invalid argument format",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+20,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
|
||||
scf = StorageClientFactory::getInstance();
|
||||
storage = scf->getStorageClient();
|
||||
|
||||
Ptr<UniqueId>::Ref playlistId;
|
||||
try {
|
||||
playlistId = storage->createPlaylist(sessionId);
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
std::string eMsg = "could not create playlist:\n";
|
||||
eMsg += e.what();
|
||||
XmlRpcTools :: markError(errorId+2,
|
||||
eMsg,
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->editPlaylist(sessionId, playlistId);
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
std::string eMsg = "could not create playlist:\n";
|
||||
eMsg += e.what();
|
||||
XmlRpcTools :: markError(errorId+2,
|
||||
eMsg,
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
XmlRpcTools :: playlistToXmlRpcValue(playlist, returnValue);
|
||||
}
|
|
@ -1,179 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "SchedulerDaemon.h"
|
||||
#include "DisplayAudioClipMethod.h"
|
||||
#include "DisplayAudioClipMethodTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(DisplayAudioClipMethodTest);
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayAudioClipMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<SchedulerDaemon>::Ref scheduler = SchedulerDaemon::getInstance();
|
||||
try {
|
||||
Ptr<StorageClientInterface>::Ref storage = scheduler->getStorage();
|
||||
storage->reset();
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = scheduler->getAuthentication();
|
||||
try {
|
||||
sessionId = authentication->login("root", "q");
|
||||
} catch (XmlRpcException &e) {
|
||||
std::string eMsg = "could not log in:\n";
|
||||
eMsg += e.what();
|
||||
CPPUNIT_FAIL(eMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayAudioClipMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Just a very simple smoke test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayAudioClipMethodTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<DisplayAudioClipMethod>::Ref method(new DisplayAudioClipMethod());
|
||||
XmlRpc::XmlRpcValue parameter;
|
||||
XmlRpc::XmlRpcValue rootParameter;
|
||||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
// set up a structure for the parameter
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["audioClipId"] = "0000000000010001";
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
method->execute(rootParameter, result);
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method returned error: " << e.getCode()
|
||||
<< " - " << e.getMessage();
|
||||
CPPUNIT_FAIL(eMsg.str());
|
||||
}
|
||||
CPPUNIT_ASSERT(result.hasMember("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() == 11);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* A very simple negative test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayAudioClipMethodTest :: negativeTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<DisplayAudioClipMethod>::Ref method(new DisplayAudioClipMethod());
|
||||
XmlRpc::XmlRpcValue parameter;
|
||||
XmlRpc::XmlRpcValue rootParameter;
|
||||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
// set up a structure for the parameter
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["audioClipId"] = "0000000000009999";
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
method->execute(rootParameter, result);
|
||||
CPPUNIT_FAIL("allowed to display non-existent audio clip");
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
CPPUNIT_ASSERT(e.getCode() == 603); // audio clip not found
|
||||
}
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef DisplayAudioClipMethodTest_h
|
||||
#define DisplayAudioClipMethodTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
#include "BaseTestMethod.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the DisplayAudioClipMethod class.
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
* @see DisplayAudioClipMethod
|
||||
*/
|
||||
class DisplayAudioClipMethodTest : public BaseTestMethod
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(DisplayAudioClipMethodTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST(negativeTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* A simple negative test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
negativeTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // DisplayAudioClipMethodTest_h
|
||||
|
|
@ -1,139 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "LiveSupport/StorageClient/StorageClientInterface.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "LiveSupport/Core/XmlRpcTools.h"
|
||||
|
||||
#include "DisplayAudioClipsMethod.h"
|
||||
|
||||
using namespace boost;
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of this XML-RPC method.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string DisplayAudioClipsMethod::methodName = "displayAudioClips";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The ID of this method for error reporting purposes.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const int DisplayAudioClipsMethod::errorId = 1800;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the method and register it right away.
|
||||
*----------------------------------------------------------------------------*/
|
||||
DisplayAudioClipsMethod :: DisplayAudioClipsMethod (
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) throw()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
|
||||
{
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Execute the stop XML-RPC function call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayAudioClipsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw (XmlRpc::XmlRpcException)
|
||||
{
|
||||
if (!rootParameter.valid() || rootParameter.size() != 1
|
||||
|| !rootParameter[0].valid()) {
|
||||
XmlRpcTools::markError(errorId+1, "invalid argument format",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+20,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
|
||||
scf = StorageClientFactory::getInstance();
|
||||
storage = scf->getStorageClient();
|
||||
|
||||
Ptr<StorageClientInterface::SearchResultsType>::Ref searchResults;
|
||||
try {
|
||||
searchResults = storage->getSearchResults();
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
std::string eMsg = "getSearchResults returned error:\n";
|
||||
eMsg += e.what();
|
||||
XmlRpcTools::markError(errorId+2, eMsg, returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref
|
||||
audioClips(new std::vector<Ptr<AudioClip>::Ref>);
|
||||
StorageClientInterface::SearchResultsType::const_iterator
|
||||
it = searchResults->begin();
|
||||
while (it != searchResults->end()) {
|
||||
Ptr<AudioClip>::Ref audioClip = (*it)->getAudioClip();
|
||||
if (audioClip) {
|
||||
audioClips->push_back(audioClip);
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
XmlRpcTools::audioClipVectorToXmlRpcValue(audioClips, returnValue);
|
||||
}
|
|
@ -1,159 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef DisplayAudioClipsMethod_h
|
||||
#define DisplayAudioClipsMethod_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <XmlRpcServerMethod.h>
|
||||
#include <XmlRpcValue.h>
|
||||
#include <XmlRpcException.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/AudioClip.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An XML-RPC method object to return a listing of the audio clips contained
|
||||
* in the audio clip store.
|
||||
*
|
||||
* The name of the method when called through XML-RPC is "displayAudioClips".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* </ul>
|
||||
*
|
||||
* The XML-RPC function returns an XML-RPC array, containing a structure
|
||||
* 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>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,
|
||||
* and a { faultCode, faultString } structure is returned. The
|
||||
* possible errors are:
|
||||
* <ul>
|
||||
* <li>1801 - invalid argument format </li>
|
||||
* <li>1802 - XML-RPC error </li>
|
||||
* <li>1820 - missing session ID argument </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class DisplayAudioClipsMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The name of this method, as it will be registered into the
|
||||
* XML-RPC server.
|
||||
*/
|
||||
static const std::string methodName;
|
||||
|
||||
/**
|
||||
* The ID of this method for error reporting purposes.
|
||||
*/
|
||||
static const int errorId;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* A default constructor, for testing purposes.
|
||||
*/
|
||||
DisplayAudioClipsMethod(void) throw ()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constuctor that registers the method with the server right away.
|
||||
*
|
||||
* @param xmlRpcServer the XML-RPC server to register with.
|
||||
*/
|
||||
DisplayAudioClipsMethod(
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Execute the displayAudioClips command on the Scheduler daemon.
|
||||
*
|
||||
* @param parameters XML-RPC function call parameters
|
||||
* @param returnValue the return value of the call (out parameter)
|
||||
*/
|
||||
void
|
||||
execute( XmlRpc::XmlRpcValue & parameters,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw (XmlRpc::XmlRpcException);
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // DisplayAudioClipsMethod_h
|
||||
|
|
@ -1,161 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "SchedulerDaemon.h"
|
||||
#include "DisplayAudioClipsMethod.h"
|
||||
#include "DisplayAudioClipsMethodTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(DisplayAudioClipsMethodTest);
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayAudioClipsMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<SchedulerDaemon>::Ref scheduler = SchedulerDaemon::getInstance();
|
||||
try {
|
||||
Ptr<StorageClientInterface>::Ref storage = scheduler->getStorage();
|
||||
storage->reset();
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = scheduler->getAuthentication();
|
||||
try {
|
||||
sessionId = authentication->login("root", "q");
|
||||
} catch (XmlRpcException &e) {
|
||||
std::string eMsg = "could not log in:\n";
|
||||
eMsg += e.what();
|
||||
CPPUNIT_FAIL(eMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayAudioClipsMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Just a very simple smoke test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayAudioClipsMethodTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<DisplayAudioClipsMethod>::Ref method(new DisplayAudioClipsMethod());
|
||||
XmlRpc::XmlRpcValue parameter;
|
||||
XmlRpc::XmlRpcValue rootParameter;
|
||||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
result.clear();
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
rootParameter[0] = parameter;
|
||||
try {
|
||||
method->execute(rootParameter, result);
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method returned error: " << e.getCode()
|
||||
<< " - " << e.getMessage();
|
||||
CPPUNIT_FAIL(eMsg.str());
|
||||
}
|
||||
CPPUNIT_ASSERT(result.size() >= 2);
|
||||
|
||||
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() == 11);
|
||||
|
||||
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() == 12);
|
||||
}
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef DisplayAudioClipsMethodTest_h
|
||||
#define DisplayAudioClipsMethodTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
#include "BaseTestMethod.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the DisplayAudioClipsMethod class.
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
* @see DisplayAudioClipsMethod
|
||||
*/
|
||||
class DisplayAudioClipsMethodTest : public BaseTestMethod
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(DisplayAudioClipsMethodTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // DisplayAudioClipsMethodTest_h
|
||||
|
|
@ -1,180 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "SchedulerDaemon.h"
|
||||
#include "DisplayPlaylistMethod.h"
|
||||
#include "DisplayPlaylistMethodTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(DisplayPlaylistMethodTest);
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayPlaylistMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<SchedulerDaemon>::Ref scheduler = SchedulerDaemon::getInstance();
|
||||
try {
|
||||
Ptr<StorageClientInterface>::Ref storage = scheduler->getStorage();
|
||||
storage->reset();
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = scheduler->getAuthentication();
|
||||
try {
|
||||
sessionId = authentication->login("root", "q");
|
||||
} catch (XmlRpcException &e) {
|
||||
std::string eMsg = "could not log in:\n";
|
||||
eMsg += e.what();
|
||||
CPPUNIT_FAIL(eMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayPlaylistMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Just a very simple smoke test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayPlaylistMethodTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<DisplayPlaylistMethod>::Ref method(new DisplayPlaylistMethod());
|
||||
XmlRpc::XmlRpcValue parameter;
|
||||
XmlRpc::XmlRpcValue rootParameter;
|
||||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
// set up a structure for the parameter
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["playlistId"] = "0000000000000001";
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
method->execute(rootParameter, result);
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method returned error: " << e.getCode()
|
||||
<< " - " << e.getMessage();
|
||||
CPPUNIT_FAIL(eMsg.str());
|
||||
}
|
||||
CPPUNIT_ASSERT(result.hasMember("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);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* A very simple negative test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayPlaylistMethodTest :: negativeTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<DisplayPlaylistMethod>::Ref method(new DisplayPlaylistMethod());
|
||||
XmlRpc::XmlRpcValue parameter;
|
||||
XmlRpc::XmlRpcValue rootParameter;
|
||||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
// set up a structure for the parameter
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["playlistId"] = "0000000000009999";
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
method->execute(rootParameter, result);
|
||||
CPPUNIT_FAIL("allowed to display non-existent playlist");
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
CPPUNIT_ASSERT(e.getCode() == 1003); // playlist not found
|
||||
}
|
||||
}
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef DisplayPlaylistMethodTest_h
|
||||
#define DisplayPlaylistMethodTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
#include "BaseTestMethod.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the DisplayPlaylistMethod class.
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
* @see DisplayPlaylistMethod
|
||||
*/
|
||||
class DisplayPlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(DisplayPlaylistMethodTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST(negativeTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* A simple negative test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
negativeTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // DisplayPlaylistMethodTest_h
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "LiveSupport/StorageClient/StorageClientInterface.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "LiveSupport/Core/XmlRpcTools.h"
|
||||
|
||||
#include "DisplayPlaylistsMethod.h"
|
||||
|
||||
using namespace boost;
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of this XML-RPC method.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string DisplayPlaylistsMethod::methodName = "displayPlaylists";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The ID of this method for error reporting purposes.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const int DisplayPlaylistsMethod::errorId = 1700;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the method and register it right away.
|
||||
*----------------------------------------------------------------------------*/
|
||||
DisplayPlaylistsMethod :: DisplayPlaylistsMethod (
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) throw()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Execute the stop XML-RPC function call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw (XmlRpc::XmlRpcException)
|
||||
{
|
||||
if (!rootParameter.valid() || rootParameter.size() != 1
|
||||
|| !rootParameter[0].valid()) {
|
||||
XmlRpcTools::markError(errorId+1, "invalid argument format",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+20,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
|
||||
scf = StorageClientFactory::getInstance();
|
||||
storage = scf->getStorageClient();
|
||||
|
||||
Ptr<StorageClientInterface::SearchResultsType>::Ref searchResults;
|
||||
try {
|
||||
searchResults = storage->getSearchResults();
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
std::string eMsg = "getSearchResults returned error:\n";
|
||||
eMsg += e.what();
|
||||
XmlRpcTools::markError(errorId+2, eMsg, returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
|
||||
playlists(new std::vector<Ptr<Playlist>::Ref>);
|
||||
StorageClientInterface::SearchResultsType::const_iterator
|
||||
it = searchResults->begin();
|
||||
while (it != searchResults->end()) {
|
||||
Ptr<Playlist>::Ref playlist = (*it)->getPlaylist();
|
||||
if (playlist) {
|
||||
playlists->push_back(playlist);
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
XmlRpcTools::playlistVectorToXmlRpcValue(playlists, returnValue);
|
||||
}
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef DisplayPlaylistsMethod_h
|
||||
#define DisplayPlaylistsMethod_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <XmlRpcServerMethod.h>
|
||||
#include <XmlRpcValue.h>
|
||||
#include <XmlRpcException.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An XML-RPC method object to return a listing of the playlists contained
|
||||
* in the playlist store.
|
||||
*
|
||||
* The name of the method when called through XML-RPC is "displayPlaylists".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* </ul>
|
||||
*
|
||||
* The XML-RPC function returns an XML-RPC array, containing a structure
|
||||
* 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>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,
|
||||
* and a { faultCode, faultString } structure is returned. The
|
||||
* possible errors are:
|
||||
* <ul>
|
||||
* <li>1701 - invalid argument format </li>
|
||||
* <li>1702 - XML-RPC error </li>
|
||||
* <li>1720 - missing session ID argument </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The name of this method, as it will be registered into the
|
||||
* XML-RPC server.
|
||||
*/
|
||||
static const std::string methodName;
|
||||
|
||||
/**
|
||||
* The ID of this method for error reporting purposes.
|
||||
*/
|
||||
static const int errorId;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* A default constructor, for testing purposes.
|
||||
*/
|
||||
DisplayPlaylistsMethod(void) throw ()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constuctor that registers the method with the server right away.
|
||||
*
|
||||
* @param xmlRpcServer the XML-RPC server to register with.
|
||||
*/
|
||||
DisplayPlaylistsMethod(
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Execute the displayPlaylists command on the Scheduler daemon.
|
||||
*
|
||||
* @param parameters XML-RPC function call parameters
|
||||
* @param returnValue the return value of the call (out parameter)
|
||||
*/
|
||||
void
|
||||
execute( XmlRpc::XmlRpcValue & parameters,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw (XmlRpc::XmlRpcException);
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // DisplayPlaylistsMethod_h
|
||||
|
|
@ -1,163 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "SchedulerDaemon.h"
|
||||
#include "DisplayPlaylistsMethod.h"
|
||||
#include "DisplayPlaylistsMethodTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(DisplayPlaylistsMethodTest);
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayPlaylistsMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<SchedulerDaemon>::Ref scheduler = SchedulerDaemon::getInstance();
|
||||
try {
|
||||
Ptr<StorageClientInterface>::Ref storage = scheduler->getStorage();
|
||||
storage->reset();
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = scheduler->getAuthentication();
|
||||
try {
|
||||
sessionId = authentication->login("root", "q");
|
||||
} catch (XmlRpcException &e) {
|
||||
std::string eMsg = "could not log in:\n";
|
||||
eMsg += e.what();
|
||||
CPPUNIT_FAIL(eMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayPlaylistsMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Just a very simple smoke test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayPlaylistsMethodTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<DisplayPlaylistsMethod>::Ref method(new DisplayPlaylistsMethod());
|
||||
XmlRpc::XmlRpcValue parameters;
|
||||
XmlRpc::XmlRpcValue rootParameter;
|
||||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
result.clear();
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
rootParameter[0] = parameters;
|
||||
try {
|
||||
method->execute(rootParameter, result);
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method returned error: " << e.getCode()
|
||||
<< " - " << e.getMessage();
|
||||
CPPUNIT_FAIL(eMsg.str());
|
||||
}
|
||||
CPPUNIT_ASSERT(result.size() == 3);
|
||||
XmlRpc::XmlRpcValue result0;
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
|
||||
// check the first returned playlist
|
||||
result0 = result[0];
|
||||
CPPUNIT_ASSERT(result0.hasMember("playlist"));
|
||||
CPPUNIT_ASSERT(result0["playlist"].getType()
|
||||
== XmlRpc::XmlRpcValue::TypeString);
|
||||
CPPUNIT_ASSERT_NO_THROW(playlist.reset(new Playlist(result0)));
|
||||
CPPUNIT_ASSERT(playlist->getId()->getId() == 1);
|
||||
CPPUNIT_ASSERT(playlist->getPlaylength()->total_seconds() == 90 * 60);
|
||||
|
||||
// check the second returned playlist
|
||||
result0 = result[1];
|
||||
CPPUNIT_ASSERT(result0.hasMember("playlist"));
|
||||
CPPUNIT_ASSERT(result0["playlist"].getType()
|
||||
== XmlRpc::XmlRpcValue::TypeString);
|
||||
CPPUNIT_ASSERT_NO_THROW(playlist.reset(new Playlist(result0)));
|
||||
CPPUNIT_ASSERT(playlist->getId()->getId() == 2);
|
||||
CPPUNIT_ASSERT(playlist->getPlaylength()->total_seconds() == 29);
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef DisplayPlaylistsMethodTest_h
|
||||
#define DisplayPlaylistsMethodTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
#include "BaseTestMethod.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the DisplayPlaylistsMethod class.
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
* @see DisplayPlaylistsMethod
|
||||
*/
|
||||
class DisplayPlaylistsMethodTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(DisplayPlaylistsMethodTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // DisplayPlaylistsMethodTest_h
|
||||
|
|
@ -80,7 +80,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(DisplayScheduleMethodTest);
|
|||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayScheduleMethodTest :: setUp(void) throw ()
|
||||
DisplayScheduleMethodTest :: setUp(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<SchedulerDaemon>::Ref scheduler = SchedulerDaemon::getInstance();
|
||||
try {
|
||||
|
@ -115,7 +115,7 @@ DisplayScheduleMethodTest :: setUp(void) throw ()
|
|||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayScheduleMethodTest :: tearDown(void) throw ()
|
||||
DisplayScheduleMethodTest :: tearDown(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
schedule->uninstall();
|
||||
|
||||
|
@ -175,7 +175,7 @@ DisplayScheduleMethodTest :: firstTest(void)
|
|||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayScheduleMethodTest :: insertEntries(void)
|
||||
throw ()
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<UploadPlaylistMethod>::Ref method(new UploadPlaylistMethod());
|
||||
XmlRpcValue parameters;
|
||||
|
|
|
@ -96,7 +96,7 @@ class DisplayScheduleMethodTest : public CPPUNIT_NS::TestFixture
|
|||
* Insert some entries into the schedule to provide test data.
|
||||
*/
|
||||
void
|
||||
insertEntries(void) throw ();
|
||||
insertEntries(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -123,13 +123,13 @@ class DisplayScheduleMethodTest : public CPPUNIT_NS::TestFixture
|
|||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
setUp(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
tearDown(void) throw (CPPUNIT_NS::Exception);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(GeneratePlayReportMethodTest);
|
|||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GeneratePlayReportMethodTest :: setUp(void) throw ()
|
||||
GeneratePlayReportMethodTest :: setUp(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<SchedulerDaemon>::Ref scheduler = SchedulerDaemon::getInstance();
|
||||
try {
|
||||
|
@ -114,7 +114,7 @@ GeneratePlayReportMethodTest :: setUp(void) throw ()
|
|||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GeneratePlayReportMethodTest :: tearDown(void) throw ()
|
||||
GeneratePlayReportMethodTest :: tearDown(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
playLog->uninstall();
|
||||
|
||||
|
@ -174,7 +174,7 @@ GeneratePlayReportMethodTest :: firstTest(void)
|
|||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GeneratePlayReportMethodTest :: insertEntries(void)
|
||||
throw ()
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<const UniqueId>::Ref audioClipId(new UniqueId(10001));
|
||||
Ptr<const ptime>::Ref timestamp(new ptime(time_from_string(
|
||||
|
|
|
@ -96,7 +96,7 @@ class GeneratePlayReportMethodTest : public CPPUNIT_NS::TestFixture
|
|||
* Insert some entries into the play log to provide test data.
|
||||
*/
|
||||
void
|
||||
insertEntries(void) throw ();
|
||||
insertEntries(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -123,13 +123,13 @@ class GeneratePlayReportMethodTest : public CPPUNIT_NS::TestFixture
|
|||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
setUp(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
tearDown(void) throw (CPPUNIT_NS::Exception);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(GetSchedulerTimeMethodTest);
|
|||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GetSchedulerTimeMethodTest :: setUp(void) throw ()
|
||||
GetSchedulerTimeMethodTest :: setUp(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ GetSchedulerTimeMethodTest :: setUp(void) throw ()
|
|||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GetSchedulerTimeMethodTest :: tearDown(void) throw ()
|
||||
GetSchedulerTimeMethodTest :: tearDown(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -86,13 +86,13 @@ class GetSchedulerTimeMethodTest : public CPPUNIT_NS::TestFixture
|
|||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
setUp(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
tearDown(void) throw (CPPUNIT_NS::Exception);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ static const std::string versionPrefix = "LiveSupport Scheduler Daemon";
|
|||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GetVersionMethodTest :: setUp(void) throw ()
|
||||
GetVersionMethodTest :: setUp(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ GetVersionMethodTest :: setUp(void) throw ()
|
|||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GetVersionMethodTest :: tearDown(void) throw ()
|
||||
GetVersionMethodTest :: tearDown(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -90,13 +90,13 @@ class GetVersionMethodTest : public CPPUNIT_NS::TestFixture
|
|||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
setUp(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
tearDown(void) throw (CPPUNIT_NS::Exception);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,150 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#else
|
||||
#error need time.h
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "LiveSupport/StorageClient/StorageClientInterface.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "ScheduleInterface.h"
|
||||
#include "ScheduleFactory.h"
|
||||
#include "LiveSupport/Core/XmlRpcTools.h"
|
||||
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
|
||||
|
||||
using namespace boost;
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of this XML-RPC method.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string OpenPlaylistForEditingMethod::methodName
|
||||
= "openPlaylistForEditing";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The ID of this method for error reporting purposes.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const int OpenPlaylistForEditingMethod::errorId = 100;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the method and register it right away.
|
||||
*----------------------------------------------------------------------------*/
|
||||
OpenPlaylistForEditingMethod :: OpenPlaylistForEditingMethod (
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) throw()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Execute the stop XML-RPC function call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
OpenPlaylistForEditingMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw (XmlRpc::XmlRpcException)
|
||||
{
|
||||
if (!rootParameter.valid() || rootParameter.size() != 1
|
||||
|| !rootParameter[0].valid()) {
|
||||
XmlRpcTools::markError(errorId+1, "invalid argument format",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+20,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref id;
|
||||
try{
|
||||
id = XmlRpcTools::extractPlaylistId(parameters);
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+2, "argument is not a playlist ID",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
|
||||
scf = StorageClientFactory::getInstance();
|
||||
storage = scf->getStorageClient();
|
||||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->editPlaylist(sessionId, id);
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
std::string eMsg = "could not open playlist for editing:\n";
|
||||
eMsg += e.what();
|
||||
XmlRpcTools::markError(errorId+4, eMsg, returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
playlist->createSavedCopy();
|
||||
|
||||
XmlRpcTools::playlistToXmlRpcValue(playlist, returnValue);
|
||||
return;
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef OpenPlaylistForEditingMethod_h
|
||||
#define OpenPlaylistForEditingMethod_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <XmlRpcServerMethod.h>
|
||||
#include <XmlRpcValue.h>
|
||||
#include <XmlRpcException.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An XML-RPC method object to open a playlist (specified by its playlist id)
|
||||
* for editing.
|
||||
*
|
||||
* The name of the method when called through XML-RPC is
|
||||
* "openPlaylistForEditing".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </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>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,
|
||||
* and a { faultCode, faultString } structure is returned. The
|
||||
* possible errors are:
|
||||
* <ul>
|
||||
* <li>101 - invalid argument format </li>
|
||||
* <li>102 - argument is not a playlist ID </li>
|
||||
* <li>104 - could not open playlist for editing </li>
|
||||
* <li>120 - missing session ID argument </li>
|
||||
* </ul>
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class OpenPlaylistForEditingMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The name of this method, as it will be registered into the
|
||||
* XML-RPC server.
|
||||
*/
|
||||
static const std::string methodName;
|
||||
|
||||
/**
|
||||
* The ID of this method for error reporting purposes.
|
||||
*/
|
||||
static const int errorId;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* A default constructor, for testing purposes.
|
||||
*/
|
||||
OpenPlaylistForEditingMethod(void) throw ()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constuctor that registers the method with the server right away.
|
||||
*
|
||||
* @param xmlRpcServer the XML-RPC server to register with.
|
||||
*/
|
||||
OpenPlaylistForEditingMethod(
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Execute the display schedule command on the Scheduler daemon.
|
||||
*
|
||||
* @param parameters XML-RPC function call parameters
|
||||
* @param returnValue the return value of the call (out parameter)
|
||||
*/
|
||||
void
|
||||
execute( XmlRpc::XmlRpcValue & parameters,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw (XmlRpc::XmlRpcException);
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // OpenPlaylistForEditingMethod_h
|
||||
|
|
@ -1,178 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "LiveSupport/Core/XmlRpcTools.h"
|
||||
|
||||
#include "SchedulerDaemon.h"
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
#include "OpenPlaylistForEditingMethodTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(OpenPlaylistForEditingMethodTest);
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
OpenPlaylistForEditingMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<SchedulerDaemon>::Ref scheduler = SchedulerDaemon::getInstance();
|
||||
try {
|
||||
Ptr<StorageClientInterface>::Ref storage = scheduler->getStorage();
|
||||
storage->reset();
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = scheduler->getAuthentication();
|
||||
try {
|
||||
sessionId = authentication->login("root", "q");
|
||||
} catch (XmlRpcException &e) {
|
||||
std::string eMsg = "could not log in:\n";
|
||||
eMsg += e.what();
|
||||
CPPUNIT_FAIL(eMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
OpenPlaylistForEditingMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Just a very simple smoke test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
OpenPlaylistForEditingMethodTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<OpenPlaylistForEditingMethod>::Ref
|
||||
method(new OpenPlaylistForEditingMethod());
|
||||
XmlRpc::XmlRpcValue parameter;
|
||||
XmlRpc::XmlRpcValue rootParameter;
|
||||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["playlistId"] = "0000000000000001";
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
method->execute(rootParameter, result);
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method returned error: " << e.getCode()
|
||||
<< " - " << e.getMessage();
|
||||
CPPUNIT_FAIL(eMsg.str());
|
||||
}
|
||||
CPPUNIT_ASSERT(result.hasMember("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();
|
||||
parameter["playlistId"] = "0000000000009999";
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
method->execute(rootParameter, result);
|
||||
CPPUNIT_FAIL("allowed to open non-existent playlist");
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
CPPUNIT_ASSERT(e.getCode() == 104); // could not open playlist
|
||||
}
|
||||
|
||||
parameter.clear();
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["playlistId"] = "0000000000000001";
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
method->execute(rootParameter, result);
|
||||
CPPUNIT_FAIL("allowed to open the same playlist twice");
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
CPPUNIT_ASSERT(e.getCode() == 104); // could not open playlist
|
||||
}
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef OpenPlaylistForEditingMethodTest_h
|
||||
#define OpenPlaylistForEditingMethodTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
#include "BaseTestMethod.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the OpenPlaylistForEditingMethod class.
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
* @see OpenPlaylistForEditingMethod
|
||||
*/
|
||||
class OpenPlaylistForEditingMethodTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(OpenPlaylistForEditingMethodTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // OpenPlaylistForEditingMethodTest_h
|
||||
|
|
@ -81,7 +81,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(PlaylistEventContainerTest);
|
|||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PlaylistEventContainerTest :: setUp(void) throw ()
|
||||
PlaylistEventContainerTest :: setUp(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<SchedulerDaemon>::Ref scheduler = SchedulerDaemon::getInstance();
|
||||
try {
|
||||
|
@ -118,7 +118,7 @@ PlaylistEventContainerTest :: setUp(void) throw ()
|
|||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PlaylistEventContainerTest :: tearDown(void) throw ()
|
||||
PlaylistEventContainerTest :: tearDown(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
audioPlayer->deInitialize();
|
||||
schedule->uninstall();
|
||||
|
|
|
@ -144,13 +144,13 @@ class PlaylistEventContainerTest : public CPPUNIT_NS::TestFixture
|
|||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
setUp(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
tearDown(void) throw (CPPUNIT_NS::Exception);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(PlaylistEventTest);
|
|||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PlaylistEventTest :: setUp(void) throw ()
|
||||
PlaylistEventTest :: setUp(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<SchedulerDaemon>::Ref scheduler = SchedulerDaemon::getInstance();
|
||||
try {
|
||||
|
@ -111,7 +111,7 @@ PlaylistEventTest :: setUp(void) throw ()
|
|||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PlaylistEventTest :: tearDown(void) throw ()
|
||||
PlaylistEventTest :: tearDown(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
playLog->uninstall();
|
||||
audioPlayer->deInitialize();
|
||||
|
@ -131,7 +131,7 @@ PlaylistEventTest :: tearDown(void) throw ()
|
|||
* Create a sample playlist event
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<PlaylistEvent>::Ref
|
||||
PlaylistEventTest :: createTestEvent(void) throw ()
|
||||
PlaylistEventTest :: createTestEvent(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
// create a fake schedule entry, with id 1 for playlist 1, starting
|
||||
// 10 seconds from now, and lasting 30 seconds
|
||||
|
|
|
@ -117,7 +117,7 @@ class PlaylistEventTest : public CPPUNIT_NS::TestFixture
|
|||
* Create a playlist event for testing purposes.
|
||||
*/
|
||||
Ptr<PlaylistEvent>::Ref
|
||||
createTestEvent(void) throw ();
|
||||
createTestEvent(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -153,13 +153,13 @@ class PlaylistEventTest : public CPPUNIT_NS::TestFixture
|
|||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
setUp(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
tearDown(void) throw (CPPUNIT_NS::Exception);
|
||||
};
|
||||
|
||||
|
||||
|
|
503
livesupport/src/products/scheduler/src/PostgresqlBackup.cxx
Normal file
503
livesupport/src/products/scheduler/src/PostgresqlBackup.cxx
Normal file
|
@ -0,0 +1,503 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#include <odbc++/statement.h>
|
||||
#include <odbc++/preparedstatement.h>
|
||||
#include <odbc++/resultset.h>
|
||||
#include <libxml++/libxml++.h>
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/Core/FileTools.h"
|
||||
#include "LiveSupport/Db/Conversion.h"
|
||||
#include "PostgresqlBackup.h"
|
||||
|
||||
using namespace odbc;
|
||||
using namespace boost::posix_time;
|
||||
using namespace xmlpp;
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the config element for this class
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string PostgresqlBackup::configElementNameStr
|
||||
= "postgresqlBackup";
|
||||
|
||||
namespace {
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the schedule export element
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string scheduleExportElementName = "scheduleExport";
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the fromTime attribute
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string fromTimeAttrName = "fromTime";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the toTime attribute
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string toTimeAttrName = "toTime";
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The working backup state
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string workingState = "working";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The finished / success backup state
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string successState = "success";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The finished / failure backup state
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string failureState = "fault";
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the schedule export fie in the export tarbal;
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string scheduleExportFileName = "meta-inf/scheduler.xml";
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* A statement to check if the database can be accessed.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string check1Stmt = "SELECT 1";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The SQL create statement, used for installation.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string createStmt =
|
||||
"CREATE TABLE backup\n"
|
||||
"(\n"
|
||||
" token VARCHAR(64) NOT NULL,\n"
|
||||
" sessionId VARCHAR(64) NOT NULL,\n"
|
||||
" status VARCHAR(32) NOT NULL,\n"
|
||||
" fromTime TIMESTAMP NOT NULL,\n"
|
||||
" toTime TIMESTAMP NOT NULL,\n"
|
||||
"\n"
|
||||
" PRIMARY KEY(token)\n"
|
||||
");";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The SQL create statement, used for installation.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string dropStmt = "DROP TABLE backup;";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* A statement to check if the backup table exists.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string backupCountStmt = "SELECT COUNT(*) FROM backup";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* A statement to store a backup entry.
|
||||
* - token - the token of the backup
|
||||
* - status - the status of the backup, either 'working', 'success' or 'fault'
|
||||
* - fromTime - the start time of the schedule backup
|
||||
* - toTime - the end time of the schedule backup
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string storeBackupStmt =
|
||||
"INSERT INTO backup(token, sessionId, status, fromTime, toTime) "
|
||||
"VALUES(?, ?, ?, ?, ?)";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Get a backup from the database.
|
||||
* - token - the token of an existing backup
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string getBackupStmt =
|
||||
"SELECT token, sessionId, status, fromTime, toTime FROM backup "
|
||||
"WHERE token = ?";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* A statement to update a backup entry.
|
||||
* - status - the new status of the backup
|
||||
* - token - the token of an existing backup
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string updateBackupStmt =
|
||||
"UPDATE backup SET status = ? WHERE token = ?";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* A statement to delete a backup entry
|
||||
* - token - the token of an existing backup
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string deleteBackupStmt = "DELETE FROM backup WHERE token = ?";
|
||||
|
||||
}
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Configure the backup.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PostgresqlBackup :: configure(const xmlpp::Element & element)
|
||||
throw (std::invalid_argument,
|
||||
std::logic_error)
|
||||
{
|
||||
if (element.get_name() != configElementNameStr) {
|
||||
std::string eMsg = "Bad configuration element ";
|
||||
eMsg += element.get_name();
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
|
||||
// nothing to do here, really
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Install the PostgresqlBackup.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PostgresqlBackup :: install(void) throw (std::exception)
|
||||
{
|
||||
if (!isInstalled()) {
|
||||
Ptr<Connection>::Ref conn;
|
||||
try {
|
||||
conn = connectionManager->getConnection();
|
||||
Ptr<Statement>::Ref stmt(conn->createStatement());
|
||||
stmt->execute(createStmt);
|
||||
connectionManager->returnConnection(conn);
|
||||
} catch (std::exception &e) {
|
||||
if (conn) {
|
||||
connectionManager->returnConnection(conn);
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check to see if the PostgresqlBackup has already been installed.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
PostgresqlBackup :: isInstalled(void) throw (std::exception)
|
||||
{
|
||||
Ptr<Connection>::Ref conn;
|
||||
try {
|
||||
Ptr<Statement>::Ref stmt;
|
||||
ResultSet * res;
|
||||
|
||||
conn = connectionManager->getConnection();
|
||||
|
||||
// see if we can connect at all
|
||||
stmt.reset(conn->createStatement());
|
||||
stmt->execute(check1Stmt);
|
||||
res = stmt->getResultSet();
|
||||
if (!res->next() || (res->getInt(1) != 1)) {
|
||||
throw std::runtime_error("Can't connect to database");
|
||||
}
|
||||
|
||||
// see if the backup table exists
|
||||
try {
|
||||
stmt.reset(conn->createStatement());
|
||||
stmt->execute(backupCountStmt);
|
||||
res = stmt->getResultSet();
|
||||
if (!res->next() || (res->getInt(1) < 0)) {
|
||||
connectionManager->returnConnection(conn);
|
||||
return false;
|
||||
}
|
||||
} catch (std::exception &e) {
|
||||
connectionManager->returnConnection(conn);
|
||||
return false;
|
||||
}
|
||||
|
||||
connectionManager->returnConnection(conn);
|
||||
} catch (std::exception &e) {
|
||||
if (conn) {
|
||||
connectionManager->returnConnection(conn);
|
||||
}
|
||||
throw;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Uninstall the PostgresqlBackup.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PostgresqlBackup :: uninstall(void) throw (std::exception)
|
||||
{
|
||||
Ptr<Connection>::Ref conn;
|
||||
try {
|
||||
conn = connectionManager->getConnection();
|
||||
Ptr<Statement>::Ref stmt(conn->createStatement());
|
||||
stmt->execute(dropStmt);
|
||||
connectionManager->returnConnection(conn);
|
||||
} catch (std::exception &e) {
|
||||
if (conn) {
|
||||
connectionManager->returnConnection(conn);
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Start a backup process.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Glib::ustring>::Ref
|
||||
PostgresqlBackup ::createBackupOpen(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<SearchCriteria>::Ref criteria,
|
||||
Ptr<ptime>::Ref fromTime,
|
||||
Ptr<ptime>::Ref toTime)
|
||||
throw (XmlRpcException)
|
||||
{
|
||||
Ptr<Glib::ustring>::Ref token;
|
||||
Ptr<Connection>::Ref conn;
|
||||
bool result = false;
|
||||
|
||||
// open up a backup process with the storage server
|
||||
token = storage->createBackupOpen(sessionId, criteria);
|
||||
|
||||
// store the details of the backup, with a pending status
|
||||
try {
|
||||
conn = connectionManager->getConnection();
|
||||
Ptr<Timestamp>::Ref timestamp;
|
||||
Ptr<PreparedStatement>::Ref pstmt(conn->prepareStatement(
|
||||
storeBackupStmt));
|
||||
pstmt->setString(1, *token);
|
||||
pstmt->setString(2, sessionId->getId());
|
||||
pstmt->setString(3, asyncStateToString(AsyncState::pendingState));
|
||||
|
||||
timestamp = Conversion::ptimeToTimestamp(fromTime);
|
||||
pstmt->setTimestamp(4, *timestamp);
|
||||
|
||||
timestamp = Conversion::ptimeToTimestamp(toTime);
|
||||
pstmt->setTimestamp(5, *timestamp);
|
||||
|
||||
result = pstmt->executeUpdate() == 1;
|
||||
|
||||
connectionManager->returnConnection(conn);
|
||||
} catch (std::exception &e) {
|
||||
if (conn) {
|
||||
connectionManager->returnConnection(conn);
|
||||
}
|
||||
throw std::invalid_argument(e.what());
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
throw std::invalid_argument("couldn't insert into database");
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check on the status of a backup process.
|
||||
*----------------------------------------------------------------------------*/
|
||||
AsyncState
|
||||
PostgresqlBackup ::createBackupCheck(
|
||||
const Glib::ustring & token,
|
||||
Ptr<const Glib::ustring>::Ref & url,
|
||||
Ptr<const Glib::ustring>::Ref & path,
|
||||
Ptr<const Glib::ustring>::Ref & errorMessage)
|
||||
throw (XmlRpcException)
|
||||
{
|
||||
Ptr<Connection>::Ref conn;
|
||||
AsyncState status;
|
||||
Ptr<ptime>::Ref fromTime;
|
||||
Ptr<ptime>::Ref toTime;
|
||||
bool result;
|
||||
|
||||
// first, check on the status ourselves
|
||||
try {
|
||||
Ptr<Timestamp>::Ref timestamp;
|
||||
|
||||
conn = connectionManager->getConnection();
|
||||
Ptr<PreparedStatement>::Ref pstmt(conn->prepareStatement(
|
||||
getBackupStmt));
|
||||
|
||||
pstmt->setString(1, token);
|
||||
|
||||
Ptr<ResultSet>::Ref rs(pstmt->executeQuery());
|
||||
if (rs->next()) {
|
||||
status = stringToAsyncState(rs->getString(3));
|
||||
|
||||
timestamp.reset(new Timestamp(rs->getTimestamp(4)));
|
||||
fromTime = Conversion::timestampToPtime(timestamp);
|
||||
|
||||
timestamp.reset(new Timestamp(rs->getTimestamp(5)));
|
||||
toTime = Conversion::timestampToPtime(timestamp);
|
||||
}
|
||||
|
||||
connectionManager->returnConnection(conn);
|
||||
} catch (std::exception &e) {
|
||||
if (conn) {
|
||||
connectionManager->returnConnection(conn);
|
||||
}
|
||||
// TODO: report error
|
||||
return status;
|
||||
}
|
||||
|
||||
if (status == AsyncState::pendingState) {
|
||||
status = storage->createBackupCheck(token, url, path, errorMessage);
|
||||
|
||||
if (status == AsyncState::finishedState) {
|
||||
putScheduleExportIntoTar(path, fromTime, toTime);
|
||||
}
|
||||
}
|
||||
|
||||
// update the status
|
||||
try {
|
||||
conn = connectionManager->getConnection();
|
||||
Ptr<Timestamp>::Ref timestamp;
|
||||
Ptr<PreparedStatement>::Ref pstmt(conn->prepareStatement(
|
||||
updateBackupStmt));
|
||||
pstmt->setString(1, asyncStateToString(status));
|
||||
pstmt->setString(2, token);
|
||||
|
||||
result = pstmt->executeUpdate() == 1;
|
||||
|
||||
connectionManager->returnConnection(conn);
|
||||
} catch (std::exception &e) {
|
||||
if (conn) {
|
||||
connectionManager->returnConnection(conn);
|
||||
}
|
||||
throw std::invalid_argument(e.what());
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
throw std::invalid_argument("couldn't insert into database");
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Close a backup process, and free up all resources.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PostgresqlBackup ::putScheduleExportIntoTar(
|
||||
Ptr<const Glib::ustring>::Ref & path,
|
||||
Ptr<ptime>::Ref fromTime,
|
||||
Ptr<ptime>::Ref toTime)
|
||||
throw (std::runtime_error)
|
||||
{
|
||||
Ptr<Document>::Ref document(new Document());
|
||||
Element * root = document->create_root_node("scheduler");
|
||||
std::string tmpFileName = FileTools::tempnam();
|
||||
|
||||
// create the export, and write it to a temporary file
|
||||
schedule->exportScheduleEntries(root, fromTime, toTime);
|
||||
document->write_to_file(tmpFileName);
|
||||
|
||||
try {
|
||||
FileTools::appendFileToTarball(*path,
|
||||
tmpFileName,
|
||||
scheduleExportFileName);
|
||||
} catch (std::runtime_error &e) {
|
||||
remove(tmpFileName.c_str());
|
||||
throw;
|
||||
}
|
||||
|
||||
remove(tmpFileName.c_str());
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Close a backup process, and free up all resources.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PostgresqlBackup ::createBackupClose(const Glib::ustring & token)
|
||||
throw (XmlRpcException)
|
||||
{
|
||||
Ptr<Connection>::Ref conn;
|
||||
bool result;
|
||||
|
||||
storage->createBackupClose(token);
|
||||
|
||||
// delete the backup from our database
|
||||
try {
|
||||
conn = connectionManager->getConnection();
|
||||
Ptr<Timestamp>::Ref timestamp;
|
||||
Ptr<PreparedStatement>::Ref pstmt(conn->prepareStatement(
|
||||
deleteBackupStmt));
|
||||
pstmt->setString(1, token);
|
||||
|
||||
result = pstmt->executeUpdate() == 1;
|
||||
|
||||
connectionManager->returnConnection(conn);
|
||||
} catch (std::exception &e) {
|
||||
if (conn) {
|
||||
connectionManager->returnConnection(conn);
|
||||
}
|
||||
throw std::invalid_argument(e.what());
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
throw std::invalid_argument("couldn't insert into database");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert a string status to an AsyncState.
|
||||
*----------------------------------------------------------------------------*/
|
||||
AsyncState
|
||||
PostgresqlBackup ::stringToAsyncState(const std::string & statusString)
|
||||
throw ()
|
||||
{
|
||||
return AsyncState::fromBackupString(statusString);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert an AsyncState to a string.
|
||||
*----------------------------------------------------------------------------*/
|
||||
std::string
|
||||
PostgresqlBackup ::asyncStateToString(AsyncState status)
|
||||
throw ()
|
||||
{
|
||||
return *status.toBackupString();
|
||||
}
|
||||
|
324
livesupport/src/products/scheduler/src/PostgresqlBackup.h
Normal file
324
livesupport/src/products/scheduler/src/PostgresqlBackup.h
Normal file
|
@ -0,0 +1,324 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef PostgresqlBackup_h
|
||||
#define PostgresqlBackup_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Configurable.h"
|
||||
#include "LiveSupport/Db/ConnectionManagerInterface.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientInterface.h"
|
||||
#include "ScheduleInterface.h"
|
||||
#include "BackupInterface.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An object containing the schedule of events in a PostreSQL database.
|
||||
*
|
||||
* This object has to be configured with a simple empty element, as
|
||||
* the following:
|
||||
*
|
||||
* <pre><code>
|
||||
* <postgresqlBackup/>
|
||||
* </code></pre>
|
||||
*
|
||||
* The DTD for the above element is:
|
||||
*
|
||||
* <pre><code>
|
||||
* <!ELEMENT postgresqlBackup EMPTY >
|
||||
* </code></pre>
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class PostgresqlBackup : public Configurable,
|
||||
public BackupInterface
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The name of the configuration XML elmenent used by this object.
|
||||
*/
|
||||
static const std::string configElementNameStr;
|
||||
|
||||
/**
|
||||
* The database connection manager to use for connecting to the
|
||||
* database.
|
||||
*/
|
||||
Ptr<ConnectionManagerInterface>::Ref connectionManager;
|
||||
|
||||
/**
|
||||
* The storage client to use for connecting to the storage server.
|
||||
*/
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
|
||||
/**
|
||||
* The schedule to use for reading the schedule entries from.
|
||||
*/
|
||||
Ptr<ScheduleInterface>::Ref schedule;
|
||||
|
||||
/**
|
||||
* The default constructor.
|
||||
*/
|
||||
PostgresqlBackup(void) throw()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a schedule export XML file into an existing tarball.
|
||||
*
|
||||
* @param path the file path to the existing tarball.
|
||||
* @param fromTime the time to generate the XML export from
|
||||
* @param toTime the time to generate the XML export to
|
||||
* @throws std::runtime_error on file / tarball handling issues.
|
||||
*/
|
||||
void
|
||||
putScheduleExportIntoTar(
|
||||
Ptr<const Glib::ustring>::Ref & path,
|
||||
Ptr<ptime>::Ref fromTime,
|
||||
Ptr<ptime>::Ref toTime)
|
||||
throw (std::runtime_error);
|
||||
|
||||
/**
|
||||
* Convert a string status to an AsyncState.
|
||||
* It converts
|
||||
* <ul>
|
||||
* <li> "working" -> pendingState </li>
|
||||
* <li> "success" -> finishedState </li>
|
||||
* <li> "fault" -> failedState </li>
|
||||
* <li> anything else -> invalidState <li>
|
||||
* </ul>
|
||||
*/
|
||||
AsyncState
|
||||
stringToAsyncState(const std::string & statusString) throw ();
|
||||
|
||||
/**
|
||||
* Convert an AsyncState to a string.
|
||||
* It converts
|
||||
* <ul>
|
||||
* <li> initState or pendingState -> "working" </li>
|
||||
* <li> finishedState -> "success" </li>
|
||||
* <li> failedState -> "fault" </li>
|
||||
* <li> anything else -> "invalid" </li>
|
||||
* </ul>
|
||||
*/
|
||||
std::string
|
||||
asyncStateToString(AsyncState status)
|
||||
throw ();
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* Construct a PostgresqlBackup.
|
||||
*
|
||||
* @param cm the connection manager the PostgresqlBackup will use to
|
||||
* connect to the database.
|
||||
*/
|
||||
PostgresqlBackup(
|
||||
Ptr<ConnectionManagerInterface>::Ref connectionManager,
|
||||
Ptr<StorageClientInterface>::Ref storage,
|
||||
Ptr<ScheduleInterface>::Ref schedule)
|
||||
throw ()
|
||||
: connectionManager(connectionManager),
|
||||
storage(storage),
|
||||
schedule(schedule)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
virtual
|
||||
~PostgresqlBackup(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the XML element this object expects
|
||||
* to be sent to a call to configure().
|
||||
*
|
||||
* @return the name of the expected XML configuration element.
|
||||
*/
|
||||
static const std::string
|
||||
getConfigElementName(void) throw ()
|
||||
{
|
||||
return configElementNameStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the object based on the XML element supplied.
|
||||
* The supplied element is expected to be of the name
|
||||
* returned by configElementName().
|
||||
*
|
||||
* @param element the XML element to configure the object from.
|
||||
* @exception std::invalid_argument if the supplied XML element
|
||||
* contains bad configuraiton information
|
||||
* @exception std::logic_error if the object has already
|
||||
* been configured, and can not be reconfigured.
|
||||
*/
|
||||
virtual void
|
||||
configure(const xmlpp::Element & element)
|
||||
throw (std::invalid_argument,
|
||||
std::logic_error);
|
||||
|
||||
/**
|
||||
* Install the component.
|
||||
* This step involves creating the environment in which the component
|
||||
* will run. This may be creation of coniguration files,
|
||||
* database tables, etc.
|
||||
*
|
||||
* @exception std::exception on installation problems.
|
||||
*/
|
||||
virtual void
|
||||
install(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Check to see if the component has already been installed.
|
||||
*
|
||||
* @return true if the component is properly installed,
|
||||
* false otherwise
|
||||
* @exception std::exception on generic problems
|
||||
*/
|
||||
virtual bool
|
||||
isInstalled(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Uninstall the component.
|
||||
* Removes all the resources created in the install step.
|
||||
*
|
||||
* @exception std::exception on unistallation problems.
|
||||
*/
|
||||
virtual void
|
||||
uninstall(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Start to create a backup by calling the storage, and also
|
||||
* adding a backup of the schedule.
|
||||
* To check if the backup procedure is still pending, call
|
||||
* createBackupCheck() regularly.
|
||||
* Make sure to close the backup by calling createBackupClose().
|
||||
*
|
||||
* @param sessionId a valid session ID to use for accessing the
|
||||
* storage
|
||||
* @param criteria the criteria to use for backing up the storage
|
||||
* @param fromTime entries are included in the schedule export starting
|
||||
* from this time.
|
||||
* @param toTime entries as included in the schedule export
|
||||
* up to but not including this time.
|
||||
* @return a token, which can be used to query the backup process.
|
||||
* @exception XmlRpcException on XML-RPC issues.
|
||||
* @see #createBackupCheck
|
||||
* @see #createBackupClose
|
||||
*/
|
||||
virtual Ptr<Glib::ustring>::Ref
|
||||
createBackupOpen(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<SearchCriteria>::Ref criteria,
|
||||
Ptr<ptime>::Ref fromTime,
|
||||
Ptr<ptime>::Ref toTime)
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Check the status of a storage backup.
|
||||
*
|
||||
* @param token the identifier of this backup task.
|
||||
* @param url return parameter;
|
||||
* if the status is "success", it contains the
|
||||
* URL of the created backup file.
|
||||
* @param path return parameter;
|
||||
* if the status is "success", it contains the
|
||||
* local access path of the created backup file.
|
||||
* @param errorMessage return parameter;
|
||||
* if the status is "fault", it contains the
|
||||
* fault string.
|
||||
* @return the state of the backup process: one of pendingState,
|
||||
* finishedState, or failedState.
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
* @see #createBackupOpen
|
||||
* @see #createBackupClose
|
||||
*/
|
||||
virtual AsyncState
|
||||
createBackupCheck(const Glib::ustring & token,
|
||||
Ptr<const Glib::ustring>::Ref & url,
|
||||
Ptr<const Glib::ustring>::Ref & path,
|
||||
Ptr<const Glib::ustring>::Ref & errorMessage)
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Close the storage backup process.
|
||||
* Frees up all resources allocated to the backup.
|
||||
*
|
||||
* @param token the identifier of this backup task.
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
* @see #createBackupOpen
|
||||
* @see #createBackupCheck
|
||||
*/
|
||||
virtual void
|
||||
createBackupClose(const Glib::ustring & token)
|
||||
throw (XmlRpcException);
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // PostgresqlBackup_h
|
||||
|
|
@ -41,32 +41,20 @@
|
|||
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "SchedulerDaemon.h"
|
||||
#include "CreatePlaylistMethod.h"
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
#include "CreatePlaylistMethodTest.h"
|
||||
#include "PostgresqlBackup.h"
|
||||
#include "PostgresqlBackupTest.h"
|
||||
|
||||
using namespace XmlRpc;
|
||||
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(CreatePlaylistMethodTest);
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(PostgresqlBackupTest);
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
@ -78,22 +66,29 @@ CPPUNIT_TEST_SUITE_REGISTRATION(CreatePlaylistMethodTest);
|
|||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
CreatePlaylistMethodTest :: setUp(void) throw ()
|
||||
PostgresqlBackupTest :: setUp(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<SchedulerDaemon>::Ref scheduler = SchedulerDaemon::getInstance();
|
||||
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
|
||||
try {
|
||||
Ptr<StorageClientInterface>::Ref storage = scheduler->getStorage();
|
||||
storage->reset();
|
||||
Ptr<ConnectionManagerInterface>::Ref connectionManager;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
Ptr<ScheduleInterface>::Ref schedule;
|
||||
|
||||
connectionManager = daemon->getConnectionManager();
|
||||
storage = daemon->getStorage();
|
||||
schedule = daemon->getSchedule();
|
||||
|
||||
backup.reset(new PostgresqlBackup(connectionManager,
|
||||
storage,
|
||||
schedule));
|
||||
backup->install();
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = scheduler->getAuthentication();
|
||||
authentication = daemon->getAuthentication();
|
||||
try {
|
||||
sessionId = authentication->login("root", "q");
|
||||
} catch (XmlRpcException &e) {
|
||||
|
@ -108,57 +103,58 @@ CreatePlaylistMethodTest :: setUp(void) throw ()
|
|||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
CreatePlaylistMethodTest :: tearDown(void) throw ()
|
||||
PostgresqlBackupTest :: tearDown(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
backup->uninstall();
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Just a very simple smoke test
|
||||
* Test to see if we can create backups
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
CreatePlaylistMethodTest :: firstTest(void)
|
||||
PostgresqlBackupTest :: createBackupTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<XmlRpcServerMethod>::Ref method(new CreatePlaylistMethod());
|
||||
XmlRpc::XmlRpcValue parameter;
|
||||
XmlRpc::XmlRpcValue rootParameter;
|
||||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
Ptr<SearchCriteria>::Ref criteria(new SearchCriteria);
|
||||
criteria->setLimit(10);
|
||||
Ptr<ptime>::Ref from(new ptime(time_from_string("2004-07-23 10:00:00")));
|
||||
Ptr<ptime>::Ref to(new ptime(time_from_string("2004-07-23 11:00:00")));
|
||||
|
||||
result.clear();
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
rootParameter[0] = parameter;
|
||||
try {
|
||||
method->execute(rootParameter, result);
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method returned error: " << e.getCode()
|
||||
<< " - " << e.getMessage();
|
||||
CPPUNIT_FAIL(eMsg.str());
|
||||
}
|
||||
CPPUNIT_ASSERT(result.hasMember("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);
|
||||
Ptr<Glib::ustring>::Ref token;
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
token = backup->createBackupOpen(sessionId, criteria, from, to);
|
||||
);
|
||||
CPPUNIT_ASSERT(token);
|
||||
|
||||
method.reset(new OpenPlaylistForEditingMethod());
|
||||
parameter.clear();
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["playlistId"] = std::string(result["id"]);
|
||||
rootParameter[0] = parameter;
|
||||
Ptr<const Glib::ustring>::Ref url;
|
||||
Ptr<const Glib::ustring>::Ref path;
|
||||
Ptr<const Glib::ustring>::Ref errorMessage;
|
||||
AsyncState status;
|
||||
int iterations = 20;
|
||||
do {
|
||||
std::cerr << "-/|\\"[iterations%4] << '\b';
|
||||
sleep(1);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
status = backup->createBackupCheck(*token, url, path, errorMessage);
|
||||
);
|
||||
CPPUNIT_ASSERT(status == AsyncState::pendingState
|
||||
|| status == AsyncState::finishedState
|
||||
|| status == AsyncState::failedState);
|
||||
} while (--iterations && status == AsyncState::pendingState);
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
method->execute(rootParameter, result);
|
||||
CPPUNIT_FAIL("allowed to open playlist twice");
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
CPPUNIT_ASSERT(e.getCode() == 104);
|
||||
}
|
||||
CPPUNIT_ASSERT_EQUAL(AsyncState::finishedState, status);
|
||||
// TODO: test accessibility of the URL?
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
backup->createBackupClose(*token);
|
||||
);
|
||||
// TODO: test existence of schedule backup in tarball
|
||||
}
|
||||
|
||||
|
|
@ -26,8 +26,8 @@
|
|||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef CreatePlaylistMethodTest_h
|
||||
#define CreatePlaylistMethodTest_h
|
||||
#ifndef PostgresqlBackupTest_h
|
||||
#define PostgresqlBackupTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
|
@ -43,15 +43,13 @@
|
|||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
#include "PostgresqlBackup.h"
|
||||
#include "BaseTestMethod.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -62,22 +60,27 @@ using namespace LiveSupport::Authentication;
|
|||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the CreatePlaylistMethod class.
|
||||
* Unit test for the PostgresqlBackup class.
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
* @see CreatePlaylistMethod
|
||||
* @see PostgresqlBackup
|
||||
*/
|
||||
class CreatePlaylistMethodTest : public BaseTestMethod
|
||||
class PostgresqlBackupTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(CreatePlaylistMethodTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST_SUITE(PostgresqlBackupTest);
|
||||
CPPUNIT_TEST(createBackupTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
* The PostgresqlBackup object which does the backup operations.
|
||||
*/
|
||||
Ptr<PostgresqlBackup>::Ref backup;
|
||||
|
||||
/**
|
||||
* The authentication client used to log in.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
|
@ -90,13 +93,12 @@ class CreatePlaylistMethodTest : public BaseTestMethod
|
|||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
* Test to see if the backup works as expected
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
createBackupTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
public:
|
||||
|
||||
|
@ -104,13 +106,13 @@ class CreatePlaylistMethodTest : public BaseTestMethod
|
|||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
setUp(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
tearDown(void) throw (CPPUNIT_NS::Exception);
|
||||
};
|
||||
|
||||
|
||||
|
@ -123,5 +125,5 @@ class CreatePlaylistMethodTest : public BaseTestMethod
|
|||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // CreatePlaylistMethodTest_h
|
||||
#endif // PostgresqlBackupTest_h
|
||||
|
|
@ -26,8 +26,8 @@
|
|||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef PostresqlPlayLog_h
|
||||
#define PostresqlPlayLog_h
|
||||
#ifndef PostgresqlPlayLog_h
|
||||
#define PostgresqlPlayLog_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
|
@ -252,5 +252,5 @@ class PostgresqlPlayLog : public Configurable,
|
|||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // PostresqlPlayLog_h
|
||||
#endif // PostgresqlPlayLog_h
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(PostgresqlPlayLogTest);
|
|||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PostgresqlPlayLogTest :: setUp(void) throw ()
|
||||
PostgresqlPlayLogTest :: setUp(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<SchedulerDaemon>::Ref scheduler = SchedulerDaemon::getInstance();
|
||||
try {
|
||||
|
@ -90,7 +90,7 @@ PostgresqlPlayLogTest :: setUp(void) throw ()
|
|||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PostgresqlPlayLogTest :: tearDown(void) throw ()
|
||||
PostgresqlPlayLogTest :: tearDown(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
try {
|
||||
playLog->uninstall();
|
||||
|
|
|
@ -113,13 +113,13 @@ class PostgresqlPlayLogTest : public CPPUNIT_NS::TestFixture
|
|||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
setUp(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
tearDown(void) throw (CPPUNIT_NS::Exception);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -42,11 +42,13 @@
|
|||
#include "PostgresqlSchedule.h"
|
||||
|
||||
using namespace odbc;
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
|
@ -58,6 +60,25 @@ using namespace LiveSupport::Scheduler;
|
|||
const std::string PostgresqlSchedule::configElementNameStr =
|
||||
"postgresqlSchedule";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the schedule export element
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string PostgresqlSchedule::scheduleExportElementName
|
||||
= "scheduleExport";
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the fromTime attribute
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string PostgresqlSchedule::fromTimeAttrName = "fromTime";
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the toTime attribute
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string PostgresqlSchedule::toTimeAttrName = "toTime";
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* A statement to check if the database can be accessed.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -244,8 +265,8 @@ PostgresqlSchedule :: isInstalled(void) throw (std::exception)
|
|||
stmt->execute(scheduleCountStmt);
|
||||
res = stmt->getResultSet();
|
||||
if (!res->next() || (res->getInt(1) < 0)) {
|
||||
return false;
|
||||
cm->returnConnection(conn);
|
||||
return false;
|
||||
}
|
||||
} catch (std::exception &e) {
|
||||
cm->returnConnection(conn);
|
||||
|
@ -374,6 +395,49 @@ PostgresqlSchedule :: schedulePlaylist(
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Insert a schedule entry into the database
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PostgresqlSchedule :: storeScheduleEntry(
|
||||
Ptr<ScheduleEntry>::Ref scheduleEntry)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
Ptr<Connection>::Ref conn;
|
||||
bool result = false;
|
||||
|
||||
try {
|
||||
conn = cm->getConnection();
|
||||
Ptr<Timestamp>::Ref timestamp;
|
||||
Ptr<ptime>::Ref ends;
|
||||
Ptr<PreparedStatement>::Ref pstmt(conn->prepareStatement(
|
||||
schedulePlaylistStmt));
|
||||
|
||||
pstmt->setLong(1, scheduleEntry->getId()->getId());
|
||||
pstmt->setLong(2, scheduleEntry->getPlaylistId()->getId());
|
||||
|
||||
timestamp = Conversion::ptimeToTimestamp(scheduleEntry->getStartTime());
|
||||
pstmt->setTimestamp(3, *timestamp);
|
||||
|
||||
timestamp = Conversion::ptimeToTimestamp(scheduleEntry->getEndTime());
|
||||
pstmt->setTimestamp(4, *timestamp);
|
||||
|
||||
result = pstmt->executeUpdate() == 1;
|
||||
|
||||
cm->returnConnection(conn);
|
||||
} catch (std::exception &e) {
|
||||
if (conn) {
|
||||
cm->returnConnection(conn);
|
||||
}
|
||||
throw std::invalid_argument(e.what());
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
throw std::invalid_argument("couldn't insert into database");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Get the scheduled entries for a given timepoint
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -428,6 +492,64 @@ PostgresqlSchedule :: getScheduleEntries(
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Export schedule entries to an XML file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PostgresqlSchedule :: exportScheduleEntries(
|
||||
xmlpp::Element * element,
|
||||
Ptr<ptime>::Ref fromTime,
|
||||
Ptr<ptime>::Ref toTime)
|
||||
throw ()
|
||||
{
|
||||
xmlpp::Element * scheduleExport;
|
||||
Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref entries;
|
||||
std::vector<Ptr<ScheduleEntry>::Ref>::iterator it;
|
||||
|
||||
scheduleExport = element->add_child(scheduleExportElementName);
|
||||
scheduleExport->set_attribute(fromTimeAttrName, to_iso_string(*fromTime));
|
||||
scheduleExport->set_attribute(toTimeAttrName, to_iso_string(*toTime));
|
||||
|
||||
entries = getScheduleEntries(fromTime, toTime);
|
||||
it = entries->begin();
|
||||
while (it != entries->end()) {
|
||||
Ptr<ScheduleEntry>::Ref entry = *it;
|
||||
|
||||
entry->toDom(scheduleExport);
|
||||
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Import schedule entries to an XML file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PostgresqlSchedule :: importScheduleEntries(xmlpp::Element * element)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
if (element->get_name() != scheduleExportElementName) {
|
||||
std::string eMsg = "bad configuration element ";
|
||||
eMsg += element->get_name();
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
|
||||
xmlpp::Node::NodeList children =
|
||||
element->get_children(ScheduleEntry::getElementName());
|
||||
xmlpp::Node::NodeList::iterator it = children.begin();
|
||||
while (it != children.end()) {
|
||||
xmlpp::Element * node = dynamic_cast<xmlpp::Element*> (*it);
|
||||
Ptr<ScheduleEntry>::Ref scheduleEntry;
|
||||
|
||||
scheduleEntry.reset(new ScheduleEntry(node));
|
||||
storeScheduleEntry(scheduleEntry);
|
||||
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Get the currently playing entry
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef PostresqlSchedule_h
|
||||
#define PostresqlSchedule_h
|
||||
#ifndef PostgresqlSchedule_h
|
||||
#define PostgresqlSchedule_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
|
@ -92,6 +92,21 @@ class PostgresqlSchedule : public Configurable,
|
|||
*/
|
||||
static const std::string configElementNameStr;
|
||||
|
||||
/**
|
||||
* The name of the schedule export element
|
||||
*/
|
||||
static const std::string scheduleExportElementName;
|
||||
|
||||
/**
|
||||
* The name of the fromTime attribute
|
||||
*/
|
||||
static const std::string fromTimeAttrName;
|
||||
|
||||
/**
|
||||
* The name of the toTime attribute
|
||||
*/
|
||||
static const std::string toTimeAttrName;
|
||||
|
||||
/**
|
||||
* A SQL statement to check if the database can be accessed.
|
||||
*/
|
||||
|
@ -286,11 +301,44 @@ class PostgresqlSchedule : public Configurable,
|
|||
* @param toTime to end of the time of the interval queried
|
||||
* @return a vector of the scheduled entries for the time region.
|
||||
*/
|
||||
virtual Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref
|
||||
virtual Ptr<ScheduleEntryList>::Ref
|
||||
getScheduleEntries(Ptr<ptime>::Ref fromTime,
|
||||
Ptr<ptime>::Ref toTime)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Export schedule entries to a DOM tree.
|
||||
*
|
||||
* @param element a new DOM element will be added as a child to
|
||||
* this element, which will contain the export.
|
||||
* @param fromTime entries are included in the export starting
|
||||
* from this time.
|
||||
* @param toTime entries as included in the export up to
|
||||
* but not including this time.
|
||||
* @return a DOM element, which is the export.
|
||||
* it is the responsibility of the caller to free up the
|
||||
* returned element.
|
||||
* @see #importScheduleEntries
|
||||
*/
|
||||
virtual void
|
||||
exportScheduleEntries(xmlpp::Element * element,
|
||||
Ptr<ptime>::Ref fromTime,
|
||||
Ptr<ptime>::Ref toTime)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Import schedule entries from a DOM tree.
|
||||
*
|
||||
* @param element the DOM element containing schedule entries
|
||||
* to import.
|
||||
* @exception std::invalid_argument if the supplied DOM tree
|
||||
* is not valid.
|
||||
* @see #exportScheduleEntries
|
||||
*/
|
||||
virtual void
|
||||
importScheduleEntries(xmlpp::Element * element)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Return the schedule entry that is being played at the moment.
|
||||
*
|
||||
|
@ -346,6 +394,17 @@ class PostgresqlSchedule : public Configurable,
|
|||
getScheduleEntry(Ptr<UniqueId>::Ref entryId)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Insert a schedule entry into the database.
|
||||
*
|
||||
* @param scheduleEntry the schedule entry to process.
|
||||
* @exception std::invalid_argument if the there is something
|
||||
* already scheduled for the duration of the playlist.
|
||||
*/
|
||||
virtual void
|
||||
storeScheduleEntry(Ptr<ScheduleEntry>::Ref scheduleEntry)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Reschedule an event to a different time.
|
||||
*
|
||||
|
@ -370,5 +429,5 @@ class PostgresqlSchedule : public Configurable,
|
|||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // PostresqlSchedule_h
|
||||
#endif // PostgresqlSchedule_h
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
|
||||
|
||||
using namespace boost::posix_time;
|
||||
using namespace xmlpp;
|
||||
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
|
@ -71,7 +72,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(PostgresqlScheduleTest);
|
|||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PostgresqlScheduleTest :: setUp(void) throw ()
|
||||
PostgresqlScheduleTest :: setUp(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<SchedulerDaemon>::Ref scheduler = SchedulerDaemon::getInstance();
|
||||
try {
|
||||
|
@ -92,7 +93,7 @@ PostgresqlScheduleTest :: setUp(void) throw ()
|
|||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PostgresqlScheduleTest :: tearDown(void) throw ()
|
||||
PostgresqlScheduleTest :: tearDown(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
schedule->uninstall();
|
||||
schedule.reset();
|
||||
|
@ -541,3 +542,61 @@ PostgresqlScheduleTest :: currentlyPlayingTest(void)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test export / import
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PostgresqlScheduleTest :: exportImportTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
// create a 1 hour long playlist
|
||||
Ptr<UniqueId>::Ref playlistId = UniqueId::generateId();
|
||||
Ptr<time_duration>::Ref playlength(new time_duration(1, 0, 0));
|
||||
Ptr<Playlist>::Ref playlist(new Playlist(playlistId, playlength));
|
||||
|
||||
Ptr<ptime>::Ref now;
|
||||
Ptr<ptime>::Ref from;
|
||||
Ptr<ptime>::Ref to;
|
||||
Ptr<time_duration>::Ref duration;
|
||||
|
||||
Ptr<UniqueId>::Ref entryId;
|
||||
|
||||
Ptr<ScheduleEntry>::Ref entry;
|
||||
Ptr<ScheduleEntry>::Ref eentry;
|
||||
Ptr<ScheduleInterface::ScheduleEntryList>::Ref entries;
|
||||
|
||||
Element * element;
|
||||
|
||||
now = TimeConversion::now();
|
||||
|
||||
// schedule our playlist for 10 seconds from now
|
||||
from.reset(new ptime(*now));
|
||||
*from += seconds(10);
|
||||
entryId = schedule->schedulePlaylist(playlist, from);
|
||||
entry = schedule->getScheduleEntry(entryId);
|
||||
|
||||
// export the schedule
|
||||
Ptr<Document>::Ref document(new Document());
|
||||
Element * root = document->create_root_node("root");
|
||||
|
||||
from.reset(new ptime(*now));
|
||||
to.reset(new ptime(*now));
|
||||
*to += minutes(1);
|
||||
schedule->exportScheduleEntries(root, from, to);
|
||||
|
||||
// remove the scheduled entry from the schedule
|
||||
schedule->removeFromSchedule(entryId);
|
||||
CPPUNIT_ASSERT(schedule->getScheduleEntries(from, to)->size() == 0);
|
||||
|
||||
// import the exported schedule
|
||||
element = dynamic_cast<Element*> (*(root->get_children().begin()));
|
||||
schedule->importScheduleEntries(element);
|
||||
|
||||
// check on the timeframe, and see that its the same as it should be
|
||||
entries = schedule->getScheduleEntries(from, to);
|
||||
CPPUNIT_ASSERT(entries->size() == 1);
|
||||
eentry = *(entries->begin());
|
||||
CPPUNIT_ASSERT(*entry == *eentry);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ class PostgresqlScheduleTest : public CPPUNIT_NS::TestFixture
|
|||
{
|
||||
CPPUNIT_TEST_SUITE(PostgresqlScheduleTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
/*
|
||||
CPPUNIT_TEST(simpleScheduleTest);
|
||||
CPPUNIT_TEST(scheduleAndQueryTest);
|
||||
CPPUNIT_TEST(getScheduleEntriesTest);
|
||||
|
@ -80,6 +81,8 @@ class PostgresqlScheduleTest : public CPPUNIT_NS::TestFixture
|
|||
CPPUNIT_TEST(removeFromScheduleTest);
|
||||
CPPUNIT_TEST(rescheduleTest);
|
||||
CPPUNIT_TEST(currentlyPlayingTest);
|
||||
*/
|
||||
CPPUNIT_TEST(exportImportTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
@ -171,19 +174,27 @@ class PostgresqlScheduleTest : public CPPUNIT_NS::TestFixture
|
|||
void
|
||||
currentlyPlayingTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Test XML export / import.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
exportImportTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
setUp(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
tearDown(void) throw (CPPUNIT_NS::Exception);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,173 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#else
|
||||
#error need time.h
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "LiveSupport/StorageClient/StorageClientInterface.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "ScheduleInterface.h"
|
||||
#include "ScheduleFactory.h"
|
||||
#include "LiveSupport/Core/XmlRpcTools.h"
|
||||
|
||||
#include "RemoveAudioClipFromPlaylistMethod.h"
|
||||
|
||||
|
||||
using namespace boost;
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of this XML-RPC method.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string RemoveAudioClipFromPlaylistMethod::methodName
|
||||
= "removeAudioClipFromPlaylist";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The ID of this method for error reporting purposes.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const int RemoveAudioClipFromPlaylistMethod::errorId = 400;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the method and register it right away.
|
||||
*----------------------------------------------------------------------------*/
|
||||
RemoveAudioClipFromPlaylistMethod :: RemoveAudioClipFromPlaylistMethod (
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) throw()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Execute the stop XML-RPC function call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RemoveAudioClipFromPlaylistMethod :: execute(
|
||||
XmlRpc::XmlRpcValue & rootParameter,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw (XmlRpc::XmlRpcException)
|
||||
{
|
||||
if (!rootParameter.valid() || rootParameter.size() != 1
|
||||
|| !rootParameter[0].valid()) {
|
||||
XmlRpcTools::markError(errorId+1, "invalid argument format",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+20,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref playlistId;
|
||||
try{
|
||||
playlistId = XmlRpcTools::extractPlaylistId(parameters);
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+2,
|
||||
"missing playlist ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref playlistElementId;
|
||||
try{
|
||||
playlistElementId = XmlRpcTools::extractPlaylistElementId(parameters);
|
||||
} catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+3,
|
||||
"missing playlist element ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
scf = StorageClientFactory::getInstance();
|
||||
storage = scf->getStorageClient();
|
||||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->getPlaylist(sessionId, playlistId);
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
std::string eMsg = "playlist does not exist:\n";
|
||||
eMsg += e.what();
|
||||
XmlRpcTools::markError(errorId+4, eMsg, returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playlist->isLocked()) {
|
||||
XmlRpcTools::markError(errorId+5,
|
||||
"playlist has not been opened for editing",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
try { // and finally, the beef
|
||||
playlist->removePlaylistElement(playlistElementId);
|
||||
} catch(std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+6,
|
||||
"no audio clip at the specified "
|
||||
"relative offset",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
}
|
|
@ -1,155 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef RemoveAudioClipFromPlaylistMethod_h
|
||||
#define RemoveAudioClipFromPlaylistMethod_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <XmlRpcServerMethod.h>
|
||||
#include <XmlRpcValue.h>
|
||||
#include <XmlRpcException.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An XML-RPC method object to remove an audio clip (specified by its relative
|
||||
* offset) from a playlist (specified by its ID).
|
||||
*
|
||||
* The name of the method when called through XML-RPC is
|
||||
* "removeAudioClipFromPlaylist".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </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,
|
||||
* and a { faultCode, faultString } structure is returned. The
|
||||
* possible errors are:
|
||||
* <ul>
|
||||
* <li>401 - invalid argument format </li>
|
||||
* <li>402 - missing playlist ID argument </li>
|
||||
* <li>403 - missing relative offset argument </li>
|
||||
* <li>404 - playlist does not exist </li>
|
||||
* <li>405 - playlist has not been opened for editing </li>
|
||||
* <li>406 - no audio clip at the specified relative offset </li>
|
||||
* <li>420 - missing session ID argument </li>
|
||||
* </ul>
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class RemoveAudioClipFromPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The name of this method, as it will be registered into the
|
||||
* XML-RPC server.
|
||||
*/
|
||||
static const std::string methodName;
|
||||
|
||||
/**
|
||||
* The ID of this method for error reporting purposes.
|
||||
*/
|
||||
static const int errorId;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* A default constructor, for testing purposes.
|
||||
*/
|
||||
RemoveAudioClipFromPlaylistMethod(void) throw ()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constuctor that registers the method with the server right away.
|
||||
*
|
||||
* @param xmlRpcServer the XML-RPC server to register with.
|
||||
*/
|
||||
RemoveAudioClipFromPlaylistMethod(
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Execute the display schedule command on the Scheduler daemon.
|
||||
*
|
||||
* @param parameters XML-RPC function call parameters
|
||||
* @param returnValue the return value of the call (out parameter)
|
||||
*/
|
||||
void
|
||||
execute( XmlRpc::XmlRpcValue & parameters,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw (XmlRpc::XmlRpcException);
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // RemoveAudioClipFromPlaylistMethod_h
|
||||
|
|
@ -1,201 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "LiveSupport/Core/XmlRpcTools.h"
|
||||
|
||||
#include "SchedulerDaemon.h"
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
#include "AddAudioClipToPlaylistMethod.h"
|
||||
#include "RemoveAudioClipFromPlaylistMethod.h"
|
||||
|
||||
#include "RemoveAudioClipFromPlaylistMethodTest.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(RemoveAudioClipFromPlaylistMethodTest);
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RemoveAudioClipFromPlaylistMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<SchedulerDaemon>::Ref scheduler = SchedulerDaemon::getInstance();
|
||||
try {
|
||||
Ptr<StorageClientInterface>::Ref storage = scheduler->getStorage();
|
||||
storage->reset();
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = scheduler->getAuthentication();
|
||||
try {
|
||||
sessionId = authentication->login("root", "q");
|
||||
} catch (XmlRpcException &e) {
|
||||
std::string eMsg = "could not log in:\n";
|
||||
eMsg += e.what();
|
||||
CPPUNIT_FAIL(eMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RemoveAudioClipFromPlaylistMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Just a very simple smoke test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RemoveAudioClipFromPlaylistMethodTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<OpenPlaylistForEditingMethod>::Ref
|
||||
openPlaylistMethod(new OpenPlaylistForEditingMethod());
|
||||
Ptr<AddAudioClipToPlaylistMethod>::Ref
|
||||
addAudioClipMethod(new AddAudioClipToPlaylistMethod());
|
||||
Ptr<RemoveAudioClipFromPlaylistMethod>::Ref
|
||||
removeAudioClipMethod(new RemoveAudioClipFromPlaylistMethod());
|
||||
XmlRpc::XmlRpcValue parameters;
|
||||
XmlRpc::XmlRpcValue rootParameter;
|
||||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = "0000000000000001";
|
||||
parameters["audioClipId"] = "0000000000010001";
|
||||
parameters["relativeOffset"] = 60*60;
|
||||
parameters["playlistElementId"] = "0000000000009999";
|
||||
rootParameter[0] = parameters;
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
removeAudioClipMethod->execute(rootParameter, result);
|
||||
CPPUNIT_FAIL("allowed to edit playlist without opening it first");
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
CPPUNIT_ASSERT(e.getCode() == 405); // not open for editing
|
||||
}
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
openPlaylistMethod->execute(rootParameter, result);
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method returned error: " << e.getCode()
|
||||
<< " - " << e.getMessage();
|
||||
CPPUNIT_FAIL(eMsg.str());
|
||||
}
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
removeAudioClipMethod->execute(rootParameter, result);
|
||||
CPPUNIT_FAIL("allowed to remove non-existent audio clip from playlist");
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
CPPUNIT_ASSERT(e.getCode() == 406); // no such playlist element
|
||||
}
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
addAudioClipMethod->execute(rootParameter, result);
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method returned error: " << e.getCode()
|
||||
<< " - " << e.getMessage();
|
||||
CPPUNIT_FAIL(eMsg.str());
|
||||
}
|
||||
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 {
|
||||
removeAudioClipMethod->execute(rootParameter, result);
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method returned error: " << e.getCode()
|
||||
<< " - " << e.getMessage();
|
||||
CPPUNIT_FAIL(eMsg.str());
|
||||
}
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef RemoveAudioClipFromPlaylistMethodTest_h
|
||||
#define RemoveAudioClipFromPlaylistMethodTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
#include "BaseTestMethod.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the RemoveAudioClipFromPlaylistMethod class.
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
* @see RemoveAudioClipFromPlaylistMethod
|
||||
*/
|
||||
class RemoveAudioClipFromPlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(RemoveAudioClipFromPlaylistMethodTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // RemoveAudioClipFromPlaylistMethodTest_h
|
||||
|
|
@ -79,7 +79,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(RemoveFromScheduleMethodTest);
|
|||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RemoveFromScheduleMethodTest :: setUp(void) throw ()
|
||||
RemoveFromScheduleMethodTest :: setUp(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<SchedulerDaemon>::Ref scheduler = SchedulerDaemon::getInstance();
|
||||
try {
|
||||
|
@ -112,7 +112,7 @@ RemoveFromScheduleMethodTest :: setUp(void) throw ()
|
|||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RemoveFromScheduleMethodTest :: tearDown(void) throw ()
|
||||
RemoveFromScheduleMethodTest :: tearDown(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
schedule->uninstall();
|
||||
|
||||
|
|
|
@ -126,13 +126,13 @@ class RemoveFromScheduleMethodTest : public CPPUNIT_NS::TestFixture
|
|||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
setUp(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
tearDown(void) throw (CPPUNIT_NS::Exception);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(RescheduleMethodTest);
|
|||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RescheduleMethodTest :: setUp(void) throw ()
|
||||
RescheduleMethodTest :: setUp(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<SchedulerDaemon>::Ref scheduler = SchedulerDaemon::getInstance();
|
||||
try {
|
||||
|
@ -110,7 +110,7 @@ RescheduleMethodTest :: setUp(void) throw ()
|
|||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RescheduleMethodTest :: tearDown(void) throw ()
|
||||
RescheduleMethodTest :: tearDown(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
schedule->uninstall();
|
||||
|
||||
|
|
|
@ -118,13 +118,13 @@ class RescheduleMethodTest : public CPPUNIT_NS::TestFixture
|
|||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
setUp(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
tearDown(void) throw (CPPUNIT_NS::Exception);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(ResetStorageMethodTest);
|
|||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ResetStorageMethodTest :: setUp(void) throw ()
|
||||
ResetStorageMethodTest :: setUp(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ ResetStorageMethodTest :: setUp(void) throw ()
|
|||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ResetStorageMethodTest :: tearDown(void) throw ()
|
||||
ResetStorageMethodTest :: tearDown(void) throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -85,66 +85,6 @@ ResetStorageMethodTest :: firstTest(void)
|
|||
CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result));
|
||||
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
|
||||
|
||||
parameters.clear();
|
||||
parameters["login"] = "root";
|
||||
parameters["password"] = "q";
|
||||
result.clear();
|
||||
CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result));
|
||||
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
|
||||
CPPUNIT_ASSERT(result.hasMember("sessionId"));
|
||||
|
||||
std::string sessionId = std::string(result["sessionId"]);
|
||||
|
||||
parameters.clear();
|
||||
parameters["sessionId"] = sessionId;
|
||||
parameters["playlistId"] = "0000000000000001";
|
||||
result.clear();
|
||||
CPPUNIT_ASSERT(xmlRpcClient.execute("displayPlaylist", parameters, result));
|
||||
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
|
||||
CPPUNIT_ASSERT(result.hasMember("playlist"));
|
||||
/*
|
||||
parameters.clear();
|
||||
parameters["sessionId"] = sessionId;
|
||||
parameters["playlistId"] = "0000000000000001";
|
||||
result.clear();
|
||||
CPPUNIT_ASSERT(xmlRpcClient.execute("deletePlaylist", parameters, result));
|
||||
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
|
||||
|
||||
parameters.clear();
|
||||
parameters["sessionId"] = sessionId;
|
||||
parameters["playlistId"] = "0000000000000001";
|
||||
result.clear();
|
||||
CPPUNIT_ASSERT(xmlRpcClient.execute("displayPlaylist", parameters, result));
|
||||
CPPUNIT_ASSERT(xmlRpcClient.isFault());
|
||||
CPPUNIT_ASSERT(result.hasMember("faultCode"));
|
||||
CPPUNIT_ASSERT(int(result["faultCode"]) == 1003);
|
||||
*/
|
||||
result.clear();
|
||||
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"));
|
||||
|
||||
sessionId = std::string(result["sessionId"]);
|
||||
|
||||
parameters.clear();
|
||||
parameters["sessionId"] = sessionId;
|
||||
parameters["playlistId"] = "0000000000000001";
|
||||
result.clear();
|
||||
CPPUNIT_ASSERT(xmlRpcClient.execute("displayPlaylist", parameters, result));
|
||||
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
|
||||
CPPUNIT_ASSERT(result.hasMember("playlist"));
|
||||
|
||||
parameters.clear();
|
||||
parameters["sessionId"] = sessionId;
|
||||
result.clear();
|
||||
CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result));
|
||||
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
|
||||
|
||||
xmlRpcClient.close();
|
||||
}
|
||||
|
||||
|
|
|
@ -87,13 +87,13 @@ class ResetStorageMethodTest : public BaseTestMethod
|
|||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
setUp(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
tearDown(void) throw (CPPUNIT_NS::Exception);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,151 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef RevertEditedPlaylistMethod_h
|
||||
#define RevertEditedPlaylistMethod_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <XmlRpcServerMethod.h>
|
||||
#include <XmlRpcValue.h>
|
||||
#include <XmlRpcException.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An XML-RPC method object to revert a playlist (specified by its playlist id)
|
||||
* to its previous state, before we started editing it.
|
||||
*
|
||||
* The name of the method when called through XML-RPC is
|
||||
* "revertEditedPlaylist".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </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,
|
||||
* and a { faultCode, faultString } structure is returned. The
|
||||
* possible errors are:
|
||||
* <ul>
|
||||
* <li>801 - invalid argument format </li>
|
||||
* <li>802 - argument is not a playlist ID </li>
|
||||
* <li>803 - playlist not found </li>
|
||||
* <li>804 - could not revert playlist </li>
|
||||
* <li>820 - missing session ID argument </li>
|
||||
* </ul>
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class RevertEditedPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The name of this method, as it will be registered into the
|
||||
* XML-RPC server.
|
||||
*/
|
||||
static const std::string methodName;
|
||||
|
||||
/**
|
||||
* The ID of this method for error reporting purposes.
|
||||
*/
|
||||
static const int errorId;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* A default constructor, for testing purposes.
|
||||
*/
|
||||
RevertEditedPlaylistMethod(void) throw ()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constuctor that registers the method with the server right away.
|
||||
*
|
||||
* @param xmlRpcServer the XML-RPC server to register with.
|
||||
*/
|
||||
RevertEditedPlaylistMethod(
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Execute the display schedule command on the Scheduler daemon.
|
||||
*
|
||||
* @param parameters XML-RPC function call parameters
|
||||
* @param returnValue the return value of the call (out parameter)
|
||||
*/
|
||||
void
|
||||
execute(XmlRpc::XmlRpcValue & parameters,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw (XmlRpc::XmlRpcException);
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // RevertEditedPlaylistMethod_h
|
||||
|
|
@ -1,218 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "SchedulerDaemon.h"
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
#include "RemoveAudioClipFromPlaylistMethod.h"
|
||||
#include "SavePlaylistMethod.h"
|
||||
|
||||
#include "RevertEditedPlaylistMethod.h"
|
||||
#include "RevertEditedPlaylistMethodTest.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(RevertEditedPlaylistMethodTest);
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RevertEditedPlaylistMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<SchedulerDaemon>::Ref scheduler = SchedulerDaemon::getInstance();
|
||||
try {
|
||||
Ptr<StorageClientInterface>::Ref storage = scheduler->getStorage();
|
||||
storage->reset();
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = scheduler->getAuthentication();
|
||||
try {
|
||||
sessionId = authentication->login("root", "q");
|
||||
} catch (XmlRpcException &e) {
|
||||
std::string eMsg = "could not log in:\n";
|
||||
eMsg += e.what();
|
||||
CPPUNIT_FAIL(eMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RevertEditedPlaylistMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Just a very simple smoke test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RevertEditedPlaylistMethodTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<OpenPlaylistForEditingMethod>::Ref
|
||||
openMethod(new OpenPlaylistForEditingMethod);
|
||||
Ptr<RemoveAudioClipFromPlaylistMethod>::Ref
|
||||
removeMethod(new RemoveAudioClipFromPlaylistMethod);
|
||||
Ptr<SavePlaylistMethod>::Ref
|
||||
saveMethod(new SavePlaylistMethod);
|
||||
Ptr<RevertEditedPlaylistMethod>::Ref
|
||||
revertMethod(new RevertEditedPlaylistMethod);
|
||||
XmlRpc::XmlRpcValue parameters;
|
||||
XmlRpc::XmlRpcValue rootParameter;
|
||||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = "0000000000000001";
|
||||
parameters["playlistElementId"] = "0000000000000101";
|
||||
rootParameter[0] = parameters;
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
revertMethod->execute(rootParameter, result);
|
||||
CPPUNIT_FAIL("allowed to revert playlist without saving it first");
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
CPPUNIT_ASSERT(e.getCode() == 804); // no saved copy
|
||||
}
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
openMethod->execute(rootParameter, result);
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method returned error: " << e.getCode()
|
||||
<< " - " << e.getMessage();
|
||||
CPPUNIT_FAIL(eMsg.str());
|
||||
}
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
removeMethod->execute(rootParameter, result);
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method returned error: " << e.getCode()
|
||||
<< " - " << e.getMessage();
|
||||
CPPUNIT_FAIL(eMsg.str());
|
||||
}
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
removeMethod->execute(rootParameter, result);
|
||||
CPPUNIT_FAIL("allowed to remove the same playlist element twice");
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
}
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
revertMethod->execute(rootParameter, result);
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method returned error: " << e.getCode()
|
||||
<< " - " << e.getMessage();
|
||||
CPPUNIT_FAIL(eMsg.str());
|
||||
}
|
||||
|
||||
result.clear();
|
||||
try { // but now we can again
|
||||
removeMethod->execute(rootParameter, result);
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method returned error: " << e.getCode()
|
||||
<< " - " << e.getMessage();
|
||||
CPPUNIT_FAIL(eMsg.str());
|
||||
}
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
saveMethod->execute(rootParameter, result);
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method returned error: " << e.getCode()
|
||||
<< " - " << e.getMessage();
|
||||
CPPUNIT_FAIL(eMsg.str());
|
||||
}
|
||||
|
||||
result.clear();
|
||||
try {
|
||||
revertMethod->execute(rootParameter, result);
|
||||
CPPUNIT_FAIL("allowed to revert playlist after discarding saved copy");
|
||||
} catch (XmlRpc::XmlRpcException &e) {
|
||||
CPPUNIT_ASSERT(e.getCode() == 804); // no saved copy
|
||||
}
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef RevertEditedPlaylistMethodTest_h
|
||||
#define RevertEditedPlaylistMethodTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
#include "BaseTestMethod.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the RevertEditedPlaylistMethod class.
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
* @see RevertEditedPlaylistMethod
|
||||
*/
|
||||
class RevertEditedPlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(RevertEditedPlaylistMethodTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // RevertEditedPlaylistMethodTest_h
|
||||
|
|
@ -1,151 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#include <string>
|
||||
#include <XmlRpcClient.h>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "SchedulerDaemon.h"
|
||||
|
||||
#include "RpcAddAudioClipToPlaylistTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(RpcAddAudioClipToPlaylistTest);
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RpcAddAudioClipToPlaylistTest :: setUp(void) throw ()
|
||||
{
|
||||
XmlRpc::XmlRpcValue parameters;
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
XmlRpc::XmlRpcClient xmlRpcClient(getXmlRpcHost().c_str(),
|
||||
getXmlRpcPort(),
|
||||
"/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"])));
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RpcAddAudioClipToPlaylistTest :: tearDown(void) throw ()
|
||||
{
|
||||
XmlRpc::XmlRpcValue parameters;
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
XmlRpc::XmlRpcClient xmlRpcClient(getXmlRpcHost().c_str(),
|
||||
getXmlRpcPort(),
|
||||
"/RPC2",
|
||||
false);
|
||||
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result));
|
||||
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
|
||||
|
||||
xmlRpcClient.close();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Just a very simple smoke test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RpcAddAudioClipToPlaylistTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
XmlRpc::XmlRpcValue parameters;
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
XmlRpc::XmlRpcClient xmlRpcClient(getXmlRpcHost().c_str(),
|
||||
getXmlRpcPort(),
|
||||
"/RPC2",
|
||||
false);
|
||||
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = "0000000000000001";
|
||||
parameters["audioClipId"] = "0000000000010001";
|
||||
parameters["relativeOffset"] = 0;
|
||||
|
||||
result.clear();
|
||||
xmlRpcClient.execute("openPlaylistForEditing", parameters, result);
|
||||
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
|
||||
|
||||
parameters.clear();
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = "0000000000000001";
|
||||
parameters["audioClipId"] = "0000000000010001";
|
||||
parameters["relativeOffset"] = 90*60;
|
||||
|
||||
result.clear();
|
||||
xmlRpcClient.execute("addAudioClipToPlaylist", parameters, result);
|
||||
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
|
||||
|
||||
result.clear();
|
||||
xmlRpcClient.execute("revertEditedPlaylist", parameters, result);
|
||||
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
|
||||
|
||||
result.clear();
|
||||
xmlRpcClient.execute("savePlaylist", parameters, result);
|
||||
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
|
||||
|
||||
xmlRpcClient.close();
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef RpcAddAudioClipToPlaylistTest_h
|
||||
#define RpcAddAudioClipToPlaylistTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
#include "BaseTestMethod.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the AddAudioClipToPlaylistMethod class.
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
* @see AddAudioClipToPlaylistMethod
|
||||
*/
|
||||
class RpcAddAudioClipToPlaylistTest : public BaseTestMethod
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(RpcAddAudioClipToPlaylistTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // RpcAddAudioClipToPlaylistTest_h
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue