summaryrefslogtreecommitdiffstats
path: root/src/Common
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/Application.cpp2
-rw-r--r--src/Common/UserCache.cpp22
-rw-r--r--src/Common/UserCache.h5
-rw-r--r--src/Common/UserManager.cpp2
-rw-r--r--src/Common/UserManager.h6
5 files changed, 23 insertions, 14 deletions
diff --git a/src/Common/Application.cpp b/src/Common/Application.cpp
index 6eca8d3..2b3ff9e 100644
--- a/src/Common/Application.cpp
+++ b/src/Common/Application.cpp
@@ -27,7 +27,7 @@ namespace Mad {
namespace Common {
Application::Application(bool server) : moduleManager(new ModuleManager(this)), requestManager(new RequestManager(this, server)),
-systemManager(new SystemManager), userManager(new UserManager) {}
+systemManager(new SystemManager), userManager(new UserManager(this)) {}
Application::~Application() {
delete userManager;
diff --git a/src/Common/UserCache.cpp b/src/Common/UserCache.cpp
index 79f27c7..887e375 100644
--- a/src/Common/UserCache.cpp
+++ b/src/Common/UserCache.cpp
@@ -18,8 +18,7 @@
*/
#include "UserCache.h"
-
-#include <iostream>
+#include "Application.h"
namespace Mad {
namespace Common {
@@ -28,11 +27,13 @@ boost::shared_ptr<const std::map<unsigned long, UserInfo> > UserCache::getUserLi
boost::lock_guard<boost::shared_mutex> lock(mutex);
if(users) {
- std::cerr << "Cached" << std::endl;
+ application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Using cached user list");
return users;
}
- else if(userException)
+ else if(userException) {
+ application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Error cached");
throw userException;
+ }
try {
users = backend->getUserList();
@@ -105,11 +106,13 @@ boost::shared_ptr<const std::map<unsigned long, GroupInfo> > UserCache::getGroup
boost::lock_guard<boost::shared_mutex> lock(mutex);
if(groups) {
- std::cerr << "Cached" << std::endl;
+ application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Using cached group list");
return groups;
}
- else if(groupException)
+ else if(groupException) {
+ application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Error cached");
throw groupException;
+ }
try {
groups = backend->getGroupList();
@@ -181,12 +184,13 @@ boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > UserCache:
boost::lock_guard<boost::shared_mutex> lock(mutex);
if(userGroups) {
- std::cerr << "Cached" << std::endl;
+ application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Using cached user-group table");
return userGroups;
}
- else if(userGroupException)
+ else if(userGroupException) {
+ application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Error cached");
throw userGroupException;
-
+ }
try {
userGroups = backend->getFullUserGroupList();
diff --git a/src/Common/UserCache.h b/src/Common/UserCache.h
index cec5ea5..548be2e 100644
--- a/src/Common/UserCache.h
+++ b/src/Common/UserCache.h
@@ -29,12 +29,15 @@
namespace Mad {
namespace Common {
+class Application;
class UserManager;
class UserCache : public UserBackend, private boost::noncopyable {
private:
friend class UserManager;
+ Application *application;
+
boost::shared_ptr<UserBackend> backend;
boost::shared_mutex mutex;
@@ -72,7 +75,7 @@ class UserCache : public UserBackend, private boost::noncopyable {
backend->addUser(userInfo);
}
- UserCache(boost::shared_ptr<UserBackend> backend0) : backend(backend0) {}
+ UserCache(Application *application0, boost::shared_ptr<UserBackend> backend0) : application(application0), backend(backend0) {}
};
}
diff --git a/src/Common/UserManager.cpp b/src/Common/UserManager.cpp
index c56195d..1b20395 100644
--- a/src/Common/UserManager.cpp
+++ b/src/Common/UserManager.cpp
@@ -36,7 +36,7 @@ bool UserManager::Compare::operator() (boost::shared_ptr<UserBackend> b1, boost:
void UserManager::registerBackendCached(boost::shared_ptr<UserBackend> backend) {
{
boost::lock_guard<boost::shared_mutex> lock(mutex);
- backends.insert(std::make_pair(backend, boost::shared_ptr<UserCache>(new UserCache(backend))));
+ backends.insert(std::make_pair(backend, boost::shared_ptr<UserCache>(new UserCache(application, backend))));
}
}
diff --git a/src/Common/UserManager.h b/src/Common/UserManager.h
index 1ba051f..c545f01 100644
--- a/src/Common/UserManager.h
+++ b/src/Common/UserManager.h
@@ -38,7 +38,7 @@ class Application;
class UserBackend;
class UserCache;
-class UserManager : boost::noncopyable {
+class UserManager : private boost::noncopyable {
private:
friend class Application;
@@ -48,11 +48,13 @@ class UserManager : boost::noncopyable {
typedef std::map<boost::shared_ptr<UserBackend>, boost::shared_ptr<UserBackend>, Compare> BackendMap;
+ Application *application;
+
BackendMap backends;
boost::shared_mutex mutex;
- UserManager() {}
+ UserManager(Application *application0) : application(application0) {}
public:
void registerBackend(boost::shared_ptr<UserBackend> backend) {