diff options
Diffstat (limited to 'src/Server/RequestHandlers/UserRequestHandlerGroup.cpp')
-rw-r--r-- | src/Server/RequestHandlers/UserRequestHandlerGroup.cpp | 98 |
1 files changed, 14 insertions, 84 deletions
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"); |