diff options
Diffstat (limited to 'asdc-controller')
-rw-r--r-- | asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java | 7 | ||||
-rw-r--r-- | asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java | 27 |
2 files changed, 34 insertions, 0 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java index 503de0429e..bcc2e15a7d 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java @@ -686,6 +686,13 @@ public class ASDCController { try { this.processCsarServiceArtifacts(iNotif, toscaResourceStructure); + IArtifactInfo iArtifact = toscaResourceStructure.getToscaArtifact(); + String filePath = System.getProperty("mso.config.path") + "/ASDC/" + iArtifact.getArtifactVersion() + "/" + iArtifact.getArtifactName(); + File csarFile = new File(filePath); + String csarFilePath = csarFile.getAbsolutePath(); + if (bpmnInstaller.containsWorkflows(csarFilePath)) { + bpmnInstaller.installBpmn(csarFilePath); + } for (IResourceInstance resource : iNotif.getResources()){ diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java index f131b73175..0fde1332d6 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java @@ -23,6 +23,7 @@ package org.onap.so.asdc.installer.bpmn; import java.io.*; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Enumeration; import java.util.zip.*; import org.apache.commons.io.IOUtils; @@ -105,6 +106,30 @@ public class BpmnInstaller { } return; } + + public boolean containsWorkflows(String csarFilePath) { + boolean workflowsInCsar = false; + try { + ZipFile zipFile = new ZipFile(csarFilePath); + Enumeration<? extends ZipEntry> zipEntries = zipFile.entries(); + while (zipEntries.hasMoreElements()) { + String fileName = ((ZipEntry) zipEntries.nextElement()).getName(); + if (fileName.endsWith(BPMN_SUFFIX)) { + workflowsInCsar = true; + break; + } + } + } + catch (Exception e) { + LOGGER.debug("Exception :",e); + LOGGER.error(MessageEnum.ASDC_ARTIFACT_CHECK_EXC, + csarFilePath, + "", + "", + e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "ASDC Unable to check CSAR entries"); + } + return workflowsInCsar; + } protected HttpResponse sendDeploymentRequest(String bpmnFileName) throws Exception { HttpClient client = HttpClientBuilder.create().build(); @@ -149,6 +174,8 @@ public class BpmnInstaller { .setField("Content-Disposition", String.format("form-data; name=\"%s\"; filename=\"%s\"; size=%d", bpmnFileName, bpmnFileName, bytesToSend.length)) .build()) .build(); + + IOUtils.closeQuietly(bpmnFileStream); return requestEntity; } |