From 912886f565f13bfb678232b3098543a6b9d3af1f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 9 Jul 2009 20:56:25 +0200 Subject: =?UTF-8?q?UserManager,=20UserBackend,=20UserCache:=20updateUser,?= =?UTF-8?q?=20addGroup=20und=20updateGroup=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/UserBackend.h | 12 +++++++++++ src/Common/UserCache.h | 12 +++++++++++ src/Common/UserManager.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++++ src/Common/UserManager.h | 3 +++ 4 files changed, 78 insertions(+) (limited to 'src') diff --git a/src/Common/UserBackend.h b/src/Common/UserBackend.h index 4004dbc..4a84fa3 100644 --- a/src/Common/UserBackend.h +++ b/src/Common/UserBackend.h @@ -93,6 +93,18 @@ class UserBackend { throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); } + virtual void updateUser(unsigned long uid _UNUSED_PARAMETER_, const UserInfo &userInfo _UNUSED_PARAMETER_) throw(Core::Exception) { + throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); + } + + virtual void addGroup(const GroupInfo &groupInfo _UNUSED_PARAMETER_) throw(Core::Exception) { + throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); + } + + virtual void updateGroup(unsigned long gid _UNUSED_PARAMETER_, const GroupInfo &groupInfo _UNUSED_PARAMETER_) throw(Core::Exception) { + throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); + } + public: virtual ~UserBackend() {} diff --git a/src/Common/UserCache.h b/src/Common/UserCache.h index 0fe26be..7327395 100644 --- a/src/Common/UserCache.h +++ b/src/Common/UserCache.h @@ -78,6 +78,18 @@ class UserCache : public UserBackend, private boost::noncopyable { backend->addUser(userInfo); } + virtual void updateUser(unsigned long uid, const UserInfo &userInfo) throw(Core::Exception) { + backend->updateUser(uid, userInfo); + } + + virtual void addGroup(const GroupInfo &groupInfo) throw(Core::Exception) { + backend->addGroup(groupInfo); + } + + virtual void updateGroup(unsigned long gid, const GroupInfo &groupInfo) throw(Core::Exception) { + backend->updateGroup(gid, groupInfo); + } + UserCache(Application *application0, boost::shared_ptr backend0) : application(application0), backend(backend0), userTime(boost::posix_time::not_a_date_time), groupTime(boost::posix_time::not_a_date_time), userGroupTime(boost::posix_time::not_a_date_time) {} diff --git a/src/Common/UserManager.cpp b/src/Common/UserManager.cpp index 0ccf314..c53a2af 100644 --- a/src/Common/UserManager.cpp +++ b/src/Common/UserManager.cpp @@ -241,5 +241,56 @@ void UserManager::addUser(const UserInfo &userInfo) throw(Core::Exception) { throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); } +void UserManager::updateUser(unsigned long uid, const UserInfo &userInfo) throw(Core::Exception) { + boost::lock_guard lock(mutex); + + for(BackendMap::iterator backend = backends.begin(); backend != backends.end(); ++backend) { + try { + backend->second->updateUser(uid, userInfo); + return; + } + catch(Core::Exception e) { + if(e.getErrorCode() != Core::Exception::NOT_IMPLEMENTED) + throw e; + } + } + + throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); +} + +void UserManager::addGroup(const GroupInfo &groupInfo) throw(Core::Exception) { + boost::lock_guard lock(mutex); + + for(BackendMap::iterator backend = backends.begin(); backend != backends.end(); ++backend) { + try { + backend->second->addGroup(groupInfo); + return; + } + catch(Core::Exception e) { + if(e.getErrorCode() != Core::Exception::NOT_IMPLEMENTED) + throw e; + } + } + + throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); +} + +void UserManager::updateGroup(unsigned long gid, const GroupInfo &groupInfo) throw(Core::Exception) { + boost::lock_guard lock(mutex); + + for(BackendMap::iterator backend = backends.begin(); backend != backends.end(); ++backend) { + try { + backend->second->updateGroup(gid, groupInfo); + return; + } + catch(Core::Exception e) { + if(e.getErrorCode() != Core::Exception::NOT_IMPLEMENTED) + throw e; + } + } + + throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); +} + } } diff --git a/src/Common/UserManager.h b/src/Common/UserManager.h index 5877bac..27f4dfe 100644 --- a/src/Common/UserManager.h +++ b/src/Common/UserManager.h @@ -84,6 +84,9 @@ class UserManager : private boost::noncopyable { void setPassword(unsigned long uid, const std::string &password) throw(Core::Exception); void addUser(const UserInfo &userInfo) throw(Core::Exception); + void updateUser(unsigned long uid, const UserInfo &userInfo) throw(Core::Exception); + void addGroup(const GroupInfo &groupInfo) throw(Core::Exception); + void updateGroup(unsigned long gid, const GroupInfo &groupInfo) throw(Core::Exception); }; } -- cgit v1.2.3