/** * Creates an empty response for a request ID that contains only the status. * * @param requestId The request ID of the command that this is the response for. * @param deviceId The device ID of the device sending the response. * @param status The HTTP status code indicating the outcome of the command. * @return The response or {@code null} if the request ID could not be parsed, the status is {@code null} or if the * status code is < 200 or >= 600. */ public static CommandResponse from(final String requestId, final String deviceId, final Integer status) { return from(requestId, deviceId, null, null, status); }
/** * Creates a command response for a reply-to ID, correlation ID and status. * * @param payload The command response payload. * @param contentType The content-type of the response payload. * @param status The HTTP status code indicating the outcome of executing the command on the device. * @param correlationId The identifier used to correlate this response with the command request. * @param address The address that the command response is to be sent to. * * @return The command response or {@code null} if any of correlationId, replyTo and status is null or if the * status code is < 200 or >= 600. */ public static CommandResponse from(final Buffer payload, final String contentType, final Integer status, final String correlationId, final ResourceIdentifier address) { if (correlationId == null || address == null || status == null) { return null; } else if (INVALID_STATUS_CODE.test(status)) { return null; } else { return new CommandResponse(payload, contentType, status, correlationId, address.getPathWithoutBase()); } }
private Message createResponseMessage(final CommandResponse commandResponse) { return createResponseMessage( targetAddress, commandResponse.getCorrelationId(), commandResponse.getContentType(), commandResponse.getPayload(), null, commandResponse.getStatus()); }
Objects.requireNonNull(response); final Future<CommandResponseSender> senderTracker = createCommandResponseSender(tenantId, response.getReplyToId()); return senderTracker .compose(sender -> sender.sendCommandResponse(response, context))
Objects.requireNonNull(response); final Future<CommandResponseSender> senderTracker = createCommandResponseSender(tenantId, response.getReplyToId()); return senderTracker .compose(sender -> sender.sendCommandResponse(response, context))
final CommandResponse commandResponse = CommandResponse.from(context.getMessagePayload(), context.getMessageContentType(), statusCode, correlationId, context.getResourceIdentifier());
final int lengthStringOne = Integer.parseInt(requestId.substring(1, 3), 16); final String replyId = requestId.substring(3 + lengthStringOne); return new CommandResponse( payload, contentType,
tenant, deviceId, commandRequestId, responseStatus); final CommandResponse commandResponse = CommandResponse.from(commandRequestId, deviceId, payload, contentType, responseStatus);
tenant, deviceId, commandRequestId, responseStatus); final CommandResponse commandResponse = CommandResponse.from(commandRequestId, deviceId, payload, contentType, responseStatus);
final Integer status = Integer.parseInt(addressPath[CommandConstants.TOPIC_POSITION_RESPONSE_STATUS]); final String reqId = addressPath[CommandConstants.TOPIC_POSITION_RESPONSE_REQ_ID]; final CommandResponse commandResponse = CommandResponse.from( reqId, targetAddress.getResourceId(), ctx.message().payload(), ctx.contentType(), status);
final Integer status = Integer.parseInt(addressPath[CommandConstants.TOPIC_POSITION_RESPONSE_STATUS]); final String reqId = addressPath[CommandConstants.TOPIC_POSITION_RESPONSE_REQ_ID]; final CommandResponse commandResponse = CommandResponse.from( reqId, targetAddress.getResourceId(), ctx.message().payload(), ctx.contentType(), status);