diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml
new file mode 100644
index 0000000000..7d49ce4471
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml
@@ -0,0 +1,174 @@
+
+
+
+
+
+ device-mgt-mdm-android
+ org.wso2.carbon.devicemgt-plugins
+ 1.9.2-SNAPSHOT
+ ../pom.xml
+
+
+ 4.0.0
+ org.wso2.carbon.device.mgt.mobile.android.api
+ Android JAX-RS API
+ Android JAX-RS API
+ war
+
+
+
+
+ maven-compiler-plugin
+
+
+ 1.5
+
+ 2.3.2
+
+
+ maven-war-plugin
+ 2.2
+
+ WEB-INF/lib/*cxf*.jar
+ ${project.artifactId}
+
+
+
+
+
+
+
+ deploy
+
+ compile
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+ 1.7
+
+
+ compile
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ client
+
+ test
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 1.2.1
+
+
+ test
+
+ java
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.cxf
+ cxf-rt-frontend-jaxws
+
+
+ org.apache.cxf
+ cxf-rt-frontend-jaxrs
+
+
+ org.apache.cxf
+ cxf-rt-transports-http
+
+
+ javax.ws.rs
+ jsr311-api
+ provided
+
+
+ org.wso2.carbon
+ org.wso2.carbon.utils
+ provided
+
+
+ org.wso2.carbon
+ org.wso2.carbon.logging
+ provided
+
+
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.device.mgt.common
+ provided
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.device.mgt.core
+ provided
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.policy.mgt.common
+ provided
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.policy.mgt.core
+ provided
+
+
+
+ commons-httpclient.wso2
+ commons-httpclient
+ provided
+
+
+
+ com.google.code.gson
+ gson
+
+
+
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/ConfigurationMgtService.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/ConfigurationMgtService.java
new file mode 100644
index 0000000000..565393e498
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/ConfigurationMgtService.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * you may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
+import org.wso2.carbon.device.mgt.common.DeviceManagementException;
+import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
+import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
+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.util.AndroidAPIUtils;
+import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
+import org.wso2.carbon.mdm.services.android.util.Message;
+
+import javax.jws.WebService;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Android Platform Configuration REST-API implementation.
+ * All end points supports JSON, XMl with content negotiation.
+ */
+@WebService
+@Produces({ "application/json", "application/xml" })
+@Consumes({ "application/json", "application/xml" })
+public class ConfigurationMgtService {
+
+ private static Log log = LogFactory.getLog(ConfigurationMgtService.class);
+
+ @POST
+ public Message configureSettings(TenantConfiguration configuration)
+ throws AndroidAgentException {
+
+ Message responseMsg = new Message();
+ String msg;
+ ConfigurationEntry licenseEntry = null;
+ try {
+ configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
+ List configs = configuration.getConfiguration();
+ for(ConfigurationEntry entry : configs){
+ if(AndroidConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())){
+ License license = new License();
+ license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
+ license.setLanguage(AndroidConstants.TenantConfigProperties.LANGUAGE_US);
+ license.setVersion("1.0.0");
+ license.setText(entry.getValue().toString());
+ AndroidAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants.
+ MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, license);
+ licenseEntry = entry;
+ break;
+ }
+ }
+
+ if(licenseEntry != null) {
+ configs.remove(licenseEntry);
+ }
+ configuration.setConfiguration(configs);
+ AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
+ Response.status(Response.Status.CREATED);
+ responseMsg.setResponseMessage("Android platform configuration saved successfully.");
+ responseMsg.setResponseCode(Response.Status.CREATED.toString());
+ } catch (DeviceManagementException e) {
+ msg = "Error occurred while configuring the android platform";
+ log.error(msg, e);
+ throw new AndroidAgentException(msg, e);
+ }
+ return responseMsg;
+ }
+
+ @GET
+ public TenantConfiguration getConfiguration() throws AndroidAgentException {
+ String msg;
+ TenantConfiguration tenantConfiguration;
+ List configs;
+ try {
+ tenantConfiguration = AndroidAPIUtils.getDeviceManagementService().
+ getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
+ if(tenantConfiguration != null) {
+ configs = tenantConfiguration.getConfiguration();
+ } else {
+ tenantConfiguration = new TenantConfiguration();
+ configs = new ArrayList();
+ }
+
+ ConfigurationEntry entry = new ConfigurationEntry();
+ License license = AndroidAPIUtils.getDeviceManagementService().getLicense(
+ DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, AndroidConstants.
+ TenantConfigProperties.LANGUAGE_US);
+
+ if(license != null && configs != null) {
+ entry.setContentType(AndroidConstants.TenantConfigProperties.CONTENT_TYPE_TEXT);
+ entry.setName(AndroidConstants.TenantConfigProperties.LICENSE_KEY);
+ entry.setValue(license.getText());
+ configs.add(entry);
+ tenantConfiguration.setConfiguration(configs);
+ }
+ } catch (DeviceManagementException e) {
+ msg = "Error occurred while retrieving the Android tenant configuration";
+ log.error(msg, e);
+ throw new AndroidAgentException(msg, e);
+ }
+ return tenantConfiguration;
+ }
+
+ @PUT
+ public Message updateConfiguration(TenantConfiguration configuration) throws AndroidAgentException {
+ String msg;
+ Message responseMsg = new Message();
+ ConfigurationEntry licenseEntry = null;
+ try {
+ configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
+ List configs = configuration.getConfiguration();
+ for(ConfigurationEntry entry : configs){
+ if(AndroidConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())){
+ License license = new License();
+ license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
+ license.setLanguage(AndroidConstants.TenantConfigProperties.LANGUAGE_US);
+ license.setVersion("1.0.0");
+ license.setText(entry.getValue().toString());
+ AndroidAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants.
+ MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, license);
+ licenseEntry = entry;
+ }
+ }
+
+ if(licenseEntry != null) {
+ configs.remove(licenseEntry);
+ }
+ configuration.setConfiguration(configs);
+ AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
+ Response.status(Response.Status.ACCEPTED);
+ responseMsg.setResponseMessage("Android platform configuration has updated successfully.");
+ responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
+ } catch (DeviceManagementException e) {
+ msg = "Error occurred while modifying configuration settings of Android platform";
+ log.error(msg, e);
+ throw new AndroidAgentException(msg, e);
+ }
+ return responseMsg;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/DeviceManagementService.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/DeviceManagementService.java
new file mode 100644
index 0000000000..a6be42cdc4
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/DeviceManagementService.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.mdm.services.android;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.device.mgt.common.Device;
+import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
+import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
+import org.wso2.carbon.device.mgt.common.DeviceManagementException;
+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.license.mgt.License;
+import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
+import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
+import org.wso2.carbon.mdm.services.android.util.Message;
+
+import javax.jws.WebService;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
+import java.util.List;
+
+/**
+ * Android Device Management REST-API implementation.
+ * All end points supports JSON, XMl with content negotiation.
+ */
+@WebService
+@Produces({ "application/json", "application/xml" })
+@Consumes({ "application/json", "application/xml" })
+public class DeviceManagementService {
+
+ private static Log log = LogFactory.getLog(DeviceManagementService.class);
+
+ /**
+ * Get all devices.Returns list of Android devices registered in MDM.
+ *
+ * @return Device List
+ * @throws org.wso2.carbon.mdm.services.android.exception.AndroidAgentException
+ */
+ @GET
+ public List getAllDevices()
+ throws AndroidAgentException {
+ String msg;
+ List devices;
+
+ try {
+ devices = AndroidAPIUtils.getDeviceManagementService().
+ getAllDevices(DeviceManagementConstants.MobileDeviceTypes.
+ MOBILE_DEVICE_TYPE_ANDROID);
+ } catch (DeviceManagementException e) {
+ msg = "Error occurred while fetching the device list.";
+ log.error(msg, e);
+ throw new AndroidAgentException(msg, e);
+ }
+ return devices;
+ }
+
+ /**
+ * Fetch Android device details of a given device Id.
+ *
+ * @param id Device Id
+ * @return Device
+ * @throws org.wso2.carbon.mdm.services.android.exception.AndroidAgentException
+ */
+ @GET
+ @Path("{id}")
+ public org.wso2.carbon.device.mgt.common.Device getDevice(@PathParam("id") String id)
+ throws AndroidAgentException {
+
+ String msg;
+ org.wso2.carbon.device.mgt.common.Device device;
+
+ try {
+ DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
+ device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
+ if (device == null) {
+ Response.status(Response.Status.NOT_FOUND);
+ }
+ } catch (DeviceManagementException deviceMgtEx) {
+ msg = "Error occurred while fetching the device information.";
+ log.error(msg, deviceMgtEx);
+ throw new AndroidAgentException(msg, deviceMgtEx);
+ }
+ return device;
+ }
+
+ /**
+ * Update Android device details of given device id.
+ *
+ * @param id Device Id
+ * @param device Device Details
+ * @return Message
+ * @throws AndroidAgentException
+ */
+ @PUT
+ @Path("{id}")
+ public Message updateDevice(@PathParam("id") String id, Device device)
+ throws AndroidAgentException {
+ String msg;
+ Message responseMessage = new Message();
+ DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
+ deviceIdentifier.setId(id);
+ deviceIdentifier
+ .setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
+ boolean result;
+ try {
+ device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
+ result = AndroidAPIUtils.getDeviceManagementService()
+ .updateDeviceInfo(deviceIdentifier, device);
+ if (result) {
+ Response.status(Response.Status.ACCEPTED);
+ responseMessage.setResponseMessage("Device information has modified successfully.");
+ } else {
+ Response.status(Response.Status.NOT_MODIFIED);
+ responseMessage.setResponseMessage("Device not found for the update.");
+ }
+ } catch (DeviceManagementException e) {
+ msg = "Error occurred while modifying the device information.";
+ log.error(msg, e);
+ throw new AndroidAgentException(msg, e);
+ }
+ return responseMessage;
+ }
+
+ @POST
+ @Path("appList/{id}")
+ public Message updateApplicationList(@PathParam("id") String id, List applications)
+ throws
+ AndroidAgentException {
+
+ Message responseMessage = new Message();
+ DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
+ deviceIdentifier.setId(id);
+ deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
+ try {
+ AndroidAPIUtils.getApplicationManagerService().
+ updateApplicationListInstalledInDevice(deviceIdentifier, applications);
+ Response.status(Response.Status.ACCEPTED);
+ responseMessage.setResponseMessage("Device information has modified successfully.");
+
+ } catch (ApplicationManagementException e) {
+ String msg = "Error occurred while modifying the application list.";
+ log.error(msg, e);
+ throw new AndroidAgentException(msg, e);
+ }
+ return responseMessage;
+ }
+
+ @GET
+ @Path("license")
+ @Produces("text/html")
+ public String getLicense() throws AndroidAgentException {
+ License license;
+
+ try {
+ license =
+ AndroidAPIUtils.getDeviceManagementService().getLicense(
+ DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID,
+ DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US);
+ } catch (DeviceManagementException e) {
+ String msg = "Error occurred while retrieving the license configured for Android device enrolment";
+ log.error(msg, e);
+ throw new AndroidAgentException(msg, e);
+ }
+ return (license == null) ? null : license.getText();
+ }
+
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/EnrollmentService.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/EnrollmentService.java
new file mode 100644
index 0000000000..c8dc893890
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/EnrollmentService.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
+import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
+import org.wso2.carbon.device.mgt.common.DeviceManagementException;
+import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
+import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
+import org.wso2.carbon.mdm.services.android.util.Message;
+
+import javax.jws.WebService;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
+
+/**
+ * Android Device Enrollment REST-API implementation.
+ * All end points supports JSON, XMl with content negotiation.
+ */
+@WebService
+@Produces({ "application/json", "application/xml" })
+@Consumes({ "application/json", "application/xml" })
+public class EnrollmentService {
+
+ private static Log log = LogFactory.getLog(EnrollmentService.class);
+
+ @POST
+ public Message enrollDevice(org.wso2.carbon.device.mgt.common.Device device)
+ throws AndroidAgentException {
+
+ Message responseMsg = new Message();
+ String msg;
+ try {
+ device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
+ AndroidAPIUtils.getDeviceManagementService().enrollDevice(device);
+ Response.status(Response.Status.CREATED);
+ responseMsg.setResponseMessage("Device enrollment succeeded");
+ responseMsg.setResponseCode(Response.Status.CREATED.toString());
+ } catch (DeviceManagementException e) {
+ msg = "Error occurred while enrolling the device";
+ log.error(msg, e);
+ throw new AndroidAgentException(msg, e);
+ }
+ return responseMsg;
+ }
+
+ @GET
+ @Path("{deviceId}")
+ public Message isEnrolled(@PathParam("deviceId") String id) throws AndroidAgentException {
+ String msg;
+ boolean result;
+ Message responseMsg = new Message();
+ DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
+
+ try {
+ result = AndroidAPIUtils.getDeviceManagementService().isEnrolled(deviceIdentifier);
+ if (result) {
+ responseMsg.setResponseMessage("Device has already enrolled");
+ responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
+ Response.status(Response.Status.ACCEPTED);
+ } else {
+ responseMsg.setResponseMessage("Device not found");
+ responseMsg.setResponseCode(Response.Status.NOT_FOUND.toString());
+ Response.status(Response.Status.NOT_FOUND);
+ }
+ } catch (DeviceManagementException e) {
+ msg = "Error occurred while enrollment of the device.";
+ log.error(msg, e);
+ throw new AndroidAgentException(msg, e);
+ }
+ return responseMsg;
+ }
+
+ @PUT
+ @Path("{deviceId}")
+ public Message modifyEnrollment(@PathParam("deviceId") String id,
+ org.wso2.carbon.device.mgt.common.Device device)
+ throws AndroidAgentException {
+ String msg;
+ boolean result;
+ Message responseMsg = new Message();
+ try {
+ device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
+ result = AndroidAPIUtils.getDeviceManagementService().modifyEnrollment(device);
+ if (result) {
+ responseMsg.setResponseMessage("Device enrollment has updated successfully");
+ responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
+ Response.status(Response.Status.ACCEPTED);
+ } else {
+ responseMsg.setResponseMessage("Device not found for enrollment");
+ responseMsg.setResponseCode(Response.Status.NOT_MODIFIED.toString());
+ Response.status(Response.Status.NOT_MODIFIED);
+ }
+ } catch (DeviceManagementException e) {
+ msg = "Error occurred while modifying enrollment of the device";
+ log.error(msg, e);
+ throw new AndroidAgentException(msg, e);
+ }
+ return responseMsg;
+ }
+
+ @DELETE
+ @Path("{deviceId}")
+ public Message disEnrollDevice(@PathParam("deviceId") String id) throws AndroidAgentException {
+ Message responseMsg = new Message();
+ boolean result;
+ String msg;
+ DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
+
+ try {
+ result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier);
+ if (result) {
+ responseMsg.setResponseMessage("Device has removed successfully");
+ responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
+ Response.status(Response.Status.ACCEPTED);
+ } else {
+ responseMsg.setResponseMessage("Device not found");
+ responseMsg.setResponseCode(Response.Status.NOT_FOUND.toString());
+ Response.status(Response.Status.NOT_FOUND);
+ }
+ } catch (DeviceManagementException e) {
+ msg = "Error occurred while dis enrolling the device";
+ log.error(msg, e);
+ throw new AndroidAgentException(msg, e);
+ }
+ return responseMsg;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/OperationMgtService.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/OperationMgtService.java
new file mode 100644
index 0000000000..91329cc94b
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/OperationMgtService.java
@@ -0,0 +1,931 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
+import org.wso2.carbon.device.mgt.common.DeviceManagementException;
+import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
+import org.wso2.carbon.device.mgt.common.notification.mgt.*;
+import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
+import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
+import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
+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.Notification;
+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.util.AndroidAPIUtils;
+import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
+import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils;
+import org.wso2.carbon.mdm.services.android.util.Message;
+import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.List;
+
+/**
+ * Android Device Operation REST-API implementation.
+ */
+public class OperationMgtService {
+
+ private static Log log = LogFactory.getLog(OperationMgtService.class);
+ private static final String ACCEPT = "Accept";
+ private static final String OPERATION_ERROR_STATUS = "ERROR";
+ private static final String DEVICE_TYPE_ANDROID = "android";
+
+ @PUT
+ @Path("{id}")
+ public List extends Operation> getPendingOperations
+ (@HeaderParam(ACCEPT) String acceptHeader, @PathParam("id") String id,
+ List extends Operation> resultOperations) {
+ Message message;
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+
+ if (id == null || id.isEmpty()) {
+ String errorMessage = "Device identifier is null or empty, hence returning device not found";
+ message = Message.responseMessage(errorMessage).
+ responseCode(Response.Status.BAD_REQUEST.toString()).build();
+ log.error(errorMessage);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+
+ DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
+ try {
+ if (!AndroidDeviceUtils.isValidDeviceIdentifier(deviceIdentifier)) {
+ String errorMessage = "Device not found for identifier '" + id + "'";
+ message = Message.responseMessage(errorMessage).
+ responseCode(Response.Status.BAD_REQUEST.toString()).build();
+ log.error(errorMessage);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking Android pending operations:" + id);
+ }
+ if (resultOperations != null && !resultOperations.isEmpty()) {
+ updateOperations(id, resultOperations);
+ }
+ } catch (OperationManagementException e) {
+ log.error("Issue in retrieving operation management service instance", e);
+ } catch (PolicyComplianceException e) {
+ log.error("Issue in updating Monitoring operation");
+ } catch (DeviceManagementException e) {
+ log.error("Issue in retrieving device management service instance", e);
+ } catch (ApplicationManagementException e) {
+ log.error("Issue in retrieving application management service instance", e);
+ } catch (NotificationManagementException e) {
+ log.error("Issue in retrieving Notification management service instance", e);
+ }
+
+ List extends Operation> pendingOperations;
+ try {
+ pendingOperations = AndroidAPIUtils.getPendingOperations(deviceIdentifier);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ return pendingOperations;
+ }
+
+ @POST
+ @Path("lock")
+ public Response configureDeviceLock(@HeaderParam(ACCEPT) String acceptHeader, List deviceIDs) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking Android device lock operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+ Response response;
+
+ try {
+ CommandOperation operation = new CommandOperation();
+ operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCK);
+ operation.setType(Operation.Type.COMMAND);
+ operation.setEnabled(true);
+ response = 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ return response;
+ }
+
+ @POST
+ @Path("location")
+ public Response getDeviceLocation(@HeaderParam(ACCEPT) String acceptHeader,
+ List deviceIDs) {
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking Android device location operation");
+ }
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ CommandOperation operation = new CommandOperation();
+ operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCATION);
+ 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("clear-password")
+ public Response removePassword(@HeaderParam(ACCEPT) String acceptHeader,
+ List deviceIDs) {
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking Android clear password operation");
+ }
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ CommandOperation operation = new CommandOperation();
+ operation.setCode(AndroidConstants.OperationCodes.CLEAR_PASSWORD);
+ 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("camera")
+ public Response configureCamera(@HeaderParam(ACCEPT) String acceptHeader,
+ CameraBeanWrapper cameraBeanWrapper) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking Android Camera operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ Camera camera = cameraBeanWrapper.getOperation();
+
+ if (camera == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("The payload of the configure camera operation is incorrect");
+ }
+ throw new OperationManagementException("Issue in creating a new camera instance");
+ }
+
+ CommandOperation operation = new CommandOperation();
+ operation.setCode(AndroidConstants.OperationCodes.CAMERA);
+ operation.setType(Operation.Type.COMMAND);
+ operation.setEnabled(camera.isEnabled());
+
+ return AndroidAPIUtils.getOperationResponse(cameraBeanWrapper.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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("device-info")
+ public Response getDeviceInformation(@HeaderParam(ACCEPT) String acceptHeader,
+ List deviceIDs) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking get Android device information operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ CommandOperation operation = new CommandOperation();
+ operation.setCode(AndroidConstants.OperationCodes.DEVICE_INFO);
+ operation.setType(Operation.Type.COMMAND);
+ getApplications(acceptHeader, deviceIDs);
+ 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("enterprise-wipe")
+ public Response wipeDevice(@HeaderParam(ACCEPT) String acceptHeader,
+ List deviceIDs) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking enterprise-wipe device operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ CommandOperation operation = new CommandOperation();
+ operation.setCode(AndroidConstants.OperationCodes.ENTERPRISE_WIPE);
+ 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("wipe-data")
+ public Response wipeData(@HeaderParam(ACCEPT) String acceptHeader,
+ WipeDataBeanWrapper wipeDataBeanWrapper) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking Android wipe-data device operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ WipeData wipeData = wipeDataBeanWrapper.getOperation();
+
+ if (wipeData == null) {
+ throw new OperationManagementException("WipeData bean is empty");
+ }
+
+ ProfileOperation operation = new ProfileOperation();
+ operation.setCode(AndroidConstants.OperationCodes.WIPE_DATA);
+ operation.setType(Operation.Type.PROFILE);
+ operation.setPayLoad(wipeData.toJSON());
+
+ return AndroidAPIUtils.getOperationResponse(wipeDataBeanWrapper.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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("application-list")
+ public Response getApplications(@HeaderParam(ACCEPT) String acceptHeader,
+ List deviceIDs) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking Android getApplicationList device operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ CommandOperation operation = new CommandOperation();
+ operation.setCode(AndroidConstants.OperationCodes.APPLICATION_LIST);
+ 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("ring-device")
+ public Response ringDevice(@HeaderParam(ACCEPT) String acceptHeader,
+ List deviceIDs) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking Android ring-device device operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ CommandOperation operation = new CommandOperation();
+ operation.setCode(AndroidConstants.OperationCodes.DEVICE_RING);
+ 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("mute")
+ public Response muteDevice(@HeaderParam(ACCEPT) String acceptHeader,
+ List deviceIDs) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking mute device operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ CommandOperation operation = new CommandOperation();
+ operation.setCode(AndroidConstants.OperationCodes.DEVICE_MUTE);
+ operation.setType(Operation.Type.COMMAND);
+ operation.setEnabled(true);
+ 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("install-application")
+ public Response installApplication(@HeaderParam(ACCEPT) String acceptHeader,
+ ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking 'InstallApplication' operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ ApplicationInstallation applicationInstallation = applicationInstallationBeanWrapper.getOperation();
+
+ if (applicationInstallation == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("The payload of the application installing operation is incorrect");
+ }
+ throw new OperationManagementException("Issue in creating a new application installation instance");
+ }
+
+ ProfileOperation operation = new ProfileOperation();
+ operation.setCode(AndroidConstants.OperationCodes.INSTALL_APPLICATION);
+ operation.setType(Operation.Type.PROFILE);
+ operation.setPayLoad(applicationInstallation.toJSON());
+
+ return AndroidAPIUtils.getOperationResponse(applicationInstallationBeanWrapper.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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("uninstall-application")
+ public Response uninstallApplication(@HeaderParam(ACCEPT) String acceptHeader,
+ ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper) {
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking 'UninstallApplication' operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ ApplicationUninstallation applicationUninstallation = applicationUninstallationBeanWrapper.getOperation();
+
+ if (applicationUninstallation == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("The payload of the application uninstalling operation is incorrect");
+ }
+ throw new OperationManagementException("Issue in creating a new application uninstallation instance");
+ }
+
+ ProfileOperation operation = new ProfileOperation();
+ operation.setCode(AndroidConstants.OperationCodes.UNINSTALL_APPLICATION);
+ operation.setType(Operation.Type.PROFILE);
+ operation.setPayLoad(applicationUninstallation.toJSON());
+
+ return AndroidAPIUtils.getOperationResponse(applicationUninstallationBeanWrapper.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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("blacklist-applications")
+ public Response blacklistApplications(@HeaderParam(ACCEPT) String acceptHeader,
+ BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper) {
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking 'Blacklist-Applications' operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ BlacklistApplications blacklistApplications = blacklistApplicationsBeanWrapper.getOperation();
+
+ if (blacklistApplications == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("The payload of the blacklisting apps operation is incorrect");
+ }
+ throw new OperationManagementException("Issue in creating a new blacklist applications instance");
+ }
+
+ ProfileOperation operation = new ProfileOperation();
+ operation.setCode(AndroidConstants.OperationCodes.BLACKLIST_APPLICATIONS);
+ operation.setType(Operation.Type.PROFILE);
+ operation.setPayLoad(blacklistApplications.toJSON());
+
+ return AndroidAPIUtils.getOperationResponse(blacklistApplicationsBeanWrapper.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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("notification")
+ public Response sendNotification(@HeaderParam(ACCEPT) String acceptHeader,
+ NotificationBeanWrapper notificationBeanWrapper) {
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking 'notification' operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ Notification notification = notificationBeanWrapper.getOperation();
+
+ if (notification == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("The payload of the notification operation is incorrect");
+ }
+ throw new OperationManagementException("Issue in creating a new notification instance");
+ }
+
+ ProfileOperation operation = new ProfileOperation();
+ operation.setCode(AndroidConstants.OperationCodes.NOTIFICATION);
+ operation.setType(Operation.Type.PROFILE);
+ operation.setPayLoad(notification.toJSON());
+
+ return AndroidAPIUtils.getOperationResponse(notificationBeanWrapper.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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("wifi")
+ public Response configureWifi(@HeaderParam(ACCEPT) String acceptHeader,
+ WifiBeanWrapper wifiBeanWrapper) {
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking 'configure wifi' operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ Wifi wifi = wifiBeanWrapper.getOperation();
+
+ if (wifi == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("The payload of the wifi operation is incorrect");
+ }
+ throw new OperationManagementException("Issue in creating a new Wifi instance");
+ }
+
+ ProfileOperation operation = new ProfileOperation();
+ operation.setCode(AndroidConstants.OperationCodes.WIFI);
+ operation.setType(Operation.Type.PROFILE);
+ operation.setPayLoad(wifi.toJSON());
+
+ return AndroidAPIUtils.getOperationResponse(wifiBeanWrapper.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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("encrypt")
+ public Response encryptStorage(@HeaderParam(ACCEPT) String acceptHeader,
+ EncryptionBeanWrapper encryptionBeanWrapper) {
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking 'encrypt' operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ DeviceEncryption deviceEncryption = encryptionBeanWrapper.getOperation();
+
+ if (deviceEncryption == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("The payload of the device encryption operation is incorrect");
+ }
+ throw new OperationManagementException("Issue in creating a new encryption instance");
+ }
+
+ CommandOperation operation = new CommandOperation();
+ operation.setCode(AndroidConstants.OperationCodes.ENCRYPT_STORAGE);
+ operation.setType(Operation.Type.COMMAND);
+ operation.setEnabled(deviceEncryption.isEncrypted());
+
+ return AndroidAPIUtils.getOperationResponse(encryptionBeanWrapper.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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("change-lock-code")
+ public Response changeLockCode(@HeaderParam(ACCEPT) String acceptHeader,
+ LockCodeBeanWrapper lockCodeBeanWrapper) {
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking 'change lock code' operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ LockCode lockCode = lockCodeBeanWrapper.getOperation();
+
+ if (lockCode == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("The payload of the change lock code operation is incorrect");
+ }
+ throw new OperationManagementException("Issue in retrieving a new lock-code instance");
+ }
+
+ ProfileOperation operation = new ProfileOperation();
+ operation.setCode(AndroidConstants.OperationCodes.CHANGE_LOCK_CODE);
+ operation.setType(Operation.Type.PROFILE);
+ operation.setPayLoad(lockCode.toJSON());
+
+ return AndroidAPIUtils.getOperationResponse(lockCodeBeanWrapper.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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("password-policy")
+ public Response setPasswordPolicy(@HeaderParam(ACCEPT) String acceptHeader,
+ PasswordPolicyBeanWrapper passwordPolicyBeanWrapper) {
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking 'password policy' operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ PasscodePolicy passcodePolicy = passwordPolicyBeanWrapper.getOperation();
+
+ if (passcodePolicy == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("The payload of the change password policy operation is incorrect");
+ }
+ throw new OperationManagementException("Issue in creating a new Password policy instance");
+ }
+
+ ProfileOperation operation = new ProfileOperation();
+ operation.setCode(AndroidConstants.OperationCodes.PASSCODE_POLICY);
+ operation.setType(Operation.Type.PROFILE);
+ operation.setPayLoad(passcodePolicy.toJSON());
+
+ return AndroidAPIUtils.getOperationResponse(passwordPolicyBeanWrapper.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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("webclip")
+ public Response setWebClip(@HeaderParam(ACCEPT) String acceptHeader,
+ WebClipBeanWrapper webClipBeanWrapper) {
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking 'webclip' operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ WebClip webClip = webClipBeanWrapper.getOperation();
+
+ if (webClip == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("The payload of the add webclip operation is incorrect");
+ }
+ throw new OperationManagementException("Issue in creating a new web clip instance");
+ }
+
+ ProfileOperation operation = new ProfileOperation();
+ operation.setCode(AndroidConstants.OperationCodes.WEBCLIP);
+ operation.setType(Operation.Type.PROFILE);
+ operation.setPayLoad(webClip.toJSON());
+
+ return AndroidAPIUtils.getOperationResponse(webClipBeanWrapper.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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ @POST
+ @Path("disenroll")
+ public Response setDisenrollment(@HeaderParam(ACCEPT) String acceptHeader,
+ DisenrollmentBeanWrapper disenrollmentBeanWrapper) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking Android device disenrollment operation");
+ }
+
+ MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
+ Message message = new Message();
+
+ try {
+ Disenrollment disenrollment = disenrollmentBeanWrapper.getOperation();
+
+ if (disenrollment == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("The payload of the device disenrollment operation is incorrect");
+ }
+ throw new OperationManagementException("Issue in creating a new disenrollment instance");
+ }
+
+ CommandOperation operation = new CommandOperation();
+ operation.setCode(AndroidConstants.OperationCodes.DISENROLL);
+ operation.setType(Operation.Type.COMMAND);
+ operation.setEnabled(disenrollment.isEnabled());
+
+ return AndroidAPIUtils.getOperationResponse(disenrollmentBeanWrapper.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);
+ throw new AndroidOperationException(message, responseMediaType);
+ } 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);
+ throw new AndroidOperationException(message, responseMediaType);
+ }
+ }
+
+ private void updateOperations(String deviceId, List extends Operation> operations)
+ throws OperationManagementException, PolicyComplianceException,
+ ApplicationManagementException, NotificationManagementException, DeviceManagementException {
+ for (org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation : operations) {
+ AndroidAPIUtils.updateOperation(deviceId, operation);
+ if(operation.getStatus().equals(OPERATION_ERROR_STATUS)){
+ org.wso2.carbon.device.mgt.common.notification.mgt.Notification notification = new
+ org.wso2.carbon.device.mgt.common.notification.mgt.Notification();
+ DeviceIdentifier id = new DeviceIdentifier();
+ id.setId(deviceId);
+ id.setType(DEVICE_TYPE_ANDROID);
+ String deviceName = AndroidAPIUtils.getDeviceManagementService().getDevice(id).getName();
+ notification.setOperationId(operation.getId());
+ notification.setStatus(org.wso2.carbon.device.mgt.common.notification.mgt.Notification.
+ Status.NEW.toString());
+ notification.setDeviceIdentifier(id);
+ notification.setDescription("Operation " + operation.getCode() + " failed to execute on device "+
+ deviceName+". Device ID : " + deviceId);
+ AndroidAPIUtils.getNotificationManagementService().addNotification(notification);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Updating operation '" + operation.toString() + "'");
+ }
+ }
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/PolicyMgtService.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/PolicyMgtService.java
new file mode 100644
index 0000000000..e2e9d2cb8a
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/PolicyMgtService.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.wso2.carbon.mdm.services.android;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
+import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
+import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
+import org.wso2.carbon.mdm.services.android.util.Message;
+import org.wso2.carbon.policy.mgt.common.FeatureManagementException;
+import org.wso2.carbon.policy.mgt.common.Policy;
+import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
+import org.wso2.carbon.policy.mgt.common.ProfileFeature;
+import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
+
+import javax.jws.WebService;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
+import java.util.List;
+
+@WebService
+@Produces({"application/json", "application/xml"})
+@Consumes({"application/json", "application/xml"})
+public class PolicyMgtService {
+
+ private static Log log = LogFactory.getLog(PolicyMgtService.class);
+
+ @GET
+ @Path("{deviceId}")
+ public Message getEffectivePolicy(@HeaderParam("Accept") String acceptHeader,
+ @PathParam("deviceId") String id) throws AndroidAgentException {
+
+ DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
+ Message responseMessage = new Message();
+ Policy policy;
+ try {
+ PolicyManagerService policyManagerService = AndroidAPIUtils.getPolicyManagerService();
+ policy = policyManagerService.getEffectivePolicy(deviceIdentifier);
+ if (policy == null) {
+ responseMessage = Message.responseMessage("No effective policy found").
+ responseCode(Response.Status.NO_CONTENT.toString()).build();
+ } else {
+ responseMessage = Message.responseMessage("Effective policy added to operation").
+ responseCode(Response.Status.OK.toString()).build();
+ }
+ } catch (PolicyManagementException e) {
+ String msg = "Error occurred while getting the policy.";
+ log.error(msg, e);
+ throw new AndroidAgentException(msg, e);
+ }
+ return responseMessage;
+ }
+
+ @GET
+ @Path("/features/{deviceId}")
+ public List getEffectiveFeatures(@HeaderParam("Accept") String acceptHeader,
+ @PathParam("deviceId") String id) throws AndroidAgentException {
+ List profileFeatures;
+ DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
+ try {
+ PolicyManagerService policyManagerService = AndroidAPIUtils.getPolicyManagerService();
+ profileFeatures = policyManagerService.getEffectiveFeatures(deviceIdentifier);
+ if (profileFeatures == null) {
+ Response.status(Response.Status.NOT_FOUND);
+ }
+ } catch (FeatureManagementException e) {
+ String msg = "Error occurred while getting the features.";
+ log.error(msg, e);
+ throw new AndroidAgentException(msg, e);
+ }
+ return profileFeatures;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidOperation.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidOperation.java
new file mode 100644
index 0000000000..297a5df757
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidOperation.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.bean;
+
+import com.google.gson.Gson;
+/*
+* This abstract class is used for extending generic functions with regard to operation.
+*/
+public abstract class AndroidOperation {
+
+ /*
+ * This method is used to convert operation object to a json format.
+ *
+ * @return json formatted String.
+ */
+ public String toJSON() {
+ Gson gson = new Gson();
+ return gson.toJson(this);
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java
new file mode 100644
index 0000000000..e545c5bab7
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * you may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.bean;
+
+import java.io.Serializable;
+
+/**
+ * This class represents the information of install application operation.
+ */
+public class ApplicationInstallation extends AndroidOperation implements Serializable {
+
+ private String appIdentifier;
+ private String type;
+ private String url;
+
+ public String getAppIdentifier() {
+ return appIdentifier;
+ }
+
+ public void setAppIdentifier(String appIdentifier) {
+ this.appIdentifier = appIdentifier;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUninstallation.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUninstallation.java
new file mode 100644
index 0000000000..5e0b2909f7
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUninstallation.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * you may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.bean;
+
+import java.io.Serializable;
+
+/**
+ * This class represents the information of uninstall application operation.
+ */
+public class ApplicationUninstallation extends AndroidOperation implements Serializable {
+
+ private String appIdentifier;
+ private String type;
+ private String url;
+ private String name;
+
+ public String getAppIdentifier() {
+ return appIdentifier;
+ }
+
+ public void setAppIdentifier(String appIdentifier) {
+ this.appIdentifier = appIdentifier;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BlacklistApplications.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BlacklistApplications.java
new file mode 100644
index 0000000000..159ddfec9c
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BlacklistApplications.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * you may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.bean;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * This class represents the blacklist applications information.
+ */
+public class BlacklistApplications extends AndroidOperation implements Serializable {
+
+ private List appIdentifiers;
+
+ public List getAppIdentifier() {
+ return appIdentifiers;
+ }
+
+ public void setAppIdentifier(List appIdentifiers) {
+ this.appIdentifiers = appIdentifiers;
+ }
+
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Camera.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Camera.java
new file mode 100644
index 0000000000..2b392a19c2
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Camera.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * you may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.bean;
+
+import java.io.Serializable;
+
+/**
+ * This class represents the information of camera operation.
+ */
+public class Camera extends AndroidOperation implements Serializable {
+
+ private boolean enabled;
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceEncryption.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceEncryption.java
new file mode 100644
index 0000000000..de81c94a57
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceEncryption.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * you may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.bean;
+
+import java.io.Serializable;
+
+/**
+ * This class represents the information of encrypt operation.
+ */
+public class DeviceEncryption extends AndroidOperation implements Serializable {
+
+ private boolean encrypted;
+
+ public boolean isEncrypted() {
+ return encrypted;
+ }
+
+ public void setEncrypted(boolean encrypted) {
+ this.encrypted = encrypted;
+ }
+}
\ No newline at end of file
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Disenrollment.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Disenrollment.java
new file mode 100644
index 0000000000..8a1c2f8ac8
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Disenrollment.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.bean;
+
+import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
+import java.io.Serializable;
+
+public class Disenrollment extends AndroidOperation implements Serializable {
+
+ private boolean enabled;
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/LockCode.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/LockCode.java
new file mode 100644
index 0000000000..a68ec2253a
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/LockCode.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.bean;
+
+import java.io.Serializable;
+
+/**
+ * This class represents the information of changing lock code operation.
+ */
+public class LockCode extends AndroidOperation implements Serializable {
+
+ private String lockCode;
+
+ public String getLockCode() {
+ return lockCode;
+ }
+
+ public void setLockCode(String lockCode) {
+ this.lockCode = lockCode;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Notification.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Notification.java
new file mode 100644
index 0000000000..95e6b56f1d
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Notification.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.bean;
+
+import java.io.Serializable;
+
+/**
+ * This class represents the information of sending notification operation.
+ */
+public class Notification extends AndroidOperation implements Serializable {
+
+ private String message;
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/PasscodePolicy.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/PasscodePolicy.java
new file mode 100644
index 0000000000..5142f9e630
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/PasscodePolicy.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.bean;
+
+import java.io.Serializable;
+
+/**
+ * This class represents the information of setting up password policy.
+ */
+public class PasscodePolicy extends AndroidOperation implements Serializable {
+
+ private int maxFailedAttempts;
+ private int minLength;
+ private int pinHistory;
+ private int minComplexChars;
+ private int maxPINAgeInDays;
+ private boolean requireAlphanumeric;
+ private boolean allowSimple;
+
+ public int getMaxFailedAttempts() {
+ return maxFailedAttempts;
+ }
+
+ public void setMaxFailedAttempts(int maxFailedAttempts) {
+ this.maxFailedAttempts = maxFailedAttempts;
+ }
+
+ public int getMinLength() {
+ return minLength;
+ }
+
+ public void setMinLength(int minLength) {
+ this.minLength = minLength;
+ }
+
+ public int getPinHistory() {
+ return pinHistory;
+ }
+
+ public void setPinHistory(int pinHistory) {
+ this.pinHistory = pinHistory;
+ }
+
+ public int getMinComplexChars() {
+ return minComplexChars;
+ }
+
+ public void setMinComplexChars(int minComplexChars) {
+ this.minComplexChars = minComplexChars;
+ }
+
+ public int getMaxPINAgeInDays() {
+ return maxPINAgeInDays;
+ }
+
+ public void setMaxPINAgeInDays(int maxPINAgeInDays) {
+ this.maxPINAgeInDays = maxPINAgeInDays;
+ }
+
+ public boolean isRequireAlphanumeric() {
+ return requireAlphanumeric;
+ }
+
+ public void setRequireAlphanumeric(boolean requireAlphanumeric) {
+ this.requireAlphanumeric = requireAlphanumeric;
+ }
+
+ public boolean isAllowSimple() {
+ return allowSimple;
+ }
+
+ public void setAllowSimple(boolean allowSimple) {
+ this.allowSimple = allowSimple;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WebClip.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WebClip.java
new file mode 100644
index 0000000000..77fa8e18d7
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WebClip.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.bean;
+
+import java.io.Serializable;
+
+/**
+ * This class represents the information of setting up webclip.
+ */
+public class WebClip extends AndroidOperation implements Serializable {
+
+ private String identity;
+ private String title;
+ private String type;
+
+ public String getIdentity() {
+ return identity;
+ }
+
+ public void setIdentity(String identity) {
+ this.identity = identity;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Wifi.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Wifi.java
new file mode 100644
index 0000000000..97cee8634d
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Wifi.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * you may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.bean;
+
+import java.io.Serializable;
+
+/**
+ * This class represents the information of configuring wifi operation.
+ */
+public class Wifi extends AndroidOperation implements Serializable {
+
+ private String ssid;
+ private String password;
+
+ public String getSsid() {
+ return ssid;
+ }
+
+ public void setSsid(String ssid) {
+ this.ssid = ssid;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WipeData.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WipeData.java
new file mode 100644
index 0000000000..e3ba747cd7
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WipeData.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.bean;
+
+import java.io.Serializable;
+
+/**
+ * This class represents the information of wipedata operation.
+ */
+public class WipeData extends AndroidOperation implements Serializable {
+
+ private String pin;
+
+ public String getPin() {
+ return pin;
+ }
+
+ public void setPin(String pin) {
+ this.pin = pin;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationInstallationBeanWrapper.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationInstallationBeanWrapper.java
new file mode 100644
index 0000000000..ae809b8ee0
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationInstallationBeanWrapper.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.mdm.services.android.bean.wrapper;
+
+import org.wso2.carbon.mdm.services.android.bean.ApplicationInstallation;
+
+import java.util.List;
+
+/**
+ * This class is used to wrap the InstallApplication bean with devices.
+ */
+public class ApplicationInstallationBeanWrapper {
+
+ private List deviceIDs;
+ private ApplicationInstallation operation;
+
+ public List getDeviceIDs() {
+ return deviceIDs;
+ }
+
+ public void setDeviceIDs(List deviceIDs) {
+ this.deviceIDs = deviceIDs;
+ }
+
+ public ApplicationInstallation getOperation() {
+ return operation;
+ }
+
+ public void setOperation(ApplicationInstallation operation) {
+ this.operation = operation;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUninstallationBeanWrapper.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUninstallationBeanWrapper.java
new file mode 100644
index 0000000000..ef34d97dcb
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUninstallationBeanWrapper.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.mdm.services.android.bean.wrapper;
+
+import org.wso2.carbon.mdm.services.android.bean.ApplicationUninstallation;
+
+import java.util.List;
+
+/**
+ * This class is used to wrap the UninstallApplication bean with devices.
+ */
+public class ApplicationUninstallationBeanWrapper {
+
+ private List deviceIDs;
+ private ApplicationUninstallation operation;
+
+ public List getDeviceIDs() {
+ return deviceIDs;
+ }
+
+ public void setDeviceIDs(List deviceIDs) {
+ this.deviceIDs = deviceIDs;
+ }
+
+ public ApplicationUninstallation getOperation() {
+ return operation;
+ }
+
+ public void setOperation(ApplicationUninstallation operation) {
+ this.operation = operation;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/BlacklistApplicationsBeanWrapper.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/BlacklistApplicationsBeanWrapper.java
new file mode 100644
index 0000000000..f74b0e863a
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/BlacklistApplicationsBeanWrapper.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.mdm.services.android.bean.wrapper;
+
+import org.wso2.carbon.mdm.services.android.bean.BlacklistApplications;
+
+import java.util.List;
+
+/**
+ * This class is used to wrap the BlacklistApplications bean with devices.
+ */
+public class BlacklistApplicationsBeanWrapper {
+
+ private BlacklistApplications operation;
+ private List deviceIDs;
+
+ public BlacklistApplications getOperation() {
+ return operation;
+ }
+
+ public void setOperation(BlacklistApplications operation) {
+ this.operation = operation;
+ }
+
+ public List getDeviceIDs() {
+ return deviceIDs;
+ }
+
+ public void setDeviceIDs(List deviceIDs) {
+ this.deviceIDs = deviceIDs;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/CameraBeanWrapper.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/CameraBeanWrapper.java
new file mode 100644
index 0000000000..4bbde3ac4f
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/CameraBeanWrapper.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.mdm.services.android.bean.wrapper;
+
+import org.wso2.carbon.mdm.services.android.bean.Camera;
+
+import java.util.List;
+
+/**
+ * This class is used to wrap the Camera bean with devices.
+ */
+public class CameraBeanWrapper {
+
+ private Camera operation;
+ private List deviceIDs;
+
+ public Camera getOperation() {
+ return operation;
+ }
+
+ public void setOperation(Camera operation) {
+ this.operation = operation;
+ }
+
+ public List getDeviceIDs() {
+ return deviceIDs;
+ }
+
+ public void setDeviceIDs(List deviceIDs) {
+ this.deviceIDs = deviceIDs;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisenrollmentBeanWrapper.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisenrollmentBeanWrapper.java
new file mode 100644
index 0000000000..c4d22061ea
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisenrollmentBeanWrapper.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.mdm.services.android.bean.wrapper;
+
+import org.wso2.carbon.mdm.services.android.bean.Disenrollment;
+
+import java.util.List;
+
+public class DisenrollmentBeanWrapper {
+
+ private Disenrollment operation;
+ private List deviceIDs;
+
+ public Disenrollment getOperation() {
+ return operation;
+ }
+
+ public void setOperation(Disenrollment operation) {
+ this.operation = operation;
+ }
+
+ public List getDeviceIDs() {
+ return deviceIDs;
+ }
+
+ public void setDeviceIDs(List deviceIDs) {
+ this.deviceIDs = deviceIDs;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EncryptionBeanWrapper.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EncryptionBeanWrapper.java
new file mode 100644
index 0000000000..462b1137f7
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EncryptionBeanWrapper.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.mdm.services.android.bean.wrapper;
+
+import org.wso2.carbon.mdm.services.android.bean.DeviceEncryption;
+
+import java.util.List;
+
+/**
+ * This class is used to wrap the Encrypt bean with devices.
+ */
+public class EncryptionBeanWrapper {
+
+ private DeviceEncryption operation;
+ private List deviceIDs;
+
+ public DeviceEncryption getOperation() {
+ return operation;
+ }
+
+ public void setOperation(DeviceEncryption operation) {
+ this.operation = operation;
+ }
+
+ public List getDeviceIDs() {
+ return deviceIDs;
+ }
+
+ public void setDeviceIDs(List deviceIDs) {
+ this.deviceIDs = deviceIDs;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/LockCodeBeanWrapper.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/LockCodeBeanWrapper.java
new file mode 100644
index 0000000000..41594c280f
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/LockCodeBeanWrapper.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.mdm.services.android.bean.wrapper;
+
+import org.wso2.carbon.mdm.services.android.bean.LockCode;
+
+import java.util.List;
+
+/**
+ * This class is used to wrap the LockCode bean with devices.
+ */
+public class LockCodeBeanWrapper {
+
+ private LockCode operation;
+ private List deviceIDs;
+
+ public LockCode getOperation() {
+ return operation;
+ }
+
+ public void setOperation(LockCode operation) {
+ this.operation = operation;
+ }
+
+ public List getDeviceIDs() {
+ return deviceIDs;
+ }
+
+ public void setDeviceIDs(List deviceIDs) {
+ this.deviceIDs = deviceIDs;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/NotificationBeanWrapper.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/NotificationBeanWrapper.java
new file mode 100644
index 0000000000..e1092861af
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/NotificationBeanWrapper.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.mdm.services.android.bean.wrapper;
+
+import org.wso2.carbon.mdm.services.android.bean.Notification;
+
+import java.util.List;
+
+/**
+ * This class is used to wrap the Notification bean with devices.
+ */
+public class NotificationBeanWrapper {
+
+ private List deviceIDs;
+ private Notification operation;
+
+ public List getDeviceIDs() {
+ return deviceIDs;
+ }
+
+ public void setDeviceIDs(List deviceIDs) {
+ this.deviceIDs = deviceIDs;
+ }
+
+ public Notification getOperation() {
+ return operation;
+ }
+
+ public void setOperation(Notification operation) {
+ this.operation = operation;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/PasswordPolicyBeanWrapper.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/PasswordPolicyBeanWrapper.java
new file mode 100644
index 0000000000..cf54147e03
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/PasswordPolicyBeanWrapper.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.mdm.services.android.bean.wrapper;
+
+import org.wso2.carbon.mdm.services.android.bean.PasscodePolicy;
+
+import java.util.List;
+
+/**
+ * This class is used to wrap the PasswordPolicy bean with devices.
+ */
+public class PasswordPolicyBeanWrapper {
+
+ private PasscodePolicy operation;
+ private List deviceIDs;
+
+ public PasscodePolicy getOperation() {
+ return operation;
+ }
+
+ public void setOperation(PasscodePolicy operation) {
+ this.operation = operation;
+ }
+
+ public List getDeviceIDs() {
+ return deviceIDs;
+ }
+
+ public void setDeviceIDs(List deviceIDs) {
+ this.deviceIDs = deviceIDs;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WebClipBeanWrapper.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WebClipBeanWrapper.java
new file mode 100644
index 0000000000..7fbbe8559f
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WebClipBeanWrapper.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.mdm.services.android.bean.wrapper;
+
+import org.wso2.carbon.mdm.services.android.bean.WebClip;
+
+import java.util.List;
+
+/**
+ * This class is used to wrap the WebClip bean with devices.
+ */
+public class WebClipBeanWrapper {
+
+ private WebClip operation;
+ private List deviceIDs;
+
+ public WebClip getOperation() {
+ return operation;
+ }
+
+ public void setOperation(WebClip operation) {
+ this.operation = operation;
+ }
+
+ public List getDeviceIDs() {
+ return deviceIDs;
+ }
+
+ public void setDeviceIDs(List deviceIDs) {
+ this.deviceIDs = deviceIDs;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WifiBeanWrapper.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WifiBeanWrapper.java
new file mode 100644
index 0000000000..b19e017269
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WifiBeanWrapper.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.mdm.services.android.bean.wrapper;
+
+import org.wso2.carbon.mdm.services.android.bean.Wifi;
+
+import java.util.List;
+
+/**
+ * This class is used to wrap the Wifi bean with devices.
+ */
+public class WifiBeanWrapper {
+
+ private Wifi operation;
+ private List deviceIDs;
+
+ public Wifi getOperation() {
+ return operation;
+ }
+
+ public void setOperation(Wifi operation) {
+ this.operation = operation;
+ }
+
+ public List getDeviceIDs() {
+ return deviceIDs;
+ }
+
+ public void setDeviceIDs(List deviceIDs) {
+ this.deviceIDs = deviceIDs;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WipeDataBeanWrapper.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WipeDataBeanWrapper.java
new file mode 100644
index 0000000000..ebf05d1cd7
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WipeDataBeanWrapper.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.mdm.services.android.bean.wrapper;
+
+import org.wso2.carbon.mdm.services.android.bean.WipeData;
+
+import java.util.List;
+
+/**
+ * This class is used to wrap the WipeData bean with devices.
+ */
+public class WipeDataBeanWrapper {
+
+ private WipeData operation;
+ private List deviceIDs;
+
+ public WipeData getOperation() {
+ return operation;
+ }
+
+ public void setOperation(WipeData operation) {
+ this.operation = operation;
+ }
+
+ public List getDeviceIDs() {
+ return deviceIDs;
+ }
+
+ public void setDeviceIDs(List deviceIDs) {
+ this.deviceIDs = deviceIDs;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorHandler.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorHandler.java
new file mode 100644
index 0000000000..6d5e0d1c4a
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorHandler.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.mdm.services.android.common;
+
+import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
+
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+
+@Produces({ "application/json", "application/xml" })
+public class ErrorHandler implements ExceptionMapper {
+
+ public Response toResponse(AndroidAgentException exception) {
+ ErrorMessage errorMessage = new ErrorMessage();
+ errorMessage.setErrorMessage(exception.getErrorMessage());
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorMessage.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorMessage.java
new file mode 100644
index 0000000000..86be36f36f
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorMessage.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.mdm.services.android.common;
+
+
+public class ErrorMessage {
+
+ private String errorMessage;
+ private String errorCode;
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public String getErrorCode() {
+ return errorCode;
+ }
+
+ public void setErrorCode(String errorCode) {
+ this.errorCode = errorCode;
+ }
+}
diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/GsonMessageBodyHandler.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/GsonMessageBodyHandler.java
new file mode 100644
index 0000000000..193eda1bc8
--- /dev/null
+++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/GsonMessageBodyHandler.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.common;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+import java.io.*;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+
+@Provider
+@Produces(APPLICATION_JSON)
+@Consumes(APPLICATION_JSON)
+public class GsonMessageBodyHandler implements MessageBodyWriter