From 380b1275b74ae27d0419c5bc99bf31476ae6f4b0 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 24 Aug 2015 08:01:33 +0200 Subject: [PATCH] Clean up the API action code a bit refs #9080 --- lib/remote/actionshandler.cpp | 23 ++++++++++++----------- lib/remote/apiaction.hpp | 3 ++- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/remote/actionshandler.cpp b/lib/remote/actionshandler.cpp index 3efb20ac8..636a4ac81 100644 --- a/lib/remote/actionshandler.cpp +++ b/lib/remote/actionshandler.cpp @@ -49,21 +49,22 @@ bool ActionsHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& reques QueryDescription qd; - BOOST_FOREACH(const String& typeName, action->GetTypes()) { - if (typeName.IsEmpty()) - break; - Type::Ptr type = Type::GetByName(typeName); - ASSERT(type); - qd.Types.insert(type); - } - Dictionary::Ptr params = HttpUtility::FetchRequestParameters(request); + + const std::vector& types = action->GetTypes(); std::vector objs; - if (!qd.Types.empty()) + if (!types.empty()) { + BOOST_FOREACH(const String& typeName, types) { + Type::Ptr type = Type::GetByName(typeName); + ASSERT(type); + qd.Types.insert(type); + } + + objs = FilterUtility::GetFilterTargets(qd, params); - else - objs.push_back(NULL); + } else + objs.push_back(ConfigObject::Ptr()); Array::Ptr results = new Array(); diff --git a/lib/remote/apiaction.hpp b/lib/remote/apiaction.hpp index e95f67853..0bf6312cd 100644 --- a/lib/remote/apiaction.hpp +++ b/lib/remote/apiaction.hpp @@ -80,7 +80,8 @@ public: boost::algorithm::replace_all(registerName, "_", "-"); \ std::vector registerTypes; \ String typeNames = types; \ - boost::algorithm::split(registerTypes, typeNames, boost::is_any_of(";")); \ + if (!typeNames.IsEmpty()) \ + boost::algorithm::split(registerTypes, typeNames, boost::is_any_of(";")); \ ApiAction::Ptr action = new ApiAction(registerTypes, callback); \ ApiActionRegistry::GetInstance()->Register(registerName, action); \ } \ -- 2.40.0