diff --git a/livesupport/modules/storage/src/WebStorageClient.cxx b/livesupport/modules/storage/src/WebStorageClient.cxx index 3be90a13d..d8dffa862 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: fgerlits $ - Version : $Revision: 1.47 $ + Author : $Author: maroy $ + Version : $Revision: 1.48 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $ ------------------------------------------------------------------------------*/ @@ -394,6 +394,11 @@ static const std::string getPlaylistSessionIdParamName = "sessid"; *----------------------------------------------------------------------------*/ static const std::string getPlaylistPlaylistIdParamName = "plid"; +/*------------------------------------------------------------------------------ + * The name of the recursive parameter in the input structure + *----------------------------------------------------------------------------*/ +static const std::string getPlaylistRecursiveParamName = "recursive"; + /*------------------------------------------------------------------------------ * The name of the result URL parameter returned by the method *----------------------------------------------------------------------------*/ @@ -931,7 +936,9 @@ WebStorageClient :: getPlaylist(Ptr::Ref sessionId, = sessionId->getId(); parameters[getPlaylistPlaylistIdParamName] = std::string(*id); - + parameters[getPlaylistRecursiveParamName] + = false; + result.clear(); if (!xmlRpcClient.execute(getPlaylistOpenMethodName.c_str(), parameters, result)) { @@ -950,7 +957,7 @@ WebStorageClient :: getPlaylist(Ptr::Ref sessionId, << result; throw Core::XmlRpcMethodFaultException(eMsg.str()); } - + if (! result.hasMember(getPlaylistUrlParamName) || result[getPlaylistUrlParamName].getType() != XmlRpcValue::TypeString @@ -1000,7 +1007,7 @@ WebStorageClient :: getPlaylist(Ptr::Ref sessionId, throw XmlRpcCommunicationException(eMsg); } xmlRpcClient.close(); - + if (xmlRpcClient.isFault()) { std::stringstream eMsg; eMsg << "XML-RPC method '" @@ -1267,8 +1274,12 @@ WebStorageClient :: acquirePlaylist(Ptr::Ref sessionId, Ptr::Ref oldPlaylist = getPlaylist(sessionId, id); Ptr::Ref playlength = oldPlaylist->getPlaylength(); - Ptr::Ref newPlaylist(new Playlist(UniqueId::generateId(), + Ptr::Ref newPlaylist(new Playlist(oldPlaylist->getId(), playlength)); + newPlaylist->setTitle(oldPlaylist->getTitle()); + newPlaylist->setToken(oldPlaylist->getToken()); + // TODO: copy over all metadata as well + Ptr::Ref smilDocument(new xmlpp::Document(xmlVersion)); xmlpp::Element * smilRootNode @@ -1399,6 +1410,7 @@ WebStorageClient :: acquirePlaylist(Ptr::Ref sessionId, Ptr::Ref playlistUri(new std::string(fileName.str())); newPlaylist->setUri(playlistUri); + return newPlaylist; } diff --git a/livesupport/modules/storage/src/WebStorageClientTest.cxx b/livesupport/modules/storage/src/WebStorageClientTest.cxx index 60affbf8f..67ff42b05 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: fgerlits $ - Version : $Revision: 1.44 $ + Author : $Author: maroy $ + Version : $Revision: 1.45 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClientTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -358,6 +358,57 @@ WebStorageClientTest :: playlistTest(void) } +/*------------------------------------------------------------------------------ + * Test on an embedded playlist + *----------------------------------------------------------------------------*/ +void +WebStorageClientTest :: embeddedPlaylistTest(void) + throw (CPPUNIT_NS::Exception) +{ + try { + wsc->reset(); + } catch (XmlRpcException &e) { + CPPUNIT_FAIL(e.what()); + } + CPPUNIT_ASSERT(wsc->getPlaylistIds()->size() >= 3); + Ptr::Ref playlistId = wsc->getPlaylistIds()->at(2); + + Ptr::Ref sessionId; + try { + sessionId = authentication->login("root", "q"); + } catch (XmlRpcException &e) { + CPPUNIT_FAIL(e.what()); + } + CPPUNIT_ASSERT(sessionId); + + + // test acquirePlaylist() + Ptr::Ref playlist; + try { + playlist = wsc->acquirePlaylist(sessionId, playlistId); + } catch (XmlRpcException &e) { + CPPUNIT_FAIL(e.what()); + } + CPPUNIT_ASSERT(playlist); + CPPUNIT_ASSERT(playlist->getUri()); + + std::ifstream ifs(playlist->getUri()->substr(7).c_str()); + if (!ifs) { // cut off "file://" + ifs.close(); + CPPUNIT_FAIL("playlist temp file not found"); + } + ifs.close(); + + // test releasePlaylist() + try { + wsc->releasePlaylist(playlist); + } catch (XmlRpcException &e) { + CPPUNIT_FAIL(e.what()); + } + CPPUNIT_ASSERT(!playlist->getUri()); +} + + /*------------------------------------------------------------------------------ * Testing the audio clip operations *----------------------------------------------------------------------------*/ diff --git a/livesupport/modules/storage/src/WebStorageClientTest.h b/livesupport/modules/storage/src/WebStorageClientTest.h index 2d5567fab..c1874acf4 100644 --- a/livesupport/modules/storage/src/WebStorageClientTest.h +++ b/livesupport/modules/storage/src/WebStorageClientTest.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: fgerlits $ - Version : $Revision: 1.11 $ + Author : $Author: maroy $ + Version : $Revision: 1.12 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClientTest.h,v $ ------------------------------------------------------------------------------*/ @@ -63,8 +63,8 @@ using namespace LiveSupport::Authentication; /** * Unit test for the UploadPlaylistMetohd class. * - * @author $Author: fgerlits $ - * @version $Revision: 1.11 $ + * @author $Author: maroy $ + * @version $Revision: 1.12 $ * @see WebStorageClient */ class WebStorageClientTest : public BaseTestMethod @@ -74,6 +74,7 @@ class WebStorageClientTest : public BaseTestMethod CPPUNIT_TEST(getVersionTest); CPPUNIT_TEST(simplePlaylistTest); CPPUNIT_TEST(playlistTest); + CPPUNIT_TEST(embeddedPlaylistTest); CPPUNIT_TEST(audioClipTest); CPPUNIT_TEST(searchTest); CPPUNIT_TEST(getAllTest); @@ -133,6 +134,14 @@ class WebStorageClientTest : public BaseTestMethod void playlistTest(void) throw (CPPUNIT_NS::Exception); + /** + * Testing an embedded playlist + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + embeddedPlaylistTest(void) throw (CPPUNIT_NS::Exception); + /** * Testing the search operations. *