added storageAdmin module to doxygen config file;
added playlength format checking in AudioClip and Playlist in the Core module so it won't crash just throw an exception; added try-catch block in Storage::getAudioClip() and getPlaylist() to catch invalid audio clip or playlist format errors
This commit is contained in:
parent
d4557842f6
commit
40ffad79dd
10 changed files with 266 additions and 52 deletions
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.26 $
|
||||
Version : $Revision: 1.27 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/AudioClip.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -131,7 +131,7 @@ using namespace boost::posix_time;
|
|||
* </code></pre>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.26 $
|
||||
* @version $Revision: 1.27 $
|
||||
*/
|
||||
class AudioClip : public Configurable,
|
||||
public Playable
|
||||
|
@ -178,11 +178,13 @@ class AudioClip : public Configurable,
|
|||
* @param value the new value of the metadata field.
|
||||
* @param name the name of the metadata field (without prefix)
|
||||
* @param prefix the prefix of the metadata field
|
||||
* @exception std::invalid_argument if the key is dcterms:extent,
|
||||
* but the value is not a valid ISO-8601 time
|
||||
*/
|
||||
virtual void
|
||||
setMetadata(Ptr<const Glib::ustring>::Ref value,
|
||||
const std::string &name, const std::string &prefix)
|
||||
throw ();
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Convert a time_duration to string, in format HH:MM:SS.ssssss.
|
||||
|
@ -197,6 +199,17 @@ class AudioClip : public Configurable,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the playlength member of this audio clip.
|
||||
*
|
||||
* @param timeString the new playlength
|
||||
* @exception std::invalid_argument if the argument is not
|
||||
* a valid ISO-8601 time
|
||||
*/
|
||||
void
|
||||
setPlaylength(const std::string & timeString)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -496,11 +509,13 @@ class AudioClip : public Configurable,
|
|||
*
|
||||
* @param value the new value of the metadata field.
|
||||
* @param key the name of the metadata field
|
||||
* @exception std::invalid_argument if the key is dcterms:extent,
|
||||
* but the value is not a valid ISO-8601 time
|
||||
*/
|
||||
virtual void
|
||||
setMetadata(Ptr<const Glib::ustring>::Ref value,
|
||||
const std::string &key)
|
||||
throw ();
|
||||
throw (std::invalid_argument);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -589,7 +604,7 @@ class AudioClip : public Configurable,
|
|||
|
||||
|
||||
/**
|
||||
* Auxilliary method used by satisfiesCondition().
|
||||
* Auxilliary method used by setMetadata() and getMetadata().
|
||||
*/
|
||||
void
|
||||
separateNameAndNameSpace(const std::string & key,
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.10 $
|
||||
Version : $Revision: 1.11 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playable.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -73,7 +73,7 @@ using namespace boost::posix_time;
|
|||
* It contains the methods which are common to these classes.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.10 $
|
||||
* @version $Revision: 1.11 $
|
||||
*/
|
||||
class Playable : public boost::enable_shared_from_this<Playable>
|
||||
{
|
||||
|
@ -208,11 +208,14 @@ class Playable : public boost::enable_shared_from_this<Playable>
|
|||
*
|
||||
* @param value the new value of the metadata field.
|
||||
* @param key the name of the metadata field
|
||||
* @exception std::invalid_argument if the key is dcterms:extent,
|
||||
* but the value is not a valid ISO-8601 time
|
||||
*/
|
||||
virtual void
|
||||
setMetadata(Ptr<const Glib::ustring>::Ref value,
|
||||
const std::string &key)
|
||||
throw () = 0;
|
||||
throw (std::invalid_argument)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Return a partial XML representation of this audio clip or playlist.
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.35 $
|
||||
Version : $Revision: 1.36 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playlist.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -128,7 +128,7 @@ using namespace boost::posix_time;
|
|||
* </code></pre>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.35 $
|
||||
* @version $Revision: 1.36 $
|
||||
*/
|
||||
class Playlist : public Configurable,
|
||||
public Playable
|
||||
|
@ -204,21 +204,34 @@ class Playlist : public Configurable,
|
|||
* @param value the new value of the metadata field.
|
||||
* @param name the name of the metadata field (without prefix)
|
||||
* @param prefix the prefix of the metadata field
|
||||
* @exception std::invalid_argument if the key is dcterms:extent,
|
||||
* but the value is not a valid ISO-8601 time
|
||||
*/
|
||||
void
|
||||
setMetadata(Ptr<const Glib::ustring>::Ref value,
|
||||
const std::string &name, const std::string &prefix)
|
||||
throw ();
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Set the total playing length of this playlist.
|
||||
*
|
||||
* @param the playing length in microseconds precision.
|
||||
* @param playlength the playing length in microseconds precision.
|
||||
*/
|
||||
void
|
||||
setPlaylength(Ptr<time_duration>::Ref playlength)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Set the playlength member of this audio clip.
|
||||
*
|
||||
* @param timeString the playing length in microseconds precision.
|
||||
* @exception std::invalid_argument if the argument is not
|
||||
* a valid ISO-8601 time
|
||||
*/
|
||||
void
|
||||
setPlaylength(const std::string & timeString)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* A private iterator type for internal use. It is non-constant;
|
||||
* otherwise it is the same as Playlist::const_iterator.
|
||||
|
@ -677,13 +690,15 @@ class Playlist : public Configurable,
|
|||
/**
|
||||
* Set the value of a metadata field in this playlist.
|
||||
*
|
||||
* @param value the new value of the metadata field.
|
||||
* @param key the name of the metadata field
|
||||
* @param value the new value of the metadata field.
|
||||
* @param key the name of the metadata field
|
||||
* @exception std::invalid_argument if the key is dcterms:extent,
|
||||
* but the value is not a valid ISO-8601 time
|
||||
*/
|
||||
virtual void
|
||||
setMetadata(Ptr<const Glib::ustring>::Ref value,
|
||||
const std::string &key)
|
||||
throw ();
|
||||
throw (std::invalid_argument);
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/core/include/LiveSupport/Core/XmlRpcInvalidDataException.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef LiveSupport_Core_XmlRpcInvalidDataException_h
|
||||
#define LiveSupport_Core_XmlRpcInvalidDataException_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include "LiveSupport/Core/XmlRpcException.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Core {
|
||||
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Exception signaling an XML-RPC problem: invalid data returned by the method.
|
||||
* This could be a malformed AudioClip or Playlist, for example.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
class XmlRpcInvalidDataException : public XmlRpcException
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor based on a string.
|
||||
*
|
||||
* @param msg the message of the exception.
|
||||
*/
|
||||
XmlRpcInvalidDataException(const std::string &msg) throw ()
|
||||
: XmlRpcException(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor based on a parent exception.
|
||||
*
|
||||
* @param parent the parent exception to this one.
|
||||
*/
|
||||
XmlRpcInvalidDataException(const std::exception & parent)
|
||||
throw ()
|
||||
: XmlRpcException(parent)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor based on a message ant a parent exception.
|
||||
*
|
||||
* @param msg the message of the exception.
|
||||
* @param parent the parent exception.
|
||||
*/
|
||||
XmlRpcInvalidDataException(const std::string & msg,
|
||||
const std::exception & parent)
|
||||
throw ()
|
||||
: XmlRpcException(msg, parent)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Virtual destructor.
|
||||
*/
|
||||
~XmlRpcInvalidDataException(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Core
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // LiveSupport_Core_XmlRpcInvalidDataException_h
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.29 $
|
||||
Version : $Revision: 1.30 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/AudioClip.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -215,7 +215,8 @@ AudioClip :: AudioClip(Ptr<UniqueId>::Ref id,
|
|||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Constructor without ID.
|
||||
*----------------------------------------------------------------------------*/AudioClip :: AudioClip(Ptr<const Glib::ustring>::Ref title,
|
||||
*----------------------------------------------------------------------------*/
|
||||
AudioClip :: AudioClip(Ptr<const Glib::ustring>::Ref title,
|
||||
Ptr<time_duration>::Ref playlength,
|
||||
Ptr<const std::string>::Ref uri)
|
||||
throw ()
|
||||
|
@ -280,6 +281,30 @@ AudioClip :: setTitle(Ptr<const Glib::ustring>::Ref title)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set the value of the playlength from a string (private).
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
AudioClip :: setPlaylength(const std::string & timeString)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
try {
|
||||
playlength.reset(new time_duration(duration_from_string(timeString)));
|
||||
} catch (boost::bad_lexical_cast &e) {
|
||||
std::string eMsg = "bad time format in playlength: ";
|
||||
eMsg += e.what();
|
||||
throw std::invalid_argument(eMsg);
|
||||
} catch (std::exception &e) {
|
||||
std::string eMsg = "bad time format in playlength: ";
|
||||
eMsg += e.what();
|
||||
throw std::invalid_argument(eMsg);
|
||||
} catch ( ... ) {
|
||||
std::string eMsg = "bad time format in playlength";
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Create an audio clip object based on an XML element.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -306,8 +331,6 @@ AudioClip :: configure(const xmlpp::Element & element)
|
|||
|
||||
if (!playlength
|
||||
&& (attribute = element.get_attribute(playlengthAttrName))) {
|
||||
playlength.reset(new time_duration(duration_from_string(
|
||||
attribute->get_value() )));
|
||||
Ptr<const Glib::ustring>::Ref playlengthString(new const Glib::ustring(
|
||||
attribute->get_value() ));
|
||||
setMetadata(playlengthString, extentElementName, extentElementPrefix);
|
||||
|
@ -357,8 +380,7 @@ AudioClip :: configure(const xmlpp::Element & element)
|
|||
if (!playlength && prefix == extentElementPrefix
|
||||
&& name == extentElementName) {
|
||||
if (dataElement->has_child_text()) {
|
||||
playlength.reset(new time_duration(duration_from_string(
|
||||
dataElement->get_child_text()->get_content() )));
|
||||
setPlaylength(dataElement->get_child_text()->get_content());
|
||||
} else { // or just leave blank? bad either way
|
||||
playlength.reset(new time_duration(0,0,0,0));
|
||||
}
|
||||
|
@ -457,7 +479,7 @@ AudioClip :: getMetadata(const string &key) const
|
|||
void
|
||||
AudioClip :: setMetadata(Ptr<const Glib::ustring>::Ref value,
|
||||
const std::string &key)
|
||||
throw ()
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
std::string name, prefix;
|
||||
separateNameAndNameSpace(key, name, prefix);
|
||||
|
@ -471,11 +493,10 @@ AudioClip :: setMetadata(Ptr<const Glib::ustring>::Ref value,
|
|||
void
|
||||
AudioClip :: setMetadata(Ptr<const Glib::ustring>::Ref value,
|
||||
const std::string &name, const std::string &prefix)
|
||||
throw ()
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
if (prefix == extentElementPrefix && name == extentElementName) {
|
||||
playlength.reset(new time_duration(
|
||||
duration_from_string(*value) ));
|
||||
setPlaylength(*value); // may throw invalid_argument
|
||||
}
|
||||
|
||||
if (prefix == titleElementPrefix && name == titleElementName) {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.35 $
|
||||
Version : $Revision: 1.36 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -274,6 +274,30 @@ Playlist :: setPlaylength(Ptr<time_duration>::Ref playlength)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set the value of the playlength from a string (private).
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Playlist :: setPlaylength(const std::string & timeString)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
try {
|
||||
playlength.reset(new time_duration(duration_from_string(timeString)));
|
||||
} catch (boost::bad_lexical_cast &e) {
|
||||
std::string eMsg = "bad time format in playlength: ";
|
||||
eMsg += e.what();
|
||||
throw std::invalid_argument(eMsg);
|
||||
} catch (std::exception &e) {
|
||||
std::string eMsg = "bad time format in playlength: ";
|
||||
eMsg += e.what();
|
||||
throw std::invalid_argument(eMsg);
|
||||
} catch ( ... ) {
|
||||
std::string eMsg = "bad time format in playlength";
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Create a playlist object based on an XML element.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -300,8 +324,6 @@ Playlist :: configure(const xmlpp::Element & element)
|
|||
|
||||
if (!playlength
|
||||
&& (attribute = element.get_attribute(playlengthAttrName))) {
|
||||
playlength.reset(new time_duration(
|
||||
duration_from_string(attribute->get_value())));
|
||||
Ptr<Glib::ustring>::Ref playlengthString(new Glib::ustring(
|
||||
attribute->get_value() ));
|
||||
setMetadata(playlengthString, extentElementName, extentElementPrefix);
|
||||
|
@ -358,8 +380,7 @@ Playlist :: configure(const xmlpp::Element & element)
|
|||
if (!playlength && prefix == extentElementPrefix
|
||||
&& name == extentElementName) {
|
||||
if (dataElement->has_child_text()) {
|
||||
playlength.reset(new time_duration(duration_from_string(
|
||||
dataElement->get_child_text()->get_content() )));
|
||||
setPlaylength(dataElement->get_child_text()->get_content());
|
||||
} else { // or just leave blank? bad either way
|
||||
playlength.reset(new time_duration(0,0,0,0));
|
||||
}
|
||||
|
@ -641,7 +662,7 @@ Playlist :: getMetadata(const string &key) const
|
|||
void
|
||||
Playlist :: setMetadata(Ptr<const Glib::ustring>::Ref value,
|
||||
const std::string &key)
|
||||
throw ()
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
std::string name, prefix;
|
||||
separateNameAndNameSpace(key, name, prefix);
|
||||
|
@ -655,11 +676,10 @@ Playlist :: setMetadata(Ptr<const Glib::ustring>::Ref value,
|
|||
void
|
||||
Playlist :: setMetadata(Ptr<const Glib::ustring>::Ref value,
|
||||
const std::string &name, const std::string &prefix)
|
||||
throw ()
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
if (prefix == extentElementPrefix && name == extentElementName) {
|
||||
playlength.reset(new time_duration(
|
||||
duration_from_string(*value) ));
|
||||
setPlaylength(*value);
|
||||
}
|
||||
|
||||
if (prefix == titleElementPrefix && name == titleElementName) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue