diff options
Diffstat (limited to 'src/main/java/org/onap/clamp/loop/CsarInstaller.java')
-rw-r--r-- | src/main/java/org/onap/clamp/loop/CsarInstaller.java | 26 |
1 files changed, 15 insertions, 11 deletions
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<LoopElementModel> createMicroServiceModels(List<BlueprintMicroService> microServicesChain) - throws InterruptedException { + private HashSet<LoopElementModel> createMicroServiceModels(BlueprintArtifact blueprintArtifact, + List<BlueprintMicroService> microServicesChain) + throws SdcArtifactInstallerException { HashSet<LoopElementModel> 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. * |