aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguochuyicmri <guochuyi@chinamobile.com>2018-11-29 17:08:57 +0800
committerguochuyicmri <guochuyi@chinamobile.com>2018-11-29 17:09:06 +0800
commit30c10fa4c0351968d5e5b296291d8094ab93778d (patch)
tree62595a0810b11d0bb460e846298af67f0d89177b
parent67f803ddee8d169cc1272bf48d86c5d0b5b86824 (diff)
Modify download logic for csar file
Change-Id: Iea00981a05b3a34a0ba2b7bc3eaef45da35c32e5 Issue-ID: USECASEUI-157 Signed-off-by: guochuyicmri <guochuyi@chinamobile.com>
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java5
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/util/UuiCommonUtil.java11
2 files changed, 15 insertions, 1 deletions
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java
index 704e4112..9aba5cca 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java
@@ -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);
diff --git a/server/src/main/java/org/onap/usecaseui/server/util/UuiCommonUtil.java b/server/src/main/java/org/onap/usecaseui/server/util/UuiCommonUtil.java
index 3a90e713..a1513fd4 100644
--- a/server/src/main/java/org/onap/usecaseui/server/util/UuiCommonUtil.java
+++ b/server/src/main/java/org/onap/usecaseui/server/util/UuiCommonUtil.java
@@ -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();
+ }
}