From 5bf8b6ce656ffe0740ec116057577044e3925887 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 10 Jul 2009 01:37:53 +0200 Subject: =?UTF-8?q?UserManager,=20UserBackend,=20UserCache:=20deleteUser?= =?UTF-8?q?=20und=20deleteGroup=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/UserBackend.h | 8 ++++++++ src/Common/UserCache.h | 8 ++++++++ src/Common/UserManager.cpp | 34 ++++++++++++++++++++++++++++++++++ src/Common/UserManager.h | 3 +++ 4 files changed, 53 insertions(+) diff --git a/src/Common/UserBackend.h b/src/Common/UserBackend.h index dfb154c..2e42e12 100644 --- a/src/Common/UserBackend.h +++ b/src/Common/UserBackend.h @@ -97,6 +97,10 @@ class UserBackend { throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); } + virtual void deleteUser(unsigned long uid _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)); } @@ -105,6 +109,10 @@ class UserBackend { throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); } + virtual void deleteGroup(unsigned long gid _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 4c97352..e778e24 100644 --- a/src/Common/UserCache.h +++ b/src/Common/UserCache.h @@ -82,6 +82,10 @@ class UserCache : public UserBackend, private boost::noncopyable { backend->updateUser(uid, userInfo); } + virtual void deleteUser(unsigned long uid) throw(Core::Exception) { + backend->deleteUser(uid); + } + virtual void addGroup(const GroupInfo &groupInfo) throw(Core::Exception) { backend->addGroup(groupInfo); } @@ -90,6 +94,10 @@ class UserCache : public UserBackend, private boost::noncopyable { backend->updateGroup(gid, groupInfo); } + virtual void deleteGroup(unsigned long gid) throw(Core::Exception) { + backend->deleteGroup(gid); + } + 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 ae8f3b2..14451aa 100644 --- a/src/Common/UserManager.cpp +++ b/src/Common/UserManager.cpp @@ -258,6 +258,23 @@ void UserManager::updateUser(unsigned long uid, const UserInfo &userInfo) throw( throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); } +void UserManager::deleteUser(unsigned long uid) throw(Core::Exception) { + boost::lock_guard lock(mutex); + + for(BackendMap::iterator backend = backends.begin(); backend != backends.end(); ++backend) { + try { + backend->second->deleteUser(uid); + 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); @@ -292,5 +309,22 @@ void UserManager::updateGroup(unsigned long gid, const GroupInfo &groupInfo) thr throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); } +void UserManager::deleteGroup(unsigned long gid) throw(Core::Exception) { + boost::lock_guard lock(mutex); + + for(BackendMap::iterator backend = backends.begin(); backend != backends.end(); ++backend) { + try { + backend->second->deleteGroup(gid); + 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 51f0441..466b9a9 100644 --- a/src/Common/UserManager.h +++ b/src/Common/UserManager.h @@ -85,8 +85,11 @@ class UserManager : private boost::noncopyable { void addUser(const UserInfo &userInfo) throw(Core::Exception); void updateUser(unsigned long uid, const UserInfo &userInfo) throw(Core::Exception); + void deleteUser(unsigned long uid) throw(Core::Exception); + void addGroup(const GroupInfo &groupInfo) throw(Core::Exception); void updateGroup(unsigned long gid, const GroupInfo &groupInfo) throw(Core::Exception); + void deleteGroup(unsigned long gid) throw(Core::Exception); }; } -- cgit v1.2.3