MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / setSerializer

Method setSerializer

src/tsd/HttpQuery.java:306–340  ·  view source on GitHub ↗

Sets the local serializer based on a query string parameter or content type. If the caller supplies a "serializer=" parameter, the proper serializer is loaded if found. If the serializer doesn't exist, an exception will be thrown and the user gets an error If no query string parameter is sup

()

Source from the content-addressed store, hash-verified

304 * not exist
305 */
306 public void setSerializer() throws InvocationTargetException,
307 IllegalArgumentException, InstantiationException, IllegalAccessException {
308 if (this.hasQueryStringParam("serializer")) {
309 final String qs = this.getQueryStringParam("serializer");
310 Constructor<? extends HttpSerializer> ctor =
311 serializer_map_query_string.get(qs);
312 if (ctor == null) {
313 this.serializer = new HttpJsonSerializer(this);
314 throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
315 "Requested serializer was not found",
316 "Could not find a serializer with the name: " + qs);
317 }
318
319 this.serializer = ctor.newInstance(this);
320 return;
321 }
322
323 // attempt to parse the Content-Type string. We only want the first part,
324 // not the character set. And if the CT is missing, we'll use the default
325 // serializer
326 String content_type = request().headers().get("Content-Type");
327 if (content_type == null || content_type.isEmpty()) {
328 return;
329 }
330 if (content_type.indexOf(";") > -1) {
331 content_type = content_type.substring(0, content_type.indexOf(";"));
332 }
333 Constructor<? extends HttpSerializer> ctor =
334 serializer_map_content_type.get(content_type);
335 if (ctor == null) {
336 return;
337 }
338
339 this.serializer = ctor.newInstance(this);
340 }
341
342 /**
343 * Sends a 500 error page to the client.

Callers 10

setSerializerMethod · 0.95
setFormatterQSMethod · 0.95
setSerializerDummyQSMethod · 0.95
setSerializerCTMethod · 0.95
setSerializerDummyCTMethod · 0.95
setSerializerNotFoundMethod · 0.95
searchLookupNSUIMethod · 0.95
handleHttpQueryMethod · 0.95

Calls 5

isEmptyMethod · 0.80
hasQueryStringParamMethod · 0.45
getQueryStringParamMethod · 0.45
getMethod · 0.45
requestMethod · 0.45

Tested by 9

setSerializerMethod · 0.76
setFormatterQSMethod · 0.76
setSerializerDummyQSMethod · 0.76
setSerializerCTMethod · 0.76
setSerializerDummyCTMethod · 0.76
setSerializerNotFoundMethod · 0.76
searchLookupNSUIMethod · 0.76