summaryrefslogtreecommitdiffstats
path: root/src/modules/UserBackendMysql/UserBackendMysql.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/UserBackendMysql/UserBackendMysql.cpp')
-rw-r--r--src/modules/UserBackendMysql/UserBackendMysql.cpp81
1 files changed, 72 insertions, 9 deletions
diff --git a/src/modules/UserBackendMysql/UserBackendMysql.cpp b/src/modules/UserBackendMysql/UserBackendMysql.cpp
index 6d64a51..82258e8 100644
--- a/src/modules/UserBackendMysql/UserBackendMysql.cpp
+++ b/src/modules/UserBackendMysql/UserBackendMysql.cpp
@@ -134,11 +134,18 @@ void UserBackendMysql::configFinished() {
}
-boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > UserBackendMysql::getUserList() throw(Core::Exception) {
+boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > UserBackendMysql::getUserList(boost::posix_time::ptime *timestamp) throw(Core::Exception) {
application->getThreadManager()->detach();
boost::unique_lock<boost::mutex> lock(mutex);
+ if(timestamp) {
+ if(timestamp->is_not_a_date_time() || *timestamp < lastUpdate)
+ *timestamp = lastUpdate;
+ else
+ return boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> >();
+ }
+
if(!mysql || mysql_ping(mysql))
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -164,11 +171,18 @@ boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > UserBackendM
return users;
}
-boost::shared_ptr<const Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long uid) throw(Core::Exception) {
+boost::shared_ptr<const Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long uid, boost::posix_time::ptime *timestamp) throw(Core::Exception) {
application->getThreadManager()->detach();
boost::unique_lock<boost::mutex> lock(mutex);
+ if(timestamp) {
+ if(timestamp->is_not_a_date_time() || *timestamp < lastUpdate)
+ *timestamp = lastUpdate;
+ else
+ return boost::shared_ptr<const Common::UserInfo>();
+ }
+
if(!mysql || mysql_ping(mysql))
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -205,11 +219,18 @@ boost::shared_ptr<const Common::UserInfo> UserBackendMysql::getUserInfo(unsigned
throw Core::Exception(Core::Exception::NOT_FOUND);
}
-boost::shared_ptr<const Common::UserInfo> UserBackendMysql::getUserInfoByName(const std::string &name) throw(Core::Exception) {
+boost::shared_ptr<const Common::UserInfo> UserBackendMysql::getUserInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) {
application->getThreadManager()->detach();
boost::unique_lock<boost::mutex> lock(mutex);
+ if(timestamp) {
+ if(timestamp->is_not_a_date_time() || *timestamp < lastUpdate)
+ *timestamp = lastUpdate;
+ else
+ return boost::shared_ptr<const Common::UserInfo>();
+ }
+
if(!mysql || mysql_ping(mysql))
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -243,11 +264,18 @@ boost::shared_ptr<const Common::UserInfo> UserBackendMysql::getUserInfoByName(co
throw Core::Exception(Core::Exception::NOT_FOUND);
}
-boost::shared_ptr<const std::set<unsigned long> > UserBackendMysql::getUserGroupList(unsigned long uid) throw(Core::Exception) {
+boost::shared_ptr<const std::set<unsigned long> > UserBackendMysql::getUserGroupList(unsigned long uid, boost::posix_time::ptime *timestamp) throw(Core::Exception) {
application->getThreadManager()->detach();
boost::unique_lock<boost::mutex> lock(mutex);
+ if(timestamp) {
+ if(timestamp->is_not_a_date_time() || *timestamp < lastUpdate)
+ *timestamp = lastUpdate;
+ else
+ return boost::shared_ptr<const std::set<unsigned long> >();
+ }
+
if(!mysql || mysql_ping(mysql))
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -275,11 +303,18 @@ boost::shared_ptr<const std::set<unsigned long> > UserBackendMysql::getUserGroup
}
-boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > UserBackendMysql::getGroupList() throw(Core::Exception) {
+boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > UserBackendMysql::getGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception) {
application->getThreadManager()->detach();
boost::unique_lock<boost::mutex> lock(mutex);
+ if(timestamp) {
+ if(timestamp->is_not_a_date_time() || *timestamp < lastUpdate)
+ *timestamp = lastUpdate;
+ else
+ return boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> >();
+ }
+
if(!mysql || mysql_ping(mysql))
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -302,11 +337,18 @@ boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > UserBackend
return groups;
}
-boost::shared_ptr<const Common::GroupInfo> UserBackendMysql::getGroupInfo(unsigned long gid) throw(Core::Exception) {
+boost::shared_ptr<const Common::GroupInfo> UserBackendMysql::getGroupInfo(unsigned long gid, boost::posix_time::ptime *timestamp) throw(Core::Exception) {
application->getThreadManager()->detach();
boost::unique_lock<boost::mutex> lock(mutex);
+ if(timestamp) {
+ if(timestamp->is_not_a_date_time() || *timestamp < lastUpdate)
+ *timestamp = lastUpdate;
+ else
+ return boost::shared_ptr<const Common::GroupInfo>();
+ }
+
if(!mysql || mysql_ping(mysql))
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -335,11 +377,18 @@ boost::shared_ptr<const Common::GroupInfo> UserBackendMysql::getGroupInfo(unsign
throw Core::Exception(Core::Exception::NOT_FOUND);
}
-boost::shared_ptr<const Common::GroupInfo> UserBackendMysql::getGroupInfoByName(const std::string &name) throw(Core::Exception) {
+boost::shared_ptr<const Common::GroupInfo> UserBackendMysql::getGroupInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) {
application->getThreadManager()->detach();
boost::unique_lock<boost::mutex> lock(mutex);
+ if(timestamp) {
+ if(timestamp->is_not_a_date_time() || *timestamp < lastUpdate)
+ *timestamp = lastUpdate;
+ else
+ return boost::shared_ptr<const Common::GroupInfo>();
+ }
+
if(!mysql || mysql_ping(mysql))
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -365,11 +414,18 @@ boost::shared_ptr<const Common::GroupInfo> UserBackendMysql::getGroupInfoByName(
throw Core::Exception(Core::Exception::NOT_FOUND);
}
-boost::shared_ptr<const std::set<unsigned long> > UserBackendMysql::getGroupUserList(unsigned long gid) throw(Core::Exception) {
+boost::shared_ptr<const std::set<unsigned long> > UserBackendMysql::getGroupUserList(unsigned long gid, boost::posix_time::ptime *timestamp) throw(Core::Exception) {
application->getThreadManager()->detach();
boost::unique_lock<boost::mutex> lock(mutex);
+ if(timestamp) {
+ if(timestamp->is_not_a_date_time() || *timestamp < lastUpdate)
+ *timestamp = lastUpdate;
+ else
+ return boost::shared_ptr<const std::set<unsigned long> >();
+ }
+
if(!mysql || mysql_ping(mysql))
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -396,11 +452,18 @@ boost::shared_ptr<const std::set<unsigned long> > UserBackendMysql::getGroupUser
return users;
}
-boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > UserBackendMysql::getFullUserGroupList() throw(Core::Exception) {
+boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > UserBackendMysql::getFullUserGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception) {
application->getThreadManager()->detach();
boost::unique_lock<boost::mutex> lock(mutex);
+ if(timestamp) {
+ if(timestamp->is_not_a_date_time() || *timestamp < lastUpdate)
+ *timestamp = lastUpdate;
+ else
+ return boost::shared_ptr<const std::multimap<unsigned long, unsigned long> >();
+ }
+
if(!mysql || mysql_ping(mysql))
throw Core::Exception(Core::Exception::NOT_AVAILABLE);