| 93 | } |
| 94 | |
| 95 | bool ObjectQueryHandler::HandleRequest( |
| 96 | const WaitGroup::Ptr&, |
| 97 | const HttpApiRequest& request, |
| 98 | HttpApiResponse& response, |
| 99 | boost::asio::yield_context& yc |
| 100 | ) |
| 101 | { |
| 102 | namespace http = boost::beast::http; |
| 103 | |
| 104 | auto url = request.Url(); |
| 105 | auto user = request.User(); |
| 106 | auto params = request.Params(); |
| 107 | |
| 108 | if (url->GetPath().size() < 3 || url->GetPath().size() > 4) |
| 109 | return false; |
| 110 | |
| 111 | if (request.method() != http::verb::get) |
| 112 | return false; |
| 113 | |
| 114 | Type::Ptr type = FilterUtility::TypeFromPluralName(url->GetPath()[2]); |
| 115 | |
| 116 | if (!type) { |
| 117 | HttpUtility::SendJsonError(response, params, 400, "Invalid type specified."); |
| 118 | return true; |
| 119 | } |
| 120 | |
| 121 | QueryDescription qd; |
| 122 | qd.Types.insert(type->GetName()); |
| 123 | qd.Permission = "objects/query/" + type->GetName(); |
| 124 | |
| 125 | Array::Ptr uattrs, ujoins, umetas; |
| 126 | |
| 127 | try { |
| 128 | uattrs = params->Get("attrs"); |
| 129 | } catch (const std::exception&) { |
| 130 | HttpUtility::SendJsonError(response, params, 400, |
| 131 | "Invalid type for 'attrs' attribute specified. Array type is required."); |
| 132 | return true; |
| 133 | } |
| 134 | |
| 135 | try { |
| 136 | ujoins = params->Get("joins"); |
| 137 | } catch (const std::exception&) { |
| 138 | HttpUtility::SendJsonError(response, params, 400, |
| 139 | "Invalid type for 'joins' attribute specified. Array type is required."); |
| 140 | return true; |
| 141 | } |
| 142 | |
| 143 | try { |
| 144 | umetas = params->Get("meta"); |
| 145 | } catch (const std::exception&) { |
| 146 | HttpUtility::SendJsonError(response, params, 400, |
| 147 | "Invalid type for 'meta' attribute specified. Array type is required."); |
| 148 | return true; |
| 149 | } |
| 150 | |
| 151 | bool includeUsedBy = false; |
| 152 | bool includeLocation = false; |
nothing calls this directly
no test coverage detected