diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestDeviceManager.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestDeviceManager.java index 1c2393a1a..2d8d65eb1 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestDeviceManager.java +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestDeviceManager.java @@ -63,10 +63,6 @@ public class TestDeviceManager implements DeviceManager { return true; } - @Override - public boolean deleteDevice(DeviceIdentifier deviceId, Device device) throws DeviceManagementException { - return true; - } @Override public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { @@ -136,4 +132,9 @@ public class TestDeviceManager implements DeviceManager { return false; } + @Override + public void deleteDevices(List deviceIdentifiers) throws DeviceManagementException { + //Does nothing since AndroidDeviceManager is not used instead DeviceTypeManager is used. + } + } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java index 59898ff89..d9bcf0ecf 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java @@ -423,10 +423,6 @@ public interface DeviceManagementService { @ApiParam( name = "id", value = "The unique device identifier.") - @PathParam("id") String id, - @ApiParam( - name = "permanentDelete", - value = "Boolean flag indicating whether to permanently delete the device.") - @QueryParam("permanentDelete") boolean permanentDelete); + @PathParam("id") String id); } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java index 568d5e5fd..a540d277e 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java @@ -447,26 +447,17 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @DELETE @Path("/{id}") @Override - public Response disEnrollDevice(@PathParam("id") String id, - @QueryParam("permanentDelete") boolean permanentDelete) { + public Response disEnrollDevice(@PathParam("id") String id) { boolean result; DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id); try { - if (permanentDelete) { - result = AndroidAPIUtils.getDeviceManagementService().deleteDevice(deviceIdentifier); - } else { - AndroidDeviceUtils.updateDisEnrollOperationStatus(deviceIdentifier); - result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); - } + AndroidDeviceUtils.updateDisEnrollOperationStatus(deviceIdentifier); + result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); if (result) { String msg = "Android device that carries id '" + id + "' is successfully "; Message responseMessage = new Message(); responseMessage.setResponseCode(Response.Status.OK.toString()); - if (permanentDelete) { - responseMessage.setResponseMessage(msg + "deleted"); - } else { - responseMessage.setResponseMessage(msg + "dis-enrolled"); - } + responseMessage.setResponseMessage(msg + "dis-enrolled"); return Response.status(Response.Status.OK).entity(responseMessage).build(); } else { Message responseMessage = new Message(); @@ -476,11 +467,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } } catch (DeviceManagementException e) { String msg = "Error occurred while %s the Android device that carries the id '" + id + "'"; - if (permanentDelete) { - msg = String.format(msg, "deleting"); - } else { - msg = String.format(msg, "dis-enrolling"); - } + msg = String.format(msg, "dis-enrolling"); log.error(msg, e); throw new UnexpectedServerErrorException( new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementServiceTests.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementServiceTests.java index 05a25cb61..8c6e0afd1 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementServiceTests.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementServiceTests.java @@ -300,7 +300,7 @@ public class DeviceManagementServiceTests { public void testDisEnrollDeviceSuccess() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { mockDeviceManagementService(); - Response response = deviceManagementService.disEnrollDevice(TestUtils.getDeviceId(), false); + Response response = deviceManagementService.disEnrollDevice(TestUtils.getDeviceId()); Assert.assertNotNull(response); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); } @@ -309,7 +309,7 @@ public class DeviceManagementServiceTests { public void testDisenrollUnSuccess() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { mockDeviceManagementService(); - Response response = deviceManagementService.disEnrollDevice("1234", false); + Response response = deviceManagementService.disEnrollDevice("1234"); Assert.assertNotNull(response); Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceManagementProviderServiceMock.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceManagementProviderServiceMock.java index 735a9390d..0f114e355 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceManagementProviderServiceMock.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceManagementProviderServiceMock.java @@ -20,6 +20,7 @@ package org.wso2.carbon.mdm.services.android.mocks; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.DeviceTransferRequest; import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.FeatureManager; import org.wso2.carbon.device.mgt.common.MonitoringOperation; @@ -367,11 +368,6 @@ public class DeviceManagementProviderServiceMock implements DeviceManagementProv return TestUtils.getDeviceId().equals(deviceIdentifier.getId()); } - @Override - public boolean deleteDevice(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { - return false; - } - @Override public boolean isEnrolled(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { return false; @@ -661,4 +657,13 @@ public class DeviceManagementProviderServiceMock implements DeviceManagementProv AmbiguousConfigurationException { return null; } + + @Override + public List transferDeviceToTenant(DeviceTransferRequest deviceTransferRequest) + throws DeviceManagementException, DeviceNotFoundException { + return null; + } + + @Override + public boolean deleteDevices(List deviceIdentifiers) throws DeviceManagementException, InvalidDeviceException {return false;} } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceManagementProviderServiceMock.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceManagementProviderServiceMock.java new file mode 100644 index 000000000..e69de29bb diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManager.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManager.java index 5024dc799..cca99f067 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManager.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManager.java @@ -220,11 +220,6 @@ public class AndroidDeviceManager implements DeviceManager { return true; } - @Override - public boolean deleteDevice(DeviceIdentifier deviceId, Device device) throws DeviceManagementException { - //Returning false since AndroidDeviceManager is not used instead DeviceTypeManager is used. - return false; - } @Override public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { @@ -374,4 +369,9 @@ public class AndroidDeviceManager implements DeviceManager { return devices; } + @Override + public void deleteDevices(List deviceIdentifiers) throws DeviceManagementException { + //Does nothing since AndroidDeviceManager is not used instead DeviceTypeManager is used. + } + }