private static void commonConstructorVerifications(IotHubClientProtocol protocol, DeviceClientConfig config) { if (protocol == IotHubClientProtocol.HTTPS) { throw new UnsupportedOperationException("Only MQTT, MQTT_WS, AMQPS and AMQPS_WS are supported for ModuleClient."); } if (config.getModuleId() == null || config.getModuleId().isEmpty()) { throw new IllegalArgumentException("Connection string must contain field for ModuleId"); } } }
private void commonConstructorVerifications() throws UnsupportedOperationException { if (this.getConfig().getModuleId() != null && !this.getConfig().getModuleId().isEmpty()) { throw new UnsupportedOperationException("DeviceClient connection string cannot contain module id. Use ModuleClient instead."); } }
@Override public void sendEventAsync(Message message, IotHubEventCallback callback, Object callbackContext) throws IllegalArgumentException { //Codes_SRS_MODULECLIENT_34_040: [This function shall set the message's connection moduleId to the config's saved module id.] message.setConnectionModuleId(this.config.getModuleId()); //Codes_SRS_MODULECLIENT_34_041: [This function shall invoke super.sendEventAsync(message, callback, callbackContext).] super.sendEventAsync(message, callback, callbackContext); }
/** * This constructor creates an instance of AmqpsDeviceMethods class and initializes member variables */ AmqpsDeviceMethods(DeviceClientConfig deviceClientConfig) throws IllegalArgumentException { // Codes_SRS_AMQPSDEVICEMETHODS_34_050: [This constructor shall call super with the provided user agent string.] super(deviceClientConfig, SENDER_LINK_ENDPOINT_PATH, RECEIVER_LINK_ENDPOINT_PATH, SENDER_LINK_ENDPOINT_PATH_MODULES, RECEIVER_LINK_ENDPOINT_PATH_MODULES, SENDER_LINK_TAG_PREFIX, RECEIVER_LINK_TAG_PREFIX); this.deviceClientConfig = deviceClientConfig; String moduleId = this.deviceClientConfig.getModuleId(); if (moduleId != null && !moduleId.isEmpty()) { // Codes_SRS_AMQPSDEVICEMETHODS_34_037: [If a moduleId is present, the constructor shall add correlation ID key and a UUID value to the amqpProperties.] this.amqpProperties.put(Symbol.getSymbol(CORRELATION_ID_KEY), Symbol.getSymbol(CORRELATION_ID_KEY_PREFIX + UUID.randomUUID().toString())); } else { // Codes_SRS_AMQPSDEVICEMETHODS_12_007: [The constructor shall add correlation ID key and deviceId value to the amqpProperties.] this.amqpProperties.put(Symbol.getSymbol(CORRELATION_ID_KEY), Symbol.getSymbol(CORRELATION_ID_KEY_PREFIX + UUID.randomUUID().toString())); } // Codes_SRS_AMQPSDEVICEMETHODS_12_006: [The constructor shall add API version key and API version value to the amqpProperties.] this.amqpProperties.put(Symbol.getSymbol(API_VERSION_KEY), TransportUtils.IOTHUB_API_VERSION); }
String moduleId = deviceClientConfig.getModuleId(); String deviceId = deviceClientConfig.getDeviceId(); if (moduleId != null && !moduleId.isEmpty())
public static String buildExceptionMessage(String baseMessage, Collection<InternalClient> clients) { String hostname = ""; String protocol = ""; Collection<String> deviceIds = new ArrayList<>(); Collection<String> moduleIds = new ArrayList<>(); for (InternalClient client : clients) { hostname = client.getConfig().getIotHubHostname(); protocol = client.getConfig().getProtocol().toString(); deviceIds.add(client.getConfig().getDeviceId()); if (client.getConfig().getModuleId() != null && !client.getConfig().getModuleId().isEmpty()) { moduleIds.add(client.getConfig().getModuleId()); } } return buildExceptionMessage( baseMessage, deviceIds, protocol, hostname, moduleIds); }
public ResponseMessage sendFileUploadMessage(IotHubTransportMessage message) throws IOException { //Codes_SRS_HTTPSTRANSPORTMANAGER_34_028 [This function shall set the uri path of the provided message to the // format devices/<deviceid>/modules/<moduleid>/files if a moduleId is present or // devices/<deviceid>/modules/<moduleid>/files otherwise, and then send it.] String uri = new IotHubUri("", this.config.getDeviceId(), PATH_FILES_STRING, this.config.getModuleId()).toStringWithoutApiVersion(); message.setUriPath(uri); return this.send(message, new HashMap<String, String>()); }
public ResponseMessage sendFileUploadNotification(IotHubTransportMessage message) throws IOException { //Codes_SRS_HTTPSTRANSPORTMANAGER_34_029 [This function shall set the uri path of the provided message to the // format devices/<deviceid>/modules/<moduleid>/files/notifications if a moduleId is present or // devices/<deviceid>/modules/<moduleid>/files/notifications otherwise, and then send it.] String uri = new IotHubUri("", this.config.getDeviceId(), PATH_NOTIFICATIONS_STRING, this.config.getModuleId()).toStringWithoutApiVersion(); message.setUriPath(uri); return this.send(message, new HashMap<String, String>()); }
/** * This constructor creates an instance of AmqpsDeviceTelemetry class and initializes member variables * * @param deviceClientConfig The configuration settings for an IoT Hub client * @throws IllegalArgumentException if the deviceClientConfig argument is null */ AmqpsDeviceTelemetry(DeviceClientConfig deviceClientConfig) throws IllegalArgumentException { // Codes_SRS_AMQPSDEVICETELEMETRY_34_050: [This constructor shall call super with the provided user agent string.] super(deviceClientConfig, SENDER_LINK_ENDPOINT_PATH_DEVICES, RECEIVER_LINK_ENDPOINT_PATH_DEVICES, SENDER_LINK_ENDPOINT_PATH_MODULES, deviceClientConfig.getGatewayHostname() != null ? RECEIVER_LINK_ENDPOINT_PATH_MODULES_EDGEHUB : RECEIVER_LINK_ENDPOINT_PATH_MODULES, SENDER_LINK_TAG_PREFIX, RECEIVER_LINK_TAG_PREFIX); this.deviceClientConfig = deviceClientConfig; String moduleId = this.deviceClientConfig.getModuleId(); if (moduleId != null && !moduleId.isEmpty()) { this.amqpProperties.put(Symbol.getSymbol(CORRELATION_ID_KEY), Symbol.getSymbol(this.deviceClientConfig.getDeviceId() + "/" + moduleId)); } else { this.amqpProperties.put(Symbol.getSymbol(CORRELATION_ID_KEY), Symbol.getSymbol(this.deviceClientConfig.getDeviceId())); } }
additionalHeaders.put(MODULE_ID, this.config.getDeviceId() + "/" + this.config.getModuleId());
public static String buildExceptionMessage(String baseMessage, InternalClient client) { if (client == null || client.getConfig() == null) { throw new IllegalArgumentException("client and config must not be null"); } return buildExceptionMessage( baseMessage, client.getConfig().getDeviceId(), client.getConfig().getProtocol().toString(), client.getConfig().getIotHubHostname(), client.getConfig().getModuleId()); }
String moduleId = this.getConfig().getModuleId(); if (!(moduleId == null || moduleId.isEmpty()))
public CorrelationDetailsLoggingAssert(InternalClient internalClient) { this(internalClient.getConfig().getIotHubHostname(), internalClient.getConfig().getDeviceId(), internalClient.getConfig().getProtocol().toString(), internalClient.getConfig().getModuleId()); }
String clientId = this.config.getDeviceId(); String moduleId = this.config.getModuleId(); if (moduleId != null && !moduleId.isEmpty()) this.deviceMessaging = new MqttMessaging(mqttConnection, this.config.getDeviceId(), this.listener, this, this.connectionId, this.config.getModuleId(), this.config.getGatewayHostname() != null); this.mqttConnection.setMqttCallback(this.deviceMessaging); this.deviceMethod = new MqttDeviceMethod(mqttConnection, this.connectionId);
new IotHubCompleteUri(iotHubHostname, deviceId, messageEtag, this.config.getModuleId()); resultUri += completeUri.toString(); new IotHubAbandonUri(iotHubHostname, deviceId, messageEtag, this.config.getModuleId()); resultUri += abandonUri.toString(); new IotHubRejectUri(iotHubHostname, deviceId, messageEtag, this.config.getModuleId()); resultUri += rejectUri.toString();
IotHubMessageUri messageUri = new IotHubMessageUri(getHostName(), this.config.getDeviceId(), this.config.getModuleId()); URL messageUrl = this.buildUrlFromString(HTTPS_HEAD_TAG + messageUri.toString());
String moduleId = this.config.getModuleId();