Committing MDM android APIs responses standardization

revert-dabc3590
Kasun Delgolla 9 years ago
parent df6f420d6e
commit 4f33789d38

@ -21,18 +21,15 @@ package org.wso2.carbon.mdm.services.android.services.configuration;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
import org.wso2.carbon.mdm.services.android.util.Message;
import javax.jws.WebService;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/** /**
* Android Platform Configuration REST-API implementation. * Android Platform Configuration REST-API implementation.
* All end points supports JSON, XMl with content negotiation. * All end points supports JSON, XMl with content negotiation.
*/ */
@Api(value = "ConfigurationMgtService") @Api(value = "ConfigurationMgtService")
@WebService
@Produces({"application/json", "application/xml"}) @Produces({"application/json", "application/xml"})
@Consumes({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"})
public interface ConfigurationMgtService { public interface ConfigurationMgtService {
@ -48,7 +45,7 @@ public interface ConfigurationMgtService {
@ApiResponse(code = 201, message = "Android platform configuration saved successfully"), @ApiResponse(code = 201, message = "Android platform configuration saved successfully"),
@ApiResponse(code = 500, message = "Internal Server Error") @ApiResponse(code = 500, message = "Internal Server Error")
}) })
Message configureSettings(@ApiParam(name = "configuration", value = "AndroidPlatformConfiguration") Response configureSettings(@ApiParam(name = "configuration", value = "AndroidPlatformConfiguration")
TenantConfiguration configuration) throws AndroidAgentException; TenantConfiguration configuration) throws AndroidAgentException;
@GET @GET
@ -62,7 +59,7 @@ public interface ConfigurationMgtService {
@ApiResponse(code = 200, message = "Get Android Configurations"), @ApiResponse(code = 200, message = "Get Android Configurations"),
@ApiResponse(code = 500, message = "Server Error") @ApiResponse(code = 500, message = "Server Error")
}) })
TenantConfiguration getConfiguration() throws AndroidAgentException; Response getConfiguration() throws AndroidAgentException;
@PUT @PUT
@ApiOperation( @ApiOperation(
@ -77,6 +74,6 @@ public interface ConfigurationMgtService {
@ApiResponse(code = 500, message = "Error occurred while modifying configuration settings of " + @ApiResponse(code = 500, message = "Error occurred while modifying configuration settings of " +
"Android platform") "Android platform")
}) })
Message updateConfiguration(@ApiParam(name = "configuration", value = "AndroidPlatformConfiguration") Response updateConfiguration(@ApiParam(name = "configuration", value = "AndroidPlatformConfiguration")
TenantConfiguration configuration) throws AndroidAgentException; TenantConfiguration configuration) throws AndroidAgentException;
} }

@ -30,8 +30,6 @@ import org.wso2.carbon.mdm.services.android.services.configuration.Configuration
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
import org.wso2.carbon.mdm.services.android.util.AndroidConstants; import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
import org.wso2.carbon.mdm.services.android.util.Message; import org.wso2.carbon.mdm.services.android.util.Message;
import javax.jws.WebService;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.ArrayList; import java.util.ArrayList;
@ -41,14 +39,13 @@ import java.util.List;
* Android Platform Configuration REST-API implementation. * Android Platform Configuration REST-API implementation.
* All end points supports JSON, XMl with content negotiation. * All end points supports JSON, XMl with content negotiation.
*/ */
@WebService
@Produces({"application/json", "application/xml"}) @Produces({"application/json", "application/xml"})
@Consumes({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"})
public class ConfigurationMgtServiceImpl implements ConfigurationMgtService { public class ConfigurationMgtServiceImpl implements ConfigurationMgtService {
private static Log log = LogFactory.getLog(ConfigurationMgtServiceImpl.class); private static Log log = LogFactory.getLog(ConfigurationMgtServiceImpl.class);
@POST @POST
public Message configureSettings(TenantConfiguration configuration) public Response configureSettings(TenantConfiguration configuration)
throws AndroidAgentException { throws AndroidAgentException {
Message responseMsg = new Message(); Message responseMsg = new Message();
@ -82,15 +79,15 @@ public class ConfigurationMgtServiceImpl implements ConfigurationMgtService {
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
msg = "Error occurred while configuring the android platform"; msg = "Error occurred while configuring the android platform";
log.error(msg, e); log.error(msg, e);
throw new AndroidAgentException(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return responseMsg; return Response.status(Response.Status.CREATED).entity(responseMsg).build();
} }
@GET @GET
public TenantConfiguration getConfiguration() throws AndroidAgentException { public Response getConfiguration() throws AndroidAgentException {
String msg; String msg;
TenantConfiguration tenantConfiguration; TenantConfiguration tenantConfiguration = null;
List<ConfigurationEntry> configs; List<ConfigurationEntry> configs;
try { try {
tenantConfiguration = AndroidAPIUtils.getDeviceManagementService(). tenantConfiguration = AndroidAPIUtils.getDeviceManagementService().
@ -99,7 +96,7 @@ public class ConfigurationMgtServiceImpl implements ConfigurationMgtService {
configs = tenantConfiguration.getConfiguration(); configs = tenantConfiguration.getConfiguration();
} else { } else {
tenantConfiguration = new TenantConfiguration(); tenantConfiguration = new TenantConfiguration();
configs = new ArrayList<ConfigurationEntry>(); configs = new ArrayList<>();
} }
ConfigurationEntry entry = new ConfigurationEntry(); ConfigurationEntry entry = new ConfigurationEntry();
@ -117,13 +114,13 @@ public class ConfigurationMgtServiceImpl implements ConfigurationMgtService {
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
msg = "Error occurred while retrieving the Android tenant configuration"; msg = "Error occurred while retrieving the Android tenant configuration";
log.error(msg, e); log.error(msg, e);
throw new AndroidAgentException(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return tenantConfiguration; return Response.status(Response.Status.OK).entity(tenantConfiguration).build();
} }
@PUT @PUT
public Message updateConfiguration(TenantConfiguration configuration) throws AndroidAgentException { public Response updateConfiguration(TenantConfiguration configuration) throws AndroidAgentException {
String msg; String msg;
Message responseMsg = new Message(); Message responseMsg = new Message();
ConfigurationEntry licenseEntry = null; ConfigurationEntry licenseEntry = null;
@ -148,15 +145,16 @@ public class ConfigurationMgtServiceImpl implements ConfigurationMgtService {
} }
configuration.setConfiguration(configs); configuration.setConfiguration(configs);
AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration); AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
AndroidAPIUtils.getGCMService().resetTenantConfigCache();
Response.status(Response.Status.ACCEPTED); Response.status(Response.Status.ACCEPTED);
responseMsg.setResponseMessage("Android platform configuration has updated successfully."); responseMsg.setResponseMessage("Android platform configuration has updated successfully.");
responseMsg.setResponseCode(Response.Status.ACCEPTED.toString()); responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
msg = "Error occurred while modifying configuration settings of Android platform"; msg = "Error occurred while modifying configuration settings of Android platform";
log.error(msg, e); log.error(msg, e);
throw new AndroidAgentException(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return responseMsg; return Response.status(Response.Status.CREATED).entity(responseMsg).build();
} }
} }

@ -22,11 +22,9 @@ import io.swagger.annotations.*;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
import org.wso2.carbon.mdm.services.android.util.Message;
import javax.jws.WebService;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
/** /**
@ -35,7 +33,6 @@ import java.util.List;
*/ */
@Api(value = "DeviceManagementService", description = "Android Device Management REST-API implementation.") @Api(value = "DeviceManagementService", description = "Android Device Management REST-API implementation.")
@WebService
@Produces({"application/json", "application/xml"}) @Produces({"application/json", "application/xml"})
@Consumes({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"})
public interface DeviceManagementService { public interface DeviceManagementService {
@ -62,7 +59,7 @@ public interface DeviceManagementService {
@ApiResponse(code = 200, message = "List of Devices"), @ApiResponse(code = 200, message = "List of Devices"),
@ApiResponse(code = 500, message = "Error occurred while fetching the device list") @ApiResponse(code = 500, message = "Error occurred while fetching the device list")
}) })
List<org.wso2.carbon.device.mgt.common.Device> getAllDevices() throws AndroidAgentException; Response getAllDevices() throws AndroidAgentException;
/** /**
* Fetch Android device details of a given device Id. * Fetch Android device details of a given device Id.
@ -86,7 +83,7 @@ public interface DeviceManagementService {
@ApiResponse(code = 200, message = "Information of the given device"), @ApiResponse(code = 200, message = "Information of the given device"),
@ApiResponse(code = 500, message = "Error occurred while fetching the device information") @ApiResponse(code = 500, message = "Error occurred while fetching the device information")
}) })
org.wso2.carbon.device.mgt.common.Device getDevice(@ApiParam(name = "id", value = "deviceIdentifier") Response getDevice(@ApiParam(name = "id", value = "deviceIdentifier")
@PathParam("id") String id) throws AndroidAgentException; @PathParam("id") String id) throws AndroidAgentException;
/** /**
@ -110,7 +107,7 @@ public interface DeviceManagementService {
@ApiResponse(code = 304, message = "Device not found for the update") @ApiResponse(code = 304, message = "Device not found for the update")
}) })
@Path("{id}") @Path("{id}")
Message updateDevice(@ApiParam(name = "id", value = "deviceIdentifier") Response updateDevice(@ApiParam(name = "id", value = "deviceIdentifier")
@PathParam("id") String id, @ApiParam(name = "device", value = "deviceIdentifier") @PathParam("id") String id, @ApiParam(name = "device", value = "deviceIdentifier")
Device device) throws AndroidAgentException; Device device) throws AndroidAgentException;
@ -125,9 +122,9 @@ public interface DeviceManagementService {
@ApiResponse(code = 202, message = "Device information has modified successfully"), @ApiResponse(code = 202, message = "Device information has modified successfully"),
@ApiResponse(code = 500, message = "Error occurred while modifying the application list") @ApiResponse(code = 500, message = "Error occurred while modifying the application list")
}) })
Message updateApplicationList(@ApiParam(name = "id", value = "deviceIdentifier") @PathParam("id") String id, Response updateApplicationList(@ApiParam(name = "id", value = "deviceIdentifier") @PathParam("id") String id,
@ApiParam(name = "applications", value = "updatable applications") @ApiParam(name = "applications", value = "updatable applications")
List<Application> applications); List<Application> applications) throws AndroidAgentException;
@GET @GET
@Path("license") @Path("license")
@ -144,5 +141,5 @@ public interface DeviceManagementService {
@ApiResponse(code = 500, message = "Error occurred while retrieving the license configured for Android " + @ApiResponse(code = 500, message = "Error occurred while retrieving the license configured for Android " +
"device enrolment") "device enrolment")
}) })
String getLicense() throws AndroidAgentException; Response getLicense() throws AndroidAgentException;
} }

@ -28,10 +28,9 @@ import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
import org.wso2.carbon.mdm.services.android.services.devicemgt.DeviceManagementService;
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
import org.wso2.carbon.mdm.services.android.util.Message; import org.wso2.carbon.mdm.services.android.util.Message;
import javax.jws.WebService;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
@ -40,10 +39,9 @@ import java.util.List;
* Android Device Management REST-API implementation. * Android Device Management REST-API implementation.
* All end points supports JSON, XMl with content negotiation. * All end points supports JSON, XMl with content negotiation.
*/ */
@WebService
@Produces({"application/json", "application/xml"}) @Produces({"application/json", "application/xml"})
@Consumes({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"})
public class DeviceManagementServiceImpl { public class DeviceManagementServiceImpl implements DeviceManagementService {
private static Log log = LogFactory.getLog(DeviceManagementServiceImpl.class); private static Log log = LogFactory.getLog(DeviceManagementServiceImpl.class);
@ -54,7 +52,7 @@ public class DeviceManagementServiceImpl {
* @throws AndroidAgentException * @throws AndroidAgentException
*/ */
@GET @GET
public List<Device> getAllDevices() public Response getAllDevices()
throws AndroidAgentException { throws AndroidAgentException {
String msg; String msg;
List<Device> devices; List<Device> devices;
@ -66,9 +64,9 @@ public class DeviceManagementServiceImpl {
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
msg = "Error occurred while fetching the device list."; msg = "Error occurred while fetching the device list.";
log.error(msg, e); log.error(msg, e);
throw new AndroidAgentException(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return devices; return Response.status(Response.Status.OK).entity(devices).build();
} }
/** /**
@ -80,7 +78,7 @@ public class DeviceManagementServiceImpl {
*/ */
@GET @GET
@Path("{id}") @Path("{id}")
public Device getDevice(@PathParam("id") String id) public Response getDevice(@PathParam("id") String id)
throws AndroidAgentException { throws AndroidAgentException {
String msg; String msg;
@ -90,14 +88,14 @@ public class DeviceManagementServiceImpl {
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
if (device == null) { if (device == null) {
Response.status(Response.Status.NOT_FOUND); return Response.status(Response.Status.NOT_FOUND).build();
} }
} catch (DeviceManagementException deviceMgtEx) { } catch (DeviceManagementException deviceMgtEx) {
msg = "Error occurred while fetching the device information."; msg = "Error occurred while fetching the device information.";
log.error(msg, deviceMgtEx); log.error(msg, deviceMgtEx);
throw new AndroidAgentException(msg, deviceMgtEx); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return device; return Response.status(Response.Status.OK).entity(device).build();
} }
/** /**
@ -110,7 +108,7 @@ public class DeviceManagementServiceImpl {
*/ */
@PUT @PUT
@Path("{id}") @Path("{id}")
public Message updateDevice(@PathParam("id") String id, Device device) public Response updateDevice(@PathParam("id") String id, Device device)
throws AndroidAgentException { throws AndroidAgentException {
String msg; String msg;
Message responseMessage = new Message(); Message responseMessage = new Message();
@ -124,23 +122,22 @@ public class DeviceManagementServiceImpl {
result = AndroidAPIUtils.getDeviceManagementService() result = AndroidAPIUtils.getDeviceManagementService()
.updateDeviceInfo(deviceIdentifier, device); .updateDeviceInfo(deviceIdentifier, device);
if (result) { if (result) {
Response.status(Response.Status.ACCEPTED);
responseMessage.setResponseMessage("Device information has modified successfully."); responseMessage.setResponseMessage("Device information has modified successfully.");
return Response.status(Response.Status.ACCEPTED).entity(responseMessage).build();
} else { } else {
Response.status(Response.Status.NOT_MODIFIED);
responseMessage.setResponseMessage("Device not found for the update."); responseMessage.setResponseMessage("Device not found for the update.");
return Response.status(Response.Status.NOT_MODIFIED).entity(responseMessage).build();
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
msg = "Error occurred while modifying the device information."; msg = "Error occurred while modifying the device information.";
log.error(msg, e); log.error(msg, e);
throw new AndroidAgentException(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return responseMessage;
} }
@POST @POST
@Path("appList/{id}") @Path("appList/{id}")
public Message updateApplicationList(@PathParam("id") String id, List<Application> applications) public Response updateApplicationList(@PathParam("id") String id, List<Application> applications)
throws throws
AndroidAgentException { AndroidAgentException {
@ -151,22 +148,20 @@ public class DeviceManagementServiceImpl {
try { try {
AndroidAPIUtils.getApplicationManagerService(). AndroidAPIUtils.getApplicationManagerService().
updateApplicationListInstalledInDevice(deviceIdentifier, applications); updateApplicationListInstalledInDevice(deviceIdentifier, applications);
Response.status(Response.Status.ACCEPTED);
responseMessage.setResponseMessage("Device information has modified successfully."); responseMessage.setResponseMessage("Device information has modified successfully.");
return Response.status(Response.Status.ACCEPTED).entity(responseMessage).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
String msg = "Error occurred while modifying the application list."; String msg = "Error occurred while modifying the application list.";
log.error(msg, e); log.error(msg, e);
throw new AndroidAgentException(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return responseMessage;
} }
@GET @GET
@Path("license") @Path("license")
@Produces("text/html") @Produces("text/html")
public String getLicense() throws AndroidAgentException { public Response getLicense() throws AndroidAgentException {
License license; License license = null;
try { try {
license = license =
@ -176,9 +171,9 @@ public class DeviceManagementServiceImpl {
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error occurred while retrieving the license configured for Android device enrolment"; String msg = "Error occurred while retrieving the license configured for Android device enrolment";
log.error(msg, e); log.error(msg, e);
throw new AndroidAgentException(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return (license == null) ? null : license.getText(); return Response.status(Response.Status.OK).entity((license == null) ? null : license.getText()).build();
} }
} }

@ -20,11 +20,9 @@ package org.wso2.carbon.mdm.services.android.services.enrollment;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
import org.wso2.carbon.mdm.services.android.util.Message;
import javax.jws.WebService;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/** /**
* Android Device Enrollment REST-API implementation. * Android Device Enrollment REST-API implementation.
@ -32,7 +30,6 @@ import javax.ws.rs.core.MediaType;
*/ */
@Api(value = "EnrollmentService", description = "Android Device Enrollment REST-API implementation.") @Api(value = "EnrollmentService", description = "Android Device Enrollment REST-API implementation.")
@WebService
@Produces({"application/json", "application/xml"}) @Produces({"application/json", "application/xml"})
@Consumes({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"})
public interface EnrollmentService { public interface EnrollmentService {
@ -51,7 +48,7 @@ public interface EnrollmentService {
@ApiResponse(code = 201, message = "Device enrollment succeeded"), @ApiResponse(code = 201, message = "Device enrollment succeeded"),
@ApiResponse(code = 500, message = "Device enrollment failed"), @ApiResponse(code = 500, message = "Device enrollment failed"),
}) })
Message enrollDevice(@ApiParam(name = "device", value = "Device Information to be enroll") Response enrollDevice(@ApiParam(name = "device", value = "Device Information to be enroll")
org.wso2.carbon.device.mgt.common.Device device) throws AndroidAgentException; org.wso2.carbon.device.mgt.common.Device device) throws AndroidAgentException;
@GET @GET
@ -65,7 +62,7 @@ public interface EnrollmentService {
@ApiResponse(code = 202, message = "Device has already enrolled"), @ApiResponse(code = 202, message = "Device has already enrolled"),
@ApiResponse(code = 404, message = "Device not found") @ApiResponse(code = 404, message = "Device not found")
}) })
Message isEnrolled(@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId") String id) Response isEnrolled(@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId") String id)
throws AndroidAgentException; throws AndroidAgentException;
@PUT @PUT
@ -79,7 +76,7 @@ public interface EnrollmentService {
@ApiResponse(code = 202, message = "Device enrollment has updated successfully"), @ApiResponse(code = 202, message = "Device enrollment has updated successfully"),
@ApiResponse(code = 404, message = "Device not found for enrollment") @ApiResponse(code = 404, message = "Device not found for enrollment")
}) })
Message modifyEnrollment(@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId") String id, Response modifyEnrollment(@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId") String id,
@ApiParam(name = "device", value = "Device information to be modify") @ApiParam(name = "device", value = "Device information to be modify")
org.wso2.carbon.device.mgt.common.Device device) org.wso2.carbon.device.mgt.common.Device device)
throws AndroidAgentException; throws AndroidAgentException;
@ -95,6 +92,6 @@ public interface EnrollmentService {
@ApiResponse(code = 404, message = "Device not found") @ApiResponse(code = 404, message = "Device not found")
}) })
@Path("{deviceId}") @Path("{deviceId}")
Message disEnrollDevice(@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId") String id) Response disEnrollDevice(@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId") String id)
throws AndroidAgentException; throws AndroidAgentException;
} }

@ -27,8 +27,6 @@ import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
import org.wso2.carbon.mdm.services.android.services.enrollment.EnrollmentService; import org.wso2.carbon.mdm.services.android.services.enrollment.EnrollmentService;
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
import org.wso2.carbon.mdm.services.android.util.Message; import org.wso2.carbon.mdm.services.android.util.Message;
import javax.jws.WebService;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@ -36,7 +34,6 @@ import javax.ws.rs.core.Response;
* Android Device Enrollment REST-API implementation. * Android Device Enrollment REST-API implementation.
* All end points supports JSON, XMl with content negotiation. * All end points supports JSON, XMl with content negotiation.
*/ */
@WebService
@Produces({"application/json", "application/xml"}) @Produces({"application/json", "application/xml"})
@Consumes({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"})
public class EnrollmentServiceImpl implements EnrollmentService { public class EnrollmentServiceImpl implements EnrollmentService {
@ -44,7 +41,7 @@ public class EnrollmentServiceImpl implements EnrollmentService {
private static Log log = LogFactory.getLog(EnrollmentService.class); private static Log log = LogFactory.getLog(EnrollmentService.class);
@POST @POST
public Message enrollDevice(org.wso2.carbon.device.mgt.common.Device device) public Response enrollDevice(org.wso2.carbon.device.mgt.common.Device device)
throws AndroidAgentException { throws AndroidAgentException {
Message responseMsg = new Message(); Message responseMsg = new Message();
@ -56,23 +53,22 @@ public class EnrollmentServiceImpl implements EnrollmentService {
if (status) { if (status) {
Response.status(Response.Status.CREATED); Response.status(Response.Status.CREATED);
responseMsg.setResponseMessage("Device enrollment succeeded."); responseMsg.setResponseMessage("Device enrollment succeeded.");
responseMsg.setResponseCode(Response.Status.CREATED.toString()); return Response.status(Response.Status.CREATED).entity(responseMsg).build();
} else { } else {
Response.status(Response.Status.INTERNAL_SERVER_ERROR); Response.status(Response.Status.INTERNAL_SERVER_ERROR);
responseMsg.setResponseMessage("Device enrollment failed."); responseMsg.setResponseMessage("Device enrollment failed.");
responseMsg.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(responseMsg).build();
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
msg = "Error occurred while enrolling the device"; msg = "Error occurred while enrolling the device";
log.error(msg, e); log.error(msg, e);
throw new AndroidAgentException(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return responseMsg;
} }
@GET @GET
@Path("{deviceId}") @Path("{deviceId}")
public Message isEnrolled(@PathParam("deviceId") String id) throws AndroidAgentException { public Response isEnrolled(@PathParam("deviceId") String id) throws AndroidAgentException {
String msg; String msg;
boolean result; boolean result;
Message responseMsg = new Message(); Message responseMsg = new Message();
@ -83,11 +79,11 @@ public class EnrollmentServiceImpl implements EnrollmentService {
if (result) { if (result) {
responseMsg.setResponseMessage("Device has already enrolled"); responseMsg.setResponseMessage("Device has already enrolled");
responseMsg.setResponseCode(Response.Status.ACCEPTED.toString()); responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
Response.status(Response.Status.ACCEPTED); return Response.status(Response.Status.ACCEPTED).entity(responseMsg).build();
} else { } else {
responseMsg.setResponseMessage("Device not found"); responseMsg.setResponseMessage("Device not found");
responseMsg.setResponseCode(Response.Status.NOT_FOUND.toString()); responseMsg.setResponseCode(Response.Status.NOT_FOUND.toString());
Response.status(Response.Status.NOT_FOUND); return Response.status(Response.Status.NOT_FOUND).entity(responseMsg).build();
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
msg = "Error occurred while checking enrollment status of the device."; msg = "Error occurred while checking enrollment status of the device.";
@ -95,14 +91,13 @@ public class EnrollmentServiceImpl implements EnrollmentService {
responseMsg.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()); responseMsg.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.toString());
Response.status(Response.Status.INTERNAL_SERVER_ERROR); Response.status(Response.Status.INTERNAL_SERVER_ERROR);
log.error(msg, e); log.error(msg, e);
throw new AndroidAgentException(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return responseMsg;
} }
@PUT @PUT
@Path("{deviceId}") @Path("{deviceId}")
public Message modifyEnrollment(@PathParam("deviceId") String id, public Response modifyEnrollment(@PathParam("deviceId") String id,
org.wso2.carbon.device.mgt.common.Device device) org.wso2.carbon.device.mgt.common.Device device)
throws AndroidAgentException { throws AndroidAgentException {
String msg; String msg;
@ -114,23 +109,22 @@ public class EnrollmentServiceImpl implements EnrollmentService {
if (result) { if (result) {
responseMsg.setResponseMessage("Device enrollment has updated successfully"); responseMsg.setResponseMessage("Device enrollment has updated successfully");
responseMsg.setResponseCode(Response.Status.ACCEPTED.toString()); responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
Response.status(Response.Status.ACCEPTED); return Response.status(Response.Status.ACCEPTED).entity(responseMsg).build();
} else { } else {
responseMsg.setResponseMessage("Device not found for enrollment"); responseMsg.setResponseMessage("Device not found for enrollment");
responseMsg.setResponseCode(Response.Status.NOT_MODIFIED.toString()); responseMsg.setResponseCode(Response.Status.NOT_MODIFIED.toString());
Response.status(Response.Status.NOT_MODIFIED); return Response.status(Response.Status.NOT_MODIFIED).entity(responseMsg).build();
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
msg = "Error occurred while modifying enrollment of the device"; msg = "Error occurred while modifying enrollment of the device";
log.error(msg, e); log.error(msg, e);
throw new AndroidAgentException(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return responseMsg;
} }
@DELETE @DELETE
@Path("{deviceId}") @Path("{deviceId}")
public Message disEnrollDevice(@PathParam("deviceId") String id) throws AndroidAgentException { public Response disEnrollDevice(@PathParam("deviceId") String id) throws AndroidAgentException {
Message responseMsg = new Message(); Message responseMsg = new Message();
boolean result; boolean result;
String msg; String msg;
@ -141,18 +135,17 @@ public class EnrollmentServiceImpl implements EnrollmentService {
if (result) { if (result) {
responseMsg.setResponseMessage("Device has removed successfully"); responseMsg.setResponseMessage("Device has removed successfully");
responseMsg.setResponseCode(Response.Status.ACCEPTED.toString()); responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
Response.status(Response.Status.ACCEPTED); return Response.status(Response.Status.ACCEPTED).entity(responseMsg).build();
} else { } else {
responseMsg.setResponseMessage("Device not found"); responseMsg.setResponseMessage("Device not found");
responseMsg.setResponseCode(Response.Status.NOT_FOUND.toString()); responseMsg.setResponseCode(Response.Status.NOT_FOUND.toString());
Response.status(Response.Status.NOT_FOUND); return Response.status(Response.Status.NOT_FOUND).entity(responseMsg).build();
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
msg = "Error occurred while dis enrolling the device"; msg = "Error occurred while dis enrolling the device";
log.error(msg, e); log.error(msg, e);
throw new AndroidAgentException(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return responseMsg;
} }
} }

@ -50,7 +50,7 @@ public interface OperationMgtService {
@ApiResponse(code = 200, message = "List of pending operations"), @ApiResponse(code = 200, message = "List of pending operations"),
@ApiResponse(code = 500, message = "Issue in retrieving operation management service instance") @ApiResponse(code = 500, message = "Issue in retrieving operation management service instance")
}) })
List<? extends Operation> getPendingOperations( Response getPendingOperations(
@ApiParam(name = "acceptHeader", value = "Accept Header") @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "acceptHeader", value = "Accept Header") @HeaderParam(ACCEPT) String acceptHeader,
@ApiParam(name = "id", value = "DeviceIdentifier") @PathParam("id") String id, @ApiParam(name = "id", value = "DeviceIdentifier") @PathParam("id") String id,
@ApiParam(name = "resultOperations", value = "Device Operation Status") @ApiParam(name = "resultOperations", value = "Device Operation Status")
@ -62,17 +62,34 @@ public interface OperationMgtService {
consumes = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST", httpMethod = "POST",
value = "Adding a Device Lock on Android Devices", value = "Adding a Device Lock on Android Devices",
responseContainer = "List",
notes = "Using this API you have the option of hard locking an Android device, where the Administrator " + notes = "Using this API you have the option of hard locking an Android device, where the Administrator " +
"permanently locks the device or screen locking an Android device", "permanently locks the device or screen locking an Android device"
)
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Created"),
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
})
Response configureDeviceLock(@ApiParam(name = "acceptHeader", value = "Accept Header")
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "cameraBeanWrapper",
value = "Device lock configurations with device IDs") DeviceLockBeanWrapper deviceLockBeanWrapper);
@POST
@Path("unlock")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Adding a Device Unlock on Android Devices",
responseContainer = "List",
notes = "Using this API you have the option of unlocking an Android device, where the Administrator " +
"unlocks the device",
response = String.class) response = String.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 201, message = "created"), @ApiResponse(code = 201, message = "created"),
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance") @ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
}) })
Response configureDeviceLock(@ApiParam(name = "acceptHeader", value = "Accept Header") Response configureDeviceUnlock(@ApiParam(name = "acceptHeader", value = "Accept Header")
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs", value = @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs", value =
"DeviceIds to be enable device lock operation") "DeviceIds to be enable device unlock operation")
List<String> deviceIDs); List<String> deviceIDs);
@ -219,6 +236,22 @@ public interface OperationMgtService {
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs", @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs",
value = "Device Ids needs to be ring") List<String> deviceIDs); value = "Device Ids needs to be ring") List<String> deviceIDs);
@POST
@Path("reboot-device")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Rebooting Android Devices",
notes = "Reboot Android devices"
)
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Created"),
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
})
Response rebootDevice(@ApiParam(name = "acceptHeader", value = "Accept Header")
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs",
value = "Device Ids needs to be rebooted") List<String> deviceIDs);
@POST @POST
@ApiOperation( @ApiOperation(
consumes = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,
@ -256,6 +289,27 @@ public interface OperationMgtService {
value = "Properties of installed apps and device IDs") value = "Properties of installed apps and device IDs")
ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper); ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper);
@POST
@Path("update-application")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Updating an Application on Android Devices",
notes = "Update an application on an Android device. If the device you are updating the application" +
" has the WSO2 system service installed, the application update will happen in silent " +
"mode, else the device user's consent will be required"
)
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Created"),
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
})
Response updateApplication(@ApiParam(name = "acceptHeader", value = "Accept Header")
@HeaderParam(ACCEPT) String acceptHeader,
@ApiParam(name = "applicationUpdateBeanWrapper",
value = "Properties of updated apps and device IDs")
ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper);
@POST @POST
@Path("uninstall-application") @Path("uninstall-application")
@ApiOperation( @ApiOperation(
@ -293,6 +347,44 @@ public interface OperationMgtService {
value = "BlacklistApplications Configuration and DeviceIds") value = "BlacklistApplications Configuration and DeviceIds")
BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper); BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper);
@POST
@Path("upgrade-firmware")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Upgrading device firmware",
notes = "Device firmware upgrade"
)
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Created"),
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
})
Response upgradeFirmware(@ApiParam(name = "acceptHeader", value = "Accept Header")
@HeaderParam(ACCEPT) String acceptHeader,
@ApiParam(name = "upgradeFirmwareBeanWrapper",
value = "Firmware upgrade configuration and DeviceIds")
UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper);
@POST
@Path("vpn")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Configuring VPN on Android devices",
notes = "Configure VPN on Android devices"
)
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Created"),
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
})
Response configureVPN(@ApiParam(name = "acceptHeader", value = "Accept Header")
@HeaderParam(ACCEPT) String acceptHeader,
@ApiParam(name = "vpnBeanWrapper",
value = "VPN configuration and DeviceIds")
VpnBeanWrapper vpnBeanWrapper);
@POST @POST
@Path("notification") @Path("notification")
@ApiOperation( @ApiOperation(

@ -29,8 +29,8 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementExcept
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
import org.wso2.carbon.mdm.services.android.bean.*; import org.wso2.carbon.mdm.services.android.bean.*;
import org.wso2.carbon.mdm.services.android.bean.Notification;
import org.wso2.carbon.mdm.services.android.bean.wrapper.*; import org.wso2.carbon.mdm.services.android.bean.wrapper.*;
import org.wso2.carbon.mdm.services.android.exception.AndroidOperationException;
import org.wso2.carbon.mdm.services.android.services.operationmgt.OperationMgtService; import org.wso2.carbon.mdm.services.android.services.operationmgt.OperationMgtService;
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
import org.wso2.carbon.mdm.services.android.util.AndroidConstants; import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
@ -43,7 +43,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
public class OperationMgtServiceImpl { public class OperationMgtServiceImpl implements OperationMgtService {
private static Log log = LogFactory.getLog(OperationMgtService.class); private static Log log = LogFactory.getLog(OperationMgtService.class);
private static final String ACCEPT = "Accept"; private static final String ACCEPT = "Accept";
@ -52,28 +52,31 @@ public class OperationMgtServiceImpl {
@PUT @PUT
@Path("{id}") @Path("{id}")
public List<? extends Operation> getPendingOperations public Response getPendingOperations
(@HeaderParam(ACCEPT) String acceptHeader, @PathParam("id") String id, (@HeaderParam(ACCEPT) String acceptHeader, @PathParam("id") String id,
List<? extends Operation> resultOperations) { List<? extends Operation> resultOperations) {
Message message; Message message;
String errorMessage;
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader); MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
if (id == null || id.isEmpty()) { if (id == null || id.isEmpty()) {
String errorMessage = "Device identifier is null or empty, hence returning device not found"; errorMessage = "Device identifier is null or empty, hence returning device not found";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.BAD_REQUEST.toString()).build(); responseCode(Response.Status.BAD_REQUEST.toString()).build();
log.error(errorMessage); log.error(errorMessage);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
try { try {
if (!AndroidDeviceUtils.isValidDeviceIdentifier(deviceIdentifier)) { if (!AndroidDeviceUtils.isValidDeviceIdentifier(deviceIdentifier)) {
String errorMessage = "Device not found for identifier '" + id + "'"; errorMessage = "Device not found for identifier '" + id + "'";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.BAD_REQUEST.toString()).build(); responseCode(Response.Status.BAD_REQUEST.toString()).build();
log.error(errorMessage); log.error(errorMessage);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Invoking Android pending operations:" + id); log.debug("Invoking Android pending operations:" + id);
@ -82,33 +85,51 @@ public class OperationMgtServiceImpl {
updateOperations(id, resultOperations); updateOperations(id, resultOperations);
} }
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
log.error("Issue in retrieving operation management service instance", e); errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).type(
responseMediaType).build();
} catch (PolicyComplianceException e) { } catch (PolicyComplianceException e) {
log.error("Issue in updating Monitoring operation"); errorMessage = "Issue in updating Monitoring operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
log.error("Issue in retrieving device management service instance", e); errorMessage = "Issue in retrieving device management service instance";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).type(
responseMediaType).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
log.error("Issue in retrieving application management service instance", e); errorMessage = "Issue in retrieving application management service instance";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).type(
responseMediaType).build();
} catch (NotificationManagementException e) { } catch (NotificationManagementException e) {
log.error("Issue in retrieving Notification management service instance", e); errorMessage = "Issue in retrieving Notification management service instance";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).type(
responseMediaType).build();
} }
List<? extends Operation> pendingOperations; List<? extends Operation> pendingOperations;
try { try {
pendingOperations = AndroidAPIUtils.getPendingOperations(deviceIdentifier); pendingOperations = AndroidAPIUtils.getPendingOperations(deviceIdentifier);
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; errorMessage = "Issue in retrieving operation management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
return pendingOperations; return Response.status(Response.Status.CREATED).entity(pendingOperations).type(
responseMediaType).build();
} }
@POST @POST
@Path("lock") @Path("lock")
public Response configureDeviceLock(@HeaderParam(ACCEPT) String acceptHeader, List<String> deviceIDs) { public Response configureDeviceLock(@HeaderParam(ACCEPT) String acceptHeader,
DeviceLockBeanWrapper deviceLockBeanWrapper) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Invoking Android device lock operation"); log.debug("Invoking Android device lock operation");
@ -119,8 +140,56 @@ public class OperationMgtServiceImpl {
Response response; Response response;
try { try {
CommandOperation operation = new CommandOperation(); DeviceLock lock = deviceLockBeanWrapper.getOperation();
if (lock == null) {
String errorMessage = "Lock bean is empty";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
}
ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCK); operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCK);
operation.setType(Operation.Type.PROFILE);
operation.setEnabled(true);
operation.setPayLoad(lock.toJSON());
response = AndroidAPIUtils.getOperationResponse(deviceLockBeanWrapper.getDeviceIDs(), operation,
message, responseMediaType);
} catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
}
return response;
}
@POST
@Path("unlock")
public Response configureDeviceUnlock(@HeaderParam(ACCEPT) String acceptHeader, List<String> deviceIDs) {
if (log.isDebugEnabled()) {
log.debug("Invoking Android device unlock operation");
}
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
Message message = new Message();
Response response;
try {
CommandOperation operation = new CommandOperation();
operation.setCode(AndroidConstants.OperationCodes.DEVICE_UNLOCK);
operation.setType(Operation.Type.COMMAND); operation.setType(Operation.Type.COMMAND);
operation.setEnabled(true); operation.setEnabled(true);
response = AndroidAPIUtils.getOperationResponse(deviceIDs, operation, message, responseMediaType); response = AndroidAPIUtils.getOperationResponse(deviceIDs, operation, message, responseMediaType);
@ -129,13 +198,15 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
return response; return response;
} }
@ -161,13 +232,15 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -194,13 +267,15 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -239,13 +314,15 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -265,7 +342,6 @@ public class OperationMgtServiceImpl {
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
operation.setCode(AndroidConstants.OperationCodes.DEVICE_INFO); operation.setCode(AndroidConstants.OperationCodes.DEVICE_INFO);
operation.setType(Operation.Type.COMMAND); operation.setType(Operation.Type.COMMAND);
getApplications(acceptHeader, deviceIDs);
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation, message, return AndroidAPIUtils.getOperationResponse(deviceIDs, operation, message,
responseMediaType); responseMediaType);
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
@ -273,13 +349,15 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -307,13 +385,15 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -349,13 +429,15 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -383,13 +465,15 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -416,13 +500,50 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
}
}
@POST
@Path("reboot-device")
public Response rebootDevice(@HeaderParam(ACCEPT) String acceptHeader,
List<String> deviceIDs) {
if (log.isDebugEnabled()) {
log.debug("Invoking Android reboot-device device operation");
}
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
Message message = new Message();
try {
CommandOperation operation = new CommandOperation();
operation.setCode(AndroidConstants.OperationCodes.DEVICE_REBOOT);
operation.setType(Operation.Type.COMMAND);
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation, message,
responseMediaType);
} catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -450,13 +571,15 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -479,7 +602,12 @@ public class OperationMgtServiceImpl {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("The payload of the application installing operation is incorrect"); log.debug("The payload of the application installing operation is incorrect");
} }
throw new OperationManagementException("Issue in creating a new application installation instance"); String errorMessage = "Issue in creating a new application installation instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
@ -494,13 +622,66 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
}
}
@POST
@Path("update-application")
public Response updateApplication(@HeaderParam(ACCEPT) String acceptHeader,
ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper) {
if (log.isDebugEnabled()) {
log.debug("Invoking 'UpdateApplication' operation");
}
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
Message message = new Message();
try {
ApplicationUpdate applicationUpdate = applicationUpdateBeanWrapper.getOperation();
if (applicationUpdate == null) {
if (log.isDebugEnabled()) {
log.debug("The payload of the application update operation is incorrect");
}
String errorMessage = "Issue in creating a new application update instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
}
ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.UPDATE_APPLICATION);
operation.setType(Operation.Type.PROFILE);
operation.setPayLoad(applicationUpdate.toJSON());
return AndroidAPIUtils.getOperationResponse(applicationUpdateBeanWrapper.getDeviceIDs(),
operation, message, responseMediaType);
} catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -522,7 +703,12 @@ public class OperationMgtServiceImpl {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("The payload of the application uninstalling operation is incorrect"); log.debug("The payload of the application uninstalling operation is incorrect");
} }
throw new OperationManagementException("Issue in creating a new application uninstallation instance"); String errorMessage = "Issue in creating a new application uninstallation instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
@ -537,13 +723,15 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -565,7 +753,12 @@ public class OperationMgtServiceImpl {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("The payload of the blacklisting apps operation is incorrect"); log.debug("The payload of the blacklisting apps operation is incorrect");
} }
throw new OperationManagementException("Issue in creating a new blacklist applications instance"); String errorMessage = "Issue in creating a new blacklist applications instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
@ -581,13 +774,115 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
}
}
@POST
@Path("upgrade-firmware")
public Response upgradeFirmware(@HeaderParam(ACCEPT) String acceptHeader,
UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper) {
if (log.isDebugEnabled()) {
log.debug("Invoking Android upgrade-firmware device operation");
}
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
Message message = new Message();
try {
UpgradeFirmware upgradeFirmware = upgradeFirmwareBeanWrapper.getOperation();
if (upgradeFirmware == null) {
if (log.isDebugEnabled()) {
log.debug("The payload of the upgrade firmware operation is incorrect");
}
String errorMessage = "Issue in creating a new upgrade firmware instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
}
ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.UPGRADE_FIRMWARE);
operation.setType(Operation.Type.PROFILE);
operation.setPayLoad(upgradeFirmware.toJSON());
return AndroidAPIUtils.getOperationResponse(upgradeFirmwareBeanWrapper.getDeviceIDs(),
operation, message, responseMediaType);
} catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
}
}
@POST
@Path("vpn")
public Response configureVPN(@HeaderParam(ACCEPT) String acceptHeader,
VpnBeanWrapper vpnBeanWrapper) {
if (log.isDebugEnabled()) {
log.debug("Invoking Android VPN device operation");
}
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
Message message = new Message();
try {
Vpn vpn = vpnBeanWrapper.getOperation();
if (vpn == null) {
if (log.isDebugEnabled()) {
log.debug("The payload of the VPN operation is incorrect");
}
String errorMessage = "Issue in creating a new VPN instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
}
ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.VPN);
operation.setType(Operation.Type.PROFILE);
operation.setPayLoad(vpn.toJSON());
return AndroidAPIUtils.getOperationResponse(vpnBeanWrapper.getDeviceIDs(),
operation, message, responseMediaType);
} catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -609,7 +904,12 @@ public class OperationMgtServiceImpl {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("The payload of the notification operation is incorrect"); log.debug("The payload of the notification operation is incorrect");
} }
throw new OperationManagementException("Issue in creating a new notification instance"); String errorMessage = "Issue in creating a new notification instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
@ -625,13 +925,15 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -653,7 +955,12 @@ public class OperationMgtServiceImpl {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("The payload of the wifi operation is incorrect"); log.debug("The payload of the wifi operation is incorrect");
} }
throw new OperationManagementException("Issue in creating a new Wifi instance"); String errorMessage = "Issue in creating a new Wifi instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
@ -669,13 +976,15 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -697,7 +1006,12 @@ public class OperationMgtServiceImpl {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("The payload of the device encryption operation is incorrect"); log.debug("The payload of the device encryption operation is incorrect");
} }
throw new OperationManagementException("Issue in creating a new encryption instance"); String errorMessage = "Issue in creating a new encryption instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
@ -713,13 +1027,15 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -741,7 +1057,12 @@ public class OperationMgtServiceImpl {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("The payload of the change lock code operation is incorrect"); log.debug("The payload of the change lock code operation is incorrect");
} }
throw new OperationManagementException("Issue in retrieving a new lock-code instance"); String errorMessage = "Issue in retrieving a new lock-code instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
@ -757,13 +1078,15 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -785,7 +1108,12 @@ public class OperationMgtServiceImpl {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("The payload of the change password policy operation is incorrect"); log.debug("The payload of the change password policy operation is incorrect");
} }
throw new OperationManagementException("Issue in creating a new Password policy instance"); String errorMessage = "Issue in creating a new Password policy instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
@ -801,13 +1129,15 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -829,7 +1159,12 @@ public class OperationMgtServiceImpl {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("The payload of the add webclip operation is incorrect"); log.debug("The payload of the add webclip operation is incorrect");
} }
throw new OperationManagementException("Issue in creating a new web clip instance"); String errorMessage = "Issue in creating a new web clip instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
@ -845,13 +1180,15 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }
@ -874,7 +1211,12 @@ public class OperationMgtServiceImpl {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("The payload of the device disenrollment operation is incorrect"); log.debug("The payload of the device disenrollment operation is incorrect");
} }
throw new OperationManagementException("Issue in creating a new disenrollment instance"); String errorMessage = "Issue in creating a new disenrollment instance";
message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
@ -890,13 +1232,15 @@ public class OperationMgtServiceImpl {
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance"; String errorMessage = "Issue in retrieving device management service instance";
message = Message.responseMessage(errorMessage). message = Message.responseMessage(errorMessage).
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build(); responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
log.error(errorMessage, e); log.error(errorMessage, e);
throw new AndroidOperationException(message, responseMediaType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(
responseMediaType).build();
} }
} }

@ -26,6 +26,7 @@ import org.wso2.carbon.policy.mgt.common.ProfileFeature;
import javax.jws.WebService; import javax.jws.WebService;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
@Api(value = "PolicyMgtService", description = "Policy management related REST-API implementation.") @Api(value = "PolicyMgtService", description = "Policy management related REST-API implementation.")
@ -47,9 +48,9 @@ public interface PolicyMgtService {
@ApiResponse(code = 200, message = "Effective policy added to operation"), @ApiResponse(code = 200, message = "Effective policy added to operation"),
@ApiResponse(code = 204, message = "No effective policy found") @ApiResponse(code = 204, message = "No effective policy found")
}) })
Message getEffectivePolicy(@ApiParam(name = "acceptHeader", value = "Accept Header") @HeaderParam("Accept") Response getEffectivePolicy(@ApiParam(name = "acceptHeader", value = "Accept Header") @HeaderParam("Accept")
String acceptHeader, String acceptHeader,
@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId") @ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId")
String id) throws AndroidAgentException; String id) throws AndroidAgentException;
@GET @GET
@ -66,7 +67,7 @@ public interface PolicyMgtService {
@ApiResponse(code = 404, message = "Not Found"), @ApiResponse(code = 404, message = "Not Found"),
@ApiResponse(code = 500, message = "Error occurred while getting the features") @ApiResponse(code = 500, message = "Error occurred while getting the features")
}) })
List<ProfileFeature> getEffectiveFeatures(@ApiParam(name = "acceptHeader", value = "Accept Header") Response getEffectiveFeatures(@ApiParam(name = "acceptHeader", value = "Accept Header")
@HeaderParam("Accept") String acceptHeader, @HeaderParam("Accept") String acceptHeader,
@ApiParam(name = "deviceId", value = "DeviceIdentifier") @ApiParam(name = "deviceId", value = "DeviceIdentifier")
@PathParam("deviceId") String id) throws AndroidAgentException; @PathParam("deviceId") String id) throws AndroidAgentException;

@ -35,18 +35,20 @@ import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam; import javax.ws.rs.HeaderParam;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
public class PolicyMgtServiceImpl { public class PolicyMgtServiceImpl implements PolicyMgtService {
private static Log log = LogFactory.getLog(PolicyMgtService.class); private static Log log = LogFactory.getLog(PolicyMgtService.class);
@GET @GET
@Path("{deviceId}") @Path("{deviceId}")
public Message getEffectivePolicy(@HeaderParam("Accept") String acceptHeader, public Response getEffectivePolicy(@HeaderParam("Accept") String acceptHeader,
@PathParam("deviceId") String id) throws AndroidAgentException { @PathParam("deviceId") String id) throws AndroidAgentException {
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
Message responseMessage = new Message(); Message responseMessage = new Message();
Policy policy; Policy policy;
try { try {
@ -55,35 +57,44 @@ public class PolicyMgtServiceImpl {
if (policy == null) { if (policy == null) {
responseMessage = Message.responseMessage("No effective policy found"). responseMessage = Message.responseMessage("No effective policy found").
responseCode(Response.Status.NO_CONTENT.toString()).build(); responseCode(Response.Status.NO_CONTENT.toString()).build();
return Response.status(Response.Status.NO_CONTENT).entity(responseMessage).type(
responseMediaType).build();
} else { } else {
responseMessage = Message.responseMessage("Effective policy added to operation"). responseMessage = Message.responseMessage("Effective policy added to operation").
responseCode(Response.Status.OK.toString()).build(); responseCode(Response.Status.OK.toString()).build();
return Response.status(Response.Status.OK).entity(responseMessage).type(
responseMediaType).build();
} }
} catch (PolicyManagementException e) { } catch (PolicyManagementException e) {
String msg = "Error occurred while getting the policy."; String msg = "Error occurred while getting the policy.";
log.error(msg, e); log.error(msg, e);
throw new AndroidAgentException(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).type(
responseMediaType).build();
} }
return responseMessage;
} }
@GET @GET
@Path("/features/{deviceId}") @Path("/features/{deviceId}")
public List<ProfileFeature> getEffectiveFeatures(@HeaderParam("Accept") String acceptHeader, public Response getEffectiveFeatures(@HeaderParam("Accept") String acceptHeader,
@PathParam("deviceId") String id) throws AndroidAgentException { @PathParam("deviceId") String id) throws AndroidAgentException {
List<ProfileFeature> profileFeatures; List<ProfileFeature> profileFeatures;
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
try { try {
PolicyManagerService policyManagerService = AndroidAPIUtils.getPolicyManagerService(); PolicyManagerService policyManagerService = AndroidAPIUtils.getPolicyManagerService();
profileFeatures = policyManagerService.getEffectiveFeatures(deviceIdentifier); profileFeatures = policyManagerService.getEffectiveFeatures(deviceIdentifier);
if (profileFeatures == null) { if (profileFeatures == null) {
Response.status(Response.Status.NOT_FOUND); Response.status(Response.Status.NOT_FOUND);
return Response.status(Response.Status.NOT_FOUND).type(
responseMediaType).build();
} }
} catch (FeatureManagementException e) { } catch (FeatureManagementException e) {
String msg = "Error occurred while getting the features."; String msg = "Error occurred while getting the features.";
log.error(msg, e); log.error(msg, e);
throw new AndroidAgentException(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).type(
responseMediaType).build();
} }
return profileFeatures; return Response.status(Response.Status.OK).entity(profileFeatures).type(
responseMediaType).build();
} }
} }

@ -281,7 +281,7 @@ public class AndroidAPIUtils {
deviceInfo.setDeviceIdentifier(deviceIdentifier); deviceInfo.setDeviceIdentifier(deviceIdentifier);
updateDeviceInfo(deviceInfo); updateDeviceInfo(deviceInfo);
} catch (DeviceDetailsMgtException e) { } catch (DeviceDetailsMgtException e) {
throw new OperationManagementException("Error occurred while updating the device infomation.", e); throw new OperationManagementException("Error occurred while updating the device information.", e);
} }

@ -46,6 +46,14 @@
<scope>emm_admin,emm_user</scope> <scope>emm_admin,emm_user</scope>
</Permission> </Permission>
<Permission>
<name>Unlock</name>
<path>/device-mgt/android/operations/unlock</path>
<url>/operation/unlock</url>
<method>POST</method>
<scope>emm_admin,emm_user</scope>
</Permission>
<Permission> <Permission>
<name>Mute</name> <name>Mute</name>
<path>/device-mgt/android/operations/mute</path> <path>/device-mgt/android/operations/mute</path>
@ -117,6 +125,30 @@
<scope>emm_admin,emm_user</scope> <scope>emm_admin,emm_user</scope>
</Permission> </Permission>
<Permission>
<name>Reboot</name>
<path>/device-mgt/android/operations/reboot-device</path>
<url>/operation/reboot-device</url>
<method>POST</method>
<scope>emm_admin,emm_user</scope>
</Permission>
<Permission>
<name>Upgrade Firmware</name>
<path>/device-mgt/android/operations/upgrade-firmware</path>
<url>/operation/upgrade-firmware</url>
<method>POST</method>
<scope>emm_admin,emm_user</scope>
</Permission>
<Permission>
<name>Configure VPN</name>
<path>/device-mgt/android/operations/vpn</path>
<url>/operation/vpn</url>
<method>POST</method>
<scope>emm_admin,emm_user</scope>
</Permission>
<Permission> <Permission>
<name>Install Application</name> <name>Install Application</name>
<path>/device-mgt/android/operations/install-application</path> <path>/device-mgt/android/operations/install-application</path>
@ -125,6 +157,14 @@
<scope>emm_admin,emm_user</scope> <scope>emm_admin,emm_user</scope>
</Permission> </Permission>
<Permission>
<name>Update Application</name>
<path>/device-mgt/android/operations/update-application</path>
<url>/operation/update-application</url>
<method>POST</method>
<scope>emm_admin,emm_user</scope>
</Permission>
<Permission> <Permission>
<name>Uninstall Application</name> <name>Uninstall Application</name>
<path>/device-mgt/android/operations/uninstall-application</path> <path>/device-mgt/android/operations/uninstall-application</path>
@ -312,4 +352,32 @@
<method>PUT</method> <method>PUT</method>
<scope>emm_admin</scope> <scope>emm_admin</scope>
</Permission> </Permission>
<Permission>
<name>Event Addition</name>
<path>/device-mgt/android/events/add</path>
<url>/events</url>
<method>POST</method>
<scope>emm_user,emm_admin</scope>
</Permission>
<Permission>
<name>Event Retrieve</name>
<path>/device-mgt/android/events/view</path>
<url>/events/*</url>
<method>GET</method>
<scope>emm_admin</scope>
</Permission>
<Permission>
<name>Event Retrieve</name>
<path>/device-mgt/android/events/date</path>
<url>/events/*/date</url>
<method>GET</method>
<scope>emm_admin</scope>
</Permission>
<Permission>
<name>Event Retrieve</name>
<path>/device-mgt/android/events/type</path>
<url>/events/*/type/*</url>
<method>GET</method>
<scope>emm_admin</scope>
</Permission>
</PermissionConfiguration> </PermissionConfiguration>

@ -68,13 +68,22 @@
<ref bean="errorHandler"/> <ref bean="errorHandler"/>
</jaxrs:providers> </jaxrs:providers>
</jaxrs:server> </jaxrs:server>
<jaxrs:server id="eventService" address="/events">
<jaxrs:serviceBeans>
<ref bean="eventServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<bean id="deviceMgtServiceBean" class="org.wso2.carbon.mdm.services.android.services.devicemgt.DeviceManagementServiceImpl"/> <bean id="deviceMgtServiceBean" class="org.wso2.carbon.mdm.services.android.services.devicemgt.impl.DeviceManagementServiceImpl"/>
<bean id="enrollmentServiceBean" class="org.wso2.carbon.mdm.services.android.services.enrollment.EnrollmentServiceImpl"/> <bean id="enrollmentServiceBean" class="org.wso2.carbon.mdm.services.android.services.enrollment.impl.EnrollmentServiceImpl"/>
<bean id="operationServiceBean" class="org.wso2.carbon.mdm.services.android.services.operationmgt.OperationMgtServiceImpl"/> <bean id="operationServiceBean" class="org.wso2.carbon.mdm.services.android.services.operationmgt.impl.OperationMgtServiceImpl"/>
<bean id="policyServiceBean" class="org.wso2.carbon.mdm.services.android.services.policymgt.PolicyMgtServiceImpl"/> <bean id="policyServiceBean" class="org.wso2.carbon.mdm.services.android.services.policymgt.impl.PolicyMgtServiceImpl"/>
<bean id="configurationServiceBean" class="org.wso2.carbon.mdm.services.android.services.configuration.ConfigurationMgtServiceImpl"/> <bean id="configurationServiceBean" class="org.wso2.carbon.mdm.services.android.services.configuration.impl.ConfigurationMgtServiceImpl"/>
<bean id="eventServiceBean" class="org.wso2.carbon.mdm.services.android.services.EventServiceImpl"/> <bean id="eventServiceBean" class="org.wso2.carbon.mdm.services.android.services.event.impl.EventServiceImpl"/>
<bean id="jsonProvider" class="org.wso2.carbon.mdm.services.android.common.GsonMessageBodyHandler"/> <bean id="jsonProvider" class="org.wso2.carbon.mdm.services.android.common.GsonMessageBodyHandler"/>
<bean id="errorHandler" class="org.wso2.carbon.mdm.services.android.common.ErrorHandler"/> <bean id="errorHandler" class="org.wso2.carbon.mdm.services.android.common.ErrorHandler"/>
</beans> </beans>

Loading…
Cancel
Save