in iothub/device/iot-device-client/src/main/java/com/microsoft/azure/sdk/iot/device/transport/mqtt/MqttTwin.java [81:140]
private String buildTopic(final IotHubTransportMessage message)
{
StringBuilder topic = new StringBuilder();
switch (message.getDeviceOperationType())
{
case DEVICE_OPERATION_TWIN_GET_REQUEST:
{
//Building $iothub/twin/GET/?$rid={request id}
topic.append(GET);
String reqid = message.getRequestId();
if (reqid != null && reqid.length() > 0)
{
topic.append(BACKSLASH);
topic.append(REQ_ID);
topic.append(reqid);
}
else
{
throw new IllegalArgumentException("Request Id is Mandatory");
}
break;
}
case DEVICE_OPERATION_TWIN_UPDATE_REPORTED_PROPERTIES_REQUEST:
{
// Building $iothub/twin/PATCH/properties/reported/?$rid={request id}&$version={base version}
topic.append(PATCH);
topic.append(BACKSLASH);
topic.append(PROPERTIES);
topic.append(BACKSLASH);
topic.append(REPORTED);
String reqid = message.getRequestId();
if (reqid != null && reqid.length() > 0)
{
topic.append(BACKSLASH);
topic.append(REQ_ID);
topic.append(message.getRequestId());
}
else
{
throw new IllegalArgumentException("Request Id is Mandatory");
}
Integer version = message.getVersion();
if (version != null) {
topic.append(AND);
topic.append(VERSION);
topic.append(version);
}
break;
}
default:
{
throw new UnsupportedOperationException("Device Twin Operation is not supported - " + message.getDeviceOperationType());
}
}
return topic.toString();
}