diff options
author | nancylizi <li.zi30@zte.com.cn> | 2016-10-22 11:24:11 +0800 |
---|---|---|
committer | nancylizi <li.zi30@zte.com.cn> | 2016-10-22 11:24:11 +0800 |
commit | dc8bf53ee07a2e14cf282c6c56d88e707f1c540f (patch) | |
tree | 2ef481e3914dda5d3b513434af208493256010cb /catalog-core | |
parent | 0f1d00623cf43a9c0401a49c2ee86370c860680b (diff) |
Fix the bug of upload package in big size failed.
Change-Id: Idf9e4aa578bf3e6a60da55777842df0685ae53aa
Issue-id:TOSCA-131
Signed-off-by: nancylizi <li.zi30@zte.com.cn>
Diffstat (limited to 'catalog-core')
-rw-r--r-- | catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapper.java | 34 |
1 files changed, 18 insertions, 16 deletions
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(); } |