diff options
Diffstat (limited to 'src/Server/RequestHandlers')
3 files changed, 19 insertions, 99 deletions
diff --git a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp index d446485..a1c492b 100644 --- a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp @@ -100,23 +100,13 @@ void ConnectionRequestHandlerGroup::handleIdentifyRequest(boost::shared_ptr<cons void ConnectionRequestHandlerGroup::handleLogRequest(boost::shared_ptr<const Common::XmlData> packet, Common::XmlData *ret, Common::Connection *connection) { // TODO Require authentication - boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - - const Core::String ×tr = packet->get<const Core::String&>("timestamp"); - if(!timestr.isEmpty()) { - try { - timestamp = boost::posix_time::from_iso_string(timestr.extract()); - } - catch(...) {} - } - try { application->getLogManager()->log( static_cast<Core::Logger::MessageCategory>(packet->get<long>("category")), static_cast<Core::Logger::MessageLevel>(packet->get<long>("level")), - timestamp, - packet->get<const Core::String&>("message").extract(), - application->getConnectionManager()->getDaemonName(connection).extract()); + packet->get<boost::posix_time::ptime>("timestamp"), + packet->get<const Core::String&>("message"), + application->getConnectionManager()->getDaemonName(connection)); } catch(Core::Exception &e) { application->logf(Core::Logger::LOG_ERROR, "Can't determine daemon name: %s", e.what()); diff --git a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp index 8f6909e..c80f493 100644 --- a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp @@ -69,7 +69,7 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::handlePacket(boost::shared ret.set("ErrorCode", e.getErrorCode()); ret.set("SubCode", e.getSubCode()); ret.set("SubSubCode", e.getSubSubCode()); - ret.set("Where", e.getWhere().c_str()); + ret.set("Where", e.getWhere()); sendPacket(ret); signalFinished(); @@ -83,7 +83,7 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::requestFinished(boost::sha ret.set("ErrorCode", error.getErrorCode()); ret.set("SubCode", error.getSubCode()); ret.set("SubSubCode", error.getSubSubCode()); - ret.set("Where", error.getWhere().c_str()); + ret.set("Where", error.getWhere()); sendPacket(ret); } diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp index f43ec86..5a7e3f9 100644 --- a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp @@ -34,22 +34,12 @@ void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptr<const Comm if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - - const Core::String ×tr = packet->get<const Core::String&>("timestamp"); - if(!timestr.isEmpty()) { - try { - timestamp = boost::posix_time::from_iso_string(timestr.extract()); - } - catch(...) {} - } + boost::posix_time::ptime timestamp = packet->get<boost::posix_time::ptime>("timestamp"); boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > users = application->getUserManager()->getUserList(×tamp); ret->setType("OK"); - - if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); + ret->set("timestamp", timestamp); if(users) { Common::XmlData::List *list = ret->createList("users"); @@ -70,15 +60,7 @@ void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr<const Comm if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - - const Core::String ×tr = packet->get<const Core::String&>("timestamp"); - if(!timestr.isEmpty()) { - try { - timestamp = boost::posix_time::from_iso_string(timestr.extract()); - } - catch(...) {} - } + boost::posix_time::ptime timestamp = packet->get<boost::posix_time::ptime>("timestamp"); boost::shared_ptr<const Common::UserInfo> info; @@ -89,9 +71,7 @@ void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr<const Comm info = application->getUserManager()->getUserInfoByName(packet->get<const Core::String&>("name"), ×tamp); ret->setType("OK"); - - if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); + ret->set("timestamp", timestamp); if(info) { ret->set("uid", info->getUid()); @@ -106,22 +86,12 @@ void UserRequestHandlerGroup::handleUserGroupListRequest(boost::shared_ptr<const if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - - const Core::String ×tr = packet->get<const Core::String&>("timestamp"); - if(!timestr.isEmpty()) { - try { - timestamp = boost::posix_time::from_iso_string(timestr.extract()); - } - catch(...) {} - } + boost::posix_time::ptime timestamp = packet->get<boost::posix_time::ptime>("timestamp"); boost::shared_ptr<const std::set<unsigned long> > groups = application->getUserManager()->getUserGroupList(packet->get<unsigned long>("uid"), ×tamp); ret->setType("OK"); - - if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); + ret->set("timestamp", timestamp); if(groups) { Common::XmlData::List *list = ret->createList("groups"); @@ -139,22 +109,12 @@ void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptr<const Com if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - - const Core::String ×tr = packet->get<const Core::String&>("timestamp"); - if(!timestr.isEmpty()) { - try { - timestamp = boost::posix_time::from_iso_string(timestr.extract()); - } - catch(...) {} - } + boost::posix_time::ptime timestamp = packet->get<boost::posix_time::ptime>("timestamp"); boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > groups = application->getUserManager()->getGroupList(×tamp); ret->setType("OK"); - - if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); + ret->set("timestamp", timestamp); if(groups) { Common::XmlData::List *list = ret->createList("groups"); @@ -173,15 +133,7 @@ void UserRequestHandlerGroup::handleGroupInfoRequest(boost::shared_ptr<const Com if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - - const Core::String ×tr = packet->get<const Core::String&>("timestamp"); - if(!timestr.isEmpty()) { - try { - timestamp = boost::posix_time::from_iso_string(timestr.extract()); - } - catch(...) {} - } + boost::posix_time::ptime timestamp = packet->get<boost::posix_time::ptime>("timestamp"); boost::shared_ptr<const Common::GroupInfo> info; @@ -192,9 +144,7 @@ void UserRequestHandlerGroup::handleGroupInfoRequest(boost::shared_ptr<const Com info = application->getUserManager()->getGroupInfoByName(packet->get<const Core::String&>("name"), ×tamp); ret->setType("OK"); - - if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); + ret->set("timestamp", timestamp); if(info) { ret->set("gid", info->getGid()); @@ -207,22 +157,12 @@ void UserRequestHandlerGroup::handleGroupUserListRequest(boost::shared_ptr<const if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - - const Core::String ×tr = packet->get<const Core::String&>("timestamp"); - if(!timestr.isEmpty()) { - try { - timestamp = boost::posix_time::from_iso_string(timestr.extract()); - } - catch(...) {} - } + boost::posix_time::ptime timestamp = packet->get<boost::posix_time::ptime>("timestamp"); boost::shared_ptr<const std::set<unsigned long> > users = application->getUserManager()->getGroupUserList(packet->get<unsigned long>("gid"), ×tamp); ret->setType("OK"); - - if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); + ret->set("timestamp", timestamp); Common::XmlData::List *list = ret->createList("users"); @@ -238,22 +178,12 @@ void UserRequestHandlerGroup::handleFullUserGroupListRequest(boost::shared_ptr<c if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - - const Core::String ×tr = packet->get<const Core::String&>("timestamp"); - if(!timestr.isEmpty()) { - try { - timestamp = boost::posix_time::from_iso_string(timestr.extract()); - } - catch(...) {} - } + boost::posix_time::ptime timestamp = packet->get<boost::posix_time::ptime>("timestamp"); boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > userGroups = application->getUserManager()->getFullUserGroupList(×tamp); ret->setType("OK"); - - if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); + ret->set("timestamp", timestamp); if(userGroups) { Common::XmlData::List *list = ret->createList("userGroupList"); |