summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main/java
diff options
context:
space:
mode:
authorToine Siebelink <toine.siebelink@est.tech>2022-06-21 09:21:59 +0000
committerGerrit Code Review <gerrit@onap.org>2022-06-21 09:21:59 +0000
commitbb751bac8610645758d8f315087e79904b94c370 (patch)
tree7a10d72d141f401b181f7c1bd742cbf12f6bb510 /cps-ncmp-service/src/main/java
parenta00dd467e73f321a5415b3f68b434134b28e5718 (diff)
parent79b2a7c04f5f81e81c8870bfef15f90b9a9f48b9 (diff)
Merge "Exclude CM-Handles that are not in state 'READY'"
Diffstat (limited to 'cps-ncmp-service/src/main/java')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java
index d409a80e55..d0e17d4c08 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java
@@ -25,11 +25,14 @@ import static org.onap.cps.ncmp.api.impl.operations.DmiOperations.DataStoreEnum.
import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum;
import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.READ;
+import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.api.impl.client.DmiRestClient;
import org.onap.cps.ncmp.api.impl.config.NcmpConfiguration;
import org.onap.cps.ncmp.api.impl.utils.DmiServiceUrlBuilder;
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
+import org.onap.cps.ncmp.api.inventory.CmHandleState;
import org.onap.cps.ncmp.api.inventory.InventoryPersistence;
+import org.onap.cps.spi.exceptions.CpsException;
import org.onap.cps.utils.CpsValidator;
import org.onap.cps.utils.JsonObjectMapper;
import org.springframework.http.ResponseEntity;
@@ -39,6 +42,7 @@ import org.springframework.stereotype.Component;
* Operations class for DMI data.
*/
@Component
+@Slf4j
public class DmiDataOperations extends DmiOperations {
/**
@@ -74,6 +78,8 @@ public class DmiDataOperations extends DmiOperations {
CpsValidator.validateNameCharacters(cmHandleId);
final YangModelCmHandle yangModelCmHandle =
inventoryPersistence.getYangModelCmHandle(cmHandleId);
+ final CmHandleState cmHandleState = yangModelCmHandle.getCompositeState().getCmHandleState();
+ isCmHandleStateReady(yangModelCmHandle, cmHandleState);
final DmiRequestBody dmiRequestBody = DmiRequestBody.builder()
.operation(READ)
.requestId(requestId)
@@ -106,6 +112,8 @@ public class DmiDataOperations extends DmiOperations {
CpsValidator.validateNameCharacters(cmHandleId);
final YangModelCmHandle yangModelCmHandle =
inventoryPersistence.getYangModelCmHandle(cmHandleId);
+ final CmHandleState cmHandleState = yangModelCmHandle.getCompositeState().getCmHandleState();
+ isCmHandleStateReady(yangModelCmHandle, cmHandleState);
final DmiRequestBody dmiRequestBody = DmiRequestBody.builder()
.operation(operation)
.data(requestData)
@@ -120,4 +128,12 @@ public class DmiDataOperations extends DmiOperations {
return dmiRestClient.postOperationWithJsonData(dmiUrl, jsonBody, operation);
}
+ private void isCmHandleStateReady(final YangModelCmHandle yangModelCmHandle, final CmHandleState cmHandleState) {
+ if (cmHandleState != CmHandleState.READY) {
+ throw new CpsException("State mismatch exception.", "Cm-Handle not in READY state. "
+ + "cm handle state is "
+ + yangModelCmHandle.getCompositeState().getCmHandleState());
+ }
+ }
+
}