- public TypeReference<T> getRequestType() {
- return command.getRequestType();
- }
- }
-
- interface CommandRunner<T> {
-
- void handleCommand(T request, OutputWriter outputWriter) throws CommandException;
-
- TypeReference<T> getRequestType();
- }
-
- private JsonNode runCommand(
- final ObjectMapper objectMapper, final ContainerNode<?> params, final CommandRunner<?> command
- ) throws JsonRpcException {
- final Object[] result = {null};
- final JsonWriter commandOutputWriter = s -> {
- if (result[0] != null) {
- throw new AssertionError("Command may only write one json result");
- }
-
- result[0] = s;
- };
-
- try {
- parseParamsAndRunCommand(objectMapper, params, commandOutputWriter, command);
- } catch (JsonMappingException e) {
- throw new JsonRpcException(new JsonRpcResponse.Error(JsonRpcResponse.Error.INVALID_REQUEST,
- e.getMessage(),
- null));
- } catch (UserErrorException e) {
- throw new JsonRpcException(new JsonRpcResponse.Error(USER_ERROR, e.getMessage(), null));
- } catch (IOErrorException e) {
- throw new JsonRpcException(new JsonRpcResponse.Error(IO_ERROR, e.getMessage(), null));
- } catch (UntrustedKeyErrorException e) {
- throw new JsonRpcException(new JsonRpcResponse.Error(UNTRUSTED_KEY_ERROR, e.getMessage(), null));
- } catch (Throwable e) {
- logger.error("Command execution failed", e);
- throw new JsonRpcException(new JsonRpcResponse.Error(JsonRpcResponse.Error.INTERNAL_ERROR,
- e.getMessage(),
- null));
+ public void handleCommand(
+ final Void request, final Manager m, final JsonWriter jsonWriter
+ ) throws CommandException {
+ final var subscriptionId = subscribeReceive(m, false);
+ jsonWriter.write(subscriptionId);