diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-06-25 15:52:39 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-06-25 15:54:42 -0400 |
commit | 93bc7a00350d6ed250b26d47d5bd28147c591523 (patch) | |
tree | 43c4cd31cb8cd43759b2c4e27f9a0a7fe6c7da33 /asdc-controller/src/main | |
parent | f417537f5258530ed15ceaec111ce08a24ad6487 (diff) | |
parent | ac2b66be54faa91e6269e2ca4d2b5c08e8273feb (diff) |
Merge remote-tracking branch 'origin/dublin' into 'origin/master'
Change-Id: I2b91332563d9c7b0f469c9e45a35cc1376465c5e
Issue-ID: SO-2058
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'asdc-controller/src/main')
-rw-r--r-- | asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java | 47 | ||||
-rw-r--r-- | asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java | 3 |
2 files changed, 36 insertions, 14 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java index b634c26cf0..46c440db0d 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java @@ -33,16 +33,19 @@ import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.so.asdc.installer.VfResourceStructure; import org.onap.so.asdc.installer.WorkflowArtifact; import org.onap.so.db.catalog.beans.ActivitySpec; +import org.onap.so.db.catalog.beans.VnfResource; import org.onap.so.db.catalog.beans.VnfResourceWorkflow; import org.onap.so.db.catalog.beans.Workflow; import org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence; import org.onap.so.db.catalog.data.repository.ActivitySpecRepository; +import org.onap.so.db.catalog.data.repository.VnfResourceRepository; import org.onap.so.db.catalog.data.repository.WorkflowRepository; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; @Component @@ -61,20 +64,33 @@ public class WorkflowResource { protected ActivitySpecRepository activityRepo; @Autowired + protected VnfResourceRepository vnfResourceRepo; + + @Autowired private BpmnInstaller bpmnInstaller; public void processWorkflows(VfResourceStructure vfResourceStructure) throws Exception { Map<String, WorkflowArtifact> artifactsMapByUUID = vfResourceStructure.getWorkflowArtifactsMapByUUID(); - String vfResourceModelUuid = vfResourceStructure.getResourceInstance().getResourceUUID(); - for (String uuid : artifactsMapByUUID.keySet()) { - WorkflowArtifact artifactToInstall = artifactsMapByUUID.get(uuid); - if (isLatestVersionAvailable(artifactsMapByUUID, artifactToInstall)) { - logger.debug("Installing the BPMN: " + artifactToInstall.getArtifactInfo().getArtifactName()); - deployWorkflowResourceToCamunda(artifactToInstall); - installWorkflowResource(artifactToInstall, vfResourceModelUuid); - } else { - logger.debug("Skipping installing - not the latest version: " - + artifactToInstall.getArtifactInfo().getArtifactName()); + if (artifactsMapByUUID != null && !artifactsMapByUUID.isEmpty()) { + String vfResourceModelUuid = vfResourceStructure.getResourceInstance().getResourceUUID(); + VnfResource vnfResource = vnfResourceRepo.findResourceByModelUUID(vfResourceModelUuid); + if (vnfResource == null) { + logger.debug("Failed deploying BPMN for vfResourceModelUUID {}", vfResourceModelUuid); + logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), + vfResourceModelUuid, vfResourceModelUuid, HttpStatus.NOT_FOUND, ErrorCode.DataError.getValue(), + "ASDC BPMN deploy failed"); + throw (new Exception("VF Resource not present in Catalog DB: " + vfResourceModelUuid)); + } + for (String uuid : artifactsMapByUUID.keySet()) { + WorkflowArtifact artifactToInstall = artifactsMapByUUID.get(uuid); + if (isLatestVersionAvailable(artifactsMapByUUID, artifactToInstall)) { + logger.debug("Installing the BPMN: " + artifactToInstall.getArtifactInfo().getArtifactName()); + deployWorkflowResourceToCamunda(artifactToInstall); + installWorkflowResource(artifactToInstall, vfResourceModelUuid); + } else { + logger.debug("Skipping installing - not the latest version: " + + artifactToInstall.getArtifactInfo().getArtifactName()); + } } } } @@ -123,13 +139,14 @@ public class WorkflowResource { VnfResourceWorkflow vnfResourceWorkflow = new VnfResourceWorkflow(); vnfResourceWorkflow.setVnfResourceModelUUID(vfResourceModelUuid); + vnfResourceWorkflow.setWorkflow(workflow); List<VnfResourceWorkflow> vnfResourceWorkflows = new ArrayList<VnfResourceWorkflow>(); vnfResourceWorkflows.add(vnfResourceWorkflow); workflow.setVnfResourceWorkflow(vnfResourceWorkflows); List<String> activityNames = getActivityNameList(artifact.getResult()); - List<WorkflowActivitySpecSequence> wfss = getWorkflowActivitySpecSequence(activityNames); + List<WorkflowActivitySpecSequence> wfss = getWorkflowActivitySpecSequence(activityNames, workflow); workflow.setWorkflowActivitySpecSequence(wfss); workflowRepo.save(workflow); @@ -167,17 +184,21 @@ public class WorkflowResource { return activityNameList; } - protected List<WorkflowActivitySpecSequence> getWorkflowActivitySpecSequence(List<String> activityNames) - throws Exception { + protected List<WorkflowActivitySpecSequence> getWorkflowActivitySpecSequence(List<String> activityNames, + Workflow workflow) throws Exception { if (activityNames == null || activityNames.size() == 0) { return null; } List<WorkflowActivitySpecSequence> workflowActivitySpecs = new ArrayList<WorkflowActivitySpecSequence>(); + int seqNo = 1; for (String activityName : activityNames) { ActivitySpec activitySpec = activityRepo.findByName(activityName); if (activitySpec != null) { WorkflowActivitySpecSequence workflowActivitySpec = new WorkflowActivitySpecSequence(); workflowActivitySpec.setActivitySpec(activitySpec); + workflowActivitySpec.setWorkflow(workflow); + workflowActivitySpec.setSeqNo(seqNo); + seqNo++; workflowActivitySpecs.add(workflowActivitySpec); } } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index d250021d19..30196379a3 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -439,7 +439,6 @@ public class ToscaResourceInstaller { vfCustomizationCategory); } - workflowResource.processWorkflows(vfResourceStructure); processResourceSequence(toscaResourceStruct, service); List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources(); processAllottedResources(toscaResourceStruct, service, allottedResourceList); @@ -453,6 +452,8 @@ public class ToscaResourceInstaller { service = serviceRepo.save(service); correlateConfigCustomResources(service); + workflowResource.processWorkflows(vfResourceStructure); + WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus( vfResourceStruct.getNotification().getDistributionID(), MSO); status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name()); |