adding validation

revert-dabc3590
inoshperera 9 years ago
parent 62a116ba71
commit 486e2f48ed

@ -26,7 +26,7 @@ import java.io.Serializable;
description = "This class carries all information related to device lock operation.") description = "This class carries all information related to device lock operation.")
public class DeviceLock extends AndroidOperation implements Serializable { public class DeviceLock extends AndroidOperation implements Serializable {
@ApiModelProperty(name = "message", value = "Pop up message of the lock operation.", required = true) @ApiModelProperty(name = "message", value = "Pop up message of the lock operation.", required = false)
private String message; private String message;
@ApiModelProperty(name = "isHardLockEnabled", value = "Hard lock enable status of the Device", required = true) @ApiModelProperty(name = "isHardLockEnabled", value = "Hard lock enable status of the Device", required = true)
private boolean isHardLockEnabled; private boolean isHardLockEnabled;

@ -56,13 +56,12 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
} }
try { try {
DeviceLock lock = deviceLockBeanWrapper.getOperation(); if (deviceLockBeanWrapper == null || deviceLockBeanWrapper.getOperation() == null) {
if (lock == null) {
String errorMessage = "Lock bean is empty."; String errorMessage = "Lock bean is empty.";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} }
DeviceLock lock = deviceLockBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCK); operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCK);
operation.setType(Operation.Type.PROFILE); operation.setType(Operation.Type.PROFILE);
@ -170,12 +169,12 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
} }
try { try {
Camera camera = cameraBeanWrapper.getOperation(); if (cameraBeanWrapper == null || cameraBeanWrapper.getOperation() == null) {
if (camera == null) {
String errorMessage = "The payload of the configure camera operation is incorrect."; String errorMessage = "The payload of the configure camera operation is incorrect.";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} }
Camera camera = cameraBeanWrapper.getOperation();
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
operation.setCode(AndroidConstants.OperationCodes.CAMERA); operation.setCode(AndroidConstants.OperationCodes.CAMERA);
operation.setType(Operation.Type.COMMAND); operation.setType(Operation.Type.COMMAND);
@ -254,14 +253,12 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
} }
try { try {
WipeData wipeData = wipeDataBeanWrapper.getOperation(); if (wipeDataBeanWrapper == null || wipeDataBeanWrapper.getOperation() == null) {
if (wipeData == null) {
String errorMessage = "WipeData bean is empty."; String errorMessage = "WipeData bean is empty.";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} }
WipeData wipeData = wipeDataBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.WIPE_DATA); operation.setCode(AndroidConstants.OperationCodes.WIPE_DATA);
operation.setType(Operation.Type.PROFILE); operation.setType(Operation.Type.PROFILE);
@ -394,14 +391,13 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
} }
try { try {
ApplicationInstallation applicationInstallation = applicationInstallationBeanWrapper.getOperation(); if (applicationInstallationBeanWrapper == null || applicationInstallationBeanWrapper.getOperation() ==
null) {
if (applicationInstallation == null) {
String errorMessage = "The payload of the application installing operation is incorrect"; String errorMessage = "The payload of the application installing operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} }
ApplicationInstallation applicationInstallation = applicationInstallationBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.INSTALL_APPLICATION); operation.setCode(AndroidConstants.OperationCodes.INSTALL_APPLICATION);
operation.setType(Operation.Type.PROFILE); operation.setType(Operation.Type.PROFILE);
@ -430,14 +426,12 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
} }
try { try {
ApplicationUpdate applicationUpdate = applicationUpdateBeanWrapper.getOperation(); if (applicationUpdateBeanWrapper == null || applicationUpdateBeanWrapper.getOperation() == null) {
if (applicationUpdate == null) {
String errorMessage = "The payload of the application update operation is incorrect"; String errorMessage = "The payload of the application update operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} }
ApplicationUpdate applicationUpdate = applicationUpdateBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.UPDATE_APPLICATION); operation.setCode(AndroidConstants.OperationCodes.UPDATE_APPLICATION);
operation.setType(Operation.Type.PROFILE); operation.setType(Operation.Type.PROFILE);
@ -467,14 +461,13 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
} }
try { try {
ApplicationUninstallation applicationUninstallation = applicationUninstallationBeanWrapper.getOperation(); if (applicationUninstallationBeanWrapper == null ||
applicationUninstallationBeanWrapper.getOperation() == null) {
if (applicationUninstallation == null) {
String errorMessage = "The payload of the application uninstalling operation is incorrect"; String errorMessage = "The payload of the application uninstalling operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} }
ApplicationUninstallation applicationUninstallation = applicationUninstallationBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.UNINSTALL_APPLICATION); operation.setCode(AndroidConstants.OperationCodes.UNINSTALL_APPLICATION);
operation.setType(Operation.Type.PROFILE); operation.setType(Operation.Type.PROFILE);
@ -504,14 +497,12 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
} }
try { try {
BlacklistApplications blacklistApplications = blacklistApplicationsBeanWrapper.getOperation(); if (blacklistApplicationsBeanWrapper == null || blacklistApplicationsBeanWrapper.getOperation() == null) {
if (blacklistApplications == null) {
String errorMessage = "The payload of the blacklisting apps operation is incorrect"; String errorMessage = "The payload of the blacklisting apps operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} }
BlacklistApplications blacklistApplications = blacklistApplicationsBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.BLACKLIST_APPLICATIONS); operation.setCode(AndroidConstants.OperationCodes.BLACKLIST_APPLICATIONS);
operation.setType(Operation.Type.PROFILE); operation.setType(Operation.Type.PROFILE);
@ -542,14 +533,12 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
} }
try { try {
UpgradeFirmware upgradeFirmware = upgradeFirmwareBeanWrapper.getOperation(); if (upgradeFirmwareBeanWrapper == null || upgradeFirmwareBeanWrapper.getOperation() == null) {
if (upgradeFirmware == null) {
String errorMessage = "The payload of the upgrade firmware operation is incorrect"; String errorMessage = "The payload of the upgrade firmware operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} }
UpgradeFirmware upgradeFirmware = upgradeFirmwareBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.UPGRADE_FIRMWARE); operation.setCode(AndroidConstants.OperationCodes.UPGRADE_FIRMWARE);
operation.setType(Operation.Type.PROFILE); operation.setType(Operation.Type.PROFILE);
@ -578,14 +567,12 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
} }
try { try {
Vpn vpn = vpnBeanWrapper.getOperation(); if (vpnBeanWrapper == null || vpnBeanWrapper.getOperation() == null) {
if (vpn == null) {
String errorMessage = "The payload of the VPN operation is incorrect"; String errorMessage = "The payload of the VPN operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} }
Vpn vpn = vpnBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.VPN); operation.setCode(AndroidConstants.OperationCodes.VPN);
operation.setType(Operation.Type.PROFILE); operation.setType(Operation.Type.PROFILE);
@ -614,14 +601,12 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
} }
try { try {
Notification notification = notificationBeanWrapper.getOperation(); if (notificationBeanWrapper == null || notificationBeanWrapper.getOperation() == null) {
if (notification == null) {
String errorMessage = "The payload of the notification operation is incorrect"; String errorMessage = "The payload of the notification operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} }
Notification notification = notificationBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.NOTIFICATION); operation.setCode(AndroidConstants.OperationCodes.NOTIFICATION);
operation.setType(Operation.Type.PROFILE); operation.setType(Operation.Type.PROFILE);
@ -651,14 +636,12 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
} }
try { try {
Wifi wifi = wifiBeanWrapper.getOperation(); if (wifiBeanWrapper == null || wifiBeanWrapper.getOperation() == null) {
if (wifi == null) {
String errorMessage = "The payload of the wifi operation is incorrect"; String errorMessage = "The payload of the wifi operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} }
Wifi wifi = wifiBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.WIFI); operation.setCode(AndroidConstants.OperationCodes.WIFI);
operation.setType(Operation.Type.PROFILE); operation.setType(Operation.Type.PROFILE);
@ -689,14 +672,12 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
} }
try { try {
DeviceEncryption deviceEncryption = encryptionBeanWrapper.getOperation(); if (encryptionBeanWrapper == null || encryptionBeanWrapper.getOperation() == null) {
if (deviceEncryption == null) {
String errorMessage = "The payload of the device encryption operation is incorrect"; String errorMessage = "The payload of the device encryption operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} }
DeviceEncryption deviceEncryption = encryptionBeanWrapper.getOperation();
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
operation.setCode(AndroidConstants.OperationCodes.ENCRYPT_STORAGE); operation.setCode(AndroidConstants.OperationCodes.ENCRYPT_STORAGE);
operation.setType(Operation.Type.COMMAND); operation.setType(Operation.Type.COMMAND);
@ -726,14 +707,12 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
} }
try { try {
LockCode lockCode = lockCodeBeanWrapper.getOperation(); if (lockCodeBeanWrapper == null || lockCodeBeanWrapper.getOperation() == null) {
if (lockCode == null) {
String errorMessage = "The payload of the change lock code operation is incorrect"; String errorMessage = "The payload of the change lock code operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} }
LockCode lockCode = lockCodeBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.CHANGE_LOCK_CODE); operation.setCode(AndroidConstants.OperationCodes.CHANGE_LOCK_CODE);
operation.setType(Operation.Type.PROFILE); operation.setType(Operation.Type.PROFILE);
@ -763,13 +742,12 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
} }
try { try {
PasscodePolicy passcodePolicy = passwordPolicyBeanWrapper.getOperation(); if (passwordPolicyBeanWrapper == null || passwordPolicyBeanWrapper.getOperation() == null) {
if (passcodePolicy == null) {
String errorMessage = "The payload of the change password policy operation is incorrect"; String errorMessage = "The payload of the change password policy operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} }
PasscodePolicy passcodePolicy = passwordPolicyBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.PASSCODE_POLICY); operation.setCode(AndroidConstants.OperationCodes.PASSCODE_POLICY);
operation.setType(Operation.Type.PROFILE); operation.setType(Operation.Type.PROFILE);
@ -800,14 +778,14 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
} }
try { try {
WebClip webClip = webClipBeanWrapper.getOperation();
if (webClip == null) {
if (webClipBeanWrapper == null || webClipBeanWrapper.getOperation() == null) {
String errorMessage = "The payload of the add webclip operation is incorrect"; String errorMessage = "The payload of the add webclip operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} }
WebClip webClip = webClipBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.WEBCLIP); operation.setCode(AndroidConstants.OperationCodes.WEBCLIP);
operation.setType(Operation.Type.PROFILE); operation.setType(Operation.Type.PROFILE);

Loading…
Cancel
Save