added playlist methods to WebStorageClient (everything except acquire and
release) finally got rid of RemoveAudioClip() in Playlist
This commit is contained in:
parent
4d777103f7
commit
6eb6926c8b
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.23 $
|
Version : $Revision: 1.24 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playlist.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playlist.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -93,7 +93,7 @@ using namespace boost::posix_time;
|
||||||
* </code></pre>
|
* </code></pre>
|
||||||
*
|
*
|
||||||
* @author $Author: fgerlits $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.23 $
|
* @version $Revision: 1.24 $
|
||||||
*/
|
*/
|
||||||
class Playlist : public Configurable,
|
class Playlist : public Configurable,
|
||||||
public Playable
|
public Playable
|
||||||
|
@ -492,20 +492,6 @@ class Playlist : public Configurable,
|
||||||
Ptr<FadeInfo>::Ref fadeInfo)
|
Ptr<FadeInfo>::Ref fadeInfo)
|
||||||
throw (std::invalid_argument);
|
throw (std::invalid_argument);
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove an audio clip from the playlist.
|
|
||||||
* THIS IS OBSOLETE, SUPERSEDED BY removePlaylistElement().
|
|
||||||
* TODO: REMOVE IT AFTER THERE ARE NO MORE REFERENCES TO IT.
|
|
||||||
*
|
|
||||||
* @param relativeOffset the start of the audio clip, relative
|
|
||||||
* to the start of the playlist
|
|
||||||
* @exception std::invalid_argument if the playlist does not contain
|
|
||||||
* an audio clip with the specified relative offset
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
removeAudioClip(Ptr<const time_duration>::Ref relativeOffset)
|
|
||||||
throw (std::invalid_argument);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a playlist element from the playlist.
|
* Remove a playlist element from the playlist.
|
||||||
*
|
*
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.19 $
|
Version : $Revision: 1.20 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -201,24 +201,6 @@ Playlist::setFadeInfo(Ptr<time_duration>::Ref relativeOffset,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Remove an audio clip from the playlist.
|
|
||||||
|
|
||||||
CHANGE references of THIS TO REFER TO removePlaylistElement()
|
|
||||||
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
void
|
|
||||||
Playlist::removeAudioClip(Ptr<const time_duration>::Ref relativeOffset)
|
|
||||||
throw (std::invalid_argument)
|
|
||||||
{
|
|
||||||
// this returns the number of elements found and erased
|
|
||||||
if (!elementList->erase(*relativeOffset)) {
|
|
||||||
std::string eMsg = "no audio clip at the specified relative offset";
|
|
||||||
throw std::invalid_argument(eMsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Remove a playlist element from the playlist.
|
* Remove a playlist element from the playlist.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.16 $
|
Version : $Revision: 1.17 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -177,6 +177,8 @@ static const std::string resetStorageMethodName
|
||||||
static const std::string resetStorageResultParamName = "gunids";
|
static const std::string resetStorageResultParamName = "gunids";
|
||||||
|
|
||||||
|
|
||||||
|
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ playlist methods */
|
||||||
|
|
||||||
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: existsPlaylist */
|
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: existsPlaylist */
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
|
@ -265,12 +267,104 @@ static const std::string editPlaylistUrlParamName = "url";
|
||||||
static const std::string editPlaylistTokenParamName = "token";
|
static const std::string editPlaylistTokenParamName = "token";
|
||||||
|
|
||||||
|
|
||||||
|
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: savePlaylist */
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* XML header string
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const Glib::ustring xmlHeaderString
|
||||||
|
= "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the 'save playlist' method on the storage server
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string savePlaylistMethodName
|
||||||
|
= "locstor.savePlaylist";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the session ID parameter in the input structure
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string savePlaylistSessionIdParamName = "sessid";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the token parameter in the input structure
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string savePlaylistTokenParamName = "token";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the new playlist parameter in the input structure
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string savePlaylistNewPlaylistParamName = "newPlaylist";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the result parameter returned by the method
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string savePlaylistResultParamName = "status";
|
||||||
|
|
||||||
|
|
||||||
|
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: acquirePlaylist */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: releasePlaylist */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: deletePlaylist */
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the delete playlist method on the storage server
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string deletePlaylistMethodName
|
||||||
|
= "locstor.deletePlaylist";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the session ID parameter in the input structure
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string deletePlaylistSessionIdParamName = "sessid";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the playlist unique ID parameter in the input structure
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string deletePlaylistPlaylistIdParamName = "plid";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the result parameter returned by the method
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string deletePlaylistResultParamName = "status";
|
||||||
|
|
||||||
|
|
||||||
|
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: createPlaylist */
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the create playlist method on the storage server
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string createPlaylistMethodName
|
||||||
|
= "locstor.createPlaylist";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the session ID parameter in the input structure
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string createPlaylistSessionIdParamName = "sessid";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the playlist unique ID parameter in the input structure
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string createPlaylistPlaylistIdParamName = "plid";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the result parameter returned by the method
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string createPlaylistResultParamName = "plid";
|
||||||
|
|
||||||
|
|
||||||
|
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ audio clip methods */
|
||||||
|
|
||||||
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: existsAudioClip */
|
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: existsAudioClip */
|
||||||
|
|
||||||
|
@ -333,8 +427,6 @@ static const std::string getAudioClipTokenParamName = "token";
|
||||||
|
|
||||||
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: storeAudioClip */
|
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: storeAudioClip */
|
||||||
|
|
||||||
// TODO: fix; this method does not exist any more
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* The name of the opening 'store audio clip' method on the storage server
|
* The name of the opening 'store audio clip' method on the storage server
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
@ -704,6 +796,39 @@ Ptr<Playlist>::Ref
|
||||||
WebStorageClient :: editPlaylist(Ptr<SessionId>::Ref sessionId,
|
WebStorageClient :: editPlaylist(Ptr<SessionId>::Ref sessionId,
|
||||||
Ptr<UniqueId>::Ref id) const
|
Ptr<UniqueId>::Ref id) const
|
||||||
throw (StorageException)
|
throw (StorageException)
|
||||||
|
{
|
||||||
|
Ptr<Playlist>::Ref playlist(new Playlist(id));
|
||||||
|
Ptr<const std::string>::Ref url, token;
|
||||||
|
editPlaylistGetUrl(sessionId, id, url, token);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Ptr<xmlpp::DomParser>::Ref parser(new xmlpp::DomParser());
|
||||||
|
parser->parse_file(*url);
|
||||||
|
const xmlpp::Document * document = parser->get_document();
|
||||||
|
const xmlpp::Element * root = document->get_root_node();
|
||||||
|
|
||||||
|
playlist->configure(*root);
|
||||||
|
|
||||||
|
} catch (std::invalid_argument &e) {
|
||||||
|
throw XmlRpcMethodResponseException(
|
||||||
|
"semantic error in playlist metafile");
|
||||||
|
} catch (xmlpp::exception &e) {
|
||||||
|
throw XmlRpcMethodResponseException(
|
||||||
|
"error parsing playlist metafile");
|
||||||
|
}
|
||||||
|
|
||||||
|
playlist->setToken(token);
|
||||||
|
|
||||||
|
return playlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WebStorageClient :: editPlaylistGetUrl(Ptr<SessionId>::Ref sessionId,
|
||||||
|
Ptr<UniqueId>::Ref id,
|
||||||
|
Ptr<const std::string>::Ref& url,
|
||||||
|
Ptr<const std::string>::Ref& token) const
|
||||||
|
throw (StorageException)
|
||||||
{
|
{
|
||||||
XmlRpcValue parameters;
|
XmlRpcValue parameters;
|
||||||
XmlRpcValue result;
|
XmlRpcValue result;
|
||||||
|
@ -749,31 +874,8 @@ WebStorageClient :: editPlaylist(Ptr<SessionId>::Ref sessionId,
|
||||||
throw XmlRpcMethodResponseException(eMsg.str());
|
throw XmlRpcMethodResponseException(eMsg.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string url = result[getPlaylistUrlParamName];
|
url.reset(new const std::string(result[getPlaylistUrlParamName]));
|
||||||
|
token.reset(new const std::string(result[getPlaylistTokenParamName]));
|
||||||
Ptr<Playlist>::Ref playlist(new Playlist(id));
|
|
||||||
|
|
||||||
try {
|
|
||||||
Ptr<xmlpp::DomParser>::Ref parser(new xmlpp::DomParser());
|
|
||||||
parser->parse_file(url);
|
|
||||||
const xmlpp::Document * document = parser->get_document();
|
|
||||||
const xmlpp::Element * root = document->get_root_node();
|
|
||||||
|
|
||||||
playlist->configure(*root);
|
|
||||||
|
|
||||||
} catch (std::invalid_argument &e) {
|
|
||||||
throw XmlRpcMethodResponseException(
|
|
||||||
"semantic error in playlist metafile");
|
|
||||||
} catch (xmlpp::exception &e) {
|
|
||||||
throw XmlRpcMethodResponseException(
|
|
||||||
"error parsing playlist metafile");
|
|
||||||
}
|
|
||||||
|
|
||||||
Ptr<const std::string>::Ref token(new const std::string(
|
|
||||||
result[getPlaylistTokenParamName] ));
|
|
||||||
playlist->setToken(token);
|
|
||||||
|
|
||||||
return playlist;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -785,6 +887,63 @@ WebStorageClient :: savePlaylist(Ptr<SessionId>::Ref sessionId,
|
||||||
Ptr<Playlist>::Ref playlist) const
|
Ptr<Playlist>::Ref playlist) const
|
||||||
throw (StorageException)
|
throw (StorageException)
|
||||||
{
|
{
|
||||||
|
if (!playlist || !playlist->getToken()) {
|
||||||
|
throw InvalidArgumentException("playlist has no token field");
|
||||||
|
}
|
||||||
|
|
||||||
|
XmlRpcValue parameters;
|
||||||
|
XmlRpcValue result;
|
||||||
|
|
||||||
|
XmlRpcClient xmlRpcClient(storageServerName.c_str(), storageServerPort,
|
||||||
|
storageServerPath.c_str(), false);
|
||||||
|
|
||||||
|
parameters.clear();
|
||||||
|
parameters[savePlaylistSessionIdParamName]
|
||||||
|
= sessionId->getId();
|
||||||
|
parameters[savePlaylistTokenParamName]
|
||||||
|
= *playlist->getToken();
|
||||||
|
parameters[savePlaylistNewPlaylistParamName]
|
||||||
|
= std::string(xmlHeaderString + *playlist->getXmlString());
|
||||||
|
|
||||||
|
result.clear();
|
||||||
|
if (!xmlRpcClient.execute(savePlaylistMethodName.c_str(),
|
||||||
|
parameters, result)) {
|
||||||
|
std::string eMsg = "cannot execute XML-RPC method '";
|
||||||
|
eMsg += savePlaylistMethodName;
|
||||||
|
eMsg += "'";
|
||||||
|
throw XmlRpcCommunicationException(eMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xmlRpcClient.isFault()) {
|
||||||
|
std::stringstream eMsg;
|
||||||
|
eMsg << "XML-RPC method '"
|
||||||
|
<< savePlaylistMethodName
|
||||||
|
<< "' returned error message:\n"
|
||||||
|
<< result;
|
||||||
|
throw XmlRpcMethodFaultException(eMsg.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! result.hasMember(savePlaylistResultParamName)
|
||||||
|
|| result[savePlaylistResultParamName].getType()
|
||||||
|
!= XmlRpcValue::TypeBoolean) {
|
||||||
|
std::stringstream eMsg;
|
||||||
|
eMsg << "XML-RPC method '"
|
||||||
|
<< savePlaylistMethodName
|
||||||
|
<< "' returned unexpected value:\n"
|
||||||
|
<< result;
|
||||||
|
throw XmlRpcMethodResponseException(eMsg.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! bool(result[savePlaylistResultParamName])) {
|
||||||
|
std::stringstream eMsg;
|
||||||
|
eMsg << "XML-RPC method '"
|
||||||
|
<< savePlaylistMethodName
|
||||||
|
<< "' returned 'false'";
|
||||||
|
throw XmlRpcMethodResponseException(eMsg.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
Ptr<const std::string>::Ref nullpointer;
|
||||||
|
playlist->setToken(nullpointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -821,7 +980,54 @@ WebStorageClient :: deletePlaylist(Ptr<SessionId>::Ref sessionId,
|
||||||
Ptr<UniqueId>::Ref id)
|
Ptr<UniqueId>::Ref id)
|
||||||
throw (StorageException)
|
throw (StorageException)
|
||||||
{
|
{
|
||||||
|
XmlRpcValue parameters;
|
||||||
|
XmlRpcValue result;
|
||||||
|
|
||||||
|
XmlRpcClient xmlRpcClient(storageServerName.c_str(), storageServerPort,
|
||||||
|
storageServerPath.c_str(), false);
|
||||||
|
|
||||||
|
parameters.clear();
|
||||||
|
parameters[deletePlaylistSessionIdParamName]
|
||||||
|
= sessionId->getId();
|
||||||
|
parameters[deletePlaylistPlaylistIdParamName]
|
||||||
|
= std::string(*id);
|
||||||
|
|
||||||
|
result.clear();
|
||||||
|
if (!xmlRpcClient.execute(deletePlaylistMethodName.c_str(),
|
||||||
|
parameters, result)) {
|
||||||
|
std::string eMsg = "cannot execute XML-RPC method '";
|
||||||
|
eMsg += deletePlaylistMethodName;
|
||||||
|
eMsg += "'";
|
||||||
|
throw XmlRpcCommunicationException(eMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xmlRpcClient.isFault()) {
|
||||||
|
std::stringstream eMsg;
|
||||||
|
eMsg << "XML-RPC method '"
|
||||||
|
<< deletePlaylistMethodName
|
||||||
|
<< "' returned error message:\n"
|
||||||
|
<< result;
|
||||||
|
throw XmlRpcMethodFaultException(eMsg.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! result.hasMember(deletePlaylistResultParamName)
|
||||||
|
|| result[deletePlaylistResultParamName].getType()
|
||||||
|
!= XmlRpcValue::TypeBoolean) {
|
||||||
|
std::stringstream eMsg;
|
||||||
|
eMsg << "XML-RPC method '"
|
||||||
|
<< deletePlaylistMethodName
|
||||||
|
<< "' returned unexpected value:\n"
|
||||||
|
<< result;
|
||||||
|
throw XmlRpcMethodResponseException(eMsg.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! bool(result[deletePlaylistResultParamName])) {
|
||||||
|
std::stringstream eMsg;
|
||||||
|
eMsg << "XML-RPC method '"
|
||||||
|
<< deletePlaylistMethodName
|
||||||
|
<< "' returned 'false'";
|
||||||
|
throw XmlRpcMethodResponseException(eMsg.str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -845,7 +1051,62 @@ Ptr<Playlist>::Ref
|
||||||
WebStorageClient :: createPlaylist(Ptr<SessionId>::Ref sessionId)
|
WebStorageClient :: createPlaylist(Ptr<SessionId>::Ref sessionId)
|
||||||
throw (StorageException)
|
throw (StorageException)
|
||||||
{
|
{
|
||||||
Ptr<Playlist>::Ref playlist(new Playlist);
|
XmlRpcValue parameters;
|
||||||
|
XmlRpcValue result;
|
||||||
|
|
||||||
|
XmlRpcClient xmlRpcClient(storageServerName.c_str(), storageServerPort,
|
||||||
|
storageServerPath.c_str(), false);
|
||||||
|
|
||||||
|
parameters.clear();
|
||||||
|
parameters[createPlaylistSessionIdParamName]
|
||||||
|
= sessionId->getId();
|
||||||
|
parameters[createPlaylistPlaylistIdParamName]
|
||||||
|
= std::string(*UniqueId::generateId()); // TODO: the server
|
||||||
|
// should generate the ID
|
||||||
|
result.clear();
|
||||||
|
if (!xmlRpcClient.execute(createPlaylistMethodName.c_str(),
|
||||||
|
parameters, result)) {
|
||||||
|
std::string eMsg = "cannot execute XML-RPC method '";
|
||||||
|
eMsg += createPlaylistMethodName;
|
||||||
|
eMsg += "'";
|
||||||
|
throw XmlRpcCommunicationException(eMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xmlRpcClient.isFault()) {
|
||||||
|
std::stringstream eMsg;
|
||||||
|
eMsg << "XML-RPC method '"
|
||||||
|
<< createPlaylistMethodName
|
||||||
|
<< "' returned error message:\n"
|
||||||
|
<< result;
|
||||||
|
throw XmlRpcMethodFaultException(eMsg.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! result.hasMember(createPlaylistResultParamName)
|
||||||
|
|| result[createPlaylistResultParamName].getType()
|
||||||
|
!= XmlRpcValue::TypeString) {
|
||||||
|
std::stringstream eMsg;
|
||||||
|
eMsg << "XML-RPC method '"
|
||||||
|
<< createPlaylistMethodName
|
||||||
|
<< "' returned unexpected value:\n"
|
||||||
|
<< result;
|
||||||
|
throw XmlRpcMethodResponseException(eMsg.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
Ptr<UniqueId>::Ref newId(new UniqueId(std::string(
|
||||||
|
result[createPlaylistResultParamName] )));
|
||||||
|
Ptr<const std::string>::Ref url, token;
|
||||||
|
|
||||||
|
editPlaylistGetUrl(sessionId, newId, url, token);
|
||||||
|
|
||||||
|
Ptr<time_duration>::Ref playlength(new time_duration(0,0,0,0));
|
||||||
|
Ptr<Playlist>::Ref playlist(new Playlist(newId, playlength));
|
||||||
|
playlist->setToken(token);
|
||||||
|
|
||||||
|
savePlaylist(sessionId, playlist);
|
||||||
|
|
||||||
|
token.reset();
|
||||||
|
playlist->setToken(token);
|
||||||
|
|
||||||
return playlist;
|
return playlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.11 $
|
Version : $Revision: 1.12 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -99,7 +99,7 @@ using namespace LiveSupport::Core;
|
||||||
* </code></pre>
|
* </code></pre>
|
||||||
*
|
*
|
||||||
* @author $Author: fgerlits $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.11 $
|
* @version $Revision: 1.12 $
|
||||||
*/
|
*/
|
||||||
class WebStorageClient :
|
class WebStorageClient :
|
||||||
virtual public Configurable,
|
virtual public Configurable,
|
||||||
|
@ -131,6 +131,24 @@ class WebStorageClient :
|
||||||
*/
|
*/
|
||||||
std::string storageServerPath;
|
std::string storageServerPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auxilliary method used by editPlaylist() and createPlaylist().
|
||||||
|
* Opens the playlist for editing, and returns its URL.
|
||||||
|
*
|
||||||
|
* @param sessionId the session ID from the authentication client
|
||||||
|
* @param id the id of the playlist to return.
|
||||||
|
* @param url pointer in which the URL of the playlist is returned.
|
||||||
|
* @param token pointer in which the token of the playlist is returned.
|
||||||
|
* @exception StorageException if there is a problem with the XML-RPC
|
||||||
|
* call or no playlist with the specified
|
||||||
|
* id exists.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
editPlaylistGetUrl(Ptr<SessionId>::Ref sessionId,
|
||||||
|
Ptr<UniqueId>::Ref id,
|
||||||
|
Ptr<const std::string>::Ref& url,
|
||||||
|
Ptr<const std::string>::Ref& token) const
|
||||||
|
throw (StorageException);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -282,6 +300,10 @@ class WebStorageClient :
|
||||||
/**
|
/**
|
||||||
* Return a list of all playlists in the playlist store.
|
* Return a list of all playlists in the playlist store.
|
||||||
*
|
*
|
||||||
|
* Since this makes no sense whatsoever, this method currently returns
|
||||||
|
* an empty list. It will be replaced by a method which uses
|
||||||
|
* <code>locstor.searchMetadata</code>.
|
||||||
|
*
|
||||||
* @param sessionId the session ID from the authentication client
|
* @param sessionId the session ID from the authentication client
|
||||||
* @return a vector containing the playlists.
|
* @return a vector containing the playlists.
|
||||||
* @exception StorageException if there is a problem with the XML-RPC
|
* @exception StorageException if there is a problem with the XML-RPC
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.18 $
|
Version : $Revision: 1.19 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClientTest.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClientTest.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -186,7 +186,7 @@ WebStorageClientTest :: playlistTest(void)
|
||||||
CPPUNIT_FAIL(e.what());
|
CPPUNIT_FAIL(e.what());
|
||||||
}
|
}
|
||||||
CPPUNIT_ASSERT(uniqueIdVector->size() > 0);
|
CPPUNIT_ASSERT(uniqueIdVector->size() > 0);
|
||||||
// Ptr<UniqueId>::Ref audioClipId01 = uniqueIdVector->at(0);
|
Ptr<UniqueId>::Ref audioClipId = uniqueIdVector->at(0);
|
||||||
|
|
||||||
Ptr<SessionId>::Ref sessionId;
|
Ptr<SessionId>::Ref sessionId;
|
||||||
try {
|
try {
|
||||||
|
@ -198,9 +198,29 @@ WebStorageClientTest :: playlistTest(void)
|
||||||
CPPUNIT_ASSERT(sessionId);
|
CPPUNIT_ASSERT(sessionId);
|
||||||
|
|
||||||
|
|
||||||
// test ...
|
// test createPlaylist()
|
||||||
|
Ptr<Playlist>::Ref playlist;
|
||||||
|
try{
|
||||||
|
playlist = wsc->createPlaylist(sessionId);
|
||||||
|
}
|
||||||
|
catch (StorageException &e) {
|
||||||
|
CPPUNIT_FAIL(e.what());
|
||||||
|
}
|
||||||
|
CPPUNIT_ASSERT(playlist);
|
||||||
|
Ptr<UniqueId>::Ref playlistIdxx = playlist->getId();
|
||||||
|
|
||||||
|
|
||||||
|
// test existsPlaylist()
|
||||||
|
bool exists = false;
|
||||||
|
try {
|
||||||
|
exists = wsc->existsPlaylist(sessionId, playlistIdxx);
|
||||||
|
}
|
||||||
|
catch (StorageException &e) {
|
||||||
|
CPPUNIT_FAIL(e.what());
|
||||||
|
}
|
||||||
|
CPPUNIT_ASSERT(exists);
|
||||||
|
|
||||||
Ptr<UniqueId>::Ref playlistId77(new UniqueId(77));
|
Ptr<UniqueId>::Ref playlistId77(new UniqueId(77));
|
||||||
bool exists = true;
|
|
||||||
try {
|
try {
|
||||||
exists = wsc->existsPlaylist(sessionId, playlistId77);
|
exists = wsc->existsPlaylist(sessionId, playlistId77);
|
||||||
}
|
}
|
||||||
|
@ -210,10 +230,84 @@ WebStorageClientTest :: playlistTest(void)
|
||||||
CPPUNIT_ASSERT(!exists);
|
CPPUNIT_ASSERT(!exists);
|
||||||
|
|
||||||
|
|
||||||
|
// test editPlaylist()
|
||||||
|
try {
|
||||||
|
playlist = wsc->editPlaylist(sessionId, playlistIdxx);
|
||||||
|
}
|
||||||
|
catch (StorageException &e) {
|
||||||
|
CPPUNIT_FAIL(e.what());
|
||||||
|
}
|
||||||
|
CPPUNIT_ASSERT(playlist);
|
||||||
|
|
||||||
|
try {
|
||||||
|
playlist = wsc->editPlaylist(sessionId, playlistIdxx);
|
||||||
|
CPPUNIT_FAIL("allowed to open playlist for editing twice");
|
||||||
|
}
|
||||||
|
catch (XmlRpcMethodFaultException &e) {
|
||||||
|
}
|
||||||
|
catch (StorageException &e) {
|
||||||
|
std::string eMsg = "editPlaylist() threw unexpected exception:\n";
|
||||||
|
CPPUNIT_FAIL(eMsg + e.what());
|
||||||
|
}
|
||||||
|
CPPUNIT_ASSERT(playlist);
|
||||||
|
|
||||||
|
Ptr<AudioClip>::Ref audioClip;
|
||||||
|
try {
|
||||||
|
audioClip = wsc->getAudioClip(sessionId, audioClipId);
|
||||||
|
}
|
||||||
|
catch (StorageException &e) {
|
||||||
|
CPPUNIT_FAIL(e.what());
|
||||||
|
}
|
||||||
|
Ptr<time_duration>::Ref relativeOffset(new time_duration(0,0,0,0));
|
||||||
|
playlist->addAudioClip(audioClip, relativeOffset);
|
||||||
|
CPPUNIT_ASSERT(playlist->valid()); // WARNING: side effect; fixes the
|
||||||
|
// playlength of the playlist
|
||||||
|
try {
|
||||||
|
Ptr<Playlist>::Ref throwAwayPlaylist
|
||||||
|
= wsc->getPlaylist(sessionId, playlistIdxx);
|
||||||
|
// this should be OK, get old copy
|
||||||
|
CPPUNIT_ASSERT(throwAwayPlaylist->getPlaylength()
|
||||||
|
->total_seconds() == 0);
|
||||||
|
}
|
||||||
|
catch (StorageException &e) {
|
||||||
|
CPPUNIT_FAIL(e.what());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
wsc->savePlaylist(sessionId, playlist);
|
||||||
|
}
|
||||||
|
catch (StorageException &e) {
|
||||||
|
CPPUNIT_FAIL(e.what());
|
||||||
|
}
|
||||||
|
|
||||||
|
// test getPlaylist()
|
||||||
|
Ptr<Playlist>::Ref newPlaylist;
|
||||||
|
try {
|
||||||
|
newPlaylist = wsc->getPlaylist(sessionId, playlistIdxx);
|
||||||
|
}
|
||||||
|
catch (StorageException &e) {
|
||||||
|
CPPUNIT_FAIL(e.what());
|
||||||
|
}
|
||||||
|
CPPUNIT_ASSERT(newPlaylist);
|
||||||
|
CPPUNIT_ASSERT(newPlaylist->getPlaylength()->total_seconds()
|
||||||
|
== playlist->getPlaylength()->total_seconds());
|
||||||
|
// NOTE: we really ought to define == for playlists...
|
||||||
|
|
||||||
|
// test deletePlaylist()
|
||||||
|
try {
|
||||||
|
wsc->deletePlaylist(sessionId, playlistIdxx);
|
||||||
|
}
|
||||||
|
catch (StorageException &e) {
|
||||||
|
CPPUNIT_FAIL(e.what());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
exists = wsc->existsPlaylist(sessionId, playlistIdxx);
|
||||||
|
}
|
||||||
|
catch (StorageException &e) {
|
||||||
|
CPPUNIT_FAIL(e.what());
|
||||||
|
}
|
||||||
|
CPPUNIT_ASSERT(!exists);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.7 $
|
Version : $Revision: 1.8 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -165,7 +165,7 @@ RemoveAudioClipFromPlaylistMethod :: execute(
|
||||||
}
|
}
|
||||||
|
|
||||||
try { // and finally, the beef
|
try { // and finally, the beef
|
||||||
playlist->removeAudioClip(relativeOffset);
|
playlist->removePlaylistElement(relativeOffset);
|
||||||
}
|
}
|
||||||
catch(std::invalid_argument &e) {
|
catch(std::invalid_argument &e) {
|
||||||
XmlRpcTools::markError(errorId+6,
|
XmlRpcTools::markError(errorId+6,
|
||||||
|
|
Loading…
Reference in New Issue