diff options
author | nancylizi <li.zi30@zte.com.cn> | 2016-10-20 13:01:41 +0800 |
---|---|---|
committer | nancylizi <li.zi30@zte.com.cn> | 2016-10-20 14:30:21 +0800 |
commit | 6d3fbf27479d06d2daf52e4e8f7564787a4cd2c3 (patch) | |
tree | 984d7a67fa445e6a4aae583225ab318ef960cbd5 /catalog-core/catalog-mgr/src | |
parent | 40cc875b84448470bc02495e4d5bc3fb6982ff75 (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')
-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)); |