From 05f5807e6a11d029658a683dd603278c45b8f299 Mon Sep 17 00:00:00 2001 From: Menaka Madushanka Date: Mon, 11 Jan 2016 14:37:07 +0530 Subject: [PATCH 1/6] Device type view typo fixed : trouble shooting ---->>> troubleshooting --- .../type-view.hbs | 3 +-- .../cdmf.unit.device.type.arduino.type-view/type-view.hbs | 3 +-- .../type-view.hbs | 3 +-- .../type-view.hbs | 3 +-- .../cdmf.unit.device.type.raspberrypi.type-view/type-view.hbs | 3 +-- .../type-view.hbs | 3 +-- .../cdmf.unit.device.type.android.type-view/type-view.hbs | 3 +-- .../cdmf.unit.device.type.windows.type-view/type-view.hbs | 3 +-- 8 files changed, 8 insertions(+), 16 deletions(-) diff --git a/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs index fee37a2ee0..e6ae8967c3 100644 --- a/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs +++ b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs @@ -9,8 +9,7 @@
+ target="_blank">[ here ] for latest instructions and troubleshooting.
diff --git a/features/device-mgt-iot-arduino-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.hbs b/features/device-mgt-iot-arduino-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.hbs index d324ae9599..90ccb704fc 100644 --- a/features/device-mgt-iot-arduino-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.hbs +++ b/features/device-mgt-iot-arduino-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.hbs @@ -9,8 +9,7 @@
+ target="_blank">[ here ] for latest instructions and troubleshooting.
diff --git a/features/device-mgt-iot-digitaldisplay-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.digital_display.type-view/type-view.hbs b/features/device-mgt-iot-digitaldisplay-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.digital_display.type-view/type-view.hbs index 99d7db07e0..d6d30c132a 100644 --- a/features/device-mgt-iot-digitaldisplay-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.digital_display.type-view/type-view.hbs +++ b/features/device-mgt-iot-digitaldisplay-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.digital_display.type-view/type-view.hbs @@ -9,8 +9,7 @@
+ target="_blank">[ here ] for latest instructions and troubleshooting.
diff --git a/features/device-mgt-iot-droneanalyzer-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.drone_analyzer.type-view/type-view.hbs b/features/device-mgt-iot-droneanalyzer-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.drone_analyzer.type-view/type-view.hbs index 5fb7c271ef..0748cdb853 100644 --- a/features/device-mgt-iot-droneanalyzer-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.drone_analyzer.type-view/type-view.hbs +++ b/features/device-mgt-iot-droneanalyzer-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.drone_analyzer.type-view/type-view.hbs @@ -9,8 +9,7 @@
+ target="_blank">[ here ] for latest instructions and troubleshooting.
diff --git a/features/device-mgt-iot-raspberrypi-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.hbs b/features/device-mgt-iot-raspberrypi-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.hbs index a285c72f86..1a5fb8eea3 100644 --- a/features/device-mgt-iot-raspberrypi-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.hbs +++ b/features/device-mgt-iot-raspberrypi-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.hbs @@ -9,8 +9,7 @@
+ target="_blank">[ here ] for latest instructions and troubleshooting.
diff --git a/features/device-mgt-iot-virtualfirealarm-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.hbs b/features/device-mgt-iot-virtualfirealarm-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.hbs index 8b8266d0d8..f20111f212 100644 --- a/features/device-mgt-iot-virtualfirealarm-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.hbs +++ b/features/device-mgt-iot-virtualfirealarm-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.hbs @@ -8,8 +8,7 @@
+ target="_blank">[ here ] for latest instructions and troubleshooting.
diff --git a/features/device-mgt-mdm-android-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.hbs b/features/device-mgt-mdm-android-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.hbs index 0aeb79a807..09c98431b0 100644 --- a/features/device-mgt-mdm-android-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.hbs +++ b/features/device-mgt-mdm-android-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.hbs @@ -8,8 +8,7 @@
+ target="_blank">[ here ] for latest instructions and troubleshooting.
diff --git a/features/device-mgt-mdm-windows-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/type-view.hbs b/features/device-mgt-mdm-windows-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/type-view.hbs index 700c136ac1..ad002615ca 100644 --- a/features/device-mgt-mdm-windows-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/type-view.hbs +++ b/features/device-mgt-mdm-windows-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/type-view.hbs @@ -8,8 +8,7 @@
+ target="_blank">[ here ] for latest instructions and troubleshooting.
From 67199866a077a80c1a8a0480e8152537e17afbe2 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Wed, 13 Jan 2016 17:30:38 +0530 Subject: [PATCH 2/6] skipped reading from configuration file --- .../device/mgt/iot/apimgt/ApisAppClient.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 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 b1cc3ddb6a..0586fbd393 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 @@ -81,14 +81,19 @@ public class ApisAppClient { String consumerKeyAndSecret = deviceTypeToApiAppMap.get(deviceType); if(consumerKeyAndSecret == null){ ArrayList iotDeviceTypeConfigs = new ArrayList<>(); - IotDeviceTypeConfig DeviceTypeConfig = IotDeviceTypeConfigurationManager.getInstance().getIotDeviceTypeConfigMap().get(deviceType); - if(DeviceTypeConfig != null) { - iotDeviceTypeConfigs.add(DeviceTypeConfig); - setBase64EncodedConsumerKeyAndSecret(iotDeviceTypeConfigs); - consumerKeyAndSecret = deviceTypeToApiAppMap.get(deviceType); - if(consumerKeyAndSecret==null){ - log.warn("There is no API application for the device type " + deviceType); - } + IotDeviceTypeConfig deviceTypeConfig = IotDeviceTypeConfigurationManager.getInstance().getIotDeviceTypeConfigMap().get(deviceType); + if(deviceTypeConfig != null) { + iotDeviceTypeConfigs.add(deviceTypeConfig); + }else{ + deviceTypeConfig = new IotDeviceTypeConfig(); + deviceTypeConfig.setType(deviceType); + deviceTypeConfig.setApiApplicationName(deviceType); + iotDeviceTypeConfigs.add(deviceTypeConfig); + } + setBase64EncodedConsumerKeyAndSecret(iotDeviceTypeConfigs); + consumerKeyAndSecret = deviceTypeToApiAppMap.get(deviceType); + if(consumerKeyAndSecret==null){ + log.warn("There is no API application for the device type " + deviceType); } } return consumerKeyAndSecret; @@ -132,8 +137,6 @@ public class ApisAppClient { getMethod.setHeader("cookie", cookie); httpResponse = httpClient.execute(getMethod); response = IoTUtil.getResponseString(httpResponse); - - if(log.isDebugEnabled()) { log.debug(response); } From c72ebbe367ec6bac09dc4a90350761649df85bb9 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Wed, 13 Jan 2016 18:23:05 +0530 Subject: [PATCH 3/6] 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) { From 3a4b3ada46c63c3ddf453975f150fb50be48a699 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Wed, 13 Jan 2016 18:33:39 +0530 Subject: [PATCH 4/6] renamed the variable --- .../wso2/carbon/device/mgt/iot/apimgt/ApisAppClient.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 83a37fa28a..c25cab600e 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 @@ -51,7 +51,7 @@ public class ApisAppClient { private String loginEndpoint; private String subscriptionListEndpoint; private static Log log = LogFactory.getLog(ApisAppClient.class); - private boolean isEnabled; + private boolean isApiManagerEnabled; public static ApisAppClient getInstance(){ @@ -66,7 +66,7 @@ public class ApisAppClient { DeviceManagementConfigurationManager.getInstance().getDeviceCloudMgtConfig().getApiManager(); String serverUrl=apiManagerConfig.getServerURL(); String serverPort=apiManagerConfig.getServerPort(); - isEnabled = apiManagerConfig.isEnabled(); + isApiManagerEnabled = apiManagerConfig.isEnabled(); String loginURL = serverUrl+":"+serverPort+apiManagerConfig.getLoginURL(); loginEndpoint= loginURL+"?action=login&username="+apiManagerConfig.getUsername() @@ -77,7 +77,7 @@ public class ApisAppClient { } public String getBase64EncodedConsumerKeyAndSecret(String deviceType) { - if (!isEnabled) return null; + if (!isApiManagerEnabled) return null; String consumerKeyAndSecret = deviceTypeToApiAppMap.get(deviceType); if (consumerKeyAndSecret == null) { ArrayList iotDeviceTypeConfigs = new ArrayList<>(); @@ -106,7 +106,7 @@ public class ApisAppClient { } public void setBase64EncodedConsumerKeyAndSecret(List iotDeviceTypeConfigList) { - if(!isEnabled) return; + if(!isApiManagerEnabled) return; URL loginURL = null; try { From 20e3d4cb7870f736cd1ecb73694a67a8cf58928a Mon Sep 17 00:00:00 2001 From: charithag Date: Wed, 13 Jan 2016 19:27:13 +0530 Subject: [PATCH 5/6] Fix issues in documentation --- .../type-view.hbs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs index e6ae8967c3..4a4678c4cb 100644 --- a/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs +++ b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs @@ -164,7 +164,8 @@
  • 03   Fill login form with the credentials. - (Use server URL as [ https://<WSO2_IoT_SERVER_HOST>:<SERVER_PORT> ] and click on + (Use server URL as [ https://<WSO2_IoT_SERVER_HOST>:<HTTPS_SERVER_PORT> ] + and click on Register Device button.)
  • From b95e229d78720d0b9ea5a148492038093dcc8ef1 Mon Sep 17 00:00:00 2001 From: charithag Date: Wed, 13 Jan 2016 19:35:27 +0530 Subject: [PATCH 6/6] Get hostname from carbon.xml --- .../carbon/device/mgt/iot/util/IoTUtil.java | 24 ++++++++++++++++--- .../carbon/device/mgt/iot/util/ZipUtil.java | 21 +++++++++------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/IoTUtil.java b/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/IoTUtil.java index eba1be0d37..38bcc34f73 100644 --- a/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/IoTUtil.java +++ b/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/IoTUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -11,7 +11,7 @@ * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -32,12 +32,15 @@ import org.apache.http.impl.conn.PoolingClientConnectionManager; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpParams; import org.apache.http.util.EntityUtils; +import org.wso2.carbon.base.ServerConfiguration; import org.wso2.carbon.device.mgt.iot.exception.IoTException; import org.wso2.carbon.device.mgt.iot.internal.IoTCommonDataHolder; +import org.wso2.carbon.utils.NetworkUtils; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import java.net.SocketException; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; @@ -46,7 +49,8 @@ import java.security.UnrecoverableKeyException; public class IoTUtil { - private static final Log log = LogFactory.getLog(IoTUtil.class); + public static final String HOST_NAME = "HostName"; + private static final Log log = LogFactory.getLog(IoTUtil.class); /** * Return a http client instance @@ -106,4 +110,18 @@ public class IoTUtil { } } + public static String getHostName() throws IoTException { + String hostName = ServerConfiguration.getInstance().getFirstProperty(HOST_NAME); + + try { + if (hostName == null) { + hostName = NetworkUtils.getLocalHostname(); + } + } catch (SocketException e) { + throw new IoTException("Error while trying to read hostname.", e); + } + + return hostName; + } + } diff --git a/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/ZipUtil.java b/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/ZipUtil.java index 92905be56f..b6ab042a0d 100644 --- a/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/ZipUtil.java +++ b/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/ZipUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -11,7 +11,7 @@ * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -22,6 +22,7 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.iot.config.server.DeviceManagementConfigurationManager; import org.wso2.carbon.device.mgt.iot.controlqueue.mqtt.MqttConfig; import org.wso2.carbon.device.mgt.iot.controlqueue.xmpp.XmppConfig; +import org.wso2.carbon.device.mgt.iot.exception.IoTException; import org.wso2.carbon.device.mgt.iot.util.iotdevice.util.IotDeviceManagementUtil; import org.wso2.carbon.utils.CarbonUtils; @@ -33,7 +34,6 @@ import java.util.Map; public class ZipUtil { - private static final String LOCAL_BIND_ADDRESS_PROPERTY = "carbon.local.ip"; private static final String HTTPS_PORT_PROPERTY = "httpsPort"; private static final String HTTP_PORT_PROPERTY = "httpPort"; @@ -56,9 +56,14 @@ public class ZipUtil { String templateSketchPath = sketchFolder + sep + deviceType; String serverName = DeviceManagementConfigurationManager.getInstance().getDeviceManagementServerInfo().getName(); - String iotServerIP = System.getProperty(LOCAL_BIND_ADDRESS_PROPERTY); // bind.address - String httpsServerPort = System.getProperty(HTTPS_PORT_PROPERTY); - String httpServerPort = System.getProperty(HTTP_PORT_PROPERTY); + String iotServerIP; + try { + iotServerIP = IoTUtil.getHostName(); + } catch (IoTException e) { + throw new DeviceManagementException(e.getMessage()); + } + String httpsServerPort = System.getProperty(HTTPS_PORT_PROPERTY); + String httpServerPort = System.getProperty(HTTP_PORT_PROPERTY); String httpsServerEP = HTTPS_PROTOCOL_APPENDER + iotServerIP + ":" + httpsServerPort; String httpServerEP = HTTP_PROTOCOL_APPENDER + iotServerIP + ":" + httpServerPort; @@ -87,8 +92,8 @@ public class ZipUtil { xmppEndpoint = xmppEndpoint + ":" + XmppConfig.getInstance().getSERVER_CONNECTION_PORT(); - Map contextParams = new HashMap(); - contextParams.put("SERVER_NAME", serverName); + Map contextParams = new HashMap<>(); + contextParams.put("SERVER_NAME", serverName); contextParams.put("DEVICE_OWNER", owner); contextParams.put("DEVICE_ID", deviceId); contextParams.put("DEVICE_NAME", deviceName);