mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Adding date validations when updating device enrollment
This commit is contained in:
parent
9cde2d815a
commit
0ee28c91d2
@ -260,7 +260,16 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
@Override
|
@Override
|
||||||
public Response modifyEnrollment(@PathParam("id") String id, @Valid AndroidDevice androidDevice) {
|
public Response modifyEnrollment(@PathParam("id") String id, @Valid AndroidDevice androidDevice) {
|
||||||
Device device = new Device();
|
Device device = new Device();
|
||||||
|
String msg = "";
|
||||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
|
if(androidDevice.getEnrolmentInfo().getDateOfEnrolment() <= 0){
|
||||||
|
msg = "Invalid Enrollment date.";
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||||
|
}
|
||||||
|
if(androidDevice.getEnrolmentInfo().getDateOfLastUpdate() <= 0){
|
||||||
|
msg = "Invalid Last Updated date.";
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||||
|
}
|
||||||
device.setEnrolmentInfo(androidDevice.getEnrolmentInfo());
|
device.setEnrolmentInfo(androidDevice.getEnrolmentInfo());
|
||||||
device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser());
|
device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser());
|
||||||
device.setDeviceInfo(androidDevice.getDeviceInfo());
|
device.setDeviceInfo(androidDevice.getDeviceInfo());
|
||||||
@ -281,7 +290,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
"carries the id '" + id + "' has not been updated").build();
|
"carries the id '" + id + "' has not been updated").build();
|
||||||
}
|
}
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
String msg = "Error occurred while modifying enrollment of the Android device that carries the id '" +
|
msg = "Error occurred while modifying enrollment of the Android device that carries the id '" +
|
||||||
id + "'";
|
id + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
throw new UnexpectedServerErrorException(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user