]> granicus.if.org Git - icinga2/commitdiff
Clean up the API action code a bit
authorGunnar Beutner <gunnar@beutner.name>
Mon, 24 Aug 2015 06:01:33 +0000 (08:01 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Mon, 24 Aug 2015 06:01:33 +0000 (08:01 +0200)
refs #9080

lib/remote/actionshandler.cpp
lib/remote/apiaction.hpp

index 3efb20ac88632f5e8d1fe66e53e693318d74caa9..636a4ac81d554b2755a9bd8eba6c73d88d319011 100644 (file)
@@ -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<String>& types = action->GetTypes();
        std::vector<ConfigObject::Ptr> 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();
 
index e95f678533735bdd34519a4a95680b1fc16ef642..0bf6312cd5c4227d04fb9e67798889fd5d1d2853 100644 (file)
@@ -80,7 +80,8 @@ public:
                        boost::algorithm::replace_all(registerName, "_", "-"); \
                        std::vector<String> 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); \
                } \