X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-ncmp-service%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fcps%2Fncmp%2Fapi%2Finventory%2FCompositeState.java;h=eeaa4cd0bef0d72565c55696c28e0e23ecfedc5c;hb=912c86dec96e675c2635298cea8869d014938042;hp=9ac49a6ceb4d6315c605abe939376accaf29f108;hpb=5d3ed6ff2fe76e2510867379fdf58d4e99b2cc9f;p=cps.git diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CompositeState.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CompositeState.java index 9ac49a6ce..eeaa4cd0b 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CompositeState.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CompositeState.java @@ -22,6 +22,8 @@ package org.onap.cps.ncmp.api.inventory; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; import lombok.Builder; import lombok.Data; import lombok.Getter; @@ -38,7 +40,7 @@ import lombok.Setter; public class CompositeState { @JsonProperty("cm-handle-state") - private CmHandleState cmhandleState; + private CmHandleState cmHandleState; @JsonProperty("lock-reason") private LockReason lockReason; @@ -52,13 +54,24 @@ public class CompositeState { @JsonProperty("datastores") private DataStores dataStores; + /** + * Date and Time in the format of yyyy-MM-dd'T'HH:mm:ss.SSSZ + */ + public static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); + + + /** + * This will specify the latest lock reason for a specific cm handle. If a cm handle is in a state other than LOCKED + * it specifies the last lock reason. + * This can be used to track retry attempts as part of the lock details. + */ @Data @Builder @JsonInclude(JsonInclude.Include.NON_NULL) public static class LockReason { @JsonProperty("reason") - private String reason; + private LockReasonCategory lockReasonCategory; @JsonProperty("details") private String details; @@ -72,9 +85,6 @@ public class CompositeState { @JsonProperty("operational") private Operational operationalDataStore; - - @JsonProperty("running") - private Running runningDataStore; } @Data @@ -101,4 +111,20 @@ public class CompositeState { private String lastSyncTime; } + /** + * The date and time format used for the cm handle sync state. + * + * @return the date and time in the format of yyyy-MM-dd'T'HH:mm:ss.SSSZ + */ + public static String nowInSyncTimeFormat() { + return dateTimeFormatter.format(OffsetDateTime.now()); + } + + /** + * Sets the last updated date and time for the cm handle sync state. + */ + public void setLastUpdateTimeNow() { + lastUpdateTime = CompositeState.nowInSyncTimeFormat(); + } + }