aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmarket-be/vnf-sdk-marketplace/src
diff options
context:
space:
mode:
authorHarry Huang <huangxiangyu5@huawei.com>2017-09-16 18:26:55 +0800
committerHarry Huang <huangxiangyu5@huawei.com>2017-09-17 15:07:07 +0800
commit6240e5328bffbc3c2a9a21920f2231297a3fcba3 (patch)
treeef18c05b1bffd3509a846cda2b495fa67bad1765 /vnfmarket-be/vnf-sdk-marketplace/src
parent1fb8387b7dc59a9ac62ef7c9b592197687818554 (diff)
fix patch 3
major: L199 L210 L240 L349 critical: L290 L326 L327 Change-Id: Iab7f2dc694aa0eedbf443bc291dfcd2d81898390 Signed-off-by: Harry Huang <huangxiangyu5@huawei.com> Issue-Id: VNFSDK-85
Diffstat (limited to 'vnfmarket-be/vnf-sdk-marketplace/src')
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java92
1 files changed, 30 insertions, 62 deletions
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 a763a361..4fba9f09 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
@@ -198,11 +198,10 @@ public class PackageWrapperUtil {
public static List<PackageMeta> packageDataList2PackageMetaList(
List<PackageData> dbResult) {
ArrayList<PackageMeta> metas = new ArrayList<>();
- PackageMeta meta = null;
if (! dbResult.isEmpty()) {
for (int i = 0; i < dbResult.size(); i++) {
PackageData data = dbResult.get(i);
- meta = packageData2PackageMeta(data);
+ PackageMeta meta = packageData2PackageMeta(data);
metas.add(meta);
}
}
@@ -245,8 +244,7 @@ public class PackageWrapperUtil {
} else {
url += uri;
}
- String urlresult = url.replace("\\", "/");
- return urlresult;
+ return url.replace("\\", "/");
}
public static String getDownloadUriHead() {
@@ -280,15 +278,15 @@ public class PackageWrapperUtil {
isXmlCsar = true;
}
for (String unzipFile : unzipFiles) {
- if (unzipFile.endsWith(CommonConstant.MANIFEST)) {
- basicInfo = readManifest(unzipFile);
+ if (unzipFile.endsWith(CommonConstant.MANIFEST)) {
+ basicInfo = readManifest(unzipFile);
}
if (ToolUtil.isYamlFile(new File(unzipFile))) {
isXmlCsar = false;
}
}
} catch (IOException e1) {
- LOG.error("judge package type error ! " + e1.getMessage());
+ LOG.error("judge package type error ! " + e1.getMessage(), e1);
}
if (isXmlCsar) {
basicInfo.setFormat(CommonConstant.PACKAGE_XML_FORMAT);
@@ -298,81 +296,51 @@ public class PackageWrapperUtil {
return basicInfo;
}
- private static PackageBasicInfo readCsarMeta(String unzipFile) {
+ /**
+ * 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 (tempString.equals("")) {
+
+ // If line is empty, ignore
+ if ("".equals(tempString)) {
continue;
}
+
int count1 = tempString.indexOf(":");
String meta = tempString.substring(0, count1).trim();
- if (CommonConstant.CSAR_TYPE_META.equalsIgnoreCase(meta)) {
- int count = tempString.indexOf(":") + 1;
- basicInfo.setType(EnumType.valueOf(tempString.substring(count).trim()));
- }
- if (CommonConstant.CSAR_PROVIDER_META.equalsIgnoreCase(meta)) {
+
+ // Check for the package provider name
+ if (meta.equalsIgnoreCase(CommonConstant.MF_PROVIDER_META)) {
int count = tempString.indexOf(":") + 1;
basicInfo.setProvider(tempString.substring(count).trim());
}
- if (CommonConstant.CSAR_VERSION_META.equalsIgnoreCase(meta)) {
+
+ // 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 e2) {
- e2.printStackTrace();
+ } catch (IOException e) {
+ LOG.error("Exception while parsing manifest file" + e, e);
}
+
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