aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmarket-be
diff options
context:
space:
mode:
Diffstat (limited to 'vnfmarket-be')
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/CommonConstant.java10
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/entity/EnumType.java2
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java48
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/resources/clearwater_ns.csarbin59854 -> 9710 bytes
4 files changed, 57 insertions, 3 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/CommonConstant.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/CommonConstant.java
index fc8ef1b8..5432300f 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/CommonConstant.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/CommonConstant.java
@@ -39,6 +39,16 @@ public class CommonConstant {
public static final String DEFINITIONS = "Definitions";
public static final String CSAR_META = "csar.meta";
+
+ public static final String MANIFEST = ".mf";
+
+ public static final String MF_VERSION_META = "vnf_package_version";
+
+ public static final String MF_PRODUCT_NAME = "vnf_product_name";
+
+ public static final String MF_PROVIDER_META = "vnf_provider_id";
+
+ public static final String MF_RELEASE_DATETIME = "vnf_release_date_time";
public static final String CSAR_SUFFIX = ".csar";
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/entity/EnumType.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/entity/EnumType.java
index e316e3cb..56945a56 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/entity/EnumType.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/entity/EnumType.java
@@ -16,5 +16,5 @@
package org.onap.vnfsdk.marketplace.entity;
public enum EnumType {
- GSAR, SSAR, NSAR, NFAR
+ CSAR, GSAR, SSAR, NSAR, NFAR
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java
index 512b80f1..a763a361 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java
@@ -280,8 +280,8 @@ public class PackageWrapperUtil {
isXmlCsar = true;
}
for (String unzipFile : unzipFiles) {
- if (unzipFile.endsWith(CommonConstant.CSAR_META)) {
- basicInfo = readCsarMeta(unzipFile);
+ if (unzipFile.endsWith(CommonConstant.MANIFEST)) {
+ basicInfo = readManifest(unzipFile);
}
if (ToolUtil.isYamlFile(new File(unzipFile))) {
isXmlCsar = false;
@@ -328,7 +328,51 @@ public class PackageWrapperUtil {
}
return basicInfo;
}
+ /**
+ * Reads the manifest file in the package and fills the basic infor about package
+ * @param unzipFile
+ * @return basic infor about package
+ */
+ private static PackageBasicInfo readManifest(String unzipFile) {
+ // Fix the package type to CSAR, temporary
+ PackageBasicInfo basicInfo = new PackageBasicInfo();
+ basicInfo.setType(EnumType.CSAR);
+
+ File file = new File(unzipFile);
+ try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
+
+ String tempString = null;
+ while ((tempString = reader.readLine()) != null) {
+
+ // If line is empty, ignore
+ if (tempString.equals("")) {
+ continue;
+ }
+
+ int count1 = tempString.indexOf(":");
+ String meta = tempString.substring(0, count1).trim();
+
+ // Check for the package provider name
+ if (meta.equalsIgnoreCase(CommonConstant.MF_PROVIDER_META)) {
+ int count = tempString.indexOf(":") + 1;
+ basicInfo.setProvider(tempString.substring(count).trim());
+ }
+
+ // Check for package version
+ if (meta.equalsIgnoreCase(CommonConstant.MF_VERSION_META)) {
+ int count = tempString.indexOf(":") + 1;
+ basicInfo.setVersion(tempString.substring(count).trim());
+ }
+ }
+
+ reader.close();
+ } catch (IOException e) {
+ LOG.error("Exception while parsing manifest file" + e);
+ }
+
+ return basicInfo;
+ }
/**
* get package format enum.
* @param format package format
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/clearwater_ns.csar b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/clearwater_ns.csar
index ac213ab1..f2794795 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/clearwater_ns.csar
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/clearwater_ns.csar
Binary files differ