Fixing issues in data types

revert-dabc3590
prabathabey 10 years ago
parent ab6c2717c9
commit 458171952e

@ -155,6 +155,15 @@
<artifactId>org.wso2.carbon.device.mgt.common</artifactId> <artifactId>org.wso2.carbon.device.mgt.common</artifactId>
<version>2.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
</dependency>
</dependencies> </dependencies>
<properties> <properties>
<cxf.version>2.6.1</cxf.version> <cxf.version>2.6.1</cxf.version>

@ -21,8 +21,8 @@ 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;
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.core.dto.Device;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
import javax.ws.rs.*; import javax.ws.rs.*;
@ -34,62 +34,66 @@ import javax.ws.rs.core.Response;
@Path("/enrollment") @Path("/enrollment")
public class Enrollment { public class Enrollment {
private static Log log = LogFactory.getLog(Enrollment.class); private static final Log log = LogFactory.getLog(Enrollment.class);
@POST
@Consumes("application/json")
public Response enrollDevice() {
JsonObject result = new JsonObject();
result.addProperty("senderId","jwwfowrjwqporqwrpqworpq");
CarbonContext context = CarbonContext.getThreadLocalCarbonContext();
DeviceManagementService dmService = (DeviceManagementService) context.getOSGiService(DeviceManagementService.class,null);
Device device = AndroidAPIUtil.convertToDeviceDTO(result);
try {
dmService.enrollDevice(null);
} catch (DeviceManagementException e) {
String msg = "Error occurred while enrolling the device";
log.error(msg, e);
}
return Response.status(201).entity("Registration Successful").build();
}
@GET @POST
@Path("{id}") @Consumes("application/json")
public String isEnrolled(@PathParam("id") String id) { public Response enrollDevice() {
CarbonContext context = CarbonContext.getThreadLocalCarbonContext(); JsonObject result = new JsonObject();
DeviceManagementService dmService = (DeviceManagementService) context.getOSGiService(DeviceManagementService.class,null); result.addProperty("senderId", "jwwfowrjwqporqwrpqworpq");
try { CarbonContext context = CarbonContext.getThreadLocalCarbonContext();
Device device = AndroidAPIUtil.convertToDeviceDTO(id); DeviceManagementService dmService =
dmService.isRegistered(null); (DeviceManagementService) context.getOSGiService(DeviceManagementService.class, null);
} catch (DeviceManagementException e) { Device device = AndroidAPIUtil.convertToDeviceDTO(result);
e.printStackTrace(); try {
} dmService.enrollDevice(device);
return "true"; } catch (DeviceManagementException e) {
} String msg = "Error occurred while enrolling the device";
log.error(msg, e);
}
return Response.status(201).entity("Registration Successful").build();
}
@PUT @GET
@Consumes("application/json") @Path("{id}")
@Path("{id}") public String isEnrolled(@PathParam("id") String id) {
public Response modifyEnrollment(@PathParam("id") String id) { CarbonContext context = CarbonContext.getThreadLocalCarbonContext();
CarbonContext context = CarbonContext.getThreadLocalCarbonContext(); DeviceManagementService dmService = (DeviceManagementService) context.getOSGiService(DeviceManagementService.class, null);
DeviceManagementService dmService = (DeviceManagementService) context.getOSGiService(DeviceManagementService.class,null); try {
try { Device device = AndroidAPIUtil.convertToDeviceDTO(id);
dmService.isRegistered(null); dmService.isRegistered(null);
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
e.printStackTrace(); e.printStackTrace();
} }
return Response.status(201).entity("Registration Successful").build(); return "true";
} }
@DELETE @PUT
@Path("{id}") @Consumes("application/json")
public Response disenrollDevice(@PathParam("id") String id) { @Path("{id}")
CarbonContext context = CarbonContext.getThreadLocalCarbonContext(); public Response modifyEnrollment(@PathParam("id") String id) {
DeviceManagementService dmService = (DeviceManagementService) context.getOSGiService(DeviceManagementService.class,null); CarbonContext context = CarbonContext.getThreadLocalCarbonContext();
try { DeviceManagementService dmService =
dmService.isRegistered(null); (DeviceManagementService) context.getOSGiService(DeviceManagementService.class, null);
} catch (DeviceManagementException e) { try {
e.printStackTrace(); dmService.isRegistered(null);
} } catch (DeviceManagementException e) {
return Response.status(201).entity("Registration Successful").build(); e.printStackTrace();
} }
return Response.status(201).entity("Registration Successful").build();
}
@DELETE
@Path("{id}")
public Response disenrollDevice(@PathParam("id") String id) {
CarbonContext context = CarbonContext.getThreadLocalCarbonContext();
DeviceManagementService dmService =
(DeviceManagementService) context.getOSGiService(DeviceManagementService.class, null);
try {
dmService.isRegistered(null);
} catch (DeviceManagementException e) {
e.printStackTrace();
}
return Response.status(201).entity("Registration Successful").build();
}
} }

Loading…
Cancel
Save