X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fclamp%2Floop%2FCsarInstaller.java;fp=src%2Fmain%2Fjava%2Forg%2Fonap%2Fclamp%2Floop%2FCsarInstaller.java;h=6752a1a36a06f9eef594bd450102c8f94c1bd275;hb=4f47b61e3dc7608f9883b1bde4d6cb60438c6368;hp=67c7ce5cff8388727420435c309e2ed4fae105a4;hpb=f4a608a7afb623b0d5acf8395863dd5982ff3bd5;p=clamp.git diff --git a/src/main/java/org/onap/clamp/loop/CsarInstaller.java b/src/main/java/org/onap/clamp/loop/CsarInstaller.java index 67c7ce5c..6752a1a3 100644 --- a/src/main/java/org/onap/clamp/loop/CsarInstaller.java +++ b/src/main/java/org/onap/clamp/loop/CsarInstaller.java @@ -152,7 +152,8 @@ public class CsarInstaller { private LoopTemplate createLoopTemplateFromBlueprint(CsarHandler csar, BlueprintArtifact blueprintArtifact, Service service) - throws IOException, ParseException, InterruptedException, BlueprintParserException { + throws IOException, ParseException, InterruptedException, BlueprintParserException, + SdcArtifactInstallerException { LoopTemplate newLoopTemplate = new LoopTemplate(); newLoopTemplate.setBlueprint(blueprintArtifact.getDcaeBlueprint()); newLoopTemplate.setName(LoopTemplate.generateLoopTemplateName(csar.getSdcNotification().getServiceName(), @@ -165,32 +166,35 @@ public class CsarInstaller { microServicesChain = BlueprintParser.fallbackToOneMicroService(); } newLoopTemplate.setModelService(service); - newLoopTemplate.addLoopElementModels(createMicroServiceModels(microServicesChain)); + newLoopTemplate.addLoopElementModels(createMicroServiceModels(blueprintArtifact, microServicesChain)); newLoopTemplate.setMaximumInstancesAllowed(0); DcaeInventoryResponse dcaeResponse = queryDcaeToGetServiceTypeId(blueprintArtifact); newLoopTemplate.setDcaeBlueprintId(dcaeResponse.getTypeId()); return newLoopTemplate; } - private HashSet createMicroServiceModels(List microServicesChain) - throws InterruptedException { + private HashSet createMicroServiceModels(BlueprintArtifact blueprintArtifact, + List microServicesChain) + throws SdcArtifactInstallerException { HashSet newSet = new HashSet<>(); for (BlueprintMicroService microService : microServicesChain) { LoopElementModel loopElementModel = new LoopElementModel(microService.getModelType(), LoopElementModel.MICRO_SERVICE_TYPE, null); newSet.add(loopElementModel); - loopElementModel.addPolicyModel(getPolicyModel(microService)); + PolicyModel newPolicyModel = policyEngineServices.createPolicyModelFromPolicyEngine(microService); + if (newPolicyModel != null) { + loopElementModel.addPolicyModel(newPolicyModel); + } else { + throw new SdcArtifactInstallerException( + "Unable to find the policy specified in the blueprint " + + blueprintArtifact.getBlueprintArtifactName() + ") on the Policy Engine:" + + microService.getModelType() + "/" + microService.getModelVersion()); + } } return newSet; } - private PolicyModel getPolicyModel(BlueprintMicroService microService) throws InterruptedException { - return policyModelsRepository - .findById(new PolicyModelId(microService.getModelType(), microService.getModelVersion())) - .orElse(policyEngineServices.createPolicyModelFromPolicyEngine(microService)); - } - /** * Get the service blueprint Id in the Dcae inventory using the SDC UUID. *