From dc8bf53ee07a2e14cf282c6c56d88e707f1c540f Mon Sep 17 00:00:00 2001 From: nancylizi Date: Sat, 22 Oct 2016 11:24:11 +0800 Subject: Fix the bug of upload package in big size failed. Change-Id: Idf9e4aa578bf3e6a60da55777842df0685ae53aa Issue-id:TOSCA-131 Signed-off-by: nancylizi --- .../catalog/wrapper/PackageWrapper.java | 34 ++++++++++++---------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'catalog-core') diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapper.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapper.java index c796b85c..9025523c 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapper.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapper.java @@ -111,20 +111,23 @@ public class PackageWrapper { LOG.info("the fileLocation when upload package is :" + fileLocation); uploadedInputStream.close(); - PackageBasicInfo basicInfo = new PackageBasicInfo(); - basicInfo = PackageWrapperUtil.getPacageBasicInfo(fileLocation); - String path = basicInfo.getType().toString() + File.separator + basicInfo.getProvider() - + File.separator + fileName.replace(".csar", "") + File.separator + basicInfo.getVersion(); - LOG.info("dest path is : " + path); - PackageMeta packageMeta = new PackageMeta(); - packageMeta = PackageWrapperUtil.getPackageMeta(fileName, fileLocation, basicInfo); - String dowloadUri = File.separator + path + File.separator; - String destPath = File.separator + path; - packageMeta.setDownloadUri(dowloadUri); - LOG.info("packageMeta = " + ToolUtil.objectToString(packageMeta)); Boolean isEnd = PackageWrapperUtil.isUploadEnd(contentRange, fileName); PackageData packateDbData = new PackageData(); + UploadPackageResponse result = new UploadPackageResponse(); if (isEnd) { + PackageBasicInfo basicInfo = new PackageBasicInfo(); + basicInfo = PackageWrapperUtil.getPacageBasicInfo(fileLocation); + String path = + basicInfo.getType().toString() + File.separator + basicInfo.getProvider() + File.separator + + fileName.replace(".csar", "") + File.separator + basicInfo.getVersion(); + LOG.info("dest path is : " + path); + PackageMeta packageMeta = new PackageMeta(); + packageMeta = PackageWrapperUtil.getPackageMeta(fileName, fileLocation, basicInfo); + String dowloadUri = File.separator + path + File.separator; + String destPath = File.separator + path; + packageMeta.setDownloadUri(dowloadUri); + LOG.info("packageMeta = " + ToolUtil.objectToString(packageMeta)); + String serviceTemplateId = null; boolean uploadResult = FileManagerFactory.createFileManager().upload(tempDirName, destPath); if (uploadResult == true) { @@ -158,11 +161,10 @@ public class PackageWrapper { } } LOG.info("upload package file end, fileName:" + fileName); - } - UploadPackageResponse result = new UploadPackageResponse(); - result.setCsarId(packateDbData.getCsarId()); - if (tempDirName != null) { - ToolUtil.deleteDir(new File(tempDirName)); + result.setCsarId(packateDbData.getCsarId()); + if (tempDirName != null) { + ToolUtil.deleteDir(new File(tempDirName)); + } } return Response.ok(result).build(); } -- cgit 1.2.3-korg