modified the authentication and storage modules to throw their

own exception classes AuthenticationException and StorageException
instead of invalid_argument and logic_error
This commit is contained in:
fgerlits 2004-12-23 11:37:55 +00:00
parent adf05eaf29
commit de2b5a49a2
61 changed files with 1121 additions and 539 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h,v $
------------------------------------------------------------------------------*/
@ -45,6 +45,7 @@
#include "LiveSupport/Core/UniqueId.h"
#include "LiveSupport/Core/Playlist.h"
#include "LiveSupport/Core/SessionId.h"
#include "LiveSupport/Storage/StorageException.h"
namespace LiveSupport {
@ -64,7 +65,7 @@ using namespace Core;
* An interface for storage clients.
*
* @author $Author: fgerlits $
* @version $Revision: 1.1 $
* @version $Revision: 1.2 $
*/
class StorageClientInterface
{
@ -76,11 +77,13 @@ class StorageClientInterface
* @param id the id of the playlist to check for.
* @return true if a playlist with the specified id exists,
* false otherwise.
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual const bool
existsPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -89,13 +92,14 @@ class StorageClientInterface
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to return.
* @return the requested playlist.
* @exception std::logic_error if no playlist with the specified
* id exists.
* @exception StorageException if there is a problem with the XML-RPC
* call or no playlist with the specified
* id exists.
*/
virtual Ptr<Playlist>::Ref
getPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -104,13 +108,14 @@ class StorageClientInterface
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to return.
* @return the requested playlist.
* @exception std::logic_error if no playlist with the specified
* id exists.
* @exception StorageException if there is a problem with the XML-RPC
* call or no playlist with the specified
* id exists.
*/
virtual Ptr<Playlist>::Ref
editPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -118,13 +123,14 @@ class StorageClientInterface
*
* @param sessionId the session ID from the authentication client
* @param playlist the playlist to save.
* @exception std::logic_error if the playlist has not been previously
* opened by getPlaylist()
* @exception StorageException if there is a problem with the XML-RPC
* call or the playlist has not been
* previously opened by getPlaylist()
*/
virtual void
savePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -135,13 +141,14 @@ class StorageClientInterface
* @return a new Playlist instance containing a uri field which
* points to an executable (playable) SMIL representation of
* the playlist (in the local storage).
* @exception std::logic_error if no playlist with the specified
* specified id exists.
* @exception StorageException if there is a problem with the XML-RPC
* call or no playlist with the specified
* specified id exists.
*/
virtual Ptr<Playlist>::Ref
acquirePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -150,26 +157,28 @@ class StorageClientInterface
*
* @param sessionId the session ID from the authentication client
* @param playlist the playlist to release.
* @exception std::logic_error if the playlist has no uri field,
* or the file does not exist, etc.
* @exception StorageException if there is a problem with the XML-RPC
* call or the playlist has no uri field,
* or the file does not exist, etc.
*/
virtual void
releasePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
* Delete a playlist with the specified id.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to be deleted.
* @exception std::logic_error if no playlist with the specified
* id exists.
* @exception StorageException if there is a problem with the XML-RPC
* call or no playlist with the specified
* id exists.
*/
virtual void
deletePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -177,10 +186,12 @@ class StorageClientInterface
*
* @param sessionId the session ID from the authentication client
* @return a vector containing the playlists.
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
getAllPlaylists(Ptr<SessionId>::Ref sessionId) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -188,10 +199,12 @@ class StorageClientInterface
*
* @param sessionId the session ID from the authentication client
* @return the newly created playlist.
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual Ptr<Playlist>::Ref
createPlaylist(Ptr<SessionId>::Ref sessionId)
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -201,11 +214,13 @@ class StorageClientInterface
* @param id the id of the audio clip to check for.
* @return true if an audio clip with the specified id exists,
* false otherwise.
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual const bool
existsAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -214,13 +229,14 @@ class StorageClientInterface
* @param sessionId the session ID from the authentication client
* @param id the id of the audio clip to return.
* @return the requested audio clip.
* @exception std::logic_error if no audio clip with the
* specified id exists.
* @exception StorageException if there is a problem with the XML-RPC
* call or no audio clip with the
* specified id exists.
*/
virtual Ptr<AudioClip>::Ref
getAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -230,12 +246,13 @@ class StorageClientInterface
* @param audioClip the audio clip to store.
* @return true if the operation was successful.
*
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call or we have not logged in yet.
*/
virtual bool
storeAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip)
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -245,13 +262,14 @@ class StorageClientInterface
* @param id the id of the audio clip to acquire.
* @return a new AudioClip instance, containing a uri field which
* points to (a way of getting) the sound file.
* @exception std::logic_error if no audio clip with the
* specified id exists.
* @exception StorageException if there is a problem with the XML-RPC
* call or if no audio clip with the
* specified id exists.
*/
virtual Ptr<AudioClip>::Ref
acquireAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -259,13 +277,14 @@ class StorageClientInterface
*
* @param sessionId the session ID from the authentication client
* @param audioClip the id of the audio clip to release.
* @exception std::logic_error if the audio clip has no uri field,
* or the file does not exist, etc.
* @exception StorageException if there is a problem with the XML-RPC
* call or the audio clip has no uri field,
* or the file does not exist, etc.
*/
virtual void
releaseAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip) const
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -273,13 +292,14 @@ class StorageClientInterface
*
* @param sessionId the session ID from the authentication client
* @param id the id of the audio clip to be deleted.
* @exception std::logic_error if no audio clip with the
* specified id exists.
* @exception StorageException if there is a problem with the XML-RPC
* call or no audio clip with the
* specified id exists.
*/
virtual void
deleteAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::logic_error)
throw (StorageException)
= 0;
/**
@ -287,10 +307,12 @@ class StorageClientInterface
*
* @param sessionId the session ID from the authentication client
* @return a vector containing the playlists.
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref
getAllAudioClips(Ptr<SessionId>::Ref sessionId) const
throw (std::logic_error)
throw (StorageException)
= 0;
};

View file

@ -0,0 +1,115 @@
/*------------------------------------------------------------------------------
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: fgerlits $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/include/LiveSupport/Storage/Attic/StorageException.h,v $
------------------------------------------------------------------------------*/
#ifndef LiveSupport_Storage_StorageException_h
#define LiveSupport_Storage_StorageException_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <stdexcept>
namespace LiveSupport {
namespace Storage {
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* Common parent of exception classes for this module.
*
* @author $Author: fgerlits $
* @version $Revision: 1.1 $
*/
class StorageException : public std::runtime_error
{
public:
StorageException(const std::string &msg)
: std::runtime_error(msg) {
}
};
/**
* XML-RPC communication problem.
*/
class XmlRpcCommunicationException : public StorageException
{
public:
XmlRpcCommunicationException(const std::string &msg)
: StorageException(msg) {
}
};
/**
* XML-RPC fault thrown by the method called.
*/
class XmlRpcMethodFaultException : public StorageException
{
public:
XmlRpcMethodFaultException(const std::string &msg)
: StorageException(msg) {
}
};
/**
* Unexpected response from the XML-RPC method.
*/
class XmlRpcMethodResponseException : public StorageException
{
public:
XmlRpcMethodResponseException(const std::string &msg)
: StorageException(msg) {
}
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace Storage
} // namespace LiveSupport
#endif // LiveSupport_Storage_StorageException_h

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/StorageClientFactoryTest.cxx,v $
------------------------------------------------------------------------------*/
@ -149,10 +149,32 @@ StorageClientFactoryTest :: firstTest(void)
Ptr<UniqueId>::Ref id01(new UniqueId(1));
Ptr<UniqueId>::Ref id77(new UniqueId(77));
CPPUNIT_ASSERT( storage->existsPlaylist(sessionId, id01));
CPPUNIT_ASSERT(!storage->existsPlaylist(sessionId, id77));
try {
CPPUNIT_ASSERT( storage->existsPlaylist(sessionId, id01));
}
catch (StorageException &e) {
std::string eMsg = "existsPlaylist returned error:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
try {
CPPUNIT_ASSERT(!storage->existsPlaylist(sessionId, id77));
}
catch (StorageException &e) {
std::string eMsg = "existsPlaylist returned error:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
Ptr<Playlist>::Ref playlist = storage->getPlaylist(sessionId, id01);
CPPUNIT_ASSERT(playlist->getId()->getId() == id01->getId());
try {
Ptr<Playlist>::Ref playlist = storage->getPlaylist(sessionId, id01);
CPPUNIT_ASSERT(playlist->getId()->getId() == id01->getId());
}
catch (StorageException &e) {
std::string eMsg = "getPlaylist returned error:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.21 $
Version : $Revision: 1.22 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.cxx,v $
------------------------------------------------------------------------------*/
@ -137,8 +137,7 @@ static const std::string smilPlaylistUriAttrName = "src";
*----------------------------------------------------------------------------*/
void
TestStorageClient :: configure(const xmlpp::Element & element)
throw (std::invalid_argument,
std::logic_error)
throw (std::invalid_argument)
{
if (element.get_name() != configElementNameStr) {
std::string eMsg = "Bad configuration element ";
@ -206,12 +205,12 @@ TestStorageClient :: existsPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref
TestStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::invalid_argument)
throw (StorageException)
{
PlaylistMap::const_iterator it = playlistMap.find(id->getId());
if (it == playlistMap.end()) {
throw std::invalid_argument("no such playlist");
throw StorageException("no such playlist");
}
return it->second;
@ -224,12 +223,12 @@ TestStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref
TestStorageClient :: editPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::invalid_argument)
throw (StorageException)
{
PlaylistMap::const_iterator it = playlistMap.find(id->getId());
if (it == playlistMap.end()) {
throw std::invalid_argument("no such playlist");
throw StorageException("no such playlist");
}
return it->second;
@ -242,7 +241,7 @@ TestStorageClient :: editPlaylist(Ptr<SessionId>::Ref sessionId,
void
TestStorageClient :: savePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error)
throw ()
{
}
@ -253,12 +252,12 @@ TestStorageClient :: savePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref
TestStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
PlaylistMap::const_iterator playlistMapIt = playlistMap.find(id->getId());
if (playlistMapIt == playlistMap.end()) {
throw std::invalid_argument("no such playlist");
throw StorageException("no such playlist");
}
Ptr<Playlist>::Ref oldPlaylist = playlistMapIt->second;
@ -342,16 +341,16 @@ TestStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
void
TestStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error)
throw (StorageException)
{
if (! playlist->getUri()) {
throw std::logic_error("playlist URI not found");
throw StorageException("playlist URI not found");
}
std::ifstream ifs(playlist->getUri()->substr(7).c_str());
if (!ifs) {
ifs.close();
throw std::logic_error("playlist temp file not found");
throw StorageException("playlist temp file not found");
}
ifs.close();
@ -365,7 +364,7 @@ TestStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
try {
releaseAudioClip(sessionId, it->second->getAudioClip());
}
catch (std::invalid_argument &e) {
catch (StorageException &e) {
++badPlaylistElements;
}
++it;
@ -374,7 +373,7 @@ TestStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
try {
releasePlaylist(sessionId, it->second->getPlaylist());
}
catch (std::invalid_argument &e) {
catch (StorageException &e) {
++badPlaylistElements;
}
++it;
@ -391,7 +390,7 @@ TestStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
std::stringstream eMsg;
eMsg << "could not release " << badPlaylistElements
<< " playlist elements in playlist";
throw std::logic_error(eMsg.str());
throw StorageException(eMsg.str());
}
}
@ -402,11 +401,11 @@ TestStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
void
TestStorageClient :: deletePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::invalid_argument)
throw (StorageException)
{
// erase() returns the number of entries found & erased
if (!playlistMap.erase(id->getId())) {
throw std::invalid_argument("no such playlist");
throw StorageException("no such playlist");
}
}
@ -474,12 +473,12 @@ TestStorageClient :: existsAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref
TestStorageClient :: getAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::invalid_argument)
throw (StorageException)
{
AudioClipMap::const_iterator it = audioClipMap.find(id->getId());
if (it == audioClipMap.end()) {
throw std::invalid_argument("no such audio clip");
throw StorageException("no such audio clip");
}
return it->second;
@ -492,7 +491,7 @@ TestStorageClient :: getAudioClip(Ptr<SessionId>::Ref sessionId,
bool
TestStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip)
throw (std::invalid_argument)
throw (StorageException)
{
audioClipMap[audioClip->getId()->getId()] = audioClip;
return true;
@ -505,18 +504,18 @@ TestStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref
TestStorageClient :: acquireAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
AudioClipMap::const_iterator it = audioClipMap.find(id->getId());
if (it == audioClipMap.end()) {
throw std::invalid_argument("no such audio clip");
throw StorageException("no such audio clip");
}
Ptr<AudioClip>::Ref storedAudioClip = it->second;
if (! storedAudioClip->getUri()) {
throw std::logic_error("audio clip URI not found");
throw StorageException("audio clip URI not found");
}
// cut the "file:" off
std::string audioClipFileName = storedAudioClip->getUri()->substr(5);
@ -524,7 +523,7 @@ TestStorageClient :: acquireAudioClip(Ptr<SessionId>::Ref sessionId,
std::ifstream ifs(audioClipFileName.c_str());
if (!ifs) {
ifs.close();
throw std::logic_error("could not read audio clip");
throw StorageException("could not read audio clip");
}
ifs.close();
@ -546,10 +545,10 @@ TestStorageClient :: acquireAudioClip(Ptr<SessionId>::Ref sessionId,
void
TestStorageClient :: releaseAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip) const
throw (std::logic_error)
throw (StorageException)
{
if (*(audioClip->getUri()) == "") {
throw std::logic_error("audio clip URI not found");
throw StorageException("audio clip URI not found");
}
Ptr<std::string>::Ref nullPointer;
@ -563,11 +562,11 @@ TestStorageClient :: releaseAudioClip(Ptr<SessionId>::Ref sessionId,
void
TestStorageClient :: deleteAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::invalid_argument)
throw (StorageException)
{
// erase() returns the number of entries found & erased
if (!audioClipMap.erase(id->getId())) {
throw std::invalid_argument("no such audio clip");
throw StorageException("no such audio clip");
}
}

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.19 $
Version : $Revision: 1.20 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.h,v $
------------------------------------------------------------------------------*/
@ -90,7 +90,7 @@ using namespace LiveSupport::Core;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.19 $
* @version $Revision: 1.20 $
*/
class TestStorageClient :
virtual public Configurable,
@ -157,14 +157,12 @@ class TestStorageClient :
* @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 scheduler daemon has already
* been configured, and can not be reconfigured.
*/
virtual void
configure(const xmlpp::Element & element)
throw (std::invalid_argument,
std::logic_error);
throw (std::invalid_argument);
/**
* Tell if a playlist with a given id exists.
*
@ -174,9 +172,10 @@ class TestStorageClient :
* false otherwise.
*/
virtual const bool
existsPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw ();
existsPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw ();
/**
* Return a playlist with the specified id, to be displayed.
@ -184,13 +183,14 @@ class TestStorageClient :
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to return.
* @return the requested playlist.
* @exception std::invalid_argument if no playlist with the specified
* id exists.
* @exception StorageException if no playlist with the specified
* id exists.
*/
virtual Ptr<Playlist>::Ref
getPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::invalid_argument);
throw (StorageException);
/**
* Return a playlist with the specified id, to be edited.
@ -198,26 +198,26 @@ class TestStorageClient :
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to return.
* @return the requested playlist.
* @exception std::invalid_argument if no playlist with the specified
* id exists.
* @exception StorageException if no playlist with the specified
* id exists.
*/
virtual Ptr<Playlist>::Ref
editPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::invalid_argument);
throw (StorageException);
/**
* Save the playlist after editing.
*
* @param sessionId the session ID from the authentication client
* @param playlist the playlist to save.
* @exception std::logic_error if the playlist has not been previously
* opened by getPlaylist()
*/
virtual void
savePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error);
throw ();
/**
* Acquire the resources for the playlist.
@ -232,13 +232,14 @@ class TestStorageClient :
* @return a new Playlist instance containing a uri field which
* points to an executable (playable) SMIL representation of
* the playlist (in the local storage).
* @exception std::invalid_argument if no playlist with the specified
* specified id exists.
* @exception StorageException if no playlist with the specified
* specified id exists.
*/
virtual Ptr<Playlist>::Ref
acquirePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
throw (StorageException);
/**
* Release the resources (audio clips, other playlists) used
@ -246,26 +247,27 @@ class TestStorageClient :
*
* @param sessionId the session ID from the authentication client
* @param playlist the playlist to release.
* @exception std::logic_error if the playlist has no uri field,
* or the file does not exist, etc.
* @exception StorageException if the playlist has no uri field,
* or the file does not exist, etc.
*/
virtual void
releasePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error);
releasePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (StorageException);
/**
* Delete the playlist with the specified id.
* Delete a playlist with the specified id.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to be deleted.
* @exception std::invalid_argument if no playlist with the specified
* id exists.
* @exception StorageException if no playlist with the specified
* id exists.
*/
virtual void
deletePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::invalid_argument);
deletePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (StorageException);
/**
* Return a list of all playlists in the playlist store.
@ -275,7 +277,8 @@ class TestStorageClient :
*/
virtual Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
getAllPlaylists(Ptr<SessionId>::Ref sessionId) const
throw ();
throw ();
/**
* Create a new playlist.
@ -285,7 +288,8 @@ class TestStorageClient :
*/
virtual Ptr<Playlist>::Ref
createPlaylist(Ptr<SessionId>::Ref sessionId)
throw ();
throw ();
/**
* Tell if an audio clip with a given id exists.
@ -298,7 +302,7 @@ class TestStorageClient :
virtual const bool
existsAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw ();
throw ();
/**
* Return an audio clip with the specified id.
@ -306,13 +310,13 @@ class TestStorageClient :
* @param sessionId the session ID from the authentication client
* @param id the id of the audio clip to return.
* @return the requested audio clip.
* @exception std::invalid_argument if no audio clip with the
* specified id exists.
* @exception StorageException if no audio clip with the
* specified id exists.
*/
virtual Ptr<AudioClip>::Ref
getAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::invalid_argument);
getAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (StorageException);
/**
* Store an audio clip.
@ -320,12 +324,13 @@ class TestStorageClient :
* @param sessionId the session ID from the authentication client
* @param audioClip the audio clip to store.
* @return true if the operation was successful.
* @exception std::invalid_argument never in this implementation
*
* @exception StorageException if we have not logged in yet.
*/
virtual bool
storeAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip)
throw (std::invalid_argument);
throw (StorageException);
/**
* Acquire the resources for the audio clip with the specified id.
@ -339,50 +344,52 @@ class TestStorageClient :
* @param id the id of the audio clip to acquire.
* @return a new AudioClip instance, containing a uri field which
* points to (a way of getting) the sound file.
* @exception std::invalid_argument if no audio clip with the
* specified id exists.
* @exception StorageException if no audio clip with the
* specified id exists.
*/
virtual Ptr<AudioClip>::Ref
acquireAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
acquireAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (StorageException);
/**
* Release the resource (sound file) used by an audio clip.
*
* @param sessionId the session ID from the authentication client
* @param audioClip the audio clip to release.
* @exception std::logic_error if the audio clip has no uri field,
* or the file does not exist, etc.
* @param audioClip the id of the audio clip to release.
* @exception StorageException if the audio clip has no uri field,
* or the file does not exist, etc.
*/
virtual void
releaseAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip) const
throw (std::logic_error);
throw (StorageException);
/**
* Delete the audio clip with the specified id.
* Delete an audio clip with the specified id.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the audio clip to be deleted.
* @exception std::invalid_argument if no audio clip with the
* specified id exists.
* @exception StorageException if no audio clip with the
* specified id exists.
*/
virtual void
deleteAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::invalid_argument);
deleteAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (StorageException);
/**
* Return a list of all audio clips in the playlist store.
*
* @param sessionId the session ID from the authentication client
* @return a vector containing the audio clips.
* @return a vector containing the playlists.
*/
virtual Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref
getAllAudioClips(Ptr<SessionId>::Ref sessionId) const
throw ();
throw ();
};

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.16 $
Version : $Revision: 1.17 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClientTest.cxx,v $
------------------------------------------------------------------------------*/
@ -135,17 +135,17 @@ TestStorageClientTest :: deletePlaylistTest(void)
try {
tsc->deletePlaylist(dummySessionId, id2);
CPPUNIT_FAIL("allowed to delete non-existent playlist");
} catch (std::invalid_argument &e) {
} catch (StorageException &e) {
}
try {
tsc->deletePlaylist(dummySessionId, id1);
} catch (std::invalid_argument &e) {
} catch (StorageException &e) {
CPPUNIT_FAIL("cannot delete existing playlist");
}
try {
tsc->deletePlaylist(dummySessionId, id1);
CPPUNIT_FAIL("allowed to delete non-existent playlist");
} catch (std::invalid_argument &e) {
} catch (StorageException &e) {
}
}
@ -227,7 +227,7 @@ TestStorageClientTest :: acquireAudioClipTest(void)
try {
audioClip = tsc->acquireAudioClip(dummySessionId, id2);
}
catch (std::logic_error &e) {
catch (StorageException &e) {
std::string eMsg = "could not acquire audio clip:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
@ -240,7 +240,7 @@ TestStorageClientTest :: acquireAudioClipTest(void)
try {
tsc->releaseAudioClip(dummySessionId, audioClip);
}
catch (std::logic_error &e) {
catch (StorageException &e) {
std::string eMsg = "could not release audio clip:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
@ -250,7 +250,7 @@ TestStorageClientTest :: acquireAudioClipTest(void)
audioClip = tsc->acquireAudioClip(dummySessionId, id77);
CPPUNIT_FAIL("allowed to acquire non-existent audio clip");
}
catch (std::logic_error &e) {
catch (StorageException &e) {
}
}
@ -269,7 +269,7 @@ TestStorageClientTest :: acquirePlaylistTest(void)
try {
playlist = tsc->acquirePlaylist(dummySessionId, id1);
}
catch (std::logic_error &e) {
catch (StorageException &e) {
std::string eMsg = "could not acquire playlist:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
@ -288,7 +288,7 @@ TestStorageClientTest :: acquirePlaylistTest(void)
try {
tsc->releasePlaylist(dummySessionId, playlist);
}
catch (std::logic_error &e) {
catch (StorageException &e) {
std::string eMsg = "could not release playlist:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
@ -305,6 +305,6 @@ TestStorageClientTest :: acquirePlaylistTest(void)
playlist = tsc->acquirePlaylist(dummySessionId, id77);
CPPUNIT_FAIL("allowed to acquire non-existent playlist");
}
catch (std::logic_error &e) {
catch (StorageException &e) {
}
}

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.10 $
Version : $Revision: 1.11 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $
------------------------------------------------------------------------------*/
@ -275,8 +275,7 @@ static const std::string storeAudioClipMethodMetadataFileParamName
*----------------------------------------------------------------------------*/
void
WebStorageClient :: configure(const xmlpp::Element & element)
throw (std::invalid_argument,
std::logic_error)
throw (std::invalid_argument)
{
if (element.get_name() != configElementNameStr) {
std::string eMsg = "Bad configuration element ";
@ -349,7 +348,7 @@ WebStorageClient :: configure(const xmlpp::Element & element)
const bool
WebStorageClient :: existsPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
return false;
}
@ -361,7 +360,7 @@ WebStorageClient :: existsPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref
WebStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
Ptr<Playlist>::Ref playlist(new Playlist);
return playlist;
@ -374,7 +373,7 @@ WebStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref
WebStorageClient :: editPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
Ptr<Playlist>::Ref playlist(new Playlist);
return playlist;
@ -387,7 +386,7 @@ WebStorageClient :: editPlaylist(Ptr<SessionId>::Ref sessionId,
void
WebStorageClient :: savePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error)
throw (StorageException)
{
}
@ -398,7 +397,7 @@ WebStorageClient :: savePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref
WebStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
Ptr<Playlist>::Ref playlist(new Playlist);
return playlist;
@ -411,7 +410,7 @@ WebStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
void
WebStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error)
throw (StorageException)
{
}
@ -423,7 +422,7 @@ WebStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
void
WebStorageClient :: deletePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::logic_error)
throw (StorageException)
{
}
@ -434,7 +433,7 @@ WebStorageClient :: deletePlaylist(Ptr<SessionId>::Ref sessionId,
*----------------------------------------------------------------------------*/
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
WebStorageClient :: getAllPlaylists(Ptr<SessionId>::Ref sessionId) const
throw (std::logic_error)
throw (StorageException)
{
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlistVector(
new std::vector<Ptr<Playlist>::Ref>);
@ -447,7 +446,7 @@ WebStorageClient :: getAllPlaylists(Ptr<SessionId>::Ref sessionId) const
*----------------------------------------------------------------------------*/
Ptr<Playlist>::Ref
WebStorageClient :: createPlaylist(Ptr<SessionId>::Ref sessionId)
throw (std::logic_error)
throw (StorageException)
{
Ptr<Playlist>::Ref playlist(new Playlist);
return playlist;
@ -460,7 +459,7 @@ WebStorageClient :: createPlaylist(Ptr<SessionId>::Ref sessionId)
const bool
WebStorageClient :: existsAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
XmlRpcValue parameters;
XmlRpcValue result;
@ -480,7 +479,7 @@ WebStorageClient :: existsAudioClip(Ptr<SessionId>::Ref sessionId,
std::string eMsg = "cannot execute XML-RPC method '";
eMsg += existsAudioClipMethodName;
eMsg += "'";
throw std::logic_error(eMsg);
throw StorageException(eMsg);
}
if (xmlRpcClient.isFault()
@ -492,7 +491,7 @@ WebStorageClient :: existsAudioClip(Ptr<SessionId>::Ref sessionId,
<< existsAudioClipMethodName
<< "' returned error message:\n"
<< result;
throw std::logic_error(eMsg.str());
throw StorageException(eMsg.str());
}
return bool(result[existsAudioClipMethodResultParamName]);
@ -505,7 +504,7 @@ WebStorageClient :: existsAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref
WebStorageClient :: getAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
XmlRpcValue parameters;
XmlRpcValue result;
@ -525,7 +524,7 @@ WebStorageClient :: getAudioClip(Ptr<SessionId>::Ref sessionId,
std::string eMsg = "cannot execute XML-RPC method '";
eMsg += getAudioClipOpenMethodName;
eMsg += "'";
throw std::logic_error(eMsg);
throw StorageException(eMsg);
}
if (xmlRpcClient.isFault()
@ -540,35 +539,12 @@ WebStorageClient :: getAudioClip(Ptr<SessionId>::Ref sessionId,
<< getAudioClipOpenMethodName
<< "' returned error message:\n"
<< result;
throw std::logic_error(eMsg.str());
throw StorageException(eMsg.str());
}
std::string url = result[getAudioClipMethodUrlParamName];
std::string token = result[getAudioClipMethodTokenParamName];
/*
int offset = 353;
std::cout << "\n" << xmlAudioClip.at(offset+0) << "\n";
std::cout << xmlAudioClip.at(offset+1) << "\n";
std::cout << xmlAudioClip.at(offset+2) << "\n";
std::cout << xmlAudioClip.at(offset+3) << "\n";
std::cout << xmlAudioClip.at(offset+4) << "\n";
std::cout << xmlAudioClip.at(offset+5) << "\n";
std::cout << xmlAudioClip.at(offset+6) << "\n";
std::cout << xmlAudioClip.at(offset+7) << "\n";
std::cout << xmlAudioClip.at(offset+8) << "\n";
std::cout << xmlAudioClip.at(offset+9) << "\n";
std::cout << xmlAudioClip.at(offset+10) << "\n";
std::cout << xmlAudioClip.at(offset+11) << "\n";
std::cout << xmlAudioClip.at(offset+12) << "\n";
std::cout << xmlAudioClip.at(offset+13) << "\n";
std::cout << xmlAudioClip.at(offset+14) << "\n";
std::cout << xmlAudioClip.at(offset+15) << "\n";
std::cout << xmlAudioClip.at(offset+16) << "\n";
std::cout << xmlAudioClip.at(offset+17) << "\n";
std::cout << xmlAudioClip.at(offset+18) << "\n";
std::cout << xmlAudioClip.at(offset+19) << "\n";
std::cout << xmlAudioClip.at(offset+20) << "\n";
*/
Ptr<AudioClip>::Ref audioClip(new AudioClip(id));
try {
@ -579,9 +555,9 @@ std::cout << xmlAudioClip.at(offset+20) << "\n";
audioClip->configure(*root);
} catch (std::invalid_argument &e) {
throw std::logic_error("semantic error in audio clip metafile");
throw StorageException("semantic error in audio clip metafile");
} catch (xmlpp::exception &e) {
throw std::logic_error("error parsing audio clip metafile");
throw StorageException("error parsing audio clip metafile");
}
parameters.clear();
@ -596,7 +572,7 @@ std::cout << xmlAudioClip.at(offset+20) << "\n";
std::string eMsg = "cannot execute XML-RPC method '";
eMsg += getAudioClipCloseMethodName;
eMsg += "'";
throw std::logic_error(eMsg);
throw StorageException(eMsg);
}
if (xmlRpcClient.isFault()
@ -610,7 +586,7 @@ std::cout << xmlAudioClip.at(offset+20) << "\n";
<< getAudioClipCloseMethodName
<< "' returned error message:\n"
<< result;
throw std::logic_error(eMsg.str());
throw StorageException(eMsg.str());
}
return audioClip;
@ -618,22 +594,22 @@ std::cout << xmlAudioClip.at(offset+20) << "\n";
/*------------------------------------------------------------------------------
* Store an audio clip.
* Upload an audio clip to the local storage.
*----------------------------------------------------------------------------*/
bool
WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip)
throw (std::logic_error)
throw (StorageException)
{
if (!audioClip || !audioClip->getUri()) {
throw std::logic_error("binary audio clip file not found");
throw StorageException("binary audio clip file not found");
}
Ptr<xmlpp::Document>::Ref metadata = audioClip->getMetadata();
std::stringstream metadataFileName;
metadataFileName << localTempStorage << "-audioClipMetadata-"
<< audioClip->getId()->getId()
<< std::string(*audioClip->getId())
<< "-" << rand() << ".xml";
metadata->write_to_file(metadataFileName.str(), "UTF-8");
@ -644,7 +620,7 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
std::ifstream ifs(binaryFileName.c_str());
if (!ifs) {
ifs.close();
throw std::logic_error("could not read audio clip");
throw StorageException("could not read audio clip");
}
ifs.close();
std::string binaryFilePrefix("file://");
@ -661,7 +637,7 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
parameters[storeAudioClipMethodSessionIdParamName]
= sessionId->getId();
parameters[storeAudioClipMethodAudioClipIdParamName]
= int(audioClip->getId()->getId());
= std::string(*audioClip->getId());
parameters[storeAudioClipMethodBinaryFileParamName]
= binaryFileName;
parameters[storeAudioClipMethodMetadataFileParamName]
@ -675,7 +651,7 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
std::string eMsg = "cannot execute XML-RPC method '";
eMsg += storeAudioClipMethodName;
eMsg += "'";
throw std::logic_error(eMsg);
throw StorageException(eMsg);
}
if (xmlRpcClient.isFault()
@ -685,7 +661,7 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
<< storeAudioClipMethodName
<< "' returned error message:\n"
<< result;
throw std::logic_error(eMsg.str());
throw StorageException(eMsg.str());
}
return true;
@ -698,7 +674,7 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref
WebStorageClient :: acquireAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
throw (StorageException)
{
Ptr<AudioClip>::Ref playlist(new AudioClip);
return playlist;
@ -712,7 +688,7 @@ WebStorageClient :: acquireAudioClip(Ptr<SessionId>::Ref sessionId,
void
WebStorageClient :: releaseAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip) const
throw (std::logic_error)
throw (StorageException)
{
}
@ -724,7 +700,7 @@ WebStorageClient :: releaseAudioClip(Ptr<SessionId>::Ref sessionId,
void
WebStorageClient :: deleteAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::logic_error)
throw (StorageException)
{
}
@ -736,7 +712,7 @@ WebStorageClient :: deleteAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref
WebStorageClient :: getAllAudioClips(Ptr<SessionId>::Ref sessionId)
const
throw (std::logic_error)
throw (StorageException)
{
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref audioClipVector(
new std::vector<Ptr<AudioClip>::Ref>);
@ -749,7 +725,7 @@ WebStorageClient :: getAllAudioClips(Ptr<SessionId>::Ref sessionId)
*----------------------------------------------------------------------------*/
Ptr<std::vector<Ptr<UniqueId>::Ref> >::Ref
WebStorageClient :: reset(void)
throw (std::logic_error)
throw (StorageException)
{
XmlRpcValue parameters;
XmlRpcValue result;
@ -766,7 +742,7 @@ WebStorageClient :: reset(void)
std::string eMsg = "cannot execute XML-RPC method '";
eMsg += resetStorageMethodName;
eMsg += "'";
throw std::logic_error(eMsg);
throw StorageException(eMsg);
}
if (xmlRpcClient.isFault()
@ -778,7 +754,7 @@ WebStorageClient :: reset(void)
<< resetStorageMethodName
<< "' returned error message:\n"
<< result;
throw std::logic_error(eMsg.str());
throw StorageException(eMsg.str());
}
XmlRpcValue uniqueIdArray = result[resetStorageMethodResultParamName];
@ -792,7 +768,7 @@ WebStorageClient :: reset(void)
<< resetStorageMethodName
<< "':\n"
<< result;
throw std::logic_error(eMsg.str());
throw StorageException(eMsg.str());
}
Ptr<UniqueId>::Ref uniqueId(new UniqueId(std::string(uniqueIdArray[i])));
returnValue->push_back(uniqueId);

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.9 $
Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.h,v $
------------------------------------------------------------------------------*/
@ -99,7 +99,7 @@ using namespace LiveSupport::Core;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.9 $
* @version $Revision: 1.10 $
*/
class WebStorageClient :
virtual public Configurable,
@ -153,19 +153,18 @@ class WebStorageClient :
return configElementNameStr;
}
/**
* 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 scheduler daemon has already
* been configured, and can not be reconfigured.
*/
virtual void
configure(const xmlpp::Element & element)
throw (std::invalid_argument,
std::logic_error);
throw (std::invalid_argument);
/**
* Tell if a playlist with a given id exists.
@ -174,12 +173,13 @@ class WebStorageClient :
* @param id the id of the playlist to check for.
* @return true if a playlist with the specified id exists,
* false otherwise.
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual const bool
existsPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
existsPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (StorageException);
/**
* Return a playlist with the specified id, to be displayed.
@ -187,14 +187,15 @@ class WebStorageClient :
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to return.
* @return the requested playlist.
* @exception std::logic_error if no playlist with the specified
* id exists.
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call or no playlist with the specified
* id exists.
*/
virtual Ptr<Playlist>::Ref
getPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
throw (StorageException);
/**
* Return a playlist with the specified id, to be edited.
@ -202,27 +203,29 @@ class WebStorageClient :
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to return.
* @return the requested playlist.
* @exception std::logic_error if no playlist with the specified
* id exists.
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call or no playlist with the specified
* id exists.
*/
virtual Ptr<Playlist>::Ref
editPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
throw (StorageException);
/**
* Save the playlist after editing.
*
* @param sessionId the session ID from the authentication client
* @param playlist the playlist to save.
* @exception std::logic_error if the playlist has not been previously
* opened by getPlaylist()
* @exception StorageException if there is a problem with the XML-RPC
* call or the playlist has not been
* previously opened by getPlaylist()
*/
virtual void
savePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error);
throw (StorageException);
/**
* Acquire the resources for the playlist.
@ -237,14 +240,14 @@ class WebStorageClient :
* @return a new Playlist instance containing a uri field which
* points to an executable (playable) SMIL representation of
* the playlist (in the local storage).
* @exception std::logic_error if no playlist with the specified
* specified id exists.
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call or no playlist with the specified
* specified id exists.
*/
virtual Ptr<Playlist>::Ref
acquirePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
throw (StorageException);
/**
* Release the resources (audio clips, other playlists) used
@ -253,50 +256,52 @@ class WebStorageClient :
*
* @param sessionId the session ID from the authentication client
* @param playlist the playlist to release.
* @exception std::logic_error if the playlist has no uri field,
* or the file does not exist, etc.
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call or the playlist has no uri field,
* or the file does not exist, etc.
*/
virtual void
releasePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error);
releasePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (StorageException);
/**
* Delete the playlist with the specified id.
* Delete a playlist with the specified id.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to be deleted.
* @exception std::logic_error if no playlist with the specified
* id exists.
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call or no playlist with the specified
* id exists.
*/
virtual void
deletePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::logic_error);
deletePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (StorageException);
/**
* Return a list of all playlists in the playlist store.
*
* @param sessionId the session ID from the authentication client
* @return a vector containing the playlists.
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
getAllPlaylists(Ptr<SessionId>::Ref sessionId) const
throw (std::logic_error);
throw (StorageException);
/**
* Create a new playlist.
*
* @param sessionId the session ID from the authentication client
* @return the newly created playlist.
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual Ptr<Playlist>::Ref
createPlaylist(Ptr<SessionId>::Ref sessionId)
throw (std::logic_error);
throw (StorageException);
/**
* Tell if an audio clip with a given id exists.
@ -305,12 +310,13 @@ class WebStorageClient :
* @param id the id of the audio clip to check for.
* @return true if an audio clip with the specified id exists,
* false otherwise.
* @exception std::logic_error if we have not logged in yet
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual const bool
existsAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
throw (StorageException);
/**
* Return an audio clip with the specified id.
@ -318,14 +324,14 @@ class WebStorageClient :
* @param sessionId the session ID from the authentication client
* @param id the id of the audio clip to return.
* @return the requested audio clip.
* @exception std::logic_error if no audio clip with the
* specified id exists.
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call or no audio clip with the
* specified id exists.
*/
virtual Ptr<AudioClip>::Ref
getAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
getAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (StorageException);
/**
* Store an audio clip. The <code>uri</code> field of the audio clip
@ -339,12 +345,13 @@ class WebStorageClient :
* @param audioClip the audio clip to store.
* @return true if the operation was successful.
*
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call or we have not logged in yet.
*/
virtual bool
storeAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip)
throw (std::logic_error);
throw (StorageException);
/**
* Acquire the resources for the audio clip with the specified id.
@ -356,14 +363,14 @@ class WebStorageClient :
* @param id the id of the audio clip to acquire.
* @return a new AudioClip instance, containing a uri field which
* points to (a way of getting) the sound file.
* @exception std::logic_error if no audio clip with the
* specified id exists.
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call or if no audio clip with the
* specified id exists.
*/
virtual Ptr<AudioClip>::Ref
acquireAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error);
acquireAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (StorageException);
/**
* Release the resource (sound file) used by an audio clip. The
@ -371,40 +378,42 @@ class WebStorageClient :
* deleted.
*
* @param sessionId the session ID from the authentication client
* @param audioClip the audio clip to release.
* @exception std::logic_error if the audio clip has no uri field,
* or the file does not exist, etc.
* @exception std::logic_error if we have not logged in yet.
* @param audioClip the id of the audio clip to release.
* @exception StorageException if there is a problem with the XML-RPC
* call or the audio clip has no uri field,
* or the file does not exist, etc.
*/
virtual void
releaseAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip) const
throw (std::logic_error);
throw (StorageException);
/**
* Delete the audio clip with the specified id.
* Delete an audio clip with the specified id.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the audio clip to be deleted.
* @exception std::logic_error if no audio clip with the
* specified id exists.
* @exception std::logic_error if we have not logged in yet.
* @exception StorageException if there is a problem with the XML-RPC
* call or no audio clip with the
* specified id exists.
*/
virtual void
deleteAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::logic_error);
deleteAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (StorageException);
/**
* Return a list of all audio clips in the playlist store.
*
* @param sessionId the session ID from the authentication client
* @return a vector containing the audio clips.
* @exception std::logic_error if we have not logged in yet.
* @return a vector containing the playlists.
* @exception StorageException if there is a problem with the XML-RPC
* call.
*/
virtual Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref
getAllAudioClips(Ptr<SessionId>::Ref sessionId) const
throw (std::logic_error);
throw (StorageException);
/**
* Reset the storage to its initial state. Used for testing.
@ -415,7 +424,7 @@ class WebStorageClient :
*/
Ptr<std::vector<Ptr<UniqueId>::Ref> >::Ref
reset(void)
throw (std::logic_error);
throw (StorageException);
};

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.9 $
Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClientTest.cxx,v $
------------------------------------------------------------------------------*/
@ -137,18 +137,37 @@ WebStorageClientTest :: firstTest(void)
{
Ptr<SessionId>::Ref sessionId(new SessionId("bad ID"));
// this does not currently work due to a bug in the storage server
// try {
// wsc->logout(sessionId);
// CPPUNIT_FAIL("allowed logout operation without login");
// }
// catch (std::logic_error &e) {
// }
try {
authentication->logout(sessionId);
CPPUNIT_FAIL("allowed logout operation without login");
}
catch (AuthenticationException &e) {
}
CPPUNIT_ASSERT(!(sessionId = authentication->login("noSuchUser",
"incorrectPassword")));
CPPUNIT_ASSERT( (sessionId = authentication->login("root", "q")));
CPPUNIT_ASSERT( authentication->logout(sessionId));
try {
sessionId = authentication->login("noSuchUser", "incorrectPassword");
CPPUNIT_FAIL("Allowed login with incorrect password.");
}
catch (AuthenticationException &e) {
}
try {
sessionId = authentication->login("root", "q");
}
catch (AuthenticationException &e) {
std::string eMsg = "Login failed.";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
try {
authentication->logout(sessionId);
}
catch (AuthenticationException &e) {
std::string eMsg = "Login failed.";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
}
@ -175,7 +194,7 @@ WebStorageClientTest :: audioClipTest(void)
try {
exists = wsc->existsAudioClip(sessionId, id01);
}
catch (std::logic_error &e) {
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(exists);
@ -184,7 +203,7 @@ WebStorageClientTest :: audioClipTest(void)
try {
audioClip = wsc->getAudioClip(sessionId, id01);
}
catch (std::logic_error &e) {
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
}
@ -192,11 +211,10 @@ WebStorageClientTest :: audioClipTest(void)
try {
exists = wsc->existsAudioClip(sessionId, id77);
}
catch (std::logic_error &e) {
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(!exists);
/*
Ptr<time_duration>::Ref playlength(new time_duration(0,0,11,0));
Ptr<std::string>::Ref uri(new std::string("file:var/test10001.mp3"));
@ -205,7 +223,7 @@ WebStorageClientTest :: audioClipTest(void)
try {
wsc->storeAudioClip(sessionId, audioClip);
}
catch (std::logic_error &e) {
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
}
@ -213,11 +231,16 @@ WebStorageClientTest :: audioClipTest(void)
Ptr<AudioClip>::Ref newAudioClip
= wsc->getAudioClip(sessionId, id01);
CPPUNIT_ASSERT(newAudioClip->getId()->getId() == id01->getId());
CPPUNIT_ASSERT(std::string(*newAudioClip->getId()) == std::string(*id01);
CPPUNIT_ASSERT(newAudioClip->getPlaylength()->total_seconds()
== audioClip->getPlaylength()->total_seconds());
*/
CPPUNIT_ASSERT( authentication->logout(sessionId));
try{
authentication->logout(sessionId);
}
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
}
/*
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref audioClipVector =
wsc->getAllAudioClips();