From e45e19c5e8b6bff0a86363bd7c6fd9ba17f2a5a7 Mon Sep 17 00:00:00 2001 From: harshanL Date: Thu, 11 Dec 2014 18:29:11 +0530 Subject: [PATCH] Fixed issues in device management APIs --- .../jax-rs/src/main/java/cdm/api/android/Device.java | 9 ++++++--- .../main/java/cdm/api/android/util/AndroidAPIUtils.java | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java index 86d3fd3a2b..4bf8c21685 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java @@ -17,6 +17,7 @@ package cdm.api.android; import cdm.api.android.util.AndroidAPIUtils; +import com.google.gson.Gson; import com.google.gson.JsonObject; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -70,7 +71,8 @@ public class Device { } switch (status) { case 1: - return Response.status(200).entity(result).build(); + String response = new Gson().toJson(result); + return Response.status(200).entity(response).build(); case -1: return Response.status(500).entity(msg).build(); } @@ -83,7 +85,7 @@ public class Device { int status = 0; String msg = ""; DeviceManagementService dmService; - org.wso2.carbon.device.mgt.common.Device device = null; + org.wso2.carbon.device.mgt.common.Device device = new org.wso2.carbon.device.mgt.common.Device(); try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); @@ -111,7 +113,8 @@ public class Device { } switch (status) { case 1: - return Response.status(200).entity(device).build(); + String response = new Gson().toJson(device); + return Response.status(200).entity(response).build(); case -1: return Response.status(500).entity(msg).build(); } diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidAPIUtils.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidAPIUtils.java index f9f32a125f..94391d40ae 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidAPIUtils.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidAPIUtils.java @@ -31,7 +31,6 @@ public class AndroidAPIUtils { public static Device convertToDeviceObject(String jsonString) { JsonObject obj = new Gson().fromJson(jsonString, JsonObject.class); Device device = new Device(); - device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); if (obj.get(AndroidConstants.DeviceConstants.DEVICE_MAC_KEY) != null) { device.setDeviceIdentifier(