From badc1b5e02d60e15d08e231883cf74d2a28d92e1 Mon Sep 17 00:00:00 2001 From: sebdet Date: Thu, 28 May 2020 17:26:39 +0200 Subject: Fix crash at SDC deploy If CDS properties are not there, it can crash a standard VF resource blueprint deployment. Issue-ID: CLAMP-857 Signed-off-by: sebdet Change-Id: I4172427046250fed52984c2b94531370727f0fa0 --- .../java/org/onap/clamp/loop/cds/CdsDataInstaller.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/main/java/org') diff --git a/src/main/java/org/onap/clamp/loop/cds/CdsDataInstaller.java b/src/main/java/org/onap/clamp/loop/cds/CdsDataInstaller.java index 9c1cd3bc2..d18cae1d6 100644 --- a/src/main/java/org/onap/clamp/loop/cds/CdsDataInstaller.java +++ b/src/main/java/org/onap/clamp/loop/cds/CdsDataInstaller.java @@ -73,18 +73,23 @@ public class CdsDataInstaller { for (NodeTemplate nodeTemplate : csar.getSdcCsarHelper().getServiceNodeTemplateBySdcType(type)) { // get cds artifact information and save in resources Prop if (SdcTypes.PNF == type || SdcTypes.VF == type) { - JsonObject controllerProperties = createCdsArtifactProperties(nodeTemplate.getPropertyValue( - SDNC_MODEL_NAME).toString(), - nodeTemplate.getPropertyValue(SDNC_MODEL_VERSION).toString()); + JsonObject controllerProperties = createCdsArtifactProperties( + String.valueOf(nodeTemplate.getPropertyValue(SDNC_MODEL_NAME)), + String.valueOf(nodeTemplate.getPropertyValue(SDNC_MODEL_VERSION))); if (controllerProperties != null) { resourcesPropByType.getAsJsonObject(nodeTemplate.getName()) .add(CONTROLLER_PROPERTIES, controllerProperties); + logger.info("Successfully installed the CDS data in Service"); + } + else { + logger.warn("Skipping CDS data installation in Service, as sdnc_model_name and " + + "sdnc_model_version are not provided in the CSAR"); } } } } serviceRepository.save(service); - logger.info("Successfully installed the CDS data in Service"); + return service; } @@ -129,7 +134,8 @@ public class CdsDataInstaller { * @return Returns CDS artifacts information */ private JsonObject createCdsArtifactProperties(String sdncModelName, String sdncModelVersion) { - if (sdncModelName != null && sdncModelVersion != null) { + if (sdncModelName != null && !"null".equals(sdncModelName) + && sdncModelVersion != null && !"null".equals(sdncModelVersion)) { JsonObject controllerProperties = new JsonObject(); controllerProperties.addProperty(SDNC_MODEL_NAME, sdncModelName); controllerProperties.addProperty(SDNC_MODEL_VERSION, sdncModelVersion); -- cgit 1.2.3-korg