Fixed issues in device management APIs

merge-requests/7/head
harshanL 10 years ago
parent f091ce70c6
commit e45e19c5e8

@ -17,6 +17,7 @@
package cdm.api.android; package cdm.api.android;
import cdm.api.android.util.AndroidAPIUtils; import cdm.api.android.util.AndroidAPIUtils;
import com.google.gson.Gson;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -70,7 +71,8 @@ public class Device {
} }
switch (status) { switch (status) {
case 1: case 1:
return Response.status(200).entity(result).build(); String response = new Gson().toJson(result);
return Response.status(200).entity(response).build();
case -1: case -1:
return Response.status(500).entity(msg).build(); return Response.status(500).entity(msg).build();
} }
@ -83,7 +85,7 @@ public class Device {
int status = 0; int status = 0;
String msg = ""; String msg = "";
DeviceManagementService dmService; 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 { try {
PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
@ -111,7 +113,8 @@ public class Device {
} }
switch (status) { switch (status) {
case 1: case 1:
return Response.status(200).entity(device).build(); String response = new Gson().toJson(device);
return Response.status(200).entity(response).build();
case -1: case -1:
return Response.status(500).entity(msg).build(); return Response.status(500).entity(msg).build();
} }

@ -31,7 +31,6 @@ public class AndroidAPIUtils {
public static Device convertToDeviceObject(String jsonString) { public static Device convertToDeviceObject(String jsonString) {
JsonObject obj = new Gson().fromJson(jsonString, JsonObject.class); JsonObject obj = new Gson().fromJson(jsonString, JsonObject.class);
Device device = new Device(); Device device = new Device();
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
if (obj.get(AndroidConstants.DeviceConstants.DEVICE_MAC_KEY) != null) { if (obj.get(AndroidConstants.DeviceConstants.DEVICE_MAC_KEY) != null) {
device.setDeviceIdentifier( device.setDeviceIdentifier(

Loading…
Cancel
Save