X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fbabel%2Fparser%2FArtifactGeneratorToscaParser.java;h=0777e516fc0a2963b293a4a9311d12599824f039;hb=refs%2Fchanges%2F37%2F83637%2F1;hp=281ac63537627b68fe404f317bf1e5d3ae1603f1;hpb=c1824169b0cfa25101c1efa8118d6b0b085edd15;p=aai%2Fbabel.git 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 281ac63..0777e51 100644 --- a/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java +++ b/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java @@ -237,10 +237,18 @@ public class ArtifactGeneratorToscaParser { } /** + * Add each of the resources to the specified resourceModel. If the resourceModel type is Allotted Resource then + * validate that one of the resources is a Providing Service. + * * @param resourceModel + * parent Resource model * @param resourceNodeTemplates + * the child node templates of the resourceModel + * @throws XmlArtifactGenerationException + * if the resourceModel is an ALLOTTED_RESOURCE with no Providing Service */ - public void processResourceModels(Model resourceModel, List resourceNodeTemplates) { + public void processResourceModels(Resource resourceModel, List resourceNodeTemplates) + throws XmlArtifactGenerationException { boolean foundProvidingService = false; for (NodeTemplate resourceNodeTemplate : resourceNodeTemplates) { @@ -261,9 +269,8 @@ public class ArtifactGeneratorToscaParser { } if (resourceModel.hasWidgetType("ALLOTTED_RESOURCE") && !foundProvidingService) { - final String modelInvariantId = resourceModel.getModelId(); - throw new IllegalArgumentException(String.format(GENERATOR_AAI_PROVIDING_SERVICE_MISSING, - modelInvariantId == null ? "" : modelInvariantId)); + throw new XmlArtifactGenerationException(String.format(GENERATOR_AAI_PROVIDING_SERVICE_MISSING, + Optional.ofNullable(resourceModel.getModelId()).orElse(""))); } }