X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fbabel%2Fcsar%2Fvnfcatalog%2FVnfVendorImageExtractor.java;h=d5ba7931a790e7e40f4d198ad7a110ef8b825aa9;hb=6342b6f7e46266caf72cbee7c96f782cc5093d80;hp=5f3d15bc5a1805cff8cd96e05f8464aef7e252d8;hpb=60457e41054465e9fa10c8e6bfdbfa62a45d1f0a;p=aai%2Fbabel.git diff --git a/src/main/java/org/onap/aai/babel/csar/vnfcatalog/VnfVendorImageExtractor.java b/src/main/java/org/onap/aai/babel/csar/vnfcatalog/VnfVendorImageExtractor.java index 5f3d15b..d5ba793 100644 --- a/src/main/java/org/onap/aai/babel/csar/vnfcatalog/VnfVendorImageExtractor.java +++ b/src/main/java/org/onap/aai/babel/csar/vnfcatalog/VnfVendorImageExtractor.java @@ -187,11 +187,14 @@ public class VnfVendorImageExtractor { * the path to the CSAR file * @return a List of Vendor Image Configurations * @throws SdcToscaParserException + * if the SDC TOSCA parser determines that the CSAR is invalid * @throws ToscaToCatalogException + * if there are no software versions defined for an image * @throws InvalidNumberOfNodesException + * if multiple VNF configuration nodes are found in the CSAR */ private List createVendorImageConfigurations(String csarFilepath) - throws SdcToscaParserException, InvalidNumberOfNodesException { + throws SdcToscaParserException, ToscaToCatalogException, InvalidNumberOfNodesException { ISdcCsarHelper csarHelper = SdcToscaParserFactory.getInstance().getSdcCsarHelper(csarFilepath); List serviceVfList = ToscaParser.getServiceNodeTemplates(csarHelper) @@ -215,7 +218,11 @@ public class VnfVendorImageExtractor { + vnfConfigs.size() + " nodes were found in the CSAR."); } - return createVendorImageConfigurations(serviceVfList, vnfConfigurationNode); + try { + return createVendorImageConfigurations(serviceVfList, vnfConfigurationNode); + } catch (IllegalArgumentException e) { + throw new ToscaToCatalogException(e.getMessage()); + } } return Collections.emptyList(); @@ -263,8 +270,11 @@ public class VnfVendorImageExtractor { * the node template for the VF * * @return a stream of VendorImageConfiguration objects + * @throws IllegalArgumentException + * if the VF has no child node templates which contain images (complex properties) that have software + * version strings */ - private Stream buildVendorImageConfigurations( + Stream buildVendorImageConfigurations( Collection>> flavorMaps, NodeTemplate vfNodeTemplate) { String resourceVendor = vfNodeTemplate.getMetaData().getValue("resourceVendor"); applicationLogger.debug("Resource Vendor " + resourceVendor); @@ -273,6 +283,10 @@ public class VnfVendorImageExtractor { extractSoftwareVersions(vfNodeTemplate.getSubMappingToscaTemplate().getNodeTemplates()); applicationLogger.debug("Software Versions: " + softwareVersions); + if (softwareVersions.isEmpty()) { + throw new IllegalArgumentException("No software versions could be found for this CSAR file"); + } + return flavorMaps.stream() // .map(value -> value.entrySet().stream() // .filter(entry -> VENDOR_INFO.equals(entry.getKey())) //