diff options
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 | 3 | ||||
-rw-r--r-- | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java | 48 | ||||
-rw-r--r-- | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java | 3 | ||||
-rw-r--r-- | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java | 12 | ||||
-rw-r--r-- | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java | 5 | ||||
-rw-r--r-- | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java | 4 | ||||
-rw-r--r-- | cps-ncmp-service/src/main/resources/models/dmi-registry@2024-02-23.yang (renamed from cps-ncmp-service/src/main/resources/models/dmi-registry@2023-11-27.yang) | 8 |
7 files changed, 65 insertions, 18 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 4c905bf90f..6ab6eab653 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 @@ -459,7 +459,8 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService dmiPluginRegistration.getDmiModelPlugin(), ncmpServiceCmHandle, ncmpServiceCmHandle.getModuleSetTag(), - ncmpServiceCmHandle.getAlternateId()); + ncmpServiceCmHandle.getAlternateId(), + ncmpServiceCmHandle.getDataProducerIdentifier()); } private void processTrustLevels(final Collection<NcmpServiceCmHandle> cmHandlesToBeCreated, diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java index 3d15291633..f861910024 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java @@ -47,6 +47,8 @@ import lombok.extern.slf4j.Slf4j; import org.onap.cps.api.CpsDataService; import org.onap.cps.ncmp.api.impl.inventory.InventoryPersistence; import org.onap.cps.ncmp.api.impl.utils.AlternateIdChecker; +import org.onap.cps.ncmp.api.impl.utils.YangDataConverter; +import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle; import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse; import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle; import org.onap.cps.spi.exceptions.DataNodeNotFoundException; @@ -55,6 +57,7 @@ import org.onap.cps.spi.model.DataNode; import org.onap.cps.spi.model.DataNodeBuilder; import org.onap.cps.utils.JsonObjectMapper; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; @Slf4j @Service @@ -110,7 +113,9 @@ public class NetworkCmProxyDataServicePropertyHandler { private void processUpdates(final DataNode existingCmHandleDataNode, final NcmpServiceCmHandle updatedNcmpServiceCmHandle) { - updateAlternateId(updatedNcmpServiceCmHandle); + setAndUpdateCmHandleField( + updatedNcmpServiceCmHandle.getCmHandleId(), "alternate-id", updatedNcmpServiceCmHandle.getAlternateId()); + updateDataProducerIdentifier(existingCmHandleDataNode, updatedNcmpServiceCmHandle); if (!updatedNcmpServiceCmHandle.getPublicProperties().isEmpty()) { updateProperties(existingCmHandleDataNode, PUBLIC_PROPERTY, updatedNcmpServiceCmHandle.getPublicProperties()); @@ -120,17 +125,24 @@ public class NetworkCmProxyDataServicePropertyHandler { } } - private void updateAlternateId(final NcmpServiceCmHandle updatedNcmpServiceCmHandle) { - final String updatedAlternateId = updatedNcmpServiceCmHandle.getAlternateId(); - final String cmHandleId = updatedNcmpServiceCmHandle.getCmHandleId(); - final Map<String, String> cmHandleProperties = new HashMap<>(2); - cmHandleProperties.put("id", cmHandleId); - cmHandleProperties.put("alternate-id", updatedAlternateId); - final Map<String, Map<String, String>> dmiRegistryProperties = new HashMap<>(1); - dmiRegistryProperties.put("cm-handles", cmHandleProperties); - cpsDataService.updateNodeLeaves(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, NCMP_DMI_REGISTRY_PARENT, - jsonObjectMapper.asJsonString(dmiRegistryProperties), OffsetDateTime.now()); - log.debug("Updating alternateId for cmHandle {} with value : {})", cmHandleId, updatedAlternateId); + private void updateDataProducerIdentifier(final DataNode cmHandleDataNode, + final NcmpServiceCmHandle ncmpServiceCmHandle) { + final String newDataProducerIdentifier = ncmpServiceCmHandle.getDataProducerIdentifier(); + if (StringUtils.hasText(newDataProducerIdentifier)) { + final YangModelCmHandle yangModelCmHandle = + YangDataConverter.convertCmHandleToYangModel(cmHandleDataNode); + final String existingDataProducerIdentifier = yangModelCmHandle.getDataProducerIdentifier(); + if (StringUtils.hasText(existingDataProducerIdentifier)) { + if (!existingDataProducerIdentifier.equals(newDataProducerIdentifier)) { + log.warn("Unable to update dataProducerIdentifier for cmHandle {}. " + + "Value for dataProducerIdentifier has been set previously.", + ncmpServiceCmHandle.getCmHandleId()); + } + } else { + setAndUpdateCmHandleField( + yangModelCmHandle.getId(), "data-producer-identifier", newDataProducerIdentifier); + } + } } private void updateProperties(final DataNode existingCmHandleDataNode, final PropertyType propertyType, @@ -202,6 +214,18 @@ public class NetworkCmProxyDataServicePropertyHandler { return new DataNodeBuilder().withXpath(xpath).withLeaves(ImmutableMap.copyOf(updatedLeaves)).build(); } + private void setAndUpdateCmHandleField(final String cmHandleIdToUpdate, final String fieldName, + final String newFieldValue) { + final Map<String, Map<String, String>> dmiRegistryData = new HashMap<>(1); + final Map<String, String> cmHandleData = new HashMap<>(2); + cmHandleData.put("id", cmHandleIdToUpdate); + cmHandleData.put(fieldName, newFieldValue); + dmiRegistryData.put("cm-handles", cmHandleData); + cpsDataService.updateNodeLeaves(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, NCMP_DMI_REGISTRY_PARENT, + jsonObjectMapper.asJsonString(dmiRegistryData), OffsetDateTime.now()); + log.debug("Updating {} for cmHandle {} with value : {})", fieldName, cmHandleIdToUpdate, newFieldValue); + } + enum PropertyType { DMI_PROPERTY("additional-properties"), PUBLIC_PROPERTY("public-properties"); diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java index 3954142976..e043e029f6 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java @@ -89,7 +89,8 @@ public class YangDataConverter { (String) cmHandleDataNode.getLeaves().get("dmi-model-service-name"), ncmpServiceCmHandle, (String) cmHandleDataNode.getLeaves().get("module-set-tag"), - (String) cmHandleDataNode.getLeaves().get("alternate-id") + (String) cmHandleDataNode.getLeaves().get("alternate-id"), + (String) cmHandleDataNode.getLeaves().get("data-producer-identifier") ); } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java index b2758d9d5f..2ca2b2eb0d 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java @@ -70,6 +70,9 @@ public class YangModelCmHandle { @JsonProperty("alternate-id") private String alternateId; + @JsonProperty("data-producer-identifier") + private String dataProducerIdentifier; + @JsonProperty("additional-properties") private List<Property> dmiProperties; @@ -95,6 +98,7 @@ public class YangModelCmHandle { original.getPublicProperties() == null ? null : new ArrayList<>(original.getPublicProperties()); copy.moduleSetTag = original.getModuleSetTag(); copy.alternateId = original.getAlternateId(); + copy.dataProducerIdentifier = original.getDataProducerIdentifier(); return copy; } @@ -105,6 +109,9 @@ public class YangModelCmHandle { * @param dmiDataServiceName dmi data service name * @param dmiModelServiceName dmi model service name * @param ncmpServiceCmHandle the cm handle + * @param moduleSetTag moduleSetTag + * @param alternateId alternateId + * @param dataProducerIdentifier dataProducerIdentifier * @return instance of yangModelCmHandle */ public static YangModelCmHandle toYangModelCmHandle(final String dmiServiceName, @@ -112,7 +119,8 @@ public class YangModelCmHandle { final String dmiModelServiceName, final NcmpServiceCmHandle ncmpServiceCmHandle, final String moduleSetTag, - final String alternateId) { + final String alternateId, + final String dataProducerIdentifier) { final YangModelCmHandle yangModelCmHandle = new YangModelCmHandle(); yangModelCmHandle.setId(ncmpServiceCmHandle.getCmHandleId()); yangModelCmHandle.setDmiServiceName(dmiServiceName); @@ -120,6 +128,8 @@ public class YangModelCmHandle { yangModelCmHandle.setDmiModelServiceName(dmiModelServiceName); yangModelCmHandle.setModuleSetTag(moduleSetTag == null ? StringUtils.EMPTY : moduleSetTag); yangModelCmHandle.setAlternateId(alternateId == null ? StringUtils.EMPTY : alternateId); + yangModelCmHandle.setDataProducerIdentifier( + dataProducerIdentifier == null ? StringUtils.EMPTY : dataProducerIdentifier); yangModelCmHandle.setDmiProperties(asYangModelCmHandleProperties(ncmpServiceCmHandle.getDmiProperties())); yangModelCmHandle.setPublicProperties(asYangModelCmHandleProperties( ncmpServiceCmHandle.getPublicProperties())); diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java index 4989878975..676eebc4d6 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 Nordix Foundation + * Copyright (C) 2021-2024 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,4 +60,7 @@ public class NcmpServiceCmHandle { @JsonSetter(nulls = Nulls.AS_EMPTY) private String alternateId; + + @JsonSetter(nulls = Nulls.AS_EMPTY) + private String dataProducerIdentifier; } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java index 01bfc2b5d4..d0d63ab8eb 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java @@ -34,8 +34,8 @@ import org.springframework.stereotype.Service; @Service public class InventoryModelLoader extends AbstractModelLoader { - private static final String NEW_MODEL_FILE_NAME = "dmi-registry@2023-11-27.yang"; - private static final String NEW_SCHEMA_SET_NAME = "dmi-registry-2023-11-27"; + private static final String NEW_MODEL_FILE_NAME = "dmi-registry@2024-02-23.yang"; + private static final String NEW_SCHEMA_SET_NAME = "dmi-registry-2024-02-23"; public InventoryModelLoader(final CpsDataspaceService cpsDataspaceService, final CpsModuleService cpsModuleService, diff --git a/cps-ncmp-service/src/main/resources/models/dmi-registry@2023-11-27.yang b/cps-ncmp-service/src/main/resources/models/dmi-registry@2024-02-23.yang index 808bbdd1bc..8daf82f336 100644 --- a/cps-ncmp-service/src/main/resources/models/dmi-registry@2023-11-27.yang +++ b/cps-ncmp-service/src/main/resources/models/dmi-registry@2024-02-23.yang @@ -8,6 +8,11 @@ module dmi-registry { contact "toine.siebelink@est.tech"; + revision "2024-02-23" { + description + "Added data-producer-identifier"; + } + revision "2023-11-27" { description "Added alternate-id"; @@ -91,6 +96,9 @@ module dmi-registry { leaf alternate-id { type string; } + leaf data-producer-identifier { + type string; + } list additional-properties { key "name"; |