summaryrefslogtreecommitdiffstats
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.java6
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java89
2 files changed, 89 insertions, 6 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 1ba18cd6..92d19de6 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
@@ -31,11 +31,11 @@ public class CommonConstant {
public static final String TOSCA_METADATA = "TOSCA-Metadata";
- public static final String CSAR_VERSION_META = "version";
+ public static final String CSAR_VERSION_META = "Version";
- public static final String CSAR_TYPE_META = "type";
+ public static final String CSAR_TYPE_META = "Type";
- public static final String CSAR_PROVIDER_META = "provider";
+ public static final String CSAR_PROVIDER_META = "Provider";
public static final String DEFINITIONS = "Definitions";
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 8eb68eb2..ab94e983 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
@@ -279,6 +279,11 @@ public class PackageWrapperUtil {
if (unzipFile.endsWith(CommonConstant.MANIFEST)) {
basicInfo = readManifest(unzipFile);
}
+
+ if (unzipFile.endsWith(CommonConstant.CSAR_META)) {
+ basicInfo = readMetaData(unzipFile);
+ }
+
if (ToolUtil.isYamlFile(new File(unzipFile))) {
isXmlCsar = false;
}
@@ -299,7 +304,7 @@ public class PackageWrapperUtil {
* @param unzipFile
* @return basic infor about package
*/
- private static PackageBasicInfo readManifest(String unzipFile) {
+ private static PackageBasicInfo readMetaData(String unzipFile) {
// Fix the package type to CSAR, temporary
PackageBasicInfo basicInfo = new PackageBasicInfo();
@@ -319,16 +324,23 @@ public class PackageWrapperUtil {
String meta = tempString.substring(0, count1).trim();
// Check for the package provider name
- if (meta.equalsIgnoreCase(CommonConstant.MF_PROVIDER_META)) {
+ if (meta.equalsIgnoreCase(CommonConstant.CSAR_PROVIDER_META)) {
int count = tempString.indexOf(":") + 1;
basicInfo.setProvider(tempString.substring(count).trim());
}
// Check for package version
- if (meta.equalsIgnoreCase(CommonConstant.MF_VERSION_META)) {
+ if (meta.equalsIgnoreCase(CommonConstant.CSAR_VERSION_META)) {
int count = tempString.indexOf(":") + 1;
basicInfo.setVersion(tempString.substring(count).trim());
}
+
+ // Check for package type
+ if (meta.equalsIgnoreCase(CommonConstant.CSAR_TYPE_META)) {
+ int count = tempString.indexOf(":") + 1;
+
+ basicInfo.setType(getEnumType(tempString.substring(count).trim()));
+ }
}
reader.close();
@@ -338,6 +350,77 @@ public class PackageWrapperUtil {
return basicInfo;
}
+
+ private static EnumType getEnumType (String type)
+ {
+ EnumType vnfType = EnumType.CSAR;
+ if (type == "CSAR")
+ {
+ vnfType = EnumType.CSAR;
+ }
+
+ if (type == "GSAR")
+ {
+ vnfType = EnumType.GSAR;
+ }
+
+ if (type == "NSAR")
+ {
+ vnfType = EnumType.NSAR;
+ }
+
+ if (type == "SSAR")
+ {
+ vnfType = EnumType.SSAR;
+ }
+
+ if (type == "NFAR")
+ {
+ vnfType = EnumType.NFAR;
+ }
+
+ return vnfType;
+ }
+
+ 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))) {
+
+ for(String tempString; (tempString = reader.readLine()) != null;)
+ {
+ // If line is empty, ignore
+ if ("".equals(tempString)) {
+ 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, e);
+ }
+
+ return basicInfo;
+ }
/**
* get package format enum.
* @param format package format