From a8ad2278025467f7cc9c9974d7e82be5752fb697 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 24 May 2009 15:09:24 +0200 Subject: Interface des UserManager ?berarbeitet --- src/Server/UserManager.cpp | 78 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 23 deletions(-) (limited to 'src/Server/UserManager.cpp') diff --git a/src/Server/UserManager.cpp b/src/Server/UserManager.cpp index e32cb57..7101b2c 100644 --- a/src/Server/UserManager.cpp +++ b/src/Server/UserManager.cpp @@ -34,52 +34,84 @@ bool UserManager::Compare::operator() (boost::shared_ptr b1, boost: } -boost::shared_ptr > UserManager::getUserList() { +boost::shared_ptr > UserManager::getUserList() throw(Net::Exception) { + Net::Exception e(Net::Exception::NOT_IMPLEMENTED); + for(std::set >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { - boost::shared_ptr > ret = (*backend)->getUserList(); - if(ret) - return ret; + try { + return (*backend)->getUserList(); + } + catch(Net::Exception e2) { + if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED) + e = e2; + } } - return boost::shared_ptr >(); + throw e; } -boost::shared_ptr UserManager::getUserInfo(unsigned long uid) { +boost::shared_ptr UserManager::getUserInfo(unsigned long uid) throw(Net::Exception) { + Net::Exception e(Net::Exception::NOT_IMPLEMENTED); + for(std::set >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { - boost::shared_ptr ret = (*backend)->getUserInfo(uid); - if(ret) - return ret; + try { + return (*backend)->getUserInfo(uid); + } + catch(Net::Exception e2) { + if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED) + e = e2; + } } - return boost::shared_ptr(); + throw e; } -boost::shared_ptr > UserManager::getGroupList() { +boost::shared_ptr > UserManager::getGroupList() throw(Net::Exception) { + Net::Exception e(Net::Exception::NOT_IMPLEMENTED); + for(std::set >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { - boost::shared_ptr > ret = (*backend)->getGroupList(); - if(ret) - return ret; + try { + return (*backend)->getGroupList(); + } + catch(Net::Exception e2) { + if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED) + e = e2; + } } - return boost::shared_ptr >(); + throw e; } -bool UserManager::setPassword(unsigned long uid, const std::string &password) { +void UserManager::setPassword(unsigned long uid, const std::string &password) throw(Net::Exception) { + Net::Exception e(Net::Exception::NOT_IMPLEMENTED); + for(std::set >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { - if((*backend)->setPassword(uid, password)) - return true; + try { + return (*backend)->setPassword(uid, password); + } + catch(Net::Exception e2) { + if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED) + e = e2; + } } - return false; + throw e; } -bool UserManager::addUser(const Common::UserInfo &userInfo) { +void UserManager::addUser(const Common::UserInfo &userInfo) throw(Net::Exception) { + Net::Exception e(Net::Exception::NOT_IMPLEMENTED); + for(std::set >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { - if((*backend)->addUser(userInfo)) - return true; + try { + return (*backend)->addUser(userInfo); + } + catch(Net::Exception e2) { + if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED) + e = e2; + } } - return false; + throw e; } } -- cgit v1.2.3