From e4bc9f87f89a8de470484a09f1ec5b2a737539c5 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Thu, 15 Dec 2022 01:05:07 +0530 Subject: [PATCH] fixed the validation issue --- .../impl/util/RequestValidationUtil.java | 13 ++++++++++++- .../impl/util/RequestValidationUtil.java | 12 +++++++++++- .../dao/util/DeviceManagementDAOUtil.java | 19 +++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/components/application-mgt/io.entgra.application.mgt.store.api/src/main/java/io/entgra/application/mgt/store/api/services/impl/util/RequestValidationUtil.java b/components/application-mgt/io.entgra.application.mgt.store.api/src/main/java/io/entgra/application/mgt/store/api/services/impl/util/RequestValidationUtil.java index 642107afc1..d36c0e2512 100644 --- a/components/application-mgt/io.entgra.application.mgt.store.api/src/main/java/io/entgra/application/mgt/store/api/services/impl/util/RequestValidationUtil.java +++ b/components/application-mgt/io.entgra.application.mgt.store.api/src/main/java/io/entgra/application/mgt/store/api/services/impl/util/RequestValidationUtil.java @@ -50,11 +50,22 @@ public class RequestValidationUtil { case "REMOVED": case "BLOCKED": 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; default: String msg = "Invalid enrollment status type: " + status + ". \nValid status types " + "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); throw new BadRequestException(msg); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java index 1308dfa970..b41d39158b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java @@ -153,11 +153,21 @@ public class RequestValidationUtil { case "REMOVED": case "BLOCKED": 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; default: String msg = "Invalid enrollment status type: " + status + ". \nValid status types 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); throw new InputValidationException(new ErrorResponse.ErrorResponseBuilder() .setCode(HttpStatus.SC_BAD_REQUEST) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java index 91b549d9e6..089bb4cf03 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java @@ -26,6 +26,7 @@ import java.util.Date; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.el.lang.ELSupport; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceBilling; @@ -211,6 +212,24 @@ public final class DeviceManagementDAOUtil { return enrolmentInfos.get(EnrolmentInfo.Status.SUSPENDED); } else if (enrolmentInfos.containsKey(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; }