added get/set methods for title and for general metadata in AudioClip
and in Playlist
This commit is contained in:
parent
54df237819
commit
3b01df226c
|
@ -21,7 +21,7 @@
|
|||
#
|
||||
#
|
||||
# Author : $Author: fgerlits $
|
||||
# Version : $Revision: 1.18 $
|
||||
# Version : $Revision: 1.19 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/etc/Makefile.in,v $
|
||||
#
|
||||
# @configure_input@
|
||||
|
@ -71,7 +71,7 @@ LIBXMLPP_LIBS=@LIBXMLPP_LIBS@
|
|||
|
||||
# TODO: move ICU flag determination to configure script
|
||||
ICU_CFLAGS=
|
||||
ICU_LIBS=`${USR_DIR}/bin/icu-config --ldflags-toolutil --ldflags-icuio`
|
||||
ICU_LIBS=`${USR_DIR}/bin/icu-config --ldflags --ldflags-toolutil --ldflags-icuio`
|
||||
|
||||
TEST_RESULTS = ${DOC_DIR}/testResults.xml
|
||||
# the text result XSLT has to be relative to the test result file, e.g. TMP_DIR
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.11 $
|
||||
Version : $Revision: 1.12 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/AudioClip.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -77,6 +77,7 @@ using namespace boost::posix_time;
|
|||
*
|
||||
* <pre><code>
|
||||
* <audioClip id="1"
|
||||
* title="Name of the Song"
|
||||
* playlength="00:18:30.000000"
|
||||
* uri="file:var/test1.mp3" >
|
||||
* <metadata
|
||||
|
@ -108,13 +109,14 @@ using namespace boost::posix_time;
|
|||
*
|
||||
* <pre><code>
|
||||
* <!ELEMENT audioClip (metadata?) >
|
||||
* <!ATTLIST audioClip id NMTOKEN #REQUIRED >
|
||||
* <!ATTLIST audioClip playlength NMTOKEN #REQUIRED >
|
||||
* <!ATTLIST audioClip id NMTOKEN #IMPLIED >
|
||||
* <!ATTLIST audioClip title CDATA #IMPLIED >
|
||||
* <!ATTLIST audioClip playlength NMTOKEN #IMPLIED >
|
||||
* <!ATTLIST audioClip uri CDATA #IMPLIED >
|
||||
* </code></pre>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.11 $
|
||||
* @version $Revision: 1.12 $
|
||||
*/
|
||||
class AudioClip : public Configurable,
|
||||
public Playable
|
||||
|
@ -130,6 +132,11 @@ class AudioClip : public Configurable,
|
|||
*/
|
||||
Ptr<UniqueId>::Ref id;
|
||||
|
||||
/**
|
||||
* The title of the audio clip.
|
||||
*/
|
||||
Ptr<UnicodeString>::Ref title;
|
||||
|
||||
/**
|
||||
* The playling length of the audio clip.
|
||||
*/
|
||||
|
@ -145,6 +152,17 @@ class AudioClip : public Configurable,
|
|||
*/
|
||||
Ptr<const string>::Ref token;
|
||||
|
||||
/**
|
||||
* The type for storing the metadata.
|
||||
*/
|
||||
typedef std::map<const std::string, Ptr<UnicodeString>::Ref>
|
||||
metadataType;
|
||||
|
||||
/**
|
||||
* The metadata for this audio clip.
|
||||
*/
|
||||
metadataType metadata;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -167,7 +185,8 @@ class AudioClip : public Configurable,
|
|||
}
|
||||
|
||||
/**
|
||||
* Create an audio clip by specifying all details.
|
||||
* Create an audio clip by specifying all details, except
|
||||
* for the title.
|
||||
* This is used for testing purposes.
|
||||
*
|
||||
* @param id the id of the audio clip.
|
||||
|
@ -181,6 +200,28 @@ class AudioClip : public Configurable,
|
|||
throw ()
|
||||
{
|
||||
this->id = id;
|
||||
this->title.reset(new UnicodeString(""));
|
||||
this->playlength = playlength;
|
||||
this->uri = uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an audio clip by specifying all details.
|
||||
* This is used for testing purposes.
|
||||
*
|
||||
* @param id the id of the audio clip.
|
||||
* @param playlength the playing length of the audio clip.
|
||||
* @param uri the location of the sound file corresponding to
|
||||
* this audio clip object (optional)
|
||||
*/
|
||||
AudioClip(Ptr<UniqueId>::Ref id,
|
||||
Ptr<UnicodeString>::Ref title,
|
||||
Ptr<time_duration>::Ref playlength,
|
||||
Ptr<string>::Ref uri = Ptr<string>::Ref())
|
||||
throw ()
|
||||
{
|
||||
this->id = id;
|
||||
this->title = title;
|
||||
this->playlength = playlength;
|
||||
this->uri = uri;
|
||||
}
|
||||
|
@ -288,6 +329,52 @@ class AudioClip : public Configurable,
|
|||
this->token = token;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the title of this audio clip.
|
||||
*
|
||||
* @return the title.
|
||||
*/
|
||||
virtual Ptr<UnicodeString>::Ref
|
||||
getTitle(void) const throw ()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title of this audio clip.
|
||||
*
|
||||
* @param title a new title.
|
||||
*/
|
||||
virtual void
|
||||
setTitle(Ptr<UnicodeString>::Ref title)
|
||||
throw ()
|
||||
{
|
||||
this->title = title;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the value of a metadata field in this audio clip.
|
||||
*
|
||||
* @return the value of the metadata field; 0 if there is
|
||||
* no such field;
|
||||
*/
|
||||
virtual Ptr<UnicodeString>::Ref
|
||||
getMetadata(const string &key) const
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Set the value of a metadata field in this audio clip.
|
||||
*
|
||||
* @param key the name of the metadata field.
|
||||
* @param value the new value of the metadata field.
|
||||
*/
|
||||
virtual void
|
||||
setMetadata(const string &key, Ptr<UnicodeString>::Ref value)
|
||||
throw ();
|
||||
|
||||
|
||||
/**
|
||||
* Return an XML representation of this audio clip. This contains
|
||||
* the metadata fields of the audio clip, and it's roughly the
|
||||
|
@ -296,7 +383,7 @@ class AudioClip : public Configurable,
|
|||
* @return an xmlpp::Document containing the metadata.
|
||||
*/
|
||||
Ptr<xmlpp::Document>::Ref
|
||||
getMetadata() throw ();
|
||||
toXml() throw ();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playable.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -44,6 +44,7 @@
|
|||
#include <string>
|
||||
#include <libxml++/libxml++.h>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <unicode/unistr.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/UniqueId.h"
|
||||
|
@ -69,7 +70,7 @@ using namespace boost::posix_time;
|
|||
* It contains the methods which are common to these classes.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
*/
|
||||
class Playable
|
||||
{
|
||||
|
@ -91,6 +92,7 @@ class Playable
|
|||
virtual Ptr<time_duration>::Ref
|
||||
getPlaylength(void) const throw () = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Return the URI of the sound file of this audio clip or
|
||||
* playlist, which can be played by the helix client. This
|
||||
|
@ -111,6 +113,7 @@ class Playable
|
|||
virtual void
|
||||
setUri(Ptr<const string>::Ref uri) throw () = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Return the token which is used to identify this audio clip
|
||||
* or playlist to the storage server.
|
||||
|
@ -128,6 +131,45 @@ class Playable
|
|||
*/
|
||||
virtual void
|
||||
setToken(Ptr<const string>::Ref token) throw () = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Return the title of this audio clip or playlist.
|
||||
*
|
||||
* @return the title.
|
||||
*/
|
||||
virtual Ptr<UnicodeString>::Ref
|
||||
getTitle(void) const throw () = 0;
|
||||
|
||||
/**
|
||||
* Set the title of this audio clip or playlist.
|
||||
*
|
||||
* @param title a new title.
|
||||
*/
|
||||
virtual void
|
||||
setTitle(Ptr<UnicodeString>::Ref title)
|
||||
throw () = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Return the value of a metadata field in this audio clip or playlist.
|
||||
*
|
||||
* @return the value of the metadata field; 0 if there is
|
||||
* no such field;
|
||||
*/
|
||||
virtual Ptr<UnicodeString>::Ref
|
||||
getMetadata(const string &key) const
|
||||
throw () = 0;
|
||||
|
||||
/**
|
||||
* Set the value of a metadata field in this audio clip or playlist.
|
||||
*
|
||||
* @param key the name of the metadata field.
|
||||
* @param value the new value of the metadata field.
|
||||
*/
|
||||
virtual void
|
||||
setMetadata(const string &key, Ptr<UnicodeString>::Ref value)
|
||||
throw () = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.19 $
|
||||
Version : $Revision: 1.20 $
|
||||
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>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.19 $
|
||||
* @version $Revision: 1.20 $
|
||||
*/
|
||||
class Playlist : public Configurable,
|
||||
public Playable
|
||||
|
@ -109,6 +109,11 @@ class Playlist : public Configurable,
|
|||
*/
|
||||
Ptr<UniqueId>::Ref id;
|
||||
|
||||
/**
|
||||
* The title of the playlist.
|
||||
*/
|
||||
Ptr<UnicodeString>::Ref title;
|
||||
|
||||
/**
|
||||
* The playling length of the playlist.
|
||||
*/
|
||||
|
@ -163,6 +168,18 @@ class Playlist : public Configurable,
|
|||
Ptr<Playlist>::Ref savedCopy;
|
||||
|
||||
|
||||
/**
|
||||
* The type for storing the metadata.
|
||||
*/
|
||||
typedef std::map<const std::string, Ptr<UnicodeString>::Ref>
|
||||
metadataType;
|
||||
|
||||
/**
|
||||
* The metadata for this playlist.
|
||||
*/
|
||||
metadataType metadata;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* Default constructor.
|
||||
|
@ -174,6 +191,29 @@ class Playlist : public Configurable,
|
|||
this->isLockedForEditing = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a playlist by specifying all details, except the title.
|
||||
* This is used for testing purposes.
|
||||
*
|
||||
* @param id the id of the playlist.
|
||||
* @param playlength the playing length of the playlist.
|
||||
* @param uri the location of the SMIL file representing this
|
||||
* playlist (optional)
|
||||
*/
|
||||
Playlist(Ptr<UniqueId>::Ref id,
|
||||
Ptr<time_duration>::Ref playlength,
|
||||
Ptr<std::string>::Ref uri = Ptr<std::string>::Ref())
|
||||
throw ()
|
||||
{
|
||||
this->id = id;
|
||||
this->title.reset(new UnicodeString(""));
|
||||
this->playlength = playlength;
|
||||
this->uri = uri;
|
||||
elementList.reset(new PlaylistElementListType);
|
||||
this->isLockedForPlaying = false;
|
||||
this->isLockedForEditing = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a playlist by specifying all details.
|
||||
* This is used for testing purposes.
|
||||
|
@ -183,12 +223,14 @@ class Playlist : public Configurable,
|
|||
* @param uri the location of the SMIL file representing this
|
||||
* playlist (optional)
|
||||
*/
|
||||
Playlist(Ptr<UniqueId>::Ref id,
|
||||
Ptr<time_duration>::Ref playlength,
|
||||
Ptr<std::string>::Ref uri = Ptr<std::string>::Ref())
|
||||
Playlist(Ptr<UniqueId>::Ref id,
|
||||
Ptr<UnicodeString>::Ref title,
|
||||
Ptr<time_duration>::Ref playlength,
|
||||
Ptr<std::string>::Ref uri = Ptr<std::string>::Ref())
|
||||
throw ()
|
||||
{
|
||||
this->id = id;
|
||||
this->title = title;
|
||||
this->playlength = playlength;
|
||||
this->uri = uri;
|
||||
elementList.reset(new PlaylistElementListType);
|
||||
|
@ -491,7 +533,56 @@ class Playlist : public Configurable,
|
|||
* saved copy, do nothing and throw an exception.
|
||||
*/
|
||||
void
|
||||
revertToSavedCopy(void) throw (std::logic_error);
|
||||
revertToSavedCopy(void) throw (std::invalid_argument);
|
||||
|
||||
|
||||
/**
|
||||
* Return the title of this playlist.
|
||||
*
|
||||
* @return the title.
|
||||
*/
|
||||
virtual Ptr<UnicodeString>::Ref
|
||||
getTitle(void) const throw ()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title of this playlist.
|
||||
*
|
||||
* @param title a new title.
|
||||
*/
|
||||
virtual void
|
||||
setTitle(Ptr<UnicodeString>::Ref title)
|
||||
throw ()
|
||||
{
|
||||
this->title = title;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the value of a metadata field in this playlist.
|
||||
*
|
||||
* Currently, this always returns a null pointer.
|
||||
*
|
||||
* @return the value of the metadata field; 0 if there is
|
||||
* no such field;
|
||||
*/
|
||||
virtual Ptr<UnicodeString>::Ref
|
||||
getMetadata(const string &key) const
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Set the value of a metadata field in this playlist.
|
||||
*
|
||||
* Currently, this does not do anything.
|
||||
*
|
||||
* @param key the name of the metadata field.
|
||||
* @param value the new value of the metadata field.
|
||||
*/
|
||||
virtual void
|
||||
setMetadata(const string &key, Ptr<UnicodeString>::Ref value)
|
||||
throw ();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.9 $
|
||||
Version : $Revision: 1.10 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/AudioClip.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -174,10 +174,40 @@ AudioClip :: configure(const xmlpp::Element & element)
|
|||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Create an XML element from this audio clip.
|
||||
* Return the value of a metadata field.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<UnicodeString>::Ref
|
||||
AudioClip :: getMetadata(const string &key) const
|
||||
throw ()
|
||||
{
|
||||
metadataType::const_iterator it = metadata.find(key);
|
||||
|
||||
if (it != metadata.end()) {
|
||||
return it->second;
|
||||
}
|
||||
else {
|
||||
Ptr<UnicodeString>::Ref nullPointer;
|
||||
return nullPointer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set the value of a metadata field.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
AudioClip :: setMetadata(const string &key, Ptr<UnicodeString>::Ref value)
|
||||
throw ()
|
||||
{
|
||||
metadata[key] = value;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Create an XML document from this audio clip.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<xmlpp::Document>::Ref
|
||||
AudioClip :: getMetadata()
|
||||
AudioClip :: toXml()
|
||||
throw ()
|
||||
{
|
||||
Ptr<xmlpp::Document>::Ref metadata(new xmlpp::Document);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.15 $
|
||||
Version : $Revision: 1.16 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -350,10 +350,10 @@ Playlist::createSavedCopy(void) throw ()
|
|||
* Revert to a saved copy of the playlist.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Playlist::revertToSavedCopy(void) throw (std::logic_error)
|
||||
Playlist::revertToSavedCopy(void) throw (std::invalid_argument)
|
||||
{
|
||||
if (savedCopy == 0) {
|
||||
throw (std::logic_error("playlist has no saved copy"));
|
||||
throw (std::invalid_argument("playlist has no saved copy"));
|
||||
}
|
||||
|
||||
this->id = savedCopy->id;
|
||||
|
@ -364,3 +364,34 @@ Playlist::revertToSavedCopy(void) throw (std::logic_error)
|
|||
|
||||
savedCopy.reset();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Return the value of a metadata field.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<UnicodeString>::Ref
|
||||
Playlist :: getMetadata(const string &key) const
|
||||
throw ()
|
||||
{
|
||||
metadataType::const_iterator it = metadata.find(key);
|
||||
|
||||
if (it != metadata.end()) {
|
||||
return it->second;
|
||||
}
|
||||
else {
|
||||
Ptr<UnicodeString>::Ref nullPointer;
|
||||
return nullPointer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set the value of a metadata field.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Playlist :: setMetadata(const string &key, Ptr<UnicodeString>::Ref value)
|
||||
throw ()
|
||||
{
|
||||
metadata[key] = value;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.13 $
|
||||
Version : $Revision: 1.14 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -260,7 +260,7 @@ PlaylistTest :: savedCopyTest(void)
|
|||
playlist->revertToSavedCopy();
|
||||
CPPUNIT_FAIL("allowed to revert to non-existent state");
|
||||
}
|
||||
catch (std::logic_error &e) {
|
||||
catch (std::invalid_argument &e) {
|
||||
}
|
||||
|
||||
playlist->createSavedCopy();
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#
|
||||
#
|
||||
# Author : $Author: fgerlits $
|
||||
# Version : $Revision: 1.12 $
|
||||
# Version : $Revision: 1.13 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/etc/Makefile.in,v $
|
||||
#
|
||||
# @configure_input@
|
||||
|
@ -73,6 +73,10 @@ VPATH = ${SRC_DIR}
|
|||
LIBXMLPP_CFLAGS=@LIBXMLPP_CFLAGS@
|
||||
LIBXMLPP_LIBS=@LIBXMLPP_LIBS@
|
||||
|
||||
# TODO: move ICU flag determination to configure script
|
||||
ICU_CFLAGS=
|
||||
ICU_LIBS=`${USR_DIR}/bin/icu-config --ldflags --ldflags-toolutil --ldflags-icuio`
|
||||
|
||||
CURL_LIBS=`${USR_DIR}/bin/curl-config --libs`
|
||||
|
||||
TEST_RESULTS = ${DOC_DIR}/testResults.xml
|
||||
|
@ -93,12 +97,14 @@ CPPFLAGS = @CPPFLAGS@
|
|||
CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
|
||||
-pedantic -Wall -Wno-long-long \
|
||||
-I${USR_INCLUDE_DIR} \
|
||||
${ICU_CFLAGS} \
|
||||
${LIBXMLPP_CFLAGS} \
|
||||
-I${BOOST_INCLUDE_DIR} \
|
||||
-I${CORE_INCLUDE_DIR} \
|
||||
-I${AUTHENTICATION_INCLUDE_DIR} \
|
||||
-I${INCLUDE_DIR} -I${TMP_DIR}
|
||||
LDFLAGS = @LDFLAGS@ -pthread \
|
||||
${ICU_LIBS} \
|
||||
${LIBXMLPP_LIBS} \
|
||||
${CURL_LIBS} \
|
||||
-L${USR_LIB_DIR} \
|
||||
|
@ -120,7 +126,7 @@ TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \
|
|||
${TMP_DIR}/WebStorageClientTest.o
|
||||
|
||||
TEST_RUNNER_LIBS = -l${STORAGE_LIB} -l${CORE_LIB} -l${AUTHENTICATION_LIB} \
|
||||
-lcppunit -ldl -lxmlrpc++ -lssl
|
||||
${ICU_LIBS} -lcppunit -ldl -lxmlrpc++ -lssl
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
|
|
@ -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/Attic/StorageException.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -58,7 +58,7 @@ namespace Storage {
|
|||
* Common parent of exception classes for this module.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
*/
|
||||
class StorageException : public std::runtime_error
|
||||
{
|
||||
|
@ -101,6 +101,28 @@ class XmlRpcMethodResponseException : public StorageException
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Bad parameter passed to storage client.
|
||||
*/
|
||||
class InvalidArgumentException : public StorageException
|
||||
{
|
||||
public:
|
||||
InvalidArgumentException(const std::string &msg)
|
||||
: StorageException(msg) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Problem with reading or writing local files.
|
||||
*/
|
||||
class IOException : public StorageException
|
||||
{
|
||||
public:
|
||||
IOException(const std::string &msg)
|
||||
: StorageException(msg) {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.12 $
|
||||
Version : $Revision: 1.13 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -497,21 +497,29 @@ WebStorageClient :: existsAudioClip(Ptr<SessionId>::Ref sessionId,
|
|||
std::string eMsg = "cannot execute XML-RPC method '";
|
||||
eMsg += existsAudioClipMethodName;
|
||||
eMsg += "'";
|
||||
throw StorageException(eMsg);
|
||||
throw XmlRpcCommunicationException(eMsg);
|
||||
}
|
||||
|
||||
if (xmlRpcClient.isFault()
|
||||
|| ! result.hasMember(existsAudioClipResultParamName)
|
||||
|| result[existsAudioClipResultParamName].getType()
|
||||
!= XmlRpcValue::TypeBoolean) {
|
||||
if (xmlRpcClient.isFault()) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method '"
|
||||
<< existsAudioClipMethodName
|
||||
<< "' returned error message:\n"
|
||||
<< result;
|
||||
throw StorageException(eMsg.str());
|
||||
throw XmlRpcMethodFaultException(eMsg.str());
|
||||
}
|
||||
|
||||
if (! result.hasMember(existsAudioClipResultParamName)
|
||||
|| result[existsAudioClipResultParamName].getType()
|
||||
!= XmlRpcValue::TypeBoolean) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method '"
|
||||
<< existsAudioClipMethodName
|
||||
<< "' returned unexpected value:\n"
|
||||
<< result;
|
||||
throw XmlRpcMethodResponseException(eMsg.str());
|
||||
}
|
||||
|
||||
return bool(result[existsAudioClipResultParamName]);
|
||||
}
|
||||
|
||||
|
@ -542,24 +550,32 @@ WebStorageClient :: getAudioClip(Ptr<SessionId>::Ref sessionId,
|
|||
std::string eMsg = "cannot execute XML-RPC method '";
|
||||
eMsg += getAudioClipOpenMethodName;
|
||||
eMsg += "'";
|
||||
throw StorageException(eMsg);
|
||||
throw XmlRpcCommunicationException(eMsg);
|
||||
}
|
||||
|
||||
if (xmlRpcClient.isFault()
|
||||
|| ! result.hasMember(getAudioClipUrlParamName)
|
||||
|| result[getAudioClipUrlParamName].getType()
|
||||
!= XmlRpcValue::TypeString
|
||||
|| ! result.hasMember(getAudioClipTokenParamName)
|
||||
|| result[getAudioClipTokenParamName].getType()
|
||||
!= XmlRpcValue::TypeString) {
|
||||
if (xmlRpcClient.isFault()) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method '"
|
||||
<< getAudioClipOpenMethodName
|
||||
<< "' returned error message:\n"
|
||||
<< result;
|
||||
throw StorageException(eMsg.str());
|
||||
throw XmlRpcMethodFaultException(eMsg.str());
|
||||
}
|
||||
|
||||
if (! result.hasMember(getAudioClipUrlParamName)
|
||||
|| result[getAudioClipUrlParamName].getType()
|
||||
!= XmlRpcValue::TypeString
|
||||
|| ! result.hasMember(getAudioClipTokenParamName)
|
||||
|| result[getAudioClipTokenParamName].getType()
|
||||
!= XmlRpcValue::TypeString) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method '"
|
||||
<< getAudioClipOpenMethodName
|
||||
<< "' returned unexpected value:\n"
|
||||
<< result;
|
||||
throw XmlRpcMethodResponseException(eMsg.str());
|
||||
}
|
||||
|
||||
std::string url = result[getAudioClipUrlParamName];
|
||||
std::string token = result[getAudioClipTokenParamName];
|
||||
|
||||
|
@ -573,9 +589,11 @@ WebStorageClient :: getAudioClip(Ptr<SessionId>::Ref sessionId,
|
|||
|
||||
audioClip->configure(*root);
|
||||
} catch (std::invalid_argument &e) {
|
||||
throw StorageException("semantic error in audio clip metafile");
|
||||
throw XmlRpcMethodResponseException(
|
||||
"semantic error in audio clip metafile");
|
||||
} catch (xmlpp::exception &e) {
|
||||
throw StorageException("error parsing audio clip metafile");
|
||||
throw XmlRpcMethodResponseException(
|
||||
"error parsing audio clip metafile");
|
||||
}
|
||||
|
||||
parameters.clear();
|
||||
|
@ -590,21 +608,29 @@ WebStorageClient :: getAudioClip(Ptr<SessionId>::Ref sessionId,
|
|||
std::string eMsg = "cannot execute XML-RPC method '";
|
||||
eMsg += getAudioClipCloseMethodName;
|
||||
eMsg += "'";
|
||||
throw StorageException(eMsg);
|
||||
throw XmlRpcCommunicationException(eMsg);
|
||||
}
|
||||
|
||||
if (xmlRpcClient.isFault()
|
||||
|| ! result.hasMember(getAudioClipAudioClipIdParamName)
|
||||
|| result[getAudioClipAudioClipIdParamName].getType()
|
||||
!= XmlRpcValue::TypeString
|
||||
|| std::string(result[getAudioClipAudioClipIdParamName])
|
||||
!= std::string(*id)) {
|
||||
if (xmlRpcClient.isFault()) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method '"
|
||||
<< getAudioClipCloseMethodName
|
||||
<< "' returned error message:\n"
|
||||
<< result;
|
||||
throw StorageException(eMsg.str());
|
||||
throw XmlRpcMethodFaultException(eMsg.str());
|
||||
}
|
||||
|
||||
if (! result.hasMember(getAudioClipAudioClipIdParamName)
|
||||
|| result[getAudioClipAudioClipIdParamName].getType()
|
||||
!= XmlRpcValue::TypeString
|
||||
|| std::string(result[getAudioClipAudioClipIdParamName])
|
||||
!= std::string(*id)) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method '"
|
||||
<< getAudioClipCloseMethodName
|
||||
<< "' returned unexpected value:\n"
|
||||
<< result;
|
||||
throw XmlRpcMethodResponseException(eMsg.str());
|
||||
}
|
||||
|
||||
return audioClip;
|
||||
|
@ -620,10 +646,10 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
|
|||
throw (StorageException)
|
||||
{
|
||||
if (!audioClip || !audioClip->getUri()) {
|
||||
throw StorageException("binary audio clip file not found");
|
||||
throw InvalidArgumentException("binary audio clip file not found");
|
||||
}
|
||||
|
||||
std::string metadata = audioClip->getMetadata()
|
||||
std::string metadata = audioClip->toXml()
|
||||
->write_to_string("UTF-8");
|
||||
|
||||
// temporary hack; we will expect an absolute file name from getUri()
|
||||
|
@ -632,7 +658,7 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
|
|||
std::ifstream ifs(binaryFileName.c_str());
|
||||
if (!ifs) {
|
||||
ifs.close();
|
||||
throw StorageException("could not read audio clip");
|
||||
throw IOException("could not read audio clip");
|
||||
}
|
||||
std::string md5string = Md5(ifs);
|
||||
ifs.close();
|
||||
|
@ -659,35 +685,47 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
|
|||
std::string eMsg = "cannot execute XML-RPC method '";
|
||||
eMsg += storeAudioClipOpenMethodName;
|
||||
eMsg += "'";
|
||||
throw StorageException(eMsg);
|
||||
throw XmlRpcCommunicationException(eMsg);
|
||||
}
|
||||
|
||||
if (xmlRpcClient.isFault()
|
||||
|| ! result.hasMember(storeAudioClipUrlParamName)
|
||||
|| result[storeAudioClipUrlParamName].getType()
|
||||
!= XmlRpcValue::TypeString
|
||||
|| ! result.hasMember(storeAudioClipTokenParamName)
|
||||
|| result[storeAudioClipTokenParamName].getType()
|
||||
!= XmlRpcValue::TypeString) {
|
||||
if (xmlRpcClient.isFault()) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method '"
|
||||
<< storeAudioClipOpenMethodName
|
||||
<< "' returned error message:\n"
|
||||
<< result;
|
||||
throw StorageException(eMsg.str());
|
||||
throw XmlRpcMethodFaultException(eMsg.str());
|
||||
}
|
||||
|
||||
if (! result.hasMember(storeAudioClipUrlParamName)
|
||||
|| result[storeAudioClipUrlParamName].getType()
|
||||
!= XmlRpcValue::TypeString
|
||||
|| ! result.hasMember(storeAudioClipTokenParamName)
|
||||
|| result[storeAudioClipTokenParamName].getType()
|
||||
!= XmlRpcValue::TypeString) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method '"
|
||||
<< storeAudioClipOpenMethodName
|
||||
<< "' returned unexpected value:\n"
|
||||
<< result;
|
||||
throw XmlRpcMethodResponseException(eMsg.str());
|
||||
}
|
||||
|
||||
|
||||
std::string url = std::string(result[storeAudioClipUrlParamName]);
|
||||
std::string token = std::string(result[storeAudioClipTokenParamName]);
|
||||
|
||||
FILE* binaryFile = fopen(binaryFileName.c_str(), "rb");
|
||||
if (!binaryFile) {
|
||||
throw IOException("Binary audio clip file not found.");
|
||||
}
|
||||
fseek(binaryFile, 0, SEEK_END);
|
||||
long binaryFileSize = ftell(binaryFile);
|
||||
rewind(binaryFile);
|
||||
|
||||
CURL* handle = curl_easy_init();
|
||||
if (!handle) {
|
||||
throw StorageException("Could not obtain curl handle.");
|
||||
throw XmlRpcCommunicationException("Could not obtain curl handle.");
|
||||
}
|
||||
|
||||
int status = curl_easy_setopt(handle, CURLOPT_READDATA, binaryFile);
|
||||
|
@ -699,13 +737,13 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
|
|||
// status |= curl_easy_setopt(handle, CURLOPT_ENCODING, "deflate");
|
||||
|
||||
if (status) {
|
||||
throw StorageException("Could not set curl options.");
|
||||
throw XmlRpcCommunicationException("Could not set curl options.");
|
||||
}
|
||||
|
||||
status = curl_easy_perform(handle);
|
||||
|
||||
if (status) {
|
||||
throw StorageException("Error uploading file.");
|
||||
throw XmlRpcCommunicationException("Error uploading file.");
|
||||
}
|
||||
|
||||
curl_easy_cleanup(handle);
|
||||
|
@ -723,23 +761,31 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
|
|||
std::string eMsg = "cannot execute XML-RPC method '";
|
||||
eMsg += storeAudioClipCloseMethodName;
|
||||
eMsg += "'";
|
||||
throw StorageException(eMsg);
|
||||
throw XmlRpcCommunicationException(eMsg);
|
||||
}
|
||||
|
||||
if (xmlRpcClient.isFault()
|
||||
|| ! result.hasMember(storeAudioClipAudioClipIdParamName)
|
||||
|| result[storeAudioClipAudioClipIdParamName].getType()
|
||||
!= XmlRpcValue::TypeString
|
||||
|| std::string(result[storeAudioClipAudioClipIdParamName])
|
||||
!= std::string(*audioClip->getId())) {
|
||||
if (xmlRpcClient.isFault()) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method '"
|
||||
<< storeAudioClipCloseMethodName
|
||||
<< "' returned error message:\n"
|
||||
<< result;
|
||||
throw StorageException(eMsg.str());
|
||||
throw XmlRpcMethodFaultException(eMsg.str());
|
||||
}
|
||||
|
||||
if (! result.hasMember(storeAudioClipAudioClipIdParamName)
|
||||
|| result[storeAudioClipAudioClipIdParamName].getType()
|
||||
!= XmlRpcValue::TypeString
|
||||
|| std::string(result[storeAudioClipAudioClipIdParamName])
|
||||
!= std::string(*audioClip->getId())) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method '"
|
||||
<< storeAudioClipCloseMethodName
|
||||
<< "' returned unexpected value:\n"
|
||||
<< result;
|
||||
throw XmlRpcMethodResponseException(eMsg.str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -818,21 +864,29 @@ WebStorageClient :: reset(void)
|
|||
std::string eMsg = "cannot execute XML-RPC method '";
|
||||
eMsg += resetStorageMethodName;
|
||||
eMsg += "'";
|
||||
throw StorageException(eMsg);
|
||||
throw XmlRpcCommunicationException(eMsg);
|
||||
}
|
||||
|
||||
if (xmlRpcClient.isFault()
|
||||
|| ! result.hasMember(resetStorageResultParamName)
|
||||
|| result[resetStorageResultParamName].getType()
|
||||
!= XmlRpcValue::TypeArray) {
|
||||
if (xmlRpcClient.isFault()) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method '"
|
||||
<< resetStorageMethodName
|
||||
<< "' returned error message:\n"
|
||||
<< result;
|
||||
throw StorageException(eMsg.str());
|
||||
throw XmlRpcMethodFaultException(eMsg.str());
|
||||
}
|
||||
|
||||
if (! result.hasMember(resetStorageResultParamName)
|
||||
|| result[resetStorageResultParamName].getType()
|
||||
!= XmlRpcValue::TypeArray) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method '"
|
||||
<< resetStorageMethodName
|
||||
<< "' returned unexpected value:\n"
|
||||
<< result;
|
||||
throw XmlRpcMethodResponseException(eMsg.str());
|
||||
}
|
||||
|
||||
XmlRpcValue uniqueIdArray = result[resetStorageResultParamName];
|
||||
Ptr<std::vector<Ptr<UniqueId>::Ref> >::Ref returnValue(
|
||||
new std::vector<Ptr<UniqueId>::Ref>);
|
||||
|
@ -844,7 +898,7 @@ WebStorageClient :: reset(void)
|
|||
<< resetStorageMethodName
|
||||
<< "':\n"
|
||||
<< result;
|
||||
throw StorageException(eMsg.str());
|
||||
throw XmlRpcMethodResponseException(eMsg.str());
|
||||
}
|
||||
Ptr<UniqueId>::Ref uniqueId(new UniqueId(std::string(uniqueIdArray[i])));
|
||||
returnValue->push_back(uniqueId);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.13 $
|
||||
Version : $Revision: 1.14 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClientTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -228,9 +228,11 @@ WebStorageClientTest :: audioClipTest(void)
|
|||
}
|
||||
CPPUNIT_ASSERT(!exists);
|
||||
|
||||
// Ptr<UniqueId>::Ref id02 = UniqueId::generateId();
|
||||
Ptr<UniqueId>::Ref id02(new UniqueId("11111111111111112222222222222222"));
|
||||
Ptr<time_duration>::Ref playlength(new time_duration(0,0,11,0));
|
||||
Ptr<std::string>::Ref uri(new std::string("file:var/test10001.mp3"));
|
||||
audioClip.reset(new AudioClip(id01, playlength, uri));
|
||||
audioClip.reset(new AudioClip(id02, playlength, uri));
|
||||
|
||||
try {
|
||||
wsc->storeAudioClip(sessionId, audioClip);
|
||||
|
@ -240,7 +242,7 @@ WebStorageClientTest :: audioClipTest(void)
|
|||
}
|
||||
|
||||
try {
|
||||
CPPUNIT_ASSERT( wsc->existsAudioClip(sessionId, id01));
|
||||
CPPUNIT_ASSERT( wsc->existsAudioClip(sessionId, id02));
|
||||
}
|
||||
catch (StorageException &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#
|
||||
#
|
||||
# Author : $Author: fgerlits $
|
||||
# Version : $Revision: 1.35 $
|
||||
# Version : $Revision: 1.36 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
|
||||
#
|
||||
# @configure_input@
|
||||
|
@ -65,6 +65,10 @@ VPATH = ${SRC_DIR}
|
|||
LIBXMLPP_CFLAGS=@LIBXMLPP_CFLAGS@
|
||||
LIBXMLPP_LIBS=@LIBXMLPP_LIBS@
|
||||
|
||||
# TODO: move ICU flag determination to configure script
|
||||
ICU_CFLAGS=
|
||||
ICU_LIBS=`${USR_DIR}/bin/icu-config --ldflags --ldflags-toolutil --ldflags-icuio`
|
||||
|
||||
CURL_LIBS=`${USR_DIR}/bin/curl-config --libs`
|
||||
|
||||
MODULES_DIR = ${BASE_DIR}/../../modules
|
||||
|
@ -126,6 +130,7 @@ export LD_LIBRARY_PATH=${USR_LIB_DIR}
|
|||
CPPFLAGS = @CPPFLAGS@
|
||||
CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
|
||||
-pedantic -Wall -Wno-long-long \
|
||||
${ICU_CFLAGS} \
|
||||
${LIBXMLPP_CFLAGS} \
|
||||
-I${USR_INCLUDE_DIR} \
|
||||
-I${BOOST_INCLUDE_DIR} \
|
||||
|
@ -138,6 +143,7 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
|
|||
-I${TMP_DIR}
|
||||
LDFLAGS = @LDFLAGS@ -pthread \
|
||||
${LIBXMLPP_LIBS} \
|
||||
${ICU_LIBS} \
|
||||
${CURL_LIBS} \
|
||||
-L${USR_LIB_DIR} \
|
||||
-L${HELIX_LIB_DIR} \
|
||||
|
@ -229,7 +235,7 @@ TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \
|
|||
${TMP_DIR}/UpdateFadeInFadeOutMethodTest.o \
|
||||
${TMP_DIR}/PlaylistEventContainerTest.o \
|
||||
${TMP_DIR}/PlaylistEventTest.o
|
||||
TEST_RUNNER_LIBS = ${SCHEDULER_EXE_LIBS} -lcppunit -ldl
|
||||
TEST_RUNNER_LIBS = ${SCHEDULER_EXE_LIBS} ${ICU_LIBS} -lcppunit -ldl
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue