added title field in saved playlist
fixed (kind of; I still don't understand them) some problems arising from StorageException -> XmlRpcException change
This commit is contained in:
parent
9a185bb141
commit
67910f4fcf
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.22 $
|
||||
Version : $Revision: 1.23 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -61,6 +61,11 @@ static const std::string idAttrName = "id";
|
|||
*/
|
||||
static const std::string playlengthAttrName = "playlength";
|
||||
|
||||
/**
|
||||
* The name of the attribute to get the title of the playlist.
|
||||
*/
|
||||
static const std::string titleAttrName = "title";
|
||||
|
||||
/**
|
||||
* The name of playlist element child nodes.
|
||||
*/
|
||||
|
@ -102,6 +107,13 @@ Playlist :: configure(const xmlpp::Element & element)
|
|||
playlength.reset(new time_duration(
|
||||
duration_from_string(attribute->get_value())));
|
||||
|
||||
if ((attribute = element.get_attribute(titleAttrName))) {
|
||||
title.reset(new const Glib::ustring(attribute->get_value()));
|
||||
}
|
||||
else {
|
||||
title.reset(new const Glib::ustring(""));
|
||||
}
|
||||
|
||||
xmlpp::Node::NodeList childNodes
|
||||
= element.get_children(elementListAttrName);
|
||||
xmlpp::Node::NodeList::iterator it = childNodes.begin();
|
||||
|
@ -365,7 +377,7 @@ Ptr<Glib::ustring>::Ref
|
|||
Playlist :: getMetadata(const string &key, const string &ns) const
|
||||
throw ()
|
||||
{
|
||||
std::string completeKey = key + ns;
|
||||
std::string completeKey = ns + ":" + key;
|
||||
metadataType::const_iterator it = metadata.find(completeKey);
|
||||
|
||||
if (it != metadata.end()) {
|
||||
|
@ -387,10 +399,19 @@ Playlist :: setMetadata(Ptr<const Glib::ustring>::Ref value,
|
|||
const string &key, const string &ns)
|
||||
throw ()
|
||||
{
|
||||
std::string completeKey = key + ns;
|
||||
std::string completeKey = ns + ":" + key;
|
||||
metadata[completeKey] = value;
|
||||
|
||||
if (completeKey == "dcterms:extent") {
|
||||
playlength.reset(new time_duration(duration_from_string(*value)));
|
||||
}
|
||||
|
||||
if (completeKey == "dc:title") {
|
||||
title = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Return a string containing the essential fields of this object, in XML.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -402,10 +423,13 @@ Playlist :: getXmlString(void) throw ()
|
|||
xmlString->append("<");
|
||||
xmlString->append(configElementNameStr + " ");
|
||||
xmlString->append(idAttrName + "=\""
|
||||
+ std::string(*id)
|
||||
+ std::string(*getId())
|
||||
+ "\" ");
|
||||
xmlString->append(playlengthAttrName + "=\""
|
||||
+ to_simple_string(*playlength)
|
||||
+ to_simple_string(*getPlaylength())
|
||||
+ "\" ");
|
||||
xmlString->append(Glib::ustring(titleAttrName) + "=\""
|
||||
+ *getTitle()
|
||||
+ "\">\n");
|
||||
|
||||
PlaylistElementListType::const_iterator it = elementList->begin();
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.18 $
|
||||
Version : $Revision: 1.19 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -114,9 +114,8 @@ PlaylistTest :: firstTest(void)
|
|||
CPPUNIT_ASSERT(duration->total_seconds() == 34);
|
||||
|
||||
CPPUNIT_ASSERT(playlist->valid());
|
||||
|
||||
CPPUNIT_ASSERT(*playlist->getXmlString() ==
|
||||
"<playlist id=\"0000000000000001\" playlength=\"00:00:34\">\n"
|
||||
"<playlist id=\"0000000000000001\" playlength=\"00:00:34\" title=\"\">\n"
|
||||
"<playlistElement id=\"0000000000000101\" relativeOffset=\"00:00:00\">\n"
|
||||
"<audioClip id=\"0000000000010001\" playlength=\"00:00:11\" title=\"one\"/>\n"
|
||||
"</playlistElement>\n"
|
||||
|
@ -126,7 +125,7 @@ PlaylistTest :: firstTest(void)
|
|||
"fadeOut=\"00:00:01.500000\"/>\n"
|
||||
"</playlistElement>\n"
|
||||
"<playlistElement id=\"0000000000000103\" relativeOffset=\"00:00:23\">\n"
|
||||
"<playlist id=\"0000000000000002\" playlength=\"00:00:11\">\n"
|
||||
"<playlist id=\"0000000000000002\" playlength=\"00:00:11\" title=\"\">\n"
|
||||
"<playlistElement id=\"0000000000000111\" relativeOffset=\"00:00:00\">\n"
|
||||
"<audioClip id=\"0000000000010003\" playlength=\"00:00:11\" title=\"three\"/>\n"
|
||||
"</playlistElement>\n"
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.21 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.22 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -650,7 +650,7 @@ WebStorageClient :: configure(const xmlpp::Element & element)
|
|||
const bool
|
||||
WebStorageClient :: existsPlaylist(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<UniqueId>::Ref id) const
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue parameters;
|
||||
XmlRpcValue result;
|
||||
|
@ -703,7 +703,7 @@ WebStorageClient :: existsPlaylist(Ptr<SessionId>::Ref sessionId,
|
|||
Ptr<Playlist>::Ref
|
||||
WebStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<UniqueId>::Ref id) const
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue parameters;
|
||||
XmlRpcValue result;
|
||||
|
@ -815,7 +815,7 @@ WebStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
|
|||
Ptr<Playlist>::Ref
|
||||
WebStorageClient :: editPlaylist(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<UniqueId>::Ref id) const
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
Ptr<Playlist>::Ref playlist(new Playlist(id));
|
||||
Ptr<const std::string>::Ref url, token;
|
||||
|
@ -849,7 +849,7 @@ WebStorageClient :: editPlaylistGetUrl(Ptr<SessionId>::Ref sessionId,
|
|||
Ptr<UniqueId>::Ref id,
|
||||
Ptr<const std::string>::Ref& url,
|
||||
Ptr<const std::string>::Ref& token) const
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue parameters;
|
||||
XmlRpcValue result;
|
||||
|
@ -906,7 +906,7 @@ WebStorageClient :: editPlaylistGetUrl(Ptr<SessionId>::Ref sessionId,
|
|||
void
|
||||
WebStorageClient :: savePlaylist(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<Playlist>::Ref playlist) const
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
if (!playlist || !playlist->getToken()) {
|
||||
throw XmlRpcInvalidArgumentException("playlist has no token field");
|
||||
|
@ -974,7 +974,7 @@ WebStorageClient :: savePlaylist(Ptr<SessionId>::Ref sessionId,
|
|||
Ptr<Playlist>::Ref
|
||||
WebStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<UniqueId>::Ref id) const
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
Ptr<Playlist>::Ref oldPlaylist = getPlaylist(sessionId, id);
|
||||
|
||||
|
@ -1058,7 +1058,7 @@ WebStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
|
|||
void
|
||||
WebStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<Playlist>::Ref playlist) const
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
if (! playlist->getUri()) {
|
||||
throw XmlRpcInvalidArgumentException("playlist URI not found");
|
||||
|
@ -1118,7 +1118,7 @@ WebStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
|
|||
void
|
||||
WebStorageClient :: deletePlaylist(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<UniqueId>::Ref id)
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue parameters;
|
||||
XmlRpcValue result;
|
||||
|
@ -1176,7 +1176,7 @@ WebStorageClient :: deletePlaylist(Ptr<SessionId>::Ref sessionId,
|
|||
*----------------------------------------------------------------------------*/
|
||||
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
|
||||
WebStorageClient :: getAllPlaylists(Ptr<SessionId>::Ref sessionId) const
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlistVector(
|
||||
new std::vector<Ptr<Playlist>::Ref>);
|
||||
|
@ -1189,7 +1189,7 @@ WebStorageClient :: getAllPlaylists(Ptr<SessionId>::Ref sessionId) const
|
|||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Playlist>::Ref
|
||||
WebStorageClient :: createPlaylist(Ptr<SessionId>::Ref sessionId)
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue parameters;
|
||||
XmlRpcValue result;
|
||||
|
@ -1258,7 +1258,7 @@ WebStorageClient :: createPlaylist(Ptr<SessionId>::Ref sessionId)
|
|||
const bool
|
||||
WebStorageClient :: existsAudioClip(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<UniqueId>::Ref id) const
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue parameters;
|
||||
XmlRpcValue result;
|
||||
|
@ -1311,7 +1311,7 @@ WebStorageClient :: existsAudioClip(Ptr<SessionId>::Ref sessionId,
|
|||
Ptr<AudioClip>::Ref
|
||||
WebStorageClient :: getAudioClip(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<UniqueId>::Ref id) const
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue parameters;
|
||||
XmlRpcValue result;
|
||||
|
@ -1425,7 +1425,7 @@ WebStorageClient :: getAudioClip(Ptr<SessionId>::Ref sessionId,
|
|||
void
|
||||
WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<AudioClip>::Ref audioClip)
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
if (!audioClip || !audioClip->getUri()) {
|
||||
throw XmlRpcInvalidArgumentException(
|
||||
|
@ -1586,7 +1586,7 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
|
|||
Ptr<AudioClip>::Ref
|
||||
WebStorageClient :: acquireAudioClip(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<UniqueId>::Ref id) const
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
Ptr<AudioClip>::Ref audioClip = getAudioClip(sessionId, id);
|
||||
|
||||
|
@ -1652,7 +1652,7 @@ WebStorageClient :: acquireAudioClip(Ptr<SessionId>::Ref sessionId,
|
|||
void
|
||||
WebStorageClient :: releaseAudioClip(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<AudioClip>::Ref audioClip) const
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue parameters;
|
||||
XmlRpcValue result;
|
||||
|
@ -1715,7 +1715,7 @@ WebStorageClient :: releaseAudioClip(Ptr<SessionId>::Ref sessionId,
|
|||
void
|
||||
WebStorageClient :: deleteAudioClip(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<UniqueId>::Ref id)
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue parameters;
|
||||
XmlRpcValue result;
|
||||
|
@ -1774,7 +1774,7 @@ WebStorageClient :: deleteAudioClip(Ptr<SessionId>::Ref sessionId,
|
|||
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref
|
||||
WebStorageClient :: getAllAudioClips(Ptr<SessionId>::Ref sessionId)
|
||||
const
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref audioClipVector(
|
||||
new std::vector<Ptr<AudioClip>::Ref>);
|
||||
|
@ -1787,7 +1787,7 @@ WebStorageClient :: getAllAudioClips(Ptr<SessionId>::Ref sessionId)
|
|||
*----------------------------------------------------------------------------*/
|
||||
Ptr<std::vector<Ptr<UniqueId>::Ref> >::Ref
|
||||
WebStorageClient :: reset(void)
|
||||
throw (XmlRpcException)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue parameters;
|
||||
XmlRpcValue result;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.24 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.25 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClientTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -47,6 +47,13 @@
|
|||
#include "WebStorageClient.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
#include "LiveSupport/Core/XmlRpcException.h"
|
||||
#include "LiveSupport/Core/XmlRpcCommunicationException.h"
|
||||
#include "LiveSupport/Core/XmlRpcMethodFaultException.h"
|
||||
#include "LiveSupport/Core/XmlRpcMethodResponseException.h"
|
||||
#include "LiveSupport/Core/XmlRpcInvalidArgumentException.h"
|
||||
#include "LiveSupport/Core/XmlRpcIOException.h"
|
||||
|
||||
#include "WebStorageClientTest.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -243,7 +250,7 @@ WebStorageClientTest :: playlistTest(void)
|
|||
playlist = wsc->editPlaylist(sessionId, playlistIdxx);
|
||||
CPPUNIT_FAIL("allowed to open playlist for editing twice");
|
||||
}
|
||||
catch (XmlRpcMethodFaultException &e) {
|
||||
catch (Core::XmlRpcMethodFaultException &e) {
|
||||
}
|
||||
catch (XmlRpcException &e) {
|
||||
std::string eMsg = "editPlaylist() threw unexpected exception:\n";
|
||||
|
@ -582,13 +589,16 @@ WebStorageClientTest :: simplePlaylistTest(void)
|
|||
CPPUNIT_ASSERT(newPlaylist->getTitle().get());
|
||||
CPPUNIT_ASSERT(*newPlaylist->getTitle() == *title);
|
||||
|
||||
|
||||
/*
|
||||
// this is not needed here
|
||||
// releasePlaylist() is the closing pair of acquirePlaylist()
|
||||
try {
|
||||
wsc->releasePlaylist(sessionId, newPlaylist);
|
||||
} catch (XmlRpcException &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
CPPUNIT_ASSERT(!newPlaylist->getUri());
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue