diff options
-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)); |