From 6d3fbf27479d06d2daf52e4e8f7564787a4cd2c3 Mon Sep 17 00:00:00 2001
From: nancylizi
Date: Thu, 20 Oct 2016 13:01:41 +0800
Subject: Fix the bug "Repeat upload package has logic error".
Change-Id: I548de180491738f3e13a119e9d6cc5e03253ca2d
Issue-id:TOSCA-124
Signed-off-by: nancylizi
---
.../org/openo/commontosca/catalog/wrapper/PackageWrapper.java | 9 +++++++++
1 file changed, 9 insertions(+)
(limited to 'catalog-core/catalog-mgr/src')
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 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));
--
cgit 1.2.3-korg