From c72ebbe367ec6bac09dc4a90350761649df85bb9 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Wed, 13 Jan 2016 18:23:05 +0530 Subject: [PATCH] with changes with formatting --- .../device/mgt/iot/apimgt/ApisAppClient.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/apimgt/ApisAppClient.java b/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/apimgt/ApisAppClient.java index 0586fbd393..83a37fa28a 100644 --- a/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/apimgt/ApisAppClient.java +++ b/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/apimgt/ApisAppClient.java @@ -77,14 +77,20 @@ public class ApisAppClient { } public String getBase64EncodedConsumerKeyAndSecret(String deviceType) { - if(!isEnabled) return null; + if (!isEnabled) return null; String consumerKeyAndSecret = deviceTypeToApiAppMap.get(deviceType); - if(consumerKeyAndSecret == null){ + if (consumerKeyAndSecret == null) { ArrayList iotDeviceTypeConfigs = new ArrayList<>(); - IotDeviceTypeConfig deviceTypeConfig = IotDeviceTypeConfigurationManager.getInstance().getIotDeviceTypeConfigMap().get(deviceType); - if(deviceTypeConfig != null) { + IotDeviceTypeConfigurationManager deviceTypeConfigurationManager = + IotDeviceTypeConfigurationManager.getInstance(); + IotDeviceTypeConfig deviceTypeConfig = null; + if (deviceTypeConfigurationManager != null) { + deviceTypeConfig = deviceTypeConfigurationManager.getIotDeviceTypeConfigMap().get( + deviceType); + } + if (deviceTypeConfig != null) { iotDeviceTypeConfigs.add(deviceTypeConfig); - }else{ + } else { deviceTypeConfig = new IotDeviceTypeConfig(); deviceTypeConfig.setType(deviceType); deviceTypeConfig.setApiApplicationName(deviceType); @@ -92,11 +98,11 @@ public class ApisAppClient { } setBase64EncodedConsumerKeyAndSecret(iotDeviceTypeConfigs); consumerKeyAndSecret = deviceTypeToApiAppMap.get(deviceType); - if(consumerKeyAndSecret==null){ + if (consumerKeyAndSecret == null) { log.warn("There is no API application for the device type " + deviceType); } } - return consumerKeyAndSecret; + return consumerKeyAndSecret; } public void setBase64EncodedConsumerKeyAndSecret(List iotDeviceTypeConfigList) {