Merge branch 'application-mgt-new' into 'application-mgt-new'

Sync with master branch

See merge request entgra/carbon-device-mgt-plugins!84
revert-dabc3590
Dharmakeerthi Lasantha 5 years ago
commit f23bd5e2f1

@ -63,10 +63,6 @@ public class TestDeviceManager implements DeviceManager {
return true; return true;
} }
@Override
public boolean deleteDevice(DeviceIdentifier deviceId, Device device) throws DeviceManagementException {
return true;
}
@Override @Override
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
@ -136,4 +132,9 @@ public class TestDeviceManager implements DeviceManager {
return false; return false;
} }
@Override
public void deleteDevices(List<String> deviceIdentifiers) throws DeviceManagementException {
//Does nothing since AndroidDeviceManager is not used instead DeviceTypeManager is used.
}
} }

@ -423,10 +423,6 @@ public interface DeviceManagementService {
@ApiParam( @ApiParam(
name = "id", name = "id",
value = "The unique device identifier.") value = "The unique device identifier.")
@PathParam("id") String id, @PathParam("id") String id);
@ApiParam(
name = "permanentDelete",
value = "Boolean flag indicating whether to permanently delete the device.")
@QueryParam("permanentDelete") boolean permanentDelete);
} }

@ -447,26 +447,17 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@DELETE @DELETE
@Path("/{id}") @Path("/{id}")
@Override @Override
public Response disEnrollDevice(@PathParam("id") String id, public Response disEnrollDevice(@PathParam("id") String id) {
@QueryParam("permanentDelete") boolean permanentDelete) {
boolean result; boolean result;
DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id); DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id);
try { try {
if (permanentDelete) { AndroidDeviceUtils.updateDisEnrollOperationStatus(deviceIdentifier);
result = AndroidAPIUtils.getDeviceManagementService().deleteDevice(deviceIdentifier); result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier);
} else {
AndroidDeviceUtils.updateDisEnrollOperationStatus(deviceIdentifier);
result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier);
}
if (result) { if (result) {
String msg = "Android device that carries id '" + id + "' is successfully "; String msg = "Android device that carries id '" + id + "' is successfully ";
Message responseMessage = new Message(); Message responseMessage = new Message();
responseMessage.setResponseCode(Response.Status.OK.toString()); responseMessage.setResponseCode(Response.Status.OK.toString());
if (permanentDelete) { responseMessage.setResponseMessage(msg + "dis-enrolled");
responseMessage.setResponseMessage(msg + "deleted");
} else {
responseMessage.setResponseMessage(msg + "dis-enrolled");
}
return Response.status(Response.Status.OK).entity(responseMessage).build(); return Response.status(Response.Status.OK).entity(responseMessage).build();
} else { } else {
Message responseMessage = new Message(); Message responseMessage = new Message();
@ -476,11 +467,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error occurred while %s the Android device that carries the id '" + id + "'"; String msg = "Error occurred while %s the Android device that carries the id '" + id + "'";
if (permanentDelete) { msg = String.format(msg, "dis-enrolling");
msg = String.format(msg, "deleting");
} else {
msg = String.format(msg, "dis-enrolling");
}
log.error(msg, e); log.error(msg, e);
throw new UnexpectedServerErrorException( throw new UnexpectedServerErrorException(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());

@ -300,7 +300,7 @@ public class DeviceManagementServiceTests {
public void testDisEnrollDeviceSuccess() public void testDisEnrollDeviceSuccess()
throws DeviceManagementException, OperationManagementException, InvalidDeviceException { throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
mockDeviceManagementService(); mockDeviceManagementService();
Response response = deviceManagementService.disEnrollDevice(TestUtils.getDeviceId(), false); Response response = deviceManagementService.disEnrollDevice(TestUtils.getDeviceId());
Assert.assertNotNull(response); Assert.assertNotNull(response);
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
} }
@ -309,7 +309,7 @@ public class DeviceManagementServiceTests {
public void testDisenrollUnSuccess() public void testDisenrollUnSuccess()
throws DeviceManagementException, OperationManagementException, InvalidDeviceException { throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
mockDeviceManagementService(); mockDeviceManagementService();
Response response = deviceManagementService.disEnrollDevice("1234", false); Response response = deviceManagementService.disEnrollDevice("1234");
Assert.assertNotNull(response); Assert.assertNotNull(response);
Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
} }

@ -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.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; 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.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.FeatureManager; import org.wso2.carbon.device.mgt.common.FeatureManager;
import org.wso2.carbon.device.mgt.common.MonitoringOperation; import org.wso2.carbon.device.mgt.common.MonitoringOperation;
@ -367,11 +368,6 @@ public class DeviceManagementProviderServiceMock implements DeviceManagementProv
return TestUtils.getDeviceId().equals(deviceIdentifier.getId()); return TestUtils.getDeviceId().equals(deviceIdentifier.getId());
} }
@Override
public boolean deleteDevice(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
return false;
}
@Override @Override
public boolean isEnrolled(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { public boolean isEnrolled(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
return false; return false;
@ -661,4 +657,13 @@ public class DeviceManagementProviderServiceMock implements DeviceManagementProv
AmbiguousConfigurationException { AmbiguousConfigurationException {
return null; return null;
} }
@Override
public List<String> transferDeviceToTenant(DeviceTransferRequest deviceTransferRequest)
throws DeviceManagementException, DeviceNotFoundException {
return null;
}
@Override
public boolean deleteDevices(List<String> deviceIdentifiers) throws DeviceManagementException, InvalidDeviceException {return false;}
} }

@ -220,11 +220,6 @@ public class AndroidDeviceManager implements DeviceManager {
return true; 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 @Override
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
@ -374,4 +369,9 @@ public class AndroidDeviceManager implements DeviceManager {
return devices; return devices;
} }
@Override
public void deleteDevices(List<String> deviceIdentifiers) throws DeviceManagementException {
//Does nothing since AndroidDeviceManager is not used instead DeviceTypeManager is used.
}
} }

Loading…
Cancel
Save