mirror of https://github.com/Icinga/icinga2.git
parent
1634dbc6e4
commit
625a7eafbe
|
@ -75,7 +75,7 @@ std::vector<DynamicObject::Ptr> FilterUtility::GetFilterTargets(const QueryDescr
|
|||
boost::algorithm::to_lower(attr);
|
||||
|
||||
if (query->Contains(attr)) {
|
||||
String name = query->Get(attr);
|
||||
String name = HttpUtility::GetLastParameter(query, attr);
|
||||
DynamicObject::Ptr obj = GetObjectByTypeAndName(type->GetName(), name);
|
||||
if (!obj)
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Object does not exist."));
|
||||
|
@ -87,21 +87,28 @@ std::vector<DynamicObject::Ptr> FilterUtility::GetFilterTargets(const QueryDescr
|
|||
|
||||
if (query->Contains(attr)) {
|
||||
Array::Ptr names = query->Get(attr);
|
||||
ObjectLock olock(names);
|
||||
BOOST_FOREACH(const String& name, names) {
|
||||
DynamicObject::Ptr obj = GetObjectByTypeAndName(type->GetName(), name);
|
||||
if (!obj)
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Object does not exist."));
|
||||
result.push_back(obj);
|
||||
if (names) {
|
||||
ObjectLock olock(names);
|
||||
BOOST_FOREACH(const String& name, names) {
|
||||
DynamicObject::Ptr obj = GetObjectByTypeAndName(type->GetName(), name);
|
||||
if (!obj)
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Object does not exist."));
|
||||
result.push_back(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (query->Contains("filter")) {
|
||||
if (query->Contains("filter") || result.empty()) {
|
||||
if (!query->Contains("type"))
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Type must be specified when using a filter."));
|
||||
|
||||
String filter = HttpUtility::GetLastParameter(query, "filter");
|
||||
String filter;
|
||||
if (!query->Contains("filter"))
|
||||
filter = "true";
|
||||
else
|
||||
filter = HttpUtility::GetLastParameter(query, "filter");
|
||||
|
||||
String type = HttpUtility::GetLastParameter(query, "type");
|
||||
|
||||
Log(LogInformation, "FilterUtility", filter);
|
||||
|
|
|
@ -52,8 +52,6 @@ bool StatusQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& re
|
|||
String attr = type->GetName();
|
||||
boost::algorithm::to_lower(attr);
|
||||
params->Set(attr, request.RequestUrl->GetPath()[2]);
|
||||
} else if (!params->Contains("filter")) {
|
||||
params->Set("filter", "true");
|
||||
}
|
||||
|
||||
std::vector<DynamicObject::Ptr> objs = FilterUtility::GetFilterTargets(qd, params);
|
||||
|
@ -78,10 +76,6 @@ bool StatusQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& re
|
|||
Dictionary::Ptr result1 = new Dictionary();
|
||||
for (int fid = 0; fid < type->GetFieldCount(); fid++) {
|
||||
Field field = type->GetFieldInfo(fid);
|
||||
|
||||
if ((field.Attributes & (FAConfig|FAState)) == 0)
|
||||
continue;
|
||||
|
||||
String aname = prefix + "." + field.Name;
|
||||
if (!attrs.empty() && attrs.find(aname) == attrs.end())
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue