Package name should be unique
Error if someone upload with same name
Issue-ID: VNFSDK-142
Change-Id: I4b2cf10e58c62e14bccc5b0dbcf997745d1e9137
Signed-off-by: Murali-P <murali.p@huawei.com>
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java
index d793a32..cc3ec20 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java
@@ -198,6 +198,13 @@
LOG.info("packageMeta = " + ToolUtil.objectToString(packageMeta));
PackageData packageData = PackageWrapperUtil.getPackageData(packageMeta);
+
+ List<PackageData> lstPkgData = PackageManager.getInstance().queryPackage(packageMeta.getName(), "", "", "", "");
+ if (!lstPkgData.isEmpty())
+ {
+ LOG.error ("Package name is not unique");
+ return null;
+ }
String destPath = File.separator + path + File.separator + File.separator;
boolean uploadResult = FileManagerFactory.createFileManager().upload(localDirName, destPath);
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java
index de3ba45..c9c03cc 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java
@@ -640,6 +640,13 @@
packageDataList.add(packageData);
return packageDataList;
}
+
+ @Mock
+ public List<PackageData> getPackageDataSubset(Map<String, String> paramsMap) {
+ List<PackageData> packageDataList = new ArrayList<PackageData>();
+
+ return packageDataList;
+ }
};
new MockUp<HttpFileManagerImpl>() {
@@ -739,7 +746,7 @@
if(ins != null) {
try {
result = PackageWrapper.getInstance().uploadPackage(ins, fileDetail, null, null);
- PackageWrapper.getInstance().updateValidateStatus(ins);
+ // PackageWrapper.getInstance().updateValidateStatus(ins);
} catch(Exception e3) {
e3.printStackTrace();
}