From 67910f4fcfb71f1881cfc41bd40de656e2646cdb Mon Sep 17 00:00:00 2001 From: fgerlits Date: Mon, 10 Jan 2005 10:36:56 +0000 Subject: [PATCH] added title field in saved playlist fixed (kind of; I still don't understand them) some problems arising from StorageException -> XmlRpcException change --- livesupport/modules/core/src/Playlist.cxx | 36 ++++++++++++++--- livesupport/modules/core/src/PlaylistTest.cxx | 7 ++-- .../modules/storage/src/WebStorageClient.cxx | 40 +++++++++---------- .../storage/src/WebStorageClientTest.cxx | 18 +++++++-- 4 files changed, 67 insertions(+), 34 deletions(-) diff --git a/livesupport/modules/core/src/Playlist.cxx b/livesupport/modules/core/src/Playlist.cxx index 84957b673..8034b1159 100644 --- a/livesupport/modules/core/src/Playlist.cxx +++ b/livesupport/modules/core/src/Playlist.cxx @@ -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::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::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,11 +423,14 @@ 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) - + "\">\n"); + + to_simple_string(*getPlaylength()) + + "\" "); + xmlString->append(Glib::ustring(titleAttrName) + "=\"" + + *getTitle() + + "\">\n"); PlaylistElementListType::const_iterator it = elementList->begin(); while (it != elementList->end()) { diff --git a/livesupport/modules/core/src/PlaylistTest.cxx b/livesupport/modules/core/src/PlaylistTest.cxx index 58362f1a9..b7627fe06 100644 --- a/livesupport/modules/core/src/PlaylistTest.cxx +++ b/livesupport/modules/core/src/PlaylistTest.cxx @@ -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() == -"\n" +"\n" "\n" "\n" "\n" @@ -126,7 +125,7 @@ PlaylistTest :: firstTest(void) "fadeOut=\"00:00:01.500000\"/>\n" "\n" "\n" -"\n" +"\n" "\n" "\n" "\n" diff --git a/livesupport/modules/storage/src/WebStorageClient.cxx b/livesupport/modules/storage/src/WebStorageClient.cxx index 17c8dfe97..3750831db 100644 --- a/livesupport/modules/storage/src/WebStorageClient.cxx +++ b/livesupport/modules/storage/src/WebStorageClient.cxx @@ -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::Ref sessionId, Ptr::Ref id) const - throw (XmlRpcException) + throw (Core::XmlRpcException) { XmlRpcValue parameters; XmlRpcValue result; @@ -703,7 +703,7 @@ WebStorageClient :: existsPlaylist(Ptr::Ref sessionId, Ptr::Ref WebStorageClient :: getPlaylist(Ptr::Ref sessionId, Ptr::Ref id) const - throw (XmlRpcException) + throw (Core::XmlRpcException) { XmlRpcValue parameters; XmlRpcValue result; @@ -815,7 +815,7 @@ WebStorageClient :: getPlaylist(Ptr::Ref sessionId, Ptr::Ref WebStorageClient :: editPlaylist(Ptr::Ref sessionId, Ptr::Ref id) const - throw (XmlRpcException) + throw (Core::XmlRpcException) { Ptr::Ref playlist(new Playlist(id)); Ptr::Ref url, token; @@ -849,7 +849,7 @@ WebStorageClient :: editPlaylistGetUrl(Ptr::Ref sessionId, Ptr::Ref id, Ptr::Ref& url, Ptr::Ref& token) const - throw (XmlRpcException) + throw (Core::XmlRpcException) { XmlRpcValue parameters; XmlRpcValue result; @@ -906,7 +906,7 @@ WebStorageClient :: editPlaylistGetUrl(Ptr::Ref sessionId, void WebStorageClient :: savePlaylist(Ptr::Ref sessionId, Ptr::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::Ref sessionId, Ptr::Ref WebStorageClient :: acquirePlaylist(Ptr::Ref sessionId, Ptr::Ref id) const - throw (XmlRpcException) + throw (Core::XmlRpcException) { Ptr::Ref oldPlaylist = getPlaylist(sessionId, id); @@ -1058,7 +1058,7 @@ WebStorageClient :: acquirePlaylist(Ptr::Ref sessionId, void WebStorageClient :: releasePlaylist(Ptr::Ref sessionId, Ptr::Ref playlist) const - throw (XmlRpcException) + throw (Core::XmlRpcException) { if (! playlist->getUri()) { throw XmlRpcInvalidArgumentException("playlist URI not found"); @@ -1118,7 +1118,7 @@ WebStorageClient :: releasePlaylist(Ptr::Ref sessionId, void WebStorageClient :: deletePlaylist(Ptr::Ref sessionId, Ptr::Ref id) - throw (XmlRpcException) + throw (Core::XmlRpcException) { XmlRpcValue parameters; XmlRpcValue result; @@ -1176,7 +1176,7 @@ WebStorageClient :: deletePlaylist(Ptr::Ref sessionId, *----------------------------------------------------------------------------*/ Ptr::Ref> >::Ref WebStorageClient :: getAllPlaylists(Ptr::Ref sessionId) const - throw (XmlRpcException) + throw (Core::XmlRpcException) { Ptr::Ref> >::Ref playlistVector( new std::vector::Ref>); @@ -1189,7 +1189,7 @@ WebStorageClient :: getAllPlaylists(Ptr::Ref sessionId) const *----------------------------------------------------------------------------*/ Ptr::Ref WebStorageClient :: createPlaylist(Ptr::Ref sessionId) - throw (XmlRpcException) + throw (Core::XmlRpcException) { XmlRpcValue parameters; XmlRpcValue result; @@ -1258,7 +1258,7 @@ WebStorageClient :: createPlaylist(Ptr::Ref sessionId) const bool WebStorageClient :: existsAudioClip(Ptr::Ref sessionId, Ptr::Ref id) const - throw (XmlRpcException) + throw (Core::XmlRpcException) { XmlRpcValue parameters; XmlRpcValue result; @@ -1311,7 +1311,7 @@ WebStorageClient :: existsAudioClip(Ptr::Ref sessionId, Ptr::Ref WebStorageClient :: getAudioClip(Ptr::Ref sessionId, Ptr::Ref id) const - throw (XmlRpcException) + throw (Core::XmlRpcException) { XmlRpcValue parameters; XmlRpcValue result; @@ -1425,7 +1425,7 @@ WebStorageClient :: getAudioClip(Ptr::Ref sessionId, void WebStorageClient :: storeAudioClip(Ptr::Ref sessionId, Ptr::Ref audioClip) - throw (XmlRpcException) + throw (Core::XmlRpcException) { if (!audioClip || !audioClip->getUri()) { throw XmlRpcInvalidArgumentException( @@ -1586,7 +1586,7 @@ WebStorageClient :: storeAudioClip(Ptr::Ref sessionId, Ptr::Ref WebStorageClient :: acquireAudioClip(Ptr::Ref sessionId, Ptr::Ref id) const - throw (XmlRpcException) + throw (Core::XmlRpcException) { Ptr::Ref audioClip = getAudioClip(sessionId, id); @@ -1652,7 +1652,7 @@ WebStorageClient :: acquireAudioClip(Ptr::Ref sessionId, void WebStorageClient :: releaseAudioClip(Ptr::Ref sessionId, Ptr::Ref audioClip) const - throw (XmlRpcException) + throw (Core::XmlRpcException) { XmlRpcValue parameters; XmlRpcValue result; @@ -1715,7 +1715,7 @@ WebStorageClient :: releaseAudioClip(Ptr::Ref sessionId, void WebStorageClient :: deleteAudioClip(Ptr::Ref sessionId, Ptr::Ref id) - throw (XmlRpcException) + throw (Core::XmlRpcException) { XmlRpcValue parameters; XmlRpcValue result; @@ -1774,7 +1774,7 @@ WebStorageClient :: deleteAudioClip(Ptr::Ref sessionId, Ptr::Ref> >::Ref WebStorageClient :: getAllAudioClips(Ptr::Ref sessionId) const - throw (XmlRpcException) + throw (Core::XmlRpcException) { Ptr::Ref> >::Ref audioClipVector( new std::vector::Ref>); @@ -1787,7 +1787,7 @@ WebStorageClient :: getAllAudioClips(Ptr::Ref sessionId) *----------------------------------------------------------------------------*/ Ptr::Ref> >::Ref WebStorageClient :: reset(void) - throw (XmlRpcException) + throw (Core::XmlRpcException) { XmlRpcValue parameters; XmlRpcValue result; diff --git a/livesupport/modules/storage/src/WebStorageClientTest.cxx b/livesupport/modules/storage/src/WebStorageClientTest.cxx index e88b3c95c..a4ab14e86 100644 --- a/livesupport/modules/storage/src/WebStorageClientTest.cxx +++ b/livesupport/modules/storage/src/WebStorageClientTest.cxx @@ -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()); +*/ }