From 5c18630e1c81ac5267c9356e27c1a8f81b4ef6f7 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 14 Jul 2009 19:24:06 +0200 Subject: =?UTF-8?q?Benutze=20gecachete=20Benutzerlisten,=20wenn=20der=20Se?= =?UTF-8?q?rver=20nicht=20verf=C3=BCgbar=20ist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/UserCache.cpp | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/Common/UserCache.cpp b/src/Common/UserCache.cpp index b0dd37a..4058c4c 100644 --- a/src/Common/UserCache.cpp +++ b/src/Common/UserCache.cpp @@ -26,12 +26,15 @@ namespace Common { boost::shared_ptr > UserCache::getUserList(boost::posix_time::ptime *timestamp) throw(Core::Exception) { boost::lock_guard lock(mutex); + boost::posix_time::ptime newTime(userTime); + try { - boost::shared_ptr > newUsers = backend->getUserList(&userTime); + boost::shared_ptr > newUsers = backend->getUserList(&newTime); if(newUsers) { users = newUsers; userException = Core::Exception(); + userTime = newTime; userNames.reset(new std::map); for(std::map::const_iterator user = users->begin(); user != users->end(); ++user) @@ -45,8 +48,11 @@ boost::shared_ptr > UserCache::getUserLi } } catch(Core::Exception e) { - users.reset(); - userException = e; + if(e.getErrorCode() != Core::Exception::NOT_AVAILABLE || !users) { + users.reset(); + userException = e; + userTime = newTime; + } } if((!timestamp) || timestamp->is_not_a_date_time() || (*timestamp < userTime)) { @@ -111,12 +117,15 @@ boost::shared_ptr > UserCache::getUserGroupList(un boost::shared_ptr > UserCache::getGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception) { boost::lock_guard lock(mutex); + boost::posix_time::ptime newTime(groupTime); + try { - boost::shared_ptr > newGroups = backend->getGroupList(&groupTime); + boost::shared_ptr > newGroups = backend->getGroupList(&newTime); if(newGroups) { groups = newGroups; groupException = Core::Exception(); + groupTime = newTime; groupNames.reset(new std::map); for(std::map::const_iterator group = groups->begin(); group != groups->end(); ++group) @@ -130,8 +139,11 @@ boost::shared_ptr > UserCache::getGroup } } catch(Core::Exception e) { - groups.reset(); - groupException = e; + if(e.getErrorCode() != Core::Exception::NOT_AVAILABLE || !groups) { + groups.reset(); + groupException = e; + groupTime = newTime; + } } if((!timestamp) || timestamp->is_not_a_date_time() || (*timestamp < groupTime)) { @@ -195,12 +207,15 @@ boost::shared_ptr > UserCache::getGroupUserList(un boost::shared_ptr > UserCache::getFullUserGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception) { boost::lock_guard lock(mutex); + boost::posix_time::ptime newTime(userGroupTime); + try { - boost::shared_ptr > newUserGroups = backend->getFullUserGroupList(&userGroupTime); + boost::shared_ptr > newUserGroups = backend->getFullUserGroupList(&newTime); if(newUserGroups) { userGroups = newUserGroups; userGroupException = Core::Exception(); + userGroupTime = newTime; groupUsers.reset(new std::multimap); for(std::multimap::const_iterator usergroup = userGroups->begin(); usergroup != userGroups->end(); ++usergroup) @@ -214,8 +229,11 @@ boost::shared_ptr > UserCache: } } catch(Core::Exception e) { - userGroups.reset(); - userGroupException = e; + if(e.getErrorCode() != Core::Exception::NOT_AVAILABLE || !userGroups) { + userGroups.reset(); + userGroupException = e; + userGroupTime = newTime; + } } if((!timestamp) || timestamp->is_not_a_date_time() || (*timestamp < userTime)) { -- cgit v1.2.3