@Override public String toString() { if (valid) { return String.format("Command [name: %s, tenant-id: %s, device-id %s, request-id: %s]", getName(), getTenant(), getDeviceId(), getRequestId()); } else { return "Invalid Command"; } } }
private void setResponsePayload(final HttpServerResponse response, final CommandContext commandContext, final Span currentSpan) { if (commandContext == null) { response.setStatusCode(HttpURLConnection.HTTP_ACCEPTED); } else { final Command command = commandContext.getCommand(); response.putHeader(Constants.HEADER_COMMAND, command.getName()); currentSpan.setTag(Constants.HEADER_COMMAND, command.getName()); LOG.trace("adding command [name: {}, request-id: {}] to response for device [tenant-id: {}, device-id: {}]", command.getName(), command.getRequestId(), command.getTenant(), command.getDeviceId()); if (!command.isOneWay()) { response.putHeader(Constants.HEADER_COMMAND_REQUEST_ID, command.getRequestId()); currentSpan.setTag(Constants.HEADER_COMMAND_REQUEST_ID, command.getRequestId()); } response.setStatusCode(HttpURLConnection.HTTP_OK); HttpUtils.setResponseBody(response, command.getPayload(), command.getContentType()); } }
private void setResponsePayload(final HttpServerResponse response, final CommandContext commandContext, final Span currentSpan) { if (commandContext == null) { response.setStatusCode(HttpURLConnection.HTTP_ACCEPTED); } else { final Command command = commandContext.getCommand(); response.putHeader(Constants.HEADER_COMMAND, command.getName()); currentSpan.setTag(Constants.HEADER_COMMAND, command.getName()); LOG.trace("adding command [name: {}, request-id: {}] to response for device [tenant-id: {}, device-id: {}]", command.getName(), command.getRequestId(), command.getTenant(), command.getDeviceId()); if (!command.isOneWay()) { response.putHeader(Constants.HEADER_COMMAND_REQUEST_ID, command.getRequestId()); currentSpan.setTag(Constants.HEADER_COMMAND_REQUEST_ID, command.getRequestId()); } response.setStatusCode(HttpURLConnection.HTTP_OK); HttpUtils.setResponseBody(response, command.getPayload(), command.getContentType()); } }