public static ExecutionRequest readRequest0( String content, MultivaluedMap<String, String> headers) throws Exception { ExecutionRequest req = new ExecutionRequest(); JsonParser jp = JsonWriter.getFactory().createJsonParser(content); jp.nextToken(); // skip { JsonToken tok = jp.nextToken(); while (tok != JsonToken.END_OBJECT) { String key = jp.getCurrentName(); jp.nextToken(); if ("input".equals(key)) { String input = jp.getText(); if (input != null) { req.setInput(resolveInput(input)); } } else if ("params".equals(key)) { readParams(jp, req); } else if ("context".equals(key)) { readContext(jp, req); } else if ("documentProperties".equals(key)) { // TODO XXX - this is wrong - headers are ready only! see with td String documentProperties = jp.getText(); if (documentProperties != null) { headers.putSingle(JsonDocumentWriter.DOCUMENT_PROPERTIES_HEADER, documentProperties); } } tok = jp.nextToken(); } return req; }
private static void readContext(JsonParser jp, ExecutionRequest req) throws Exception { JsonToken tok = jp.nextToken(); // move to first entry while (tok != JsonToken.END_OBJECT) { String key = jp.getCurrentName(); tok = jp.nextToken(); if (tok.isScalarValue()) { req.setContextParam(key, jp.getText()); } else { if (jp.getCodec() == null) { jp.setCodec(new ObjectMapper()); } req.setContextParam(key, jp.readValueAsTree()); } tok = jp.nextToken(); } }