diff options
author | mark.j.leonard <mark.j.leonard@gmail.com> | 2018-12-05 18:59:58 +0000 |
---|---|---|
committer | mark.j.leonard <mark.j.leonard@gmail.com> | 2018-12-05 19:07:37 +0000 |
commit | 0babe59ef157c1d767bce05cf0bebc12d962d1e0 (patch) | |
tree | c7547ab7f1b8f56978f202a327b202feea15d254 /src | |
parent | 0408ea82dc1a55b4f30e7062eb91e76b94091392 (diff) |
Add null check for Group member with no A&AI Model
Protect against a Null Pointer Exception when any member of an Instance
Group cannot be mapped to an output XML Resource or Widget.
Change-Id: Icf099686681b8dffb86e9f003bd92ace6e8679b1
Issue-ID: AAI-1991
Signed-off-by: mark.j.leonard <mark.j.leonard@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java b/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java index cae0324..615ad1e 100644 --- a/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java +++ b/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java @@ -307,18 +307,28 @@ public class ArtifactGeneratorToscaParser { */ private List<Resource> generateResourcesAndWidgets(final ArrayList<NodeTemplate> memberNodes, final Resource groupModel) { + log.debug(String.format("Processing member nodes for Group %s (invariant UUID %s)", // + groupModel.getModelName(), groupModel.getModelId())); + List<Resource> resources = new ArrayList<>(); + for (NodeTemplate nodeTemplate : memberNodes) { String nodeTypeName = normaliseNodeTypeName(nodeTemplate); - Model memberModel = Model.getModelFor(nodeTypeName, nodeTemplate.getMetaData().getValue("type")); - memberModel.populateModelIdentificationInformation(nodeTemplate.getMetaData().getAllProperties()); + final String metadataType = nodeTemplate.getMetaData().getValue("type"); + + log.debug(String.format("Get model for %s (metadata type %s)", nodeTypeName, metadataType)); + Model memberModel = Model.getModelFor(nodeTypeName, metadataType); - log.debug(String.format("Generating grouped %s (%s) from TOSCA type %s", - memberModel.getClass().getSuperclass().getSimpleName(), memberModel.getClass(), nodeTypeName)); + if (memberModel != null) { + memberModel.populateModelIdentificationInformation(nodeTemplate.getMetaData().getAllProperties()); - addRelatedModel(groupModel, memberModel); - if (memberModel instanceof Resource) { - resources.add((Resource) memberModel); + log.debug(String.format("Generating grouped %s (%s) from TOSCA type %s", + memberModel.getClass().getSuperclass().getSimpleName(), memberModel.getClass(), nodeTypeName)); + + addRelatedModel(groupModel, memberModel); + if (memberModel instanceof Resource) { + resources.add((Resource) memberModel); + } } } return resources; @@ -384,7 +394,7 @@ public class ArtifactGeneratorToscaParser { * @param resourceModel * parent Resource * @param metaData - * metadata for populating the Resource IDs + * for populating the Resource IDs * @param resourceNode * any Model (will be ignored if not a Resource) * @param nodeProperties |