diff options
-rw-r--r-- | src/Common/UserCache.cpp | 36 |
1 files 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<const std::map<unsigned long, UserInfo> > UserCache::getUserList(boost::posix_time::ptime *timestamp) throw(Core::Exception) { boost::lock_guard<boost::recursive_mutex> lock(mutex); + boost::posix_time::ptime newTime(userTime); + try { - boost::shared_ptr<const std::map<unsigned long, UserInfo> > newUsers = backend->getUserList(&userTime); + boost::shared_ptr<const std::map<unsigned long, UserInfo> > newUsers = backend->getUserList(&newTime); if(newUsers) { users = newUsers; userException = Core::Exception(); + userTime = newTime; userNames.reset(new std::map<std::string, unsigned long>); for(std::map<unsigned long, UserInfo>::const_iterator user = users->begin(); user != users->end(); ++user) @@ -45,8 +48,11 @@ boost::shared_ptr<const std::map<unsigned long, UserInfo> > 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<const std::set<unsigned long> > UserCache::getUserGroupList(un boost::shared_ptr<const std::map<unsigned long, GroupInfo> > UserCache::getGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception) { boost::lock_guard<boost::recursive_mutex> lock(mutex); + boost::posix_time::ptime newTime(groupTime); + try { - boost::shared_ptr<const std::map<unsigned long, GroupInfo> > newGroups = backend->getGroupList(&groupTime); + boost::shared_ptr<const std::map<unsigned long, GroupInfo> > newGroups = backend->getGroupList(&newTime); if(newGroups) { groups = newGroups; groupException = Core::Exception(); + groupTime = newTime; groupNames.reset(new std::map<std::string, unsigned long>); for(std::map<unsigned long, GroupInfo>::const_iterator group = groups->begin(); group != groups->end(); ++group) @@ -130,8 +139,11 @@ boost::shared_ptr<const std::map<unsigned long, GroupInfo> > 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<const std::set<unsigned long> > UserCache::getGroupUserList(un boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > UserCache::getFullUserGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception) { boost::lock_guard<boost::recursive_mutex> lock(mutex); + boost::posix_time::ptime newTime(userGroupTime); + try { - boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > newUserGroups = backend->getFullUserGroupList(&userGroupTime); + boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > newUserGroups = backend->getFullUserGroupList(&newTime); if(newUserGroups) { userGroups = newUserGroups; userGroupException = Core::Exception(); + userGroupTime = newTime; groupUsers.reset(new std::multimap<unsigned long, unsigned long>); for(std::multimap<unsigned long, unsigned long>::const_iterator usergroup = userGroups->begin(); usergroup != userGroups->end(); ++usergroup) @@ -214,8 +229,11 @@ boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > 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)) { |