Reading template files from uui location 37/73937/1
authorzhangab <zhanganbing@chinamobile.com>
Thu, 29 Nov 2018 14:02:30 +0000 (22:02 +0800)
committerzhangab <zhanganbing@chinamobile.com>
Thu, 29 Nov 2018 14:02:31 +0000 (22:02 +0800)
Change-Id: I41697e221774aedf3d62a81f9915f7483bd2fd41
Issue-ID: USECASEUI-190
Signed-off-by: zhangab <zhanganbing@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();
+    }
 }