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);
|
boost::algorithm::to_lower(attr);
|
||||||
|
|
||||||
if (query->Contains(attr)) {
|
if (query->Contains(attr)) {
|
||||||
String name = query->Get(attr);
|
String name = HttpUtility::GetLastParameter(query, attr);
|
||||||
DynamicObject::Ptr obj = GetObjectByTypeAndName(type->GetName(), name);
|
DynamicObject::Ptr obj = GetObjectByTypeAndName(type->GetName(), name);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Object does not exist."));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Object does not exist."));
|
||||||
|
@ -87,6 +87,7 @@ std::vector<DynamicObject::Ptr> FilterUtility::GetFilterTargets(const QueryDescr
|
||||||
|
|
||||||
if (query->Contains(attr)) {
|
if (query->Contains(attr)) {
|
||||||
Array::Ptr names = query->Get(attr);
|
Array::Ptr names = query->Get(attr);
|
||||||
|
if (names) {
|
||||||
ObjectLock olock(names);
|
ObjectLock olock(names);
|
||||||
BOOST_FOREACH(const String& name, names) {
|
BOOST_FOREACH(const String& name, names) {
|
||||||
DynamicObject::Ptr obj = GetObjectByTypeAndName(type->GetName(), name);
|
DynamicObject::Ptr obj = GetObjectByTypeAndName(type->GetName(), name);
|
||||||
|
@ -96,12 +97,18 @@ std::vector<DynamicObject::Ptr> FilterUtility::GetFilterTargets(const QueryDescr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (query->Contains("filter")) {
|
if (query->Contains("filter") || result.empty()) {
|
||||||
if (!query->Contains("type"))
|
if (!query->Contains("type"))
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Type must be specified when using a filter."));
|
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");
|
String type = HttpUtility::GetLastParameter(query, "type");
|
||||||
|
|
||||||
Log(LogInformation, "FilterUtility", filter);
|
Log(LogInformation, "FilterUtility", filter);
|
||||||
|
|
|
@ -52,8 +52,6 @@ bool StatusQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& re
|
||||||
String attr = type->GetName();
|
String attr = type->GetName();
|
||||||
boost::algorithm::to_lower(attr);
|
boost::algorithm::to_lower(attr);
|
||||||
params->Set(attr, request.RequestUrl->GetPath()[2]);
|
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);
|
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();
|
Dictionary::Ptr result1 = new Dictionary();
|
||||||
for (int fid = 0; fid < type->GetFieldCount(); fid++) {
|
for (int fid = 0; fid < type->GetFieldCount(); fid++) {
|
||||||
Field field = type->GetFieldInfo(fid);
|
Field field = type->GetFieldInfo(fid);
|
||||||
|
|
||||||
if ((field.Attributes & (FAConfig|FAState)) == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
String aname = prefix + "." + field.Name;
|
String aname = prefix + "." + field.Name;
|
||||||
if (!attrs.empty() && attrs.find(aname) == attrs.end())
|
if (!attrs.empty() && attrs.find(aname) == attrs.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue