Clean up the API action code a bit

refs #9080
This commit is contained in:
Gunnar Beutner 2015-08-24 08:01:33 +02:00
parent 92364d7b73
commit 380b1275b7
2 changed files with 14 additions and 12 deletions

View 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();

View 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); \
} \