From d3205401e03a367bdd07491813f14d89de2fbca7 Mon Sep 17 00:00:00 2001 From: Jiri Srain Date: Wed, 30 Nov 2005 10:41:17 +0000 Subject: [PATCH] added exception handling --- zypp/source/yum/YUMPackageImpl.cc | 12 ++- zypp/source/yum/YUMPackageImpl.h | 4 +- zypp/source/yum/YUMPatchImpl.cc | 2 +- zypp/source/yum/YUMSource.cc | 179 ++++++++++++++++++++++++++------------ zypp/source/yum/YUMSource.h | 5 ++ 5 files changed, 143 insertions(+), 59 deletions(-) diff --git a/zypp/source/yum/YUMPackageImpl.cc b/zypp/source/yum/YUMPackageImpl.cc index 688c771..d33abf6 100644 --- a/zypp/source/yum/YUMPackageImpl.cc +++ b/zypp/source/yum/YUMPackageImpl.cc @@ -12,6 +12,7 @@ #include "zypp/source/yum/YUMPackageImpl.h" #include "zypp/base/String.h" +#include "zypp/base/Logger.h" using namespace std; using namespace zypp::detail; @@ -34,7 +35,9 @@ namespace zypp /** Default ctor */ YUMPackageImpl::YUMPackageImpl( - const zypp::parser::yum::YUMPrimaryData & parsed + const zypp::parser::yum::YUMPrimaryData & parsed, + const zypp::parser::yum::YUMFileListData & filelist, + const zypp::parser::yum::YUMOtherData & other ) : _summary(parsed.summary), _description(), @@ -68,7 +71,12 @@ namespace zypp #endif { _description.push_back(parsed.description); -// TODO files + for (std::list::const_iterator it = filelist.files.begin(); + it != filelist.files.end(); + it++) + { + _filenames.push_back(it->name); + } // TODO changelog } diff --git a/zypp/source/yum/YUMPackageImpl.h b/zypp/source/yum/YUMPackageImpl.h index a8d1d0d..905c486 100644 --- a/zypp/source/yum/YUMPackageImpl.h +++ b/zypp/source/yum/YUMPackageImpl.h @@ -36,7 +36,9 @@ namespace zypp /** Default ctor */ YUMPackageImpl( - const zypp::parser::yum::YUMPrimaryData & parsed + const zypp::parser::yum::YUMPrimaryData & parsed, + const zypp::parser::yum::YUMFileListData & filelist, + const zypp::parser::yum::YUMOtherData & other ); YUMPackageImpl( const zypp::parser::yum::YUMPatchPackage & parsed diff --git a/zypp/source/yum/YUMPatchImpl.cc b/zypp/source/yum/YUMPatchImpl.cc index ed2aa87..17e6884 100644 --- a/zypp/source/yum/YUMPatchImpl.cc +++ b/zypp/source/yum/YUMPatchImpl.cc @@ -74,7 +74,7 @@ namespace zypp Capability cap( _f.parse( ResType::TraitsType::kind, parsed.name, - Rel(Rel::EQ), + Rel::EQ, Edition(parsed.ver, parsed.rel, parsed.epoch) )); for (std::list >::const_iterator it diff --git a/zypp/source/yum/YUMSource.cc b/zypp/source/yum/YUMSource.cc index 06e5f8a..e2118a5 100644 --- a/zypp/source/yum/YUMSource.cc +++ b/zypp/source/yum/YUMSource.cc @@ -45,87 +45,156 @@ namespace zypp Package::Ptr YUMSource::createPackage( + const zypp::parser::yum::YUMPrimaryData & parsed, + const zypp::parser::yum::YUMFileListData & filelist, + const zypp::parser::yum::YUMOtherData & other + ) + { + try + { + shared_ptr impl( + new YUMPackageImpl(parsed, filelist, other)); + Dependencies _deps = createDependencies(parsed, + ResTraits::kind); + Package::Ptr package = detail::makeResolvableFromImpl( + parsed.name, + Edition( parsed.ver, parsed.rel, parsed.epoch ), + Arch( parsed.arch ), + impl + ); + package->setDeps(_deps); + return package; + } + catch (const Exception & excpt_r) + { + ERR << excpt_r << endl; + throw "Cannot create package object"; + } + } + + Package::Ptr YUMSource::createPackage( const zypp::parser::yum::YUMPatchPackage & parsed ) { - shared_ptr impl(new YUMPackageImpl(parsed)); - Dependencies _deps = createDependencies(parsed, - ResTraits::kind); - Package::Ptr package = detail::makeResolvableFromImpl( - parsed.name, - Edition( parsed.ver, parsed.rel, parsed.epoch ), - Arch( parsed.arch ), - impl - ); - package->setDeps(_deps); - return package; + try + { + shared_ptr impl(new YUMPackageImpl(parsed)); + Dependencies _deps = createDependencies(parsed, + ResTraits::kind); + Package::Ptr package = detail::makeResolvableFromImpl( + parsed.name, + Edition( parsed.ver, parsed.rel, parsed.epoch ), + Arch( parsed.arch ), + impl + ); + package->setDeps(_deps); + return package; + } + catch (const Exception & excpt_r) + { + ERR << excpt_r << endl; + throw "Cannot create package object"; + } } + Message::Ptr YUMSource::createMessage( const zypp::parser::yum::YUMPatchMessage & parsed ) { - shared_ptr impl(new YUMMessageImpl(parsed)); - Dependencies _deps = createDependencies(parsed, - ResTraits::kind); - Message::Ptr message = detail::makeResolvableFromImpl( - parsed.name, - Edition( parsed.ver, parsed.rel, parsed.epoch ), - Arch_noarch, - impl - ); - message->setDeps(_deps); - return message; + try + { + shared_ptr impl(new YUMMessageImpl(parsed)); + Dependencies _deps = createDependencies(parsed, + ResTraits::kind); + Message::Ptr message = detail::makeResolvableFromImpl( + parsed.name, + Edition( parsed.ver, parsed.rel, parsed.epoch ), + Arch_noarch, + impl + ); + message->setDeps(_deps); + return message; + } + catch (const Exception & excpt_r) + { + ERR << excpt_r << endl; + throw "Cannot create message object"; + } } Script::Ptr YUMSource::createScript( const zypp::parser::yum::YUMPatchScript & parsed ) { - shared_ptr impl(new YUMScriptImpl(parsed)); - Dependencies _deps = createDependencies(parsed, - ResTraits