private void handleCBSResponseMessage()

in iothub/device/iot-device-client/src/main/java/com/microsoft/azure/sdk/iot/device/transport/amqps/AmqpsCbsReceiverLinkHandler.java [64:113]


    private void handleCBSResponseMessage(Receiver receiver)
    {
        AmqpsMessage amqpsMessage = super.getMessageFromReceiverLink(receiver);
        if (amqpsMessage != null)
        {
            if (amqpsMessage.getApplicationProperties() != null && amqpsMessage.getProperties() != null)
            {
                Properties properties = amqpsMessage.getProperties();
                UUID correlationId = (UUID) properties.getCorrelationId();
                Map<String, Object> applicationProperties = amqpsMessage.getApplicationProperties().getValue();

                if (!this.correlationMap.containsKey(correlationId))
                {
                    log.error("Received cbs authentication message with no correlation id. Ignoring it...");
                    amqpsMessage.acknowledge(Released.getInstance());
                    return;
                }

                AuthenticationMessageCallback authenticationMessageCallback = this.correlationMap.remove(correlationId);
                for (Map.Entry<String, Object> entry : applicationProperties.entrySet())
                {
                    String propertyKey = entry.getKey();
                    if (propertyKey.equals(APPLICATION_PROPERTY_STATUS_CODE) && entry.getValue() instanceof Integer)
                    {
                        int authenticationResponseCode = (int) entry.getValue();

                        String statusDescription = "";
                        if (applicationProperties.containsKey(APPLICATION_PROPERTY_STATUS_DESCRIPTION))
                        {
                            statusDescription = (String) applicationProperties.get(APPLICATION_PROPERTY_STATUS_DESCRIPTION);
                        }

                        DeliveryState ackType = authenticationMessageCallback.handleAuthenticationResponseMessage(authenticationResponseCode, statusDescription, receiver.getSession().getConnection().getReactor());
                        amqpsMessage.acknowledge(ackType);
                        return;
                    }
                }
            }
            else
            {
                log.warn("Could not handle authentication message because it had no application properties or had no system properties");
            }
        }

        // By default, we can't process the message
        if (amqpsMessage != null)
        {
            amqpsMessage.acknowledge(Released.getInstance());
        }
    }