diff options
author | aditya puthuparambil <aditya.puthuparambil@bell.ca> | 2021-08-24 17:44:34 +0100 |
---|---|---|
committer | Renu Kumari <renu.kumari@bell.ca> | 2021-08-25 15:01:06 -0400 |
commit | 673c6d94830a1677e685cab82a76747a0808d347 (patch) | |
tree | 7eaaee1002bfda4adc20503b4850e8070fdeffc7 /cps-ncmp-service/src/main | |
parent | 0b0a89eec95e2cb2671bdd393e94fdaa89b9cc66 (diff) |
Add optional observed timestamp in the cps data api
- Added optional query parameter in cps data endpoints
- Updated service layer and notification to use observedTimestamp
Note:
- NCMP REST endpoints are not updated as a part of this patch
- NCMP does not sent observed timestamp when using cps data services
Issue-ID: CPS-477
Signed-off-by: puthuparambil.aditya <aditya.puthuparambil@bell.ca>
Change-Id: I1f92da3da7b3a13c45405fdf44e5fef861991d9a
Signed-off-by: Renu Kumari <renu.kumari@bell.ca>
Diffstat (limited to 'cps-ncmp-service/src/main')
-rwxr-xr-x | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java index 235030a84c..b5a591401a 100755 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java @@ -3,6 +3,7 @@ * Copyright (C) 2021 highstreet technologies GmbH * Modifications Copyright (C) 2021 Nordix Foundation * Modifications Copyright (C) 2021 Pantheon.tech + * Modifications Copyright (C) 2021 Bell Canada * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +25,7 @@ package org.onap.cps.ncmp.api.impl; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import java.time.OffsetDateTime; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; @@ -62,6 +64,8 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService private static final String NCMP_DMI_REGISTRY_ANCHOR = "ncmp-dmi-registry"; + private static final OffsetDateTime NO_TIMESTAMP = null; + private CpsDataService cpsDataService; private ObjectMapper objectMapper; @@ -105,25 +109,25 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService @Override public void createDataNode(final String cmHandle, final String parentNodeXpath, final String jsonData) { if (!StringUtils.hasText(parentNodeXpath) || "/".equals(parentNodeXpath)) { - cpsDataService.saveData(getDataspaceName(), cmHandle, jsonData); + cpsDataService.saveData(getDataspaceName(), cmHandle, jsonData, NO_TIMESTAMP); } else { - cpsDataService.saveData(getDataspaceName(), cmHandle, parentNodeXpath, jsonData); + cpsDataService.saveData(getDataspaceName(), cmHandle, parentNodeXpath, jsonData, NO_TIMESTAMP); } } @Override public void addListNodeElements(final String cmHandle, final String parentNodeXpath, final String jsonData) { - cpsDataService.saveListNodeData(getDataspaceName(), cmHandle, parentNodeXpath, jsonData); + cpsDataService.saveListNodeData(getDataspaceName(), cmHandle, parentNodeXpath, jsonData, NO_TIMESTAMP); } @Override public void updateNodeLeaves(final String cmHandle, final String parentNodeXpath, final String jsonData) { - cpsDataService.updateNodeLeaves(getDataspaceName(), cmHandle, parentNodeXpath, jsonData); + cpsDataService.updateNodeLeaves(getDataspaceName(), cmHandle, parentNodeXpath, jsonData, NO_TIMESTAMP); } @Override public void replaceNodeTree(final String cmHandle, final String parentNodeXpath, final String jsonData) { - cpsDataService.replaceNodeTree(getDataspaceName(), cmHandle, parentNodeXpath, jsonData); + cpsDataService.replaceNodeTree(getDataspaceName(), cmHandle, parentNodeXpath, jsonData, NO_TIMESTAMP); } @Override @@ -150,7 +154,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService persistenceCmHandlesList.setCmHandles(createdPersistenceCmHandles); final String cmHandleJsonData = objectMapper.writeValueAsString(persistenceCmHandlesList); cpsDataService.saveListNodeData(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, "/dmi-registry", - cmHandleJsonData); + cmHandleJsonData, NO_TIMESTAMP); } catch (final JsonProcessingException e) { log.error("Parsing error occurred while converting Object to JSON for Dmi Registry."); throw new DataValidationException( @@ -170,7 +174,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService persistenceCmHandlesList.setCmHandles(updatedPersistenceCmHandles); final String cmHandlesJsonData = objectMapper.writeValueAsString(persistenceCmHandlesList); cpsDataService.updateNodeLeavesAndExistingDescendantLeaves(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, - "/dmi-registry", cmHandlesJsonData); + "/dmi-registry", cmHandlesJsonData, NO_TIMESTAMP); } catch (final JsonProcessingException e) { log.error("Parsing error occurred while converting Object to JSON Dmi Registry."); throw new DataValidationException( @@ -183,7 +187,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService for (final String cmHandle: dmiPluginRegistration.getRemovedCmHandles()) { try { cpsDataService.deleteListNodeData(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, - "/dmi-registry/cm-handles[@id='" + cmHandle + "']"); + "/dmi-registry/cm-handles[@id='" + cmHandle + "']", NO_TIMESTAMP); } catch (final DataNodeNotFoundException e) { log.warn("Datanode {} not deleted message {}", cmHandle, e.getMessage()); } |