diff options
30 files changed, 298 insertions, 38 deletions
diff --git a/checkstyle/pom.xml b/checkstyle/pom.xml index 5baa5d0dad..9aea19e3ec 100644 --- a/checkstyle/pom.xml +++ b/checkstyle/pom.xml @@ -26,7 +26,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.onap.cps</groupId> <artifactId>checkstyle</artifactId> - <version>3.2.2-SNAPSHOT</version> + <version>3.2.3-SNAPSHOT</version> <profiles> <profile> diff --git a/cps-application/pom.xml b/cps-application/pom.xml index fb50efda66..1a4e2d1f80 100755 --- a/cps-application/pom.xml +++ b/cps-application/pom.xml @@ -28,7 +28,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.2.2-SNAPSHOT</version> + <version>3.2.3-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> diff --git a/cps-bom/pom.xml b/cps-bom/pom.xml index 4870e0fde8..b7046d342f 100644 --- a/cps-bom/pom.xml +++ b/cps-bom/pom.xml @@ -25,7 +25,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.onap.cps</groupId> <artifactId>cps-bom</artifactId> - <version>3.2.2-SNAPSHOT</version> + <version>3.2.3-SNAPSHOT</version> <packaging>pom</packaging> <description>This artifact contains dependencyManagement declarations of all published CPS components.</description> diff --git a/cps-dependencies/pom.xml b/cps-dependencies/pom.xml index 43e773e87e..c215990c15 100755 --- a/cps-dependencies/pom.xml +++ b/cps-dependencies/pom.xml @@ -27,7 +27,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.onap.cps</groupId> <artifactId>cps-dependencies</artifactId> - <version>3.2.2-SNAPSHOT</version> + <version>3.2.3-SNAPSHOT</version> <packaging>pom</packaging> <name>${project.groupId}:${project.artifactId}</name> diff --git a/cps-events/pom.xml b/cps-events/pom.xml index d0398ca38a..ce8a9592ee 100644 --- a/cps-events/pom.xml +++ b/cps-events/pom.xml @@ -24,7 +24,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.2.2-SNAPSHOT</version> + <version>3.2.3-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> diff --git a/cps-ncmp-events/pom.xml b/cps-ncmp-events/pom.xml index 405bea59db..0b0c7f6a7d 100644 --- a/cps-ncmp-events/pom.xml +++ b/cps-ncmp-events/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.2.2-SNAPSHOT</version> + <version>3.2.3-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> diff --git a/cps-ncmp-rest-stub/pom.xml b/cps-ncmp-rest-stub/pom.xml index 2c842db863..b1b65067d1 100644 --- a/cps-ncmp-rest-stub/pom.xml +++ b/cps-ncmp-rest-stub/pom.xml @@ -26,7 +26,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.2.2-SNAPSHOT</version> + <version>3.2.3-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> diff --git a/cps-ncmp-rest/pom.xml b/cps-ncmp-rest/pom.xml index 4a652243f3..ffbf6176fc 100644 --- a/cps-ncmp-rest/pom.xml +++ b/cps-ncmp-rest/pom.xml @@ -27,7 +27,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.2.2-SNAPSHOT</version> + <version>3.2.3-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> diff --git a/cps-ncmp-service/pom.xml b/cps-ncmp-service/pom.xml index de86cff7f5..e8c2d933cf 100644 --- a/cps-ncmp-service/pom.xml +++ b/cps-ncmp-service/pom.xml @@ -27,7 +27,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.2.2-SNAPSHOT</version> + <version>3.2.3-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> 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 95ff48a9c2..f8e06593c5 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 @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation + * Copyright (C) 2022-2023 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,11 +20,16 @@ package org.onap.cps.ncmp.api.impl.utils; +import java.util.ArrayList; +import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import lombok.AccessLevel; import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle; import org.onap.cps.ncmp.api.inventory.CompositeState; import org.onap.cps.ncmp.api.inventory.CompositeStateBuilder; @@ -32,8 +37,11 @@ import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle; import org.onap.cps.spi.model.DataNode; @NoArgsConstructor(access = AccessLevel.PRIVATE) +@Slf4j public class YangDataConverter { + private static final Pattern cmHandleIdInXpathPattern = Pattern.compile("\\[@id='(.*?)']"); + /** * This method convert yang model cm handle to ncmp service cm handle. * @param yangModelCmHandle the yang model of the cm handle @@ -78,10 +86,72 @@ public class YangDataConverter { (String) cmHandleDataNode.getLeaves().get("dmi-service-name"), (String) cmHandleDataNode.getLeaves().get("dmi-data-service-name"), (String) cmHandleDataNode.getLeaves().get("dmi-model-service-name"), - ncmpServiceCmHandle + ncmpServiceCmHandle + ); + } + + /** + * This method convert cm handle data node to yang model cm handle without using NcmpServiceCmHandle. + * + * @param cmHandleDataNode the datanode of the cm handle + * @param cmHandleId the id of the cm handle + * @return yang model cm handle + */ + public static YangModelCmHandle convertCmHandleToYangModelWithoutNcmpServiceCmHandle( + final DataNode cmHandleDataNode, + final String cmHandleId) { + final Map<String, String> dmiProperties = new LinkedHashMap<>(); + final Map<String, String> publicProperties = new LinkedHashMap<>(); + final CompositeStateBuilder compositeStateBuilder = new CompositeStateBuilder(); + CompositeState compositeState = compositeStateBuilder.build(); + for (final DataNode childDataNode : cmHandleDataNode.getChildDataNodes()) { + if (childDataNode.getXpath().contains("/additional-properties[@name=")) { + addProperty(childDataNode, dmiProperties); + } else if (childDataNode.getXpath().contains("/public-properties[@name=")) { + addProperty(childDataNode, publicProperties); + } else if (childDataNode.getXpath().endsWith("/state")) { + compositeState = compositeStateBuilder.fromDataNode(childDataNode).build(); + } + } + return YangModelCmHandle.toYangModelCmHandleWithoutNcmpServiceHandle( + (String) cmHandleDataNode.getLeaves().get("dmi-service-name"), + (String) cmHandleDataNode.getLeaves().get("dmi-data-service-name"), + (String) cmHandleDataNode.getLeaves().get("dmi-model-service-name"), + cmHandleId, + dmiProperties, + publicProperties, + compositeState ); } + /** + * This method convert cm handle data nodes to yang model cm handles. + * @param cmHandleDataNodes the datanode of the cm handle + * @return yang model cm handles + */ + public static Collection<YangModelCmHandle> convertDataNodesToYangModelCmHandles( + final Collection<DataNode> cmHandleDataNodes) { + final Collection<YangModelCmHandle> yangModelCmHandles = new ArrayList<>(cmHandleDataNodes.size()); + cmHandleDataNodes.forEach(dataNode -> { + final String cmHandleId = extractCmHandleIdFromXpath(dataNode.getXpath()); + if (cmHandleId != null) { + yangModelCmHandles.add(convertCmHandleToYangModelWithoutNcmpServiceCmHandle(dataNode, cmHandleId)); + } + }); + return yangModelCmHandles; + } + + private static String extractCmHandleIdFromXpath(final String xpath) { + final Matcher matcher = cmHandleIdInXpathPattern.matcher(xpath); + if (matcher.find()) { + return matcher.group(1); + } else { + log.error("Unexpected xpath {}", xpath); + } + return null; + } + + private static void populateCmHandleDetails(final DataNode cmHandleDataNode, final NcmpServiceCmHandle ncmpServiceCmHandle) { final Map<String, String> dmiProperties = new LinkedHashMap<>(); @@ -108,14 +178,14 @@ public class YangDataConverter { } private static void setDmiProperties(final List<YangModelCmHandle.Property> dmiProperties, - final NcmpServiceCmHandle ncmpServiceCmHandle) { + final NcmpServiceCmHandle ncmpServiceCmHandle) { final Map<String, String> dmiPropertiesMap = new LinkedHashMap<>(dmiProperties.size()); asPropertiesMap(dmiProperties, dmiPropertiesMap); ncmpServiceCmHandle.setDmiProperties(dmiPropertiesMap); } private static void setPublicProperties(final List<YangModelCmHandle.Property> publicProperties, - final NcmpServiceCmHandle ncmpServiceCmHandle) { + final NcmpServiceCmHandle ncmpServiceCmHandle) { final Map<String, String> publicPropertiesMap = new LinkedHashMap<>(); asPropertiesMap(publicProperties, publicPropertiesMap); ncmpServiceCmHandle.setPublicProperties(publicPropertiesMap); 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 aabc52c592..5f98f14995 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 @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation + * Copyright (C) 2021-2023 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -115,6 +115,38 @@ public class YangModelCmHandle { return yangModelCmHandle; } + + /** + * Create a yangModelCmHandle without the use of NcmpServiceHandle. + * + * @param dmiServiceName dmi service name + * @param dmiDataServiceName dmi data service name + * @param dmiModelServiceName dmi model service name + * @param cmHandleId the cm handle id + * @param dmiProperties dmiProperties + * @param publicProperties publicProperties + * @param compositeState compositeState + * @return instance of yangModelCmHandle + */ + public static YangModelCmHandle toYangModelCmHandleWithoutNcmpServiceHandle(final String dmiServiceName, + final String dmiDataServiceName, + final String dmiModelServiceName, + final String cmHandleId, + final Map<String, String> dmiProperties, + final Map<String, String> publicProperties, + final CompositeState compositeState) { + final YangModelCmHandle yangModelCmHandle = new YangModelCmHandle(); + yangModelCmHandle.setId(cmHandleId); + yangModelCmHandle.setDmiServiceName(dmiServiceName); + yangModelCmHandle.setDmiDataServiceName(dmiDataServiceName); + yangModelCmHandle.setDmiModelServiceName(dmiModelServiceName); + yangModelCmHandle.setDmiProperties(asYangModelCmHandleProperties(dmiProperties)); + yangModelCmHandle.setPublicProperties(asYangModelCmHandleProperties(publicProperties)); + yangModelCmHandle.setCompositeState(compositeState); + return yangModelCmHandle; + } + + /** * Resolve a dmi service name. * diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java index 55442ecffb..10227cf26f 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java @@ -62,6 +62,14 @@ public interface InventoryPersistence { YangModelCmHandle getYangModelCmHandle(String cmHandleId); /** + * This method retrieves DMI service name, DMI properties and the state for a given cm handle. + * + * @param cmHandleIds a list of the ids of the cm handles + * @return collection of yang model cm handles + */ + Collection<YangModelCmHandle> getYangModelCmHandles(Collection<String> cmHandleIds); + + /** * Method to return module definitions by cmHandleId. * * @param cmHandleId cm handle ID @@ -123,6 +131,23 @@ public interface InventoryPersistence { DataNode getDataNode(String xpath, FetchDescendantsOption fetchDescendantsOption); /** + * Get collection of data nodes via xpaths. + * + * @param xpaths collection of xpaths + * @return collection of data nodes + */ + Collection<DataNode> getDataNodes(Collection<String> xpaths); + + /** + * Get collection of data nodes via xpaths. + * + * @param xpaths collection of xpaths + * @param fetchDescendantsOption fetch descendants option + * @return collection of data nodes + */ + Collection<DataNode> getDataNodes(Collection<String> xpaths, FetchDescendantsOption fetchDescendantsOption); + + /** * Get data node of given cm handle. * * @param cmHandleId cmHandle ID @@ -131,6 +156,14 @@ public interface InventoryPersistence { DataNode getCmHandleDataNode(String cmHandleId); /** + * Get collection of data nodes of given cm handles. + * + * @param cmHandleIds collection of cmHandle IDs + * @return collection of data nodes + */ + Collection<DataNode> getCmHandleDataNodes(Collection<String> cmHandleIds); + + /** * get CM handles that has given module names. * * @param moduleNamesForQuery module names diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImpl.java index 29712f4d0b..c2578ccbf7 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImpl.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022-2023 Nordix Foundation + * Copyright (C) 2022 Nordix Foundation * Modifications Copyright (C) 2022 Bell Canada * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -33,6 +33,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.onap.cps.api.CpsAdminService; @@ -41,6 +42,7 @@ import org.onap.cps.api.CpsModuleService; import org.onap.cps.ncmp.api.impl.utils.YangDataConverter; import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle; import org.onap.cps.spi.FetchDescendantsOption; +import org.onap.cps.spi.exceptions.DataValidationException; import org.onap.cps.spi.exceptions.SchemaSetNotFoundException; import org.onap.cps.spi.model.DataNode; import org.onap.cps.spi.model.ModuleDefinition; @@ -75,8 +77,8 @@ public class InventoryPersistenceImpl implements InventoryPersistence { @Override public CompositeState getCmHandleState(final String cmHandleId) { final DataNode stateAsDataNode = cpsDataService.getDataNode(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, - String.format(CM_HANDLE_XPATH_TEMPLATE, cmHandleId) + "/state", - FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS); + String.format(CM_HANDLE_XPATH_TEMPLATE, cmHandleId) + "/state", + FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS); cpsValidator.validateNameCharacters(cmHandleId); return new CompositeStateBuilder().fromDataNode(stateAsDataNode).build(); } @@ -107,6 +109,21 @@ public class InventoryPersistenceImpl implements InventoryPersistence { } @Override + public Collection<YangModelCmHandle> getYangModelCmHandles(final Collection<String> cmHandleIds) { + final Collection<String> validCmHandleIds = new ArrayList<>(); + cmHandleIds.forEach(cmHandleId -> { + try { + cpsValidator.validateNameCharacters(cmHandleId); + validCmHandleIds.add(cmHandleId); + } catch (final DataValidationException dataValidationException) { + log.error("DataValidationException in CmHandleId {} to be ignored", + dataValidationException.getMessage()); + } + }); + return YangDataConverter.convertDataNodesToYangModelCmHandles(getCmHandleDataNodes(validCmHandleIds)); + } + + @Override public Collection<ModuleDefinition> getModuleDefinitionsByCmHandleId(final String cmHandleId) { return cpsModuleService.getModuleDefinitionsByAnchorName(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId); } @@ -142,7 +159,7 @@ public class InventoryPersistenceImpl implements InventoryPersistence { @Override @Timed(value = "cps.ncmp.inventory.persistence.schemaset.delete", - description = "Time taken to delete a schemaset") + description = "Time taken to delete a schemaset") public void deleteSchemaSetWithCascade(final String schemaSetName) { try { cpsValidator.validateNameCharacters(schemaSetName); @@ -154,24 +171,46 @@ public class InventoryPersistenceImpl implements InventoryPersistence { } @Override + @Timed(value = "cps.ncmp.inventory.persistence.datanode.get", + description = "Time taken to get a data node (from ncmp dmi registry)") public DataNode getDataNode(final String xpath) { return getDataNode(xpath, INCLUDE_ALL_DESCENDANTS); } @Override @Timed(value = "cps.ncmp.inventory.persistence.datanode.get", - description = "Time taken to get a data node (from ncmp dmi registry)") + description = "Time taken to get a data node (from ncmp dmi registry)") public DataNode getDataNode(final String xpath, final FetchDescendantsOption fetchDescendantsOption) { return cpsDataService.getDataNode(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, xpath, fetchDescendantsOption); } @Override + public Collection<DataNode> getDataNodes(final Collection<String> xpaths) { + return getDataNodes(xpaths, INCLUDE_ALL_DESCENDANTS); + } + + @Override + public Collection<DataNode> getDataNodes(final Collection<String> xpaths, + final FetchDescendantsOption fetchDescendantsOption) { + return cpsDataService.getDataNodes(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, + xpaths, fetchDescendantsOption); + } + + @Override public DataNode getCmHandleDataNode(final String cmHandleId) { return this.getDataNode(String.format(CM_HANDLE_XPATH_TEMPLATE, cmHandleId)); } @Override + public Collection<DataNode> getCmHandleDataNodes(final Collection<String> cmHandleIds) { + final Collection<String> xpaths = cmHandleIds.stream().map(cmHandleId -> + String.format(CM_HANDLE_XPATH_TEMPLATE, cmHandleId)) + .collect(Collectors.toList()); + return this.getDataNodes(xpaths); + } + + @Override public Collection<String> getCmHandleIdsWithGivenModules(final Collection<String> moduleNamesForQuery) { return cpsAdminService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, moduleNamesForQuery); } @@ -191,4 +230,4 @@ public class InventoryPersistenceImpl implements InventoryPersistence { public void deleteDataNodes(final Collection<String> dataNodeXpaths) { cpsDataService.deleteDataNodes(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, dataNodeXpaths, NO_TIMESTAMP); } -} +}
\ No newline at end of file diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/YangDataConverterSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/YangDataConverterSpec.groovy index 3ef3df5ef6..dd673eb8f8 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/YangDataConverterSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/YangDataConverterSpec.groovy @@ -38,4 +38,18 @@ class YangDataConverterSpec extends Specification{ assert yangModelCmHandle.dmiProperties[0].name == 'dmiProp1' assert yangModelCmHandle.dmiProperties[0].value == 'dmiValue1' } + + def 'Convert multiple cm handle data nodes'(){ + given: 'two data nodes in a collection one with private properties' + def dataNodeAdditionalProperties = new DataNode(xpath:'/additional-properties[@name="dmiProp1"]', + leaves: ['name': 'dmiProp1', 'value': 'dmiValue1']) + def dataNodes = [new DataNode(xpath:'/dmi-registry/cm-handles[@id=\'some-cm-handle\']'), + new DataNode(xpath:'/dmi-registry/cm-handles[@id=\'another-cm-handle\']', childDataNodes:[dataNodeAdditionalProperties])] + when: 'the data nodes are converted' + def yangModelCmHandles = YangDataConverter.convertDataNodesToYangModelCmHandles(dataNodes) + then: 'verify both have returned and cmhandleIds are correct' + assert yangModelCmHandles.size() == 2 + assert yangModelCmHandles.id.containsAll(['some-cm-handle', 'another-cm-handle']) + } + } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy index 2ca0e9964a..93e79f6824 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation + * Copyright (C) 2022-2023 Nordix Foundation * Modifications Copyright (C) 2022 Bell Canada * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,6 +28,7 @@ import org.onap.cps.api.CpsModuleService import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle import org.onap.cps.spi.CascadeDeleteAllowed import org.onap.cps.spi.FetchDescendantsOption +import org.onap.cps.spi.exceptions.DataValidationException import org.onap.cps.spi.model.DataNode import org.onap.cps.spi.model.ModuleDefinition import org.onap.cps.spi.model.ModuleReference @@ -38,6 +39,7 @@ import spock.lang.Specification import java.time.OffsetDateTime import java.time.ZoneOffset import java.time.format.DateTimeFormatter +import java.util.stream.Collectors import static org.onap.cps.ncmp.api.impl.constants.DmiRegistryConstants.NO_TIMESTAMP import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS @@ -64,6 +66,9 @@ class InventoryPersistenceImplSpec extends Specification { def leaves = ["dmi-service-name":"common service name","dmi-data-service-name":"data service name","dmi-model-service-name":"model service name"] def xpath = "/dmi-registry/cm-handles[@id='some-cm-handle']" + def cmHandleId2 = 'another-cm-handle' + def xpath2 = "/dmi-registry/cm-handles[@id='another-cm-handle']" + @Shared def childDataNodesForCmHandleWithAllProperties = [new DataNode(xpath: "/dmi-registry/cm-handles[@id='some cm handle']/additional-properties[@name='name1']", leaves: ["name":"name1", "value":"value1"]), new DataNode(xpath: "/dmi-registry/cm-handles[@id='some cm handle']/public-properties[@name='name2']", leaves: ["name":"name2","value":"value2"])] @@ -118,6 +123,26 @@ class InventoryPersistenceImplSpec extends Specification { 1 * mockCpsValidator.validateNameCharacters(cmHandleId) } + def "Retrieve multiple YangModelCmHandles"() { + given: 'the cps data service returns 2 data nodes from the DMI registry' + def dataNodes = [new DataNode(xpath: xpath), new DataNode(xpath: xpath2)] + mockCpsDataService.getDataNodes('NCMP-Admin', 'ncmp-dmi-registry', [xpath, xpath2] , INCLUDE_ALL_DESCENDANTS) >> dataNodes + when: 'retrieving the yang modelled cm handle' + def results = objectUnderTest.getYangModelCmHandles([cmHandleId, cmHandleId2]) + then: 'verify both have returned and cmhandleIds are correct' + assert results.size() == 2 + assert results.id.containsAll([cmHandleId, cmHandleId2]) + } + + def "Handling name validation errors in getYangModelCmHandles."() { + given: 'the cps data service returns one of two data nodes from the DMI registry with empty leaf attributes' + mockCpsValidator.validateNameCharacters(cmHandleId) >> {throw new DataValidationException('some message', 'some detail')} + when: + objectUnderTest.getYangModelCmHandle(cmHandleId) + then: 'exception is thrown' + thrown(DataValidationException) + } + def 'Get a Cm Handle Composite State'() { given: 'a valid cm handle id' def cmHandleId = 'Some-Cm-Handle' diff --git a/cps-parent/pom.xml b/cps-parent/pom.xml index 4d7c4284d8..f66f57b15b 100755 --- a/cps-parent/pom.xml +++ b/cps-parent/pom.xml @@ -32,7 +32,7 @@ <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.2.2-SNAPSHOT</version> + <version>3.2.3-SNAPSHOT</version> <packaging>pom</packaging> <properties> diff --git a/cps-path-parser/pom.xml b/cps-path-parser/pom.xml index f7cc2a385a..3a468eedf5 100644 --- a/cps-path-parser/pom.xml +++ b/cps-path-parser/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.2.2-SNAPSHOT</version> + <version>3.2.3-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> diff --git a/cps-rest/pom.xml b/cps-rest/pom.xml index 1e79d0519e..7f1ff59381 100755 --- a/cps-rest/pom.xml +++ b/cps-rest/pom.xml @@ -28,7 +28,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.2.2-SNAPSHOT</version> + <version>3.2.3-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> diff --git a/cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java b/cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java index d5c2b092b0..534077caa6 100644 --- a/cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java @@ -136,7 +136,7 @@ public class MultipartFileUtil { while ((numberOfBytesRead = zipInputStream.read(buffer, 0, READ_BUFFER_SIZE)) > 0) { byteArrayOutputStream.write(buffer, 0, numberOfBytesRead); totalSizeEntry += numberOfBytesRead; - zipFileSizeValidator.updateTotalSizeArchive(totalSizeEntry); + zipFileSizeValidator.updateTotalSizeArchive(numberOfBytesRead); zipFileSizeValidator.validateCompresssionRatio(totalSizeEntry); } return byteArrayOutputStream.toString(StandardCharsets.UTF_8); diff --git a/cps-ri/pom.xml b/cps-ri/pom.xml index 5f7796aec3..ee1d5accfe 100644 --- a/cps-ri/pom.xml +++ b/cps-ri/pom.xml @@ -26,7 +26,7 @@ <parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.2.2-SNAPSHOT</version>
+ <version>3.2.3-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
diff --git a/cps-service/pom.xml b/cps-service/pom.xml index d9babf5301..80bf076cb6 100644 --- a/cps-service/pom.xml +++ b/cps-service/pom.xml @@ -29,7 +29,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.2.2-SNAPSHOT</version> + <version>3.2.3-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> diff --git a/docs/api/swagger/cps/openapi.yaml b/docs/api/swagger/cps/openapi.yaml index 53bc840ec7..edbf878d3d 100644 --- a/docs/api/swagger/cps/openapi.yaml +++ b/docs/api/swagger/cps/openapi.yaml @@ -1320,11 +1320,12 @@ paths: value: "/shops/bookstore/categories[@code=1]" - name: descendants in: query - description: "Number of descendants to query. Allowed values are 'none', 'all', -1 (for all), 0 (for none) and any positive number." + description: "Number of descendants to query. Allowed values are 'none', 'all',\ + \ -1 (for all), 0 (for none) and any positive number." required: false schema: type: string - example: 3 + example: "3" default: none responses: "200": @@ -2255,8 +2256,8 @@ paths: value: "//categories[@code=1]" - name: descendants in: query - description: "descendents to query depth of children. allowed values are none,\ - \ all, any number starting from -1" + description: "Number of descendants to query. Allowed values are 'none', 'all',\ + \ -1 (for all), 0 (for none) and any positive number." required: false schema: type: string diff --git a/docs/release-notes.rst b/docs/release-notes.rst index d40cd499d8..9bed964287 100755 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -16,6 +16,35 @@ CPS Release Notes .. * * * LONDON * * * .. ====================== +Version: 3.2.3 +============== + +Release Data +------------ + ++--------------------------------------+--------------------------------------------------------+ +| **CPS Project** | | +| | | ++--------------------------------------+--------------------------------------------------------+ +| **Docker images** | onap/cps-and-ncmp:3.2.3 | +| | | ++--------------------------------------+--------------------------------------------------------+ +| **Release designation** | 3.2.3 London | +| | | ++--------------------------------------+--------------------------------------------------------+ +| **Release date** | Not been released yet | +| | | ++--------------------------------------+--------------------------------------------------------+ + +Bug Fixes +--------- +3.2.3 + - None + +Features +-------- + - None + Version: 3.2.2 ============== @@ -32,13 +61,18 @@ Release Data | **Release designation** | 3.2.2 London | | | | +--------------------------------------+--------------------------------------------------------+ -| **Release date** | Not been released yet | +| **Release date** | 2023 February 08 | | | | +--------------------------------------+--------------------------------------------------------+ Bug Fixes --------- - -None +3.2.2 + - `CPS-1173 <https://jira.onap.org/browse/CPS-1173>`_ Delete Performance Improvements. + +Features +-------- + - None Version: 3.2.1 ============== diff --git a/integration-test/pom.xml b/integration-test/pom.xml index d5ba649cda..1351ff9514 100644 --- a/integration-test/pom.xml +++ b/integration-test/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.2.2-SNAPSHOT</version> + <version>3.2.3-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> diff --git a/jacoco-report/pom.xml b/jacoco-report/pom.xml index 7d293e87b9..fd50df78ed 100644 --- a/jacoco-report/pom.xml +++ b/jacoco-report/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.2.2-SNAPSHOT</version> + <version>3.2.3-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> @@ -32,7 +32,7 @@ <groupId>org.onap.cps</groupId>
<artifactId>cps-aggregator</artifactId>
- <version>3.2.2-SNAPSHOT</version>
+ <version>3.2.3-SNAPSHOT</version>
<packaging>pom</packaging>
<name>cps</name>
diff --git a/releases/3.2.2-container.yaml b/releases/3.2.2-container.yaml new file mode 100644 index 0000000000..93664a4847 --- /dev/null +++ b/releases/3.2.2-container.yaml @@ -0,0 +1,8 @@ +distribution_type: container +container_release_tag: 3.2.2 +project: cps +log_dir: cps-maven-docker-stage-master/845/ +ref: 0b5950d5ae02f527fa9e595de3f7bea8d567c26e +containers: + - name: 'cps-and-ncmp' + version: '3.2.2-20230208T094442Z' diff --git a/releases/3.2.2.yaml b/releases/3.2.2.yaml new file mode 100644 index 0000000000..0256541159 --- /dev/null +++ b/releases/3.2.2.yaml @@ -0,0 +1,4 @@ +distribution_type: maven +log_dir: cps-maven-stage-master/851/ +project: cps +version: 3.2.2
\ No newline at end of file diff --git a/spotbugs/pom.xml b/spotbugs/pom.xml index cb5cd5ea08..f6220716e6 100644 --- a/spotbugs/pom.xml +++ b/spotbugs/pom.xml @@ -25,7 +25,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.onap.cps</groupId> <artifactId>spotbugs</artifactId> - <version>3.2.2-SNAPSHOT</version> + <version>3.2.3-SNAPSHOT</version> <properties> <nexusproxy>https://nexus.onap.org</nexusproxy> diff --git a/version.properties b/version.properties index f384e8932a..7c5f0305bf 100755 --- a/version.properties +++ b/version.properties @@ -22,7 +22,7 @@ major=3 minor=2 -patch=2 +patch=3 base_version=${major}.${minor}.${patch} |