fixed the validation issue

billing-new-api
Thilina Sandaruwan 2 years ago
parent dc20995d15
commit e4bc9f87f8

@ -50,11 +50,22 @@ public class RequestValidationUtil {
case "REMOVED": case "REMOVED":
case "BLOCKED": case "BLOCKED":
case "CREATED": case "CREATED":
case "CONFIGURED":
case "READY_TO_CONNECT":
case "RETURN_PENDING":
case "RETURNED":
case "DEFECTIVE":
case "WARRANTY_PENDING":
case "WARRANTY_SENT":
case "WARRANTY_REPLACED":
case "ASSIGNED":
break; break;
default: default:
String msg = "Invalid enrollment status type: " + status + ". \nValid status types " + String msg = "Invalid enrollment status type: " + status + ". \nValid status types " +
"are ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " + "are ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " +
"DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED"; "DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED | CONFIGURED | READY_TO_CONNECT | " +
"RETURN_PENDING | RETURNED | DEFECTIVE | WARRANTY_PENDING | WARRANTY_SENT | " +
"WARRANTY_REPLACED | ASSIGNED |";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }

@ -153,11 +153,21 @@ public class RequestValidationUtil {
case "REMOVED": case "REMOVED":
case "BLOCKED": case "BLOCKED":
case "CREATED": case "CREATED":
case "CONFIGURED":
case "READY_TO_CONNECT":
case "RETURN_PENDING":
case "RETURNED":
case "DEFECTIVE":
case "WARRANTY_PENDING":
case "WARRANTY_SENT":
case "WARRANTY_REPLACED":
case "ASSIGNED":
break; break;
default: default:
String msg = "Invalid enrollment status type: " + status + ". \nValid status types are " + String msg = "Invalid enrollment status type: " + status + ". \nValid status types are " +
"ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " + "ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " +
"DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED"; "DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED | CONFIGURED | READY_TO_CONNECT | " +
"RETURN_PENDING | RETURNED | DEFECTIVE | WARRANTY_PENDING | WARRANTY_SENT | WARRANTY_REPLACED | ASSIGNED ";
log.error(msg); log.error(msg);
throw new InputValidationException(new ErrorResponse.ErrorResponseBuilder() throw new InputValidationException(new ErrorResponse.ErrorResponseBuilder()
.setCode(HttpStatus.SC_BAD_REQUEST) .setCode(HttpStatus.SC_BAD_REQUEST)

@ -26,6 +26,7 @@ import java.util.Date;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.el.lang.ELSupport;
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceBilling; import org.wso2.carbon.device.mgt.common.DeviceBilling;
@ -211,6 +212,24 @@ public final class DeviceManagementDAOUtil {
return enrolmentInfos.get(EnrolmentInfo.Status.SUSPENDED); return enrolmentInfos.get(EnrolmentInfo.Status.SUSPENDED);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.BLOCKED)) { } else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.BLOCKED)) {
return enrolmentInfos.get(EnrolmentInfo.Status.BLOCKED); return enrolmentInfos.get(EnrolmentInfo.Status.BLOCKED);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.CONFIGURED)) {
return enrolmentInfos.get(EnrolmentInfo.Status.CONFIGURED);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.READY_TO_CONNECT)) {
return enrolmentInfos.get(EnrolmentInfo.Status.READY_TO_CONNECT);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.RETURN_PENDING)) {
return enrolmentInfos.get(EnrolmentInfo.Status.RETURN_PENDING);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.RETURNED)) {
return enrolmentInfos.get(EnrolmentInfo.Status.RETURNED);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.DEFECTIVE)) {
return enrolmentInfos.get(EnrolmentInfo.Status.DEFECTIVE);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.WARRANTY_PENDING)) {
return enrolmentInfos.get(EnrolmentInfo.Status.WARRANTY_PENDING);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.WARRANTY_SENT)) {
return enrolmentInfos.get(EnrolmentInfo.Status.WARRANTY_SENT);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.WARRANTY_REPLACED)) {
return enrolmentInfos.get(EnrolmentInfo.Status.WARRANTY_REPLACED);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.ASSIGNED)) {
return enrolmentInfos.get(EnrolmentInfo.Status.ASSIGNED);
} }
return enrolmentInfo; return enrolmentInfo;
} }

Loading…
Cancel
Save