Modify download logic for csar file 92/73892/1
authorguochuyicmri <guochuyi@chinamobile.com>
Thu, 29 Nov 2018 09:08:57 +0000 (17:08 +0800)
committerguochuyicmri <guochuyi@chinamobile.com>
Thu, 29 Nov 2018 09:09:06 +0000 (17:09 +0800)
Change-Id: Iea00981a05b3a34a0ba2b7bc3eaef45da35c32e5
Issue-ID: USECASEUI-157
Signed-off-by: guochuyicmri <guochuyi@chinamobile.com>
server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java
server/src/main/java/org/onap/usecaseui/server/util/UuiCommonUtil.java

index 704e411..9aba5cc 100644 (file)
@@ -31,6 +31,7 @@ import org.onap.usecaseui.server.service.lcm.domain.sdc.SDCCatalogService;
 import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
 import org.onap.usecaseui.server.service.lcm.domain.sdc.exceptions.SDCCatalogException;
 import org.onap.usecaseui.server.util.RestfulServices;
+import org.onap.usecaseui.server.util.UuiCommonUtil;
 import org.openecomp.sdc.toscaparser.api.NodeTemplate;
 import org.openecomp.sdc.toscaparser.api.Property;
 import org.openecomp.sdc.toscaparser.api.ToscaTemplate;
@@ -94,7 +95,9 @@ public class DefaultServiceTemplateService implements ServiceTemplateService {
         String toPath = String.format("/home/uui/%s.csar", uuid);
         //String toPath = String.format("D:\\work/%s.csar", uuid);
         try {
-               downloadFile(toscaModelPath, toPath);
+               if(!UuiCommonUtil.isExistFile(toPath)){
+                       downloadFile(toscaModelPath, toPath);
+               }
             return extractTemplate(toPath, isVF);
         }  catch (IOException e) {
             throw new SDCCatalogException("download csar file failed!", e);
index 3a90e71..a1513fd 100644 (file)
@@ -16,6 +16,7 @@
 package org.onap.usecaseui.server.util;
 
 import java.io.BufferedReader;
+import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.Array;
 import java.util.ArrayList;
@@ -136,4 +137,14 @@ public class UuiCommonUtil {
         }
                return listPages;
        }
+       
+    public static boolean isExistFile(String path) {
+        
+        if (null == path || "".equals(path.trim())) {
+            return false;
+        }
+        File targetFile = new File(path);
+        return targetFile.exists();
+    }
 }