From fd821629097e9986d55325999dcd1026c7a5fa92 Mon Sep 17 00:00:00 2001 From: Rushdi Date: Wed, 5 Jan 2022 13:04:42 +0530 Subject: [PATCH] Added new operation status --- .../jaxrs/service/impl/util/RequestValidationUtil.java | 6 ++++-- .../org/wso2/carbon/device/mgt/jaxrs/util/Constants.java | 2 ++ .../carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java | 8 +++++++- .../device/mgt/common/operation/mgt/ActivityStatus.java | 2 +- .../carbon/device/mgt/common/operation/mgt/Operation.java | 2 +- .../device/mgt/core/dto/operation/mgt/Operation.java | 2 +- 6 files changed, 16 insertions(+), 6 deletions(-) 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 116c715eb2..bbf46e9984 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 @@ -610,10 +610,12 @@ public class RequestValidationUtil { || Constants.OperationStatus.NOTNOW.toUpperCase().equals(status.get(i)) || Constants.OperationStatus.REPEATED.toUpperCase().equals(status.get(i)) || Constants.OperationStatus.PENDING.toUpperCase().equals(status.get(i)) - || Constants.OperationStatus.IN_PROGRESS.toUpperCase().equals(status.get(i))) { + || Constants.OperationStatus.IN_PROGRESS.toUpperCase().equals(status.get(i)) + || Constants.OperationStatus.REQUIRE_CONFIRMATION.toUpperCase().equals(status.get(i)) + || Constants.OperationStatus.CONFIRMED.toUpperCase().equals(status.get(i))) { } else { String msg = "Invalid status type: " + status + ". \nValid status types are COMPLETED | ERROR | " + - "IN_PROGRESS | NOTNOW | PENDING | REPEATED"; + "IN_PROGRESS | NOTNOW | PENDING | REPEATED | REQUIRE_CONFIRMATION | CONFIRMED"; 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.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/Constants.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/Constants.java index 7042bb8610..07364785e3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/Constants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/Constants.java @@ -68,6 +68,8 @@ public class Constants { public static final String PENDING = "pending"; public static final String NOTNOW = "notnow"; public static final String REPEATED = "repeated"; + public static final String REQUIRE_CONFIRMATION = "require_confirmation"; + public static final String CONFIRMED = "confirmed"; } public static final String DEVICES = "devices"; public static final String ATTRIBUTE_DISPLAY_NAME = "DisplayName"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java index c26a1f49a4..c84fe9e511 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java @@ -959,9 +959,15 @@ public class DeviceMgtAPIUtils { case Constants.OperationStatus.REPEATED: operation.setStatus(Operation.Status.REPEATED); break; + case Constants.OperationStatus.REQUIRE_CONFIRMATION: + operation.setStatus(Operation.Status.REQUIRE_CONFIRMATION); + break; + case Constants.OperationStatus.CONFIRMED: + operation.setStatus(Operation.Status.CONFIRMED); + break; default: String msg = "Invalid operation status. Valid operations: " + - "[IN_PROGRESS, PENDING, COMPLETED, ERROR, REPEATED, NOTNOW]"; + "[IN_PROGRESS, PENDING, COMPLETED, ERROR, REPEATED, NOTNOW, REQUIRE_CONFIRMATION, CONFIRMED]"; log.error(msg); throw new BadRequestException(msg); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/ActivityStatus.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/ActivityStatus.java index 234aa084c2..6a1a3ba9a0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/ActivityStatus.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/ActivityStatus.java @@ -30,7 +30,7 @@ import java.util.List; public class ActivityStatus { public enum Status { - IN_PROGRESS, PENDING, COMPLETED, ERROR, REPEATED, INVALID, UNAUTHORIZED, NOTNOW + IN_PROGRESS, PENDING, COMPLETED, ERROR, REPEATED, INVALID, UNAUTHORIZED, NOTNOW, REQUIRE_CONFIRMATION, CONFIRMED } @ApiModelProperty( diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/Operation.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/Operation.java index b3b863a5f3..2483c6cf3a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/Operation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/Operation.java @@ -37,7 +37,7 @@ public class Operation implements Serializable { } public enum Status { - IN_PROGRESS, PENDING, COMPLETED, ERROR, REPEATED, NOTNOW + IN_PROGRESS, PENDING, COMPLETED, ERROR, REPEATED, NOTNOW, REQUIRE_CONFIRMATION, CONFIRMED } public enum Control { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/Operation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/Operation.java index 03acfa9a11..a10cbd9ddb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/Operation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/Operation.java @@ -30,7 +30,7 @@ public class Operation implements Serializable { } public enum Status { - IN_PROGRESS, PENDING, COMPLETED, ERROR, REPEATED, NOTNOW + IN_PROGRESS, PENDING, COMPLETED, ERROR, REPEATED, NOTNOW, REQUIRE_CONFIRMATION, CONFIRMED } public enum Control {