save csar file path add directory version 35/60835/8
authorYulian Han <elaine.hanyulian@huawei.com>
Sat, 18 Aug 2018 12:28:09 +0000 (20:28 +0800)
committerYulian Han <elaine.hanyulian@huawei.com>
Tue, 21 Aug 2018 08:35:35 +0000 (16:35 +0800)
Change-Id: Idaa55084f5ecb0dd3636c232cebc14fa70000009
Issue-ID: SO-668
Signed-off-by: Yulian Han <elaine.hanyulian@huawei.com>
asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java

index 55a437f..0af1ded 100644 (file)
@@ -22,6 +22,7 @@ d * ============LICENSE_START===================================================
 package org.onap.so.asdc.client;
 
 
+import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
@@ -352,9 +353,17 @@ public class ASDCController {
                        + artifact.getArtifactUUID ()
                        + ")");
        
+       String filePath = System.getProperty("mso.config.path") + "/ASDC" + "/" + artifact.getArtifactVersion() + "/" + artifact.getArtifactName();
+       // make parent directory
+       File file = new File(filePath);         
+       File fileParent = file.getParentFile();
+       if (!fileParent.exists()) {
+           fileParent.mkdirs();
+       }
+
        byte[] payloadBytes = resultArtifact.getArtifactPayload();
        
-       try (FileOutputStream outFile = new FileOutputStream(System.getProperty("mso.config.path") + "/ASDC" + "/" + artifact.getArtifactName())) {
+       try (FileOutputStream outFile = new FileOutputStream(filePath)) {
                LOGGER.info(MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF, "***WRITE FILE ARTIFACT NAME", "ASDC", artifact.getArtifactName());
                outFile.write(payloadBytes, 0, payloadBytes.length);
                outFile.close();
index 8353f70..0300351 100644 (file)
@@ -126,7 +126,9 @@ public class ToscaResourceStructure {
                        
                        LOGGER.debug("MSO config path is: " + System.getProperty("mso.config.path"));
                        
-                       File spoolFile = new File(System.getProperty("mso.config.path") + "/ASDC/" + artifact.getArtifactName());
+                       String filePath = System.getProperty("mso.config.path") + "/ASDC/" + artifact.getArtifactVersion() + "/" + artifact.getArtifactName();
+
+                       File spoolFile = new File(filePath);
  
                        LOGGER.debug("ASDC File path is: " + spoolFile.getAbsolutePath());
                        LOGGER.info(MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF, "***PATH", "ASDC", spoolFile.getAbsolutePath());
index ca2da77..e4bd2f1 100644 (file)
@@ -191,7 +191,9 @@ public class ResourceRequestBuilder {
 
         HashMap<String, String> map = new Gson().fromJson(value, new TypeToken<HashMap<String, String>>() {}.getType());
 
-        File csarFile = new File(System.getProperty("mso.config.path") + "ASDC/" + map.get("name"));
+        String filePath = System.getProperty("mso.config.path") + "ASDC/" +  map.get("version") + "/" + map.get("name");
+
+        File csarFile = new File(filePath);
 
         if(!csarFile.exists()) {
             throw new Exception("csar file does not exist.");