@Test public void testCreateCommandResolverSingleOp() throws IOException { bindOperations(); HttpServletRequest request = mock(HttpServletRequest.class); when(request.getScheme()).thenReturn("http"); HttpServletResponse response = mock(HttpServletResponse.class); IdentityTokenResolver tokenResolver = mock(IdentityTokenResolver.class); RequestTimer mockTimer = mock(RequestTimer.class); HttpCommand mockedCommand = mock(HttpCommand.class); when(mockedCommand.getRequest()).thenReturn(request); when(mockedCommand.getResponse()).thenReturn(response); when(mockedCommand.getIdentityTokenResolver()).thenReturn(tokenResolver); when(mockedCommand.getStatus()).thenReturn(TransportCommand.CommandStatus.InProgress); when(mockedCommand.getTimer()).thenReturn(mockTimer); String body="{ \"method\": \"" + SERVICE_NAME + "/v1.0/" + OP_NAME + "\", \"params\": [\"Hello\", 333], \"id\": 1}"; TestInputStream tis = new TestInputStream(new ByteArrayInputStream(body.getBytes("UTF-8"))); when(request.getInputStream()).thenReturn(tis); TestOutputStream tos = new TestOutputStream(); when(response.getOutputStream()).thenReturn(tos); CommandResolver<HttpCommand> resolver = commandProcessor.createCommandResolver(mockedCommand, tracer); assertNotNull(resolver); Iterable<ExecutionCommand> cmds = resolver.resolveExecutionCommands(); assertNotNull(cmds); assertTrue(cmds.iterator().hasNext()); ExecutionCommand executionCommand = cmds.iterator().next(); assertNotNull(executionCommand); Object[] args = executionCommand.getArgs(); assertTrue(args.length == 2); assertEquals(args[0], "Hello"); assertEquals(args[1], 333); OperationKey actual = executionCommand.getOperationKey(); assertEquals(TEST_OP_KEY, actual); ExecutionContext ctx = resolver.resolveExecutionContext(); assertNotNull(ctx); executionCommand.onResult(new ExecutionResult()); verify(response).getOutputStream(); verify(logger).logAccess(eq(mockedCommand), isA(ExecutionContext.class), anyLong(), anyLong(), any(MediaType.class), any(MediaType.class), any(ResponseCode.class)); verifyTracerCalls(); }
@Override protected CommandResolver<HttpCommand> createCommandResolver(final HttpCommand http, final Tracer tracer) { final DehydratedExecutionContext context = resolveExecutionContext(http, null); tracer.start(context.getRequestUUID(), CougarInternalOperations.BATCH_CALL); final List<JsonRpcRequest> requests = new ArrayList<>(); final List<ExecutionCommand> commands = new LinkedList<>(); final List<JsonRpcResponse> responses = new ArrayList<>(); JsonNode root; ByteCountingInputStream iStream = null; try { iStream = createByteCountingInputStream(http.getRequest().getInputStream()); try { EnumUtils.setHardFailureForThisThread(hardFailEnumDeserialisation); root = mapper.readTree(iStream); final long bytesRead = iStream.getCount(); final boolean isBatch = root.isArray(); if (isBatch) { requests.addAll((List<JsonRpcRequest>)mapper.convertValue(root, BATCH_REQUEST_TYPE)); } else { JsonRpcRequest rpc = mapper.convertValue(root, SINGLE_REQUEST_TYPE); requests.add(rpc); } if (requests.isEmpty()) { writeErrorResponse(http, context, new CougarValidationException(ServerFaultCode.NoRequestsFound, "No Requests found in rpc call"), true); } else { final TimeConstraints realTimeConstraints = DefaultTimeConstraints.rebaseFromNewStartTime(context.getRequestTime(), readRawTimeConstraints(http.getRequest())); for (final JsonRpcRequest rpc : requests) { final JsonRpcOperationBinding binding = bindings.get(stripMinorVersionFromUri(rpc.getMethod().toLowerCase())); if (binding!=null) { try { JsonRpcParam [] paramDefs = binding.getJsonRpcParams(); final Object [] args = new Object[paramDefs.length]; for (int i=0;i<paramDefs.length;i++) { JsonNode paramValue = rpc.getParams().isArray() ? rpc.getParams().get(i) : rpc.getParams().get(paramDefs[i].getName()); JavaType javaType = paramDefs[i].getJavaType(); args[i] = mapper.convertValue(paramValue, javaType); if (javaType.isEnumType() && args[i] != null && ((Enum)args[i]).name().equals("UNRECOGNIZED_VALUE")) { throw new IllegalArgumentException(new Exception(new EnumDerialisationException("UNRECOGNIZED_VALUE is not allowed as an input"))); } } commands.add(new ExecutionCommand() { @Override public void onResult(ExecutionResult executionResult) { JsonRpcResponse response = buildExecutionResultResponse(rpc, executionResult); synchronized(responses) { responses.add(response); writeResponseIfComplete(http, context, isBatch, requests, responses, bytesRead, tracer); } } @Override public OperationKey getOperationKey() { return binding.getOperationDefinition().getOperationKey(); } @Override public Object[] getArgs() { return args; } @Override public TimeConstraints getTimeConstraints() { return realTimeConstraints; } }); } catch (Exception e) { if (e instanceof IllegalArgumentException && e.getCause() != null && (e.getCause().getCause()==null || e.getCause().getCause() instanceof EnumDerialisationException)) { responses.add(JsonRpcErrorResponse.buildErrorResponse(rpc, new JsonRpcError(INVALID_PARAMS, ServerFaultCode.ServerDeserialisationFailure.getDetail(), null))); } else { responses.add(JsonRpcErrorResponse.buildErrorResponse(rpc, new JsonRpcError(INVALID_PARAMS, ServerFaultCode.MandatoryNotDefined.getDetail(), null))); } writeResponseIfComplete(http, context, isBatch, requests, responses, bytesRead, tracer); } } else { responses.add(JsonRpcErrorResponse.buildErrorResponse(rpc, new JsonRpcError(METHOD_NOT_FOUND, ServerFaultCode.NoSuchOperation.getDetail(), null))); writeResponseIfComplete(http, context, isBatch, requests, responses, bytesRead, tracer); } } } } catch (Exception ex) { writeErrorResponse(http, context, CougarMarshallingException.unmarshallingException("json",ex,false), true); commands.clear(); } return new CommandResolver<HttpCommand>() { @Override public List<ExecutionCommand> resolveExecutionCommands() { return commands; } @Override public DehydratedExecutionContext resolveExecutionContext() { return context; } }; } catch (Exception e) { throw CougarMarshallingException.unmarshallingException("json", "Unable to resolve requests for json-rpc", e, false); } finally { try { if (iStream != null) { iStream.close(); } } catch (IOException ignored) { ignored.printStackTrace(); } } }
JsonRpcTransportCommandProcessor extends AbstractHttpCommandProcessor<Void> { @Override protected CommandResolver<HttpCommand> createCommandResolver(final HttpCommand http, final Tracer tracer) { final DehydratedExecutionContext context = resolveExecutionContext(http, null); tracer.start(context.getRequestUUID(), CougarInternalOperations.BATCH_CALL); final List<JsonRpcRequest> requests = new ArrayList<>(); final List<ExecutionCommand> commands = new LinkedList<>(); final List<JsonRpcResponse> responses = new ArrayList<>(); JsonNode root; ByteCountingInputStream iStream = null; try { iStream = createByteCountingInputStream(http.getRequest().getInputStream()); try { EnumUtils.setHardFailureForThisThread(hardFailEnumDeserialisation); root = mapper.readTree(iStream); final long bytesRead = iStream.getCount(); final boolean isBatch = root.isArray(); if (isBatch) { requests.addAll((List<JsonRpcRequest>)mapper.convertValue(root, BATCH_REQUEST_TYPE)); } else { JsonRpcRequest rpc = mapper.convertValue(root, SINGLE_REQUEST_TYPE); requests.add(rpc); } if (requests.isEmpty()) { writeErrorResponse(http, context, new CougarValidationException(ServerFaultCode.NoRequestsFound, "No Requests found in rpc call"), true); } else { final TimeConstraints realTimeConstraints = DefaultTimeConstraints.rebaseFromNewStartTime(context.getRequestTime(), readRawTimeConstraints(http.getRequest())); for (final JsonRpcRequest rpc : requests) { final JsonRpcOperationBinding binding = bindings.get(stripMinorVersionFromUri(rpc.getMethod().toLowerCase())); if (binding!=null) { try { JsonRpcParam [] paramDefs = binding.getJsonRpcParams(); final Object [] args = new Object[paramDefs.length]; for (int i=0;i<paramDefs.length;i++) { JsonNode paramValue = rpc.getParams().isArray() ? rpc.getParams().get(i) : rpc.getParams().get(paramDefs[i].getName()); JavaType javaType = paramDefs[i].getJavaType(); args[i] = mapper.convertValue(paramValue, javaType); if (javaType.isEnumType() && args[i] != null && ((Enum)args[i]).name().equals("UNRECOGNIZED_VALUE")) { throw new IllegalArgumentException(new Exception(new EnumDerialisationException("UNRECOGNIZED_VALUE is not allowed as an input"))); } } commands.add(new ExecutionCommand() { @Override public void onResult(ExecutionResult executionResult) { JsonRpcResponse response = buildExecutionResultResponse(rpc, executionResult); synchronized(responses) { responses.add(response); writeResponseIfComplete(http, context, isBatch, requests, responses, bytesRead, tracer); } } @Override public OperationKey getOperationKey() { return binding.getOperationDefinition().getOperationKey(); } @Override public Object[] getArgs() { return args; } @Override public TimeConstraints getTimeConstraints() { return realTimeConstraints; } }); } catch (Exception e) { if (e instanceof IllegalArgumentException && e.getCause() != null && (e.getCause().getCause()==null || e.getCause().getCause() instanceof EnumDerialisationException)) { responses.add(JsonRpcErrorResponse.buildErrorResponse(rpc, new JsonRpcError(INVALID_PARAMS, ServerFaultCode.ServerDeserialisationFailure.getDetail(), null))); } else { responses.add(JsonRpcErrorResponse.buildErrorResponse(rpc, new JsonRpcError(INVALID_PARAMS, ServerFaultCode.MandatoryNotDefined.getDetail(), null))); } writeResponseIfComplete(http, context, isBatch, requests, responses, bytesRead, tracer); } } else { responses.add(JsonRpcErrorResponse.buildErrorResponse(rpc, new JsonRpcError(METHOD_NOT_FOUND, ServerFaultCode.NoSuchOperation.getDetail(), null))); writeResponseIfComplete(http, context, isBatch, requests, responses, bytesRead, tracer); } } } } catch (Exception ex) { writeErrorResponse(http, context, CougarMarshallingException.unmarshallingException("json",ex,false), true); commands.clear(); } return new CommandResolver<HttpCommand>() { @Override public List<ExecutionCommand> resolveExecutionCommands() { return commands; } @Override public DehydratedExecutionContext resolveExecutionContext() { return context; } }; } catch (Exception e) { throw CougarMarshallingException.unmarshallingException("json", "Unable to resolve requests for json-rpc", e, false); } finally { try { if (iStream != null) { iStream.close(); } } catch (IOException ignored) { ignored.printStackTrace(); } } } }
JsonRpcTransportCommandProcessor extends AbstractHttpCommandProcessor<Void> { @Override protected CommandResolver<HttpCommand> createCommandResolver(final HttpCommand http, final Tracer tracer) { final DehydratedExecutionContext context = resolveExecutionContext(http, null); tracer.start(context.getRequestUUID(), CougarInternalOperations.BATCH_CALL); final List<JsonRpcRequest> requests = new ArrayList<>(); final List<ExecutionCommand> commands = new LinkedList<>(); final List<JsonRpcResponse> responses = new ArrayList<>(); JsonNode root; ByteCountingInputStream iStream = null; try { iStream = createByteCountingInputStream(http.getRequest().getInputStream()); try { EnumUtils.setHardFailureForThisThread(hardFailEnumDeserialisation); root = mapper.readTree(iStream); final long bytesRead = iStream.getCount(); final boolean isBatch = root.isArray(); if (isBatch) { requests.addAll((List<JsonRpcRequest>)mapper.convertValue(root, BATCH_REQUEST_TYPE)); } else { JsonRpcRequest rpc = mapper.convertValue(root, SINGLE_REQUEST_TYPE); requests.add(rpc); } if (requests.isEmpty()) { writeErrorResponse(http, context, new CougarValidationException(ServerFaultCode.NoRequestsFound, "No Requests found in rpc call"), true); } else { final TimeConstraints realTimeConstraints = DefaultTimeConstraints.rebaseFromNewStartTime(context.getRequestTime(), readRawTimeConstraints(http.getRequest())); for (final JsonRpcRequest rpc : requests) { final JsonRpcOperationBinding binding = bindings.get(stripMinorVersionFromUri(rpc.getMethod().toLowerCase())); if (binding!=null) { try { JsonRpcParam [] paramDefs = binding.getJsonRpcParams(); final Object [] args = new Object[paramDefs.length]; for (int i=0;i<paramDefs.length;i++) { JsonNode paramValue = rpc.getParams().isArray() ? rpc.getParams().get(i) : rpc.getParams().get(paramDefs[i].getName()); JavaType javaType = paramDefs[i].getJavaType(); args[i] = mapper.convertValue(paramValue, javaType); if (javaType.isEnumType() && args[i] != null && ((Enum)args[i]).name().equals("UNRECOGNIZED_VALUE")) { throw new IllegalArgumentException(new Exception(new EnumDerialisationException("UNRECOGNIZED_VALUE is not allowed as an input"))); } } commands.add(new ExecutionCommand() { @Override public void onResult(ExecutionResult executionResult) { JsonRpcResponse response = buildExecutionResultResponse(rpc, executionResult); synchronized(responses) { responses.add(response); writeResponseIfComplete(http, context, isBatch, requests, responses, bytesRead, tracer); } } @Override public OperationKey getOperationKey() { return binding.getOperationDefinition().getOperationKey(); } @Override public Object[] getArgs() { return args; } @Override public TimeConstraints getTimeConstraints() { return realTimeConstraints; } }); } catch (Exception e) { if (e instanceof IllegalArgumentException && e.getCause() != null && (e.getCause().getCause()==null || e.getCause().getCause() instanceof EnumDerialisationException)) { responses.add(JsonRpcErrorResponse.buildErrorResponse(rpc, new JsonRpcError(INVALID_PARAMS, ServerFaultCode.ServerDeserialisationFailure.getDetail(), null))); } else { responses.add(JsonRpcErrorResponse.buildErrorResponse(rpc, new JsonRpcError(INVALID_PARAMS, ServerFaultCode.MandatoryNotDefined.getDetail(), null))); } writeResponseIfComplete(http, context, isBatch, requests, responses, bytesRead, tracer); } } else { responses.add(JsonRpcErrorResponse.buildErrorResponse(rpc, new JsonRpcError(METHOD_NOT_FOUND, ServerFaultCode.NoSuchOperation.getDetail(), null))); writeResponseIfComplete(http, context, isBatch, requests, responses, bytesRead, tracer); } } } } catch (Exception ex) { writeErrorResponse(http, context, CougarMarshallingException.unmarshallingException("json",ex,false), true); commands.clear(); } return new CommandResolver<HttpCommand>() { @Override public List<ExecutionCommand> resolveExecutionCommands() { return commands; } @Override public DehydratedExecutionContext resolveExecutionContext() { return context; } }; } catch (Exception e) { throw CougarMarshallingException.unmarshallingException("json", "Unable to resolve requests for json-rpc", e, false); } finally { try { if (iStream != null) { iStream.close(); } } catch (IOException ignored) { ignored.printStackTrace(); } } } JsonRpcTransportCommandProcessor(DehydratedExecutionContextResolution contextResolution, String requestTimeoutHeader, ObjectMapper mapper);  JsonRpcTransportCommandProcessor(DehydratedExecutionContextResolution contextResolution, String requestTimeoutHeader, JSONBindingFactory jsonBindingFactory); }
JsonRpcTransportCommandProcessor extends AbstractHttpCommandProcessor<Void> { @Override protected CommandResolver<HttpCommand> createCommandResolver(final HttpCommand http, final Tracer tracer) { final DehydratedExecutionContext context = resolveExecutionContext(http, null); tracer.start(context.getRequestUUID(), CougarInternalOperations.BATCH_CALL); final List<JsonRpcRequest> requests = new ArrayList<>(); final List<ExecutionCommand> commands = new LinkedList<>(); final List<JsonRpcResponse> responses = new ArrayList<>(); JsonNode root; ByteCountingInputStream iStream = null; try { iStream = createByteCountingInputStream(http.getRequest().getInputStream()); try { EnumUtils.setHardFailureForThisThread(hardFailEnumDeserialisation); root = mapper.readTree(iStream); final long bytesRead = iStream.getCount(); final boolean isBatch = root.isArray(); if (isBatch) { requests.addAll((List<JsonRpcRequest>)mapper.convertValue(root, BATCH_REQUEST_TYPE)); } else { JsonRpcRequest rpc = mapper.convertValue(root, SINGLE_REQUEST_TYPE); requests.add(rpc); } if (requests.isEmpty()) { writeErrorResponse(http, context, new CougarValidationException(ServerFaultCode.NoRequestsFound, "No Requests found in rpc call"), true); } else { final TimeConstraints realTimeConstraints = DefaultTimeConstraints.rebaseFromNewStartTime(context.getRequestTime(), readRawTimeConstraints(http.getRequest())); for (final JsonRpcRequest rpc : requests) { final JsonRpcOperationBinding binding = bindings.get(stripMinorVersionFromUri(rpc.getMethod().toLowerCase())); if (binding!=null) { try { JsonRpcParam [] paramDefs = binding.getJsonRpcParams(); final Object [] args = new Object[paramDefs.length]; for (int i=0;i<paramDefs.length;i++) { JsonNode paramValue = rpc.getParams().isArray() ? rpc.getParams().get(i) : rpc.getParams().get(paramDefs[i].getName()); JavaType javaType = paramDefs[i].getJavaType(); args[i] = mapper.convertValue(paramValue, javaType); if (javaType.isEnumType() && args[i] != null && ((Enum)args[i]).name().equals("UNRECOGNIZED_VALUE")) { throw new IllegalArgumentException(new Exception(new EnumDerialisationException("UNRECOGNIZED_VALUE is not allowed as an input"))); } } commands.add(new ExecutionCommand() { @Override public void onResult(ExecutionResult executionResult) { JsonRpcResponse response = buildExecutionResultResponse(rpc, executionResult); synchronized(responses) { responses.add(response); writeResponseIfComplete(http, context, isBatch, requests, responses, bytesRead, tracer); } } @Override public OperationKey getOperationKey() { return binding.getOperationDefinition().getOperationKey(); } @Override public Object[] getArgs() { return args; } @Override public TimeConstraints getTimeConstraints() { return realTimeConstraints; } }); } catch (Exception e) { if (e instanceof IllegalArgumentException && e.getCause() != null && (e.getCause().getCause()==null || e.getCause().getCause() instanceof EnumDerialisationException)) { responses.add(JsonRpcErrorResponse.buildErrorResponse(rpc, new JsonRpcError(INVALID_PARAMS, ServerFaultCode.ServerDeserialisationFailure.getDetail(), null))); } else { responses.add(JsonRpcErrorResponse.buildErrorResponse(rpc, new JsonRpcError(INVALID_PARAMS, ServerFaultCode.MandatoryNotDefined.getDetail(), null))); } writeResponseIfComplete(http, context, isBatch, requests, responses, bytesRead, tracer); } } else { responses.add(JsonRpcErrorResponse.buildErrorResponse(rpc, new JsonRpcError(METHOD_NOT_FOUND, ServerFaultCode.NoSuchOperation.getDetail(), null))); writeResponseIfComplete(http, context, isBatch, requests, responses, bytesRead, tracer); } } } } catch (Exception ex) { writeErrorResponse(http, context, CougarMarshallingException.unmarshallingException("json",ex,false), true); commands.clear(); } return new CommandResolver<HttpCommand>() { @Override public List<ExecutionCommand> resolveExecutionCommands() { return commands; } @Override public DehydratedExecutionContext resolveExecutionContext() { return context; } }; } catch (Exception e) { throw CougarMarshallingException.unmarshallingException("json", "Unable to resolve requests for json-rpc", e, false); } finally { try { if (iStream != null) { iStream.close(); } } catch (IOException ignored) { ignored.printStackTrace(); } } } JsonRpcTransportCommandProcessor(DehydratedExecutionContextResolution contextResolution, String requestTimeoutHeader, ObjectMapper mapper);  JsonRpcTransportCommandProcessor(DehydratedExecutionContextResolution contextResolution, String requestTimeoutHeader, JSONBindingFactory jsonBindingFactory); @Override void onCougarStart(); boolean bindOperation(OperationDefinition operationDefinition); @Override void process(HttpCommand command); @Override void writeErrorResponse(HttpCommand command, DehydratedExecutionContext context, CougarException error, boolean traceStarted); boolean writeResponseIfComplete(HttpCommand command, DehydratedExecutionContext context, boolean isBatch, List<JsonRpcRequest> requests, List<JsonRpcResponse> responses, long bytesRead, Tracer tracer); }
JsonRpcTransportCommandProcessor extends AbstractHttpCommandProcessor<Void> { @Override protected CommandResolver<HttpCommand> createCommandResolver(final HttpCommand http, final Tracer tracer) { final DehydratedExecutionContext context = resolveExecutionContext(http, null); tracer.start(context.getRequestUUID(), CougarInternalOperations.BATCH_CALL); final List<JsonRpcRequest> requests = new ArrayList<>(); final List<ExecutionCommand> commands = new LinkedList<>(); final List<JsonRpcResponse> responses = new ArrayList<>(); JsonNode root; ByteCountingInputStream iStream = null; try { iStream = createByteCountingInputStream(http.getRequest().getInputStream()); try { EnumUtils.setHardFailureForThisThread(hardFailEnumDeserialisation); root = mapper.readTree(iStream); final long bytesRead = iStream.getCount(); final boolean isBatch = root.isArray(); if (isBatch) { requests.addAll((List<JsonRpcRequest>)mapper.convertValue(root, BATCH_REQUEST_TYPE)); } else { JsonRpcRequest rpc = mapper.convertValue(root, SINGLE_REQUEST_TYPE); requests.add(rpc); } if (requests.isEmpty()) { writeErrorResponse(http, context, new CougarValidationException(ServerFaultCode.NoRequestsFound, "No Requests found in rpc call"), true); } else { final TimeConstraints realTimeConstraints = DefaultTimeConstraints.rebaseFromNewStartTime(context.getRequestTime(), readRawTimeConstraints(http.getRequest())); for (final JsonRpcRequest rpc : requests) { final JsonRpcOperationBinding binding = bindings.get(stripMinorVersionFromUri(rpc.getMethod().toLowerCase())); if (binding!=null) { try { JsonRpcParam [] paramDefs = binding.getJsonRpcParams(); final Object [] args = new Object[paramDefs.length]; for (int i=0;i<paramDefs.length;i++) { JsonNode paramValue = rpc.getParams().isArray() ? rpc.getParams().get(i) : rpc.getParams().get(paramDefs[i].getName()); JavaType javaType = paramDefs[i].getJavaType(); args[i] = mapper.convertValue(paramValue, javaType); if (javaType.isEnumType() && args[i] != null && ((Enum)args[i]).name().equals("UNRECOGNIZED_VALUE")) { throw new IllegalArgumentException(new Exception(new EnumDerialisationException("UNRECOGNIZED_VALUE is not allowed as an input"))); } } commands.add(new ExecutionCommand() { @Override public void onResult(ExecutionResult executionResult) { JsonRpcResponse response = buildExecutionResultResponse(rpc, executionResult); synchronized(responses) { responses.add(response); writeResponseIfComplete(http, context, isBatch, requests, responses, bytesRead, tracer); } } @Override public OperationKey getOperationKey() { return binding.getOperationDefinition().getOperationKey(); } @Override public Object[] getArgs() { return args; } @Override public TimeConstraints getTimeConstraints() { return realTimeConstraints; } }); } catch (Exception e) { if (e instanceof IllegalArgumentException && e.getCause() != null && (e.getCause().getCause()==null || e.getCause().getCause() instanceof EnumDerialisationException)) { responses.add(JsonRpcErrorResponse.buildErrorResponse(rpc, new JsonRpcError(INVALID_PARAMS, ServerFaultCode.ServerDeserialisationFailure.getDetail(), null))); } else { responses.add(JsonRpcErrorResponse.buildErrorResponse(rpc, new JsonRpcError(INVALID_PARAMS, ServerFaultCode.MandatoryNotDefined.getDetail(), null))); } writeResponseIfComplete(http, context, isBatch, requests, responses, bytesRead, tracer); } } else { responses.add(JsonRpcErrorResponse.buildErrorResponse(rpc, new JsonRpcError(METHOD_NOT_FOUND, ServerFaultCode.NoSuchOperation.getDetail(), null))); writeResponseIfComplete(http, context, isBatch, requests, responses, bytesRead, tracer); } } } } catch (Exception ex) { writeErrorResponse(http, context, CougarMarshallingException.unmarshallingException("json",ex,false), true); commands.clear(); } return new CommandResolver<HttpCommand>() { @Override public List<ExecutionCommand> resolveExecutionCommands() { return commands; } @Override public DehydratedExecutionContext resolveExecutionContext() { return context; } }; } catch (Exception e) { throw CougarMarshallingException.unmarshallingException("json", "Unable to resolve requests for json-rpc", e, false); } finally { try { if (iStream != null) { iStream.close(); } } catch (IOException ignored) { ignored.printStackTrace(); } } } JsonRpcTransportCommandProcessor(DehydratedExecutionContextResolution contextResolution, String requestTimeoutHeader, ObjectMapper mapper);  JsonRpcTransportCommandProcessor(DehydratedExecutionContextResolution contextResolution, String requestTimeoutHeader, JSONBindingFactory jsonBindingFactory); @Override void onCougarStart(); boolean bindOperation(OperationDefinition operationDefinition); @Override void process(HttpCommand command); @Override void writeErrorResponse(HttpCommand command, DehydratedExecutionContext context, CougarException error, boolean traceStarted); boolean writeResponseIfComplete(HttpCommand command, DehydratedExecutionContext context, boolean isBatch, List<JsonRpcRequest> requests, List<JsonRpcResponse> responses, long bytesRead, Tracer tracer);  }