Parses a timeseries data query @return A TSQuery with data ready to validate @throws JSONException if parsing failed @throws BadRequestException if the content was missing or parsing failed
()
| 262 | * @throws BadRequestException if the content was missing or parsing failed |
| 263 | */ |
| 264 | public TSQuery parseQueryV1() { |
| 265 | final String json = query.getContent(); |
| 266 | if (json == null || json.isEmpty()) { |
| 267 | throw new BadRequestException(HttpResponseStatus.BAD_REQUEST, |
| 268 | "Missing message content", |
| 269 | "Supply valid JSON formatted data in the body of your request"); |
| 270 | } |
| 271 | try { |
| 272 | TSQuery data_query = JSON.parseToObject(json, TSQuery.class); |
| 273 | // Filter out duplicate queries |
| 274 | Set<TSSubQuery> query_set = new LinkedHashSet<TSSubQuery>(data_query.getQueries()); |
| 275 | data_query.getQueries().clear(); |
| 276 | data_query.getQueries().addAll(query_set); |
| 277 | return data_query; |
| 278 | } catch (IllegalArgumentException iae) { |
| 279 | throw new BadRequestException("Unable to parse the given JSON", iae); |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | /** |
| 284 | * Parses a last data point query |
nothing calls this directly
no test coverage detected