diff options
author | 2016-10-20 13:01:41 +0800 | |
---|---|---|
committer | 2016-10-20 13:01:41 +0800 | |
commit | 18b688c58e9eb37fe23ccb559f49cd7db7a16f0d (patch) | |
tree | 020cc07efbaa9e2aa372bc24442de29f25815e3a /catalog-core/catalog-mgr/src/main/java | |
parent | e81b7ee0258a74effcfba1f32fc9a141e717dd58 (diff) |
Fix the bug "Repeat upload package has logic error".
Change-Id: I548de180491738f3e13a119e9d6cc5e03253ca2d
Issue-id:TOSCA-124
Signed-off-by: nancylizi <li.zi30@zte.com.cn>
Diffstat (limited to 'catalog-core/catalog-mgr/src/main/java')
-rw-r--r-- | catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapper.java | 9 |
1 files changed, 9 insertions, 0 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 1358674a..ab206916 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 @@ -129,6 +129,15 @@ public class PackageWrapper { boolean uploadResult = FileManagerFactory.createFileManager().upload(tempDirName, destPath); if (uploadResult == true) { PackageData packageData = PackageWrapperUtil.getPackageData(packageMeta); + ArrayList<PackageData> existPackageDatas = + PackageManager.getInstance().queryPackage(packageData.getName(), + packageData.getProvider(), packageData.getVersion(), null, packageData.getType()); + if (null != existPackageDatas && existPackageDatas.size() > 0) { + LOG.warn("The package already exist ! Begin to delete the orgin data and reupload !"); + for (int i = 0; i < existPackageDatas.size(); i++) { + this.delPackage(existPackageDatas.get(i).getCsarId()); + } + } packateDbData = PackageManager.getInstance().addPackage(packageData); LOG.info("Store package data to database succed ! packateDbData = " + ToolUtil.objectToString(packateDbData)); |