summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'csarvalidation/src/main')
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java77
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/parser/MetadataParser.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/parser/NonManoArtifactsParser.java7
-rw-r--r--csarvalidation/src/main/java/org/onap/validation/csar/CsarUtil.java242
-rw-r--r--csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java16
-rw-r--r--csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java38
-rw-r--r--csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java20
-rw-r--r--csarvalidation/src/main/java/org/onap/validation/yaml/model/YamlDocument.java6
8 files changed, 207 insertions, 201 deletions
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java b/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java
index 1c05948..70cd8f3 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java
@@ -92,6 +92,9 @@ public class CSARArchive implements AutoCloseable {
public static final String CSAR_ARCHIVE = "CSAR Archive";
public static final String DOESS_NOT_EXIST = " does not exist";
+ public static final String CERT = ".cert";
+ public static final String YAML = ".yaml";
+ public static final String MF = ".mf";
public enum Mode {
WITH_TOSCA_META_DIR,
@@ -496,7 +499,7 @@ public class CSARArchive implements AutoCloseable {
CSAR_ARCHIVE,
-1,
"Manifest file name should match the definition YAML name",
- definitionYaml + ".mf", //fix the name part
+ definitionYaml + MF, //fix the name part
manifest);
this.setCode("0x0013");
@@ -521,7 +524,7 @@ public class CSARArchive implements AutoCloseable {
CSAR_ARCHIVE,
-1,
"certificate file name should match the definition YAML name",
- definitionYaml + ".cert", //fix the name part
+ definitionYaml + CERT, //fix the name part
certificate);
this.setCode("0x0015");
@@ -966,32 +969,29 @@ public class CSARArchive implements AutoCloseable {
lineNo ++;
line = line.trim();
- if (line.startsWith("#") || line.trim().isEmpty()) {
- continue;
- }
-
- String []lineTokens = line.split(":");
+ if (!line.startsWith("#") && !line.trim().isEmpty()) {
+ String []lineTokens = line.split(":");
- if (lineTokens.length != 2) {
- errors.add(
- new CSARErrorIgnored(
- line,
- TOSCA_METADATA_TOSCA_META,
- lineNo,
- null));
- continue;
- }
+ if (lineTokens.length != 2) {
+ errors.add(
+ new CSARErrorIgnored(
+ line,
+ TOSCA_METADATA_TOSCA_META,
+ lineNo,
+ null));
+ continue;
+ }
- String key = lineTokens[0].trim();
- String value = lineTokens[1].trim();
+ String key = lineTokens[0].trim();
+ String value = lineTokens[1].trim();
- if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_TOSCA_META_FILE_VERSION)) {
+ if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_TOSCA_META_FILE_VERSION)) {
this.toscaMeta.setMetaDataFileVersion(value);
- } else if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_CSAR_VERSION)){
+ } else if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_CSAR_VERSION)){
this.toscaMeta.setCsarVersion(value);
- } else if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_CREATED_BY)) {
+ } else if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_CREATED_BY)) {
this.toscaMeta.setCompanyName(value);
- } else if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_ENTRY_DEFINITIONS)) {
+ } else if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_ENTRY_DEFINITIONS)) {
this.toscaMeta.setEntryDefinitionYaml(value);
this.definitionYamlFile = new File(this.tempDir.toFile().getAbsolutePath() + File.separator + (this.toscaMeta.getEntryDefinitionYaml()));
@@ -1001,7 +1001,7 @@ public class CSARArchive implements AutoCloseable {
this.toscaMeta.getEntryDefinitionYaml(),
lineNo));
}
- } else if(key.equalsIgnoreCase(getEntryManifestParamName())) {
+ } else if(key.equalsIgnoreCase(getEntryManifestParamName())) {
this.toscaMeta.setEntryManifestMf(value);
this.manifestMfFile = this.tempDir.resolve(this.toscaMeta.getEntryManifestMf()).toFile();
if (!this.manifestMfFile.exists()) {
@@ -1009,7 +1009,7 @@ public class CSARArchive implements AutoCloseable {
this.toscaMeta.getEntryManifestMf(),
lineNo, getEntryManifestParamName()));
}
- } else if(key.equalsIgnoreCase(getEntryChangeLogParamName())) {
+ } else if(key.equalsIgnoreCase(getEntryChangeLogParamName())) {
this.toscaMeta.setEntryChangeLog(value);
this.changeLogTxtFile = this.tempDir.resolve(this.toscaMeta.getEntryChangeLog()).toFile();
if (!this.changeLogTxtFile.exists()) {
@@ -1017,37 +1017,38 @@ public class CSARArchive implements AutoCloseable {
this.toscaMeta.getEntryChangeLog(),
lineNo, getEntryChangeLogParamName()));
}
- } else if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_ENTRY_TESTS)) {
+ } else if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_ENTRY_TESTS)) {
this.toscaMeta.setEntryTest(value);
- this.testsFolder= this.tempDir.resolve(this.toscaMeta.getEntryTest()).toFile();
+ this.testsFolder = this.tempDir.resolve(this.toscaMeta.getEntryTest()).toFile();
if (!this.testsFolder.exists() || !this.testsFolder.isDirectory()) {
errors.add(new CSARErrorInvalidEntryValueTestsNotFound(
this.toscaMeta.getEntryTest(),
lineNo));
}
- } else if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_ENTRY_LICENSES)) {
+ } else if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_ENTRY_LICENSES)) {
this.toscaMeta.setEntryLicense(value);
- this.licensesFolder= this.tempDir.resolve(this.toscaMeta.getEntryLicense()).toFile();
+ this.licensesFolder = this.tempDir.resolve(this.toscaMeta.getEntryLicense()).toFile();
if (!this.licensesFolder.exists() || !this.licensesFolder.isDirectory()) {
errors.add(new CSARErrorInvalidEntryValueLicenseNotFound(
this.toscaMeta.getEntryLicense(),
lineNo));
}
- } else if(key.equalsIgnoreCase(getEntryCertificateParamName())) {
+ } else if(key.equalsIgnoreCase(getEntryCertificateParamName())) {
this.toscaMeta.setEntryCertificate(value);
- this.certificatesFile= this.tempDir.resolve(this.toscaMeta.getEntryCertificate()).toFile();
+ this.certificatesFile = this.tempDir.resolve(this.toscaMeta.getEntryCertificate()).toFile();
if (!this.certificatesFile.exists()) {
errors.add(new CSARErrorInvalidEntryValueCertificatesNotFound(
this.toscaMeta.getEntryCertificate(),
lineNo));
}
- } else {
+ } else {
errors.add(
new CSARErrorIgnored(
key,
TOSCA_METADATA_TOSCA_META,
lineNo,
null));
+ }
}
}
@@ -1071,7 +1072,7 @@ public class CSARArchive implements AutoCloseable {
} else {
//definition files
- File []files = this.tempDir.toFile().listFiles((dir, name) -> name.endsWith(".yaml"));
+ File []files = this.tempDir.toFile().listFiles((dir, name) -> name.endsWith(YAML));
if (files.length == 0) {
errors.add(
@@ -1088,7 +1089,7 @@ public class CSARArchive implements AutoCloseable {
this.toscaMeta.setEntryDefinitionYaml(this.definitionYamlFile.getName());
//manifest
- files = this.tempDir.toFile().listFiles((dir, name) -> name.endsWith(".mf"));
+ files = this.tempDir.toFile().listFiles((dir, name) -> name.endsWith(MF));
if (files.length > 1) {
List<String> fileNames = new ArrayList<>();
@@ -1102,9 +1103,9 @@ public class CSARArchive implements AutoCloseable {
//name should match the definition yaml
String defYaml = this.toscaMeta.getEntryDefinitionYaml().substring(
- 0, this.toscaMeta.getEntryDefinitionYaml().lastIndexOf(".yaml"));
+ 0, this.toscaMeta.getEntryDefinitionYaml().lastIndexOf(YAML));
String mfFile = this.toscaMeta.getEntryManifestMf().substring(
- 0, this.toscaMeta.getEntryManifestMf().lastIndexOf(".mf"));
+ 0, this.toscaMeta.getEntryManifestMf().lastIndexOf(MF));
if (!defYaml.equalsIgnoreCase(mfFile)) {
errors.add(new CSARErrorMismatchDefinitionYamlVsManifestMf(
@@ -1115,7 +1116,7 @@ public class CSARArchive implements AutoCloseable {
}
//certificate
- files = this.tempDir.toFile().listFiles((dir, name) -> name.endsWith(".cert"));
+ files = this.tempDir.toFile().listFiles((dir, name) -> name.endsWith(CERT));
if (files.length > 1) {
List<String> fileNames = new ArrayList<>();
@@ -1130,9 +1131,9 @@ public class CSARArchive implements AutoCloseable {
//name should match the definition yaml
String defYaml = this.toscaMeta.getEntryDefinitionYaml().substring(
- 0, this.toscaMeta.getEntryDefinitionYaml().lastIndexOf(".yaml"));
+ 0, this.toscaMeta.getEntryDefinitionYaml().lastIndexOf(YAML));
String certFile = this.toscaMeta.getEntryCertificate().substring(
- 0, this.toscaMeta.getEntryCertificate().lastIndexOf(".cert"));
+ 0, this.toscaMeta.getEntryCertificate().lastIndexOf(CERT));
if (!defYaml.equalsIgnoreCase(certFile)) {
errors.add(new CSARErrorMismatchDefinitionYamlVsCertificateCert(
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/parser/MetadataParser.java b/csarvalidation/src/main/java/org/onap/cvc/csar/parser/MetadataParser.java
index b0c06ee..f529c45 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/parser/MetadataParser.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/parser/MetadataParser.java
@@ -85,7 +85,7 @@ public class MetadataParser {
private boolean isNewSection(Pair<String, String> data) {
String key = data.getKey().trim();
String value = data.getValue().trim();
- return key.matches("[a-zA-z_0-9]+") && (value.isEmpty() || ManifestLine.of(value).startsWith("#"));
+ return key.matches("[a-zA-Z_0-9]+") && (value.isEmpty() || ManifestLine.of(value).startsWith("#"));
}
private boolean isSourceSection(Pair<String, String> data) {
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/parser/NonManoArtifactsParser.java b/csarvalidation/src/main/java/org/onap/cvc/csar/parser/NonManoArtifactsParser.java
index 22e8978..1aa7d32 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/parser/NonManoArtifactsParser.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/parser/NonManoArtifactsParser.java
@@ -51,10 +51,9 @@ public class NonManoArtifactsParser {
if (isNewSection(data)) {
attributeName = data.getKey();
nonManoArtifacts.put(attributeName, new HashMap<>());
- continue;
- }
-
+ } else {
handleNonManoArtifactLine(nonManoArtifacts, attributeName, data);
+ }
}
}
@@ -68,7 +67,7 @@ public class NonManoArtifactsParser {
private boolean isNewSection(Pair<String, String> data) {
String key = data.getKey().trim();
String value = data.getValue().trim();
- return key.matches("[a-zA-z_0-9]+") && (value.isEmpty() || ManifestLine.of(value).startsWith("#"));
+ return key.matches("[a-zA-Z_0-9]+") && (value.isEmpty() || ManifestLine.of(value).startsWith("#"));
}
private void handleNonManoArtifactLine(
diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/CsarUtil.java b/csarvalidation/src/main/java/org/onap/validation/csar/CsarUtil.java
index c498479..c2d6048 100644
--- a/csarvalidation/src/main/java/org/onap/validation/csar/CsarUtil.java
+++ b/csarvalidation/src/main/java/org/onap/validation/csar/CsarUtil.java
@@ -28,133 +28,131 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Enumeration;
-
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-
+import java.util.Map;
public class CsarUtil {
-
- private static final Logger logger = LoggerFactory.getLogger(CsarUtil.class);
-
- public static String getUnzipDir(String dirName) {
- File tmpDir = new File(File.separator + dirName);
- return tmpDir.getAbsolutePath().replace(".csar", "");
- }
-
- /**
- * unzip zip file.
- *
- * @param zipFileName
- * file name to zip
- * @param extPlace
- * extPlace
- * @return unzip file names in zip
- * @throws IOException
- * e1
- * @throws ValidationException
- */
- public static HashMap<String, String> unzip(String zipFileName, String extPlace) throws IOException {
- HashMap<String, String> unzipFileNames = new HashMap<>();
-
- try(ZipFile zipFile = new ZipFile(zipFileName)) {
-
- Enumeration<?> fileEn = zipFile.entries();
- byte[] buffer = new byte[CommonConstants.BUFFER_SIZE];
-
- while (fileEn.hasMoreElements()) {
- InputStream input = null;
- BufferedOutputStream bos = null;
- try {
- ZipEntry entry = (ZipEntry) fileEn.nextElement();
- if (entry.isDirectory()) {
- continue;
- }
-
- input = zipFile.getInputStream(entry);
- File file = new File(extPlace, entry.getName());
-
- //Currently it does not support xml based VNF descriptors.
- //So skip and proceed to YAML defined files validation only.
- if (file.getAbsolutePath().contains("xml"+System.getProperty("file.separator"))) {
- continue;
- }
-
- if (!file.getParentFile().exists()) {
- FileUtil.createDirectory(file.getParentFile().getAbsolutePath());
- }
-
- bos = new BufferedOutputStream(new FileOutputStream(file));
- while (true) {
- int length = input.read(buffer);
- if (length == -1) {
- break;
- }
- bos.write(buffer, 0, length);
- }
-
- unzipFileNames.put(file.getName(), file.getAbsolutePath());
-
- } finally {
- closeOutputStream(bos);
- closeInputStream(input);
- }
- }
- }
- return unzipFileNames;
- }
-
- /**
- * close InputStream.
- *
- * @param inputStream
- * the inputstream to close
- * @throws ValidationException
- */
- public static void closeInputStream(InputStream inputStream) {
- try {
- if (inputStream != null) {
- inputStream.close();
- }
- } catch (Exception e1) {
- logger.error("FILE_IO" + ":" + "close InputStream error! " +ErrorCodes.FILE_IO+" "+ e1.getMessage(), e1);
- throw new ValidationException(ErrorCodes.FILE_IO);
- }
- }
-
- /**
- * close OutputStream.
- *
- * @param outputStream
- * the output stream to close
- * @throws ValidationException
- */
- public static void closeOutputStream(OutputStream outputStream) {
- try {
- if (outputStream != null) {
- outputStream.close();
- }
- } catch (Exception e1) {
- logger.error("FILE_IO" + ":" + "close OutputStream error! " +ErrorCodes.FILE_IO, e1);
- throw new ValidationException(ErrorCodes.FILE_IO);
+
+ private static final Logger logger = LoggerFactory.getLogger(CsarUtil.class);
+
+ public static String getUnzipDir(String dirName) {
+ File tmpDir = new File(File.separator + dirName);
+ return tmpDir.getAbsolutePath().replace(".csar", "");
+ }
+
+ /**
+ * unzip zip file.
+ *
+ * @param zipFileName
+ * file name to zip
+ * @param extPlace
+ * extPlace
+ * @return unzip file names in zip
+ * @throws IOException
+ * e1
+ * @throws ValidationException
+ */
+ public static Map<String, String> unzip(String zipFileName, String extPlace) throws IOException {
+ HashMap<String, String> unzipFileNames = new HashMap<>();
+
+ try(ZipFile zipFile = new ZipFile(zipFileName)) {
+
+ Enumeration<?> fileEn = zipFile.entries();
+ byte[] buffer = new byte[CommonConstants.BUFFER_SIZE];
+
+ while (fileEn.hasMoreElements()) {
+ InputStream input = null;
+ BufferedOutputStream bos = null;
+ ZipEntry entry = (ZipEntry) fileEn.nextElement();
+ if (!entry.isDirectory()) {
+ try {
+ input = zipFile.getInputStream(entry);
+ File file = new File(extPlace, entry.getName());
+
+ //Currently it does not support xml based VNF descriptors.
+ //So skip and proceed to YAML defined files validation only.
+ if (file.getAbsolutePath().contains("xml"+System.getProperty("file.separator"))) {
+ continue;
+ }
+
+ if (!file.getParentFile().exists()) {
+ FileUtil.createDirectory(file.getParentFile().getAbsolutePath());
+ }
+
+ bos = new BufferedOutputStream(new FileOutputStream(file));
+ while (true) {
+ int length = input.read(buffer);
+ if (length == -1) {
+ break;
+ }
+ bos.write(buffer, 0, length);
+ }
+
+ unzipFileNames.put(file.getName(), file.getAbsolutePath());
+
+ } finally {
+ closeOutputStream(bos);
+ closeInputStream(input);
+ }
+ }
+ }
+ }
+ return unzipFileNames;
+ }
+
+ /**
+ * close InputStream.
+ *
+ * @param inputStream
+ * the inputstream to close
+ * @throws ValidationException
+ */
+ public static void closeInputStream(InputStream inputStream) {
+ try {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ } catch (Exception e1) {
+ logger.error("FILE_IO" + ":" + "close InputStream error! " +ErrorCodes.FILE_IO+" "+ e1.getMessage(), e1);
+ throw new ValidationException(ErrorCodes.FILE_IO);
+ }
+ }
+
+ /**
+ * close OutputStream.
+ *
+ * @param outputStream
+ * the output stream to close
+ * @throws ValidationException
+ */
+ public static void closeOutputStream(OutputStream outputStream) {
+ try {
+ if (outputStream != null) {
+ outputStream.close();
+ }
+ } catch (Exception e1) {
+ logger.error("FILE_IO" + ":" + "close OutputStream error! " +ErrorCodes.FILE_IO, e1);
+ throw new ValidationException(ErrorCodes.FILE_IO);
- }
- }
- /**
- *
- * @param filePath
- * @return HashMap<String, String>
- */
- public static HashMap<String, String> csarExtract(String filePath) {
-
- try {
- String tempfolder = CsarUtil.getUnzipDir(filePath);
- return CsarUtil.unzip(filePath, tempfolder);
-
- } catch (IOException e1) {
- logger.error("CSAR_EXTRACTION" + ":" + "CSAR extraction error ! " +ErrorCodes.FILE_IO+" "+ e1.getMessage(), e1);
+ }
+ }
+
+ /**
+ *
+ * @param filePath
+ * @return HashMap<String, String>
+ */
+ public static Map<String, String> csarExtract(String filePath) {
+
+ try {
+ String tempfolder = CsarUtil.getUnzipDir(filePath);
+ return CsarUtil.unzip(filePath, tempfolder);
+
+ } catch (IOException e1) {
+ logger.error("CSAR_EXTRACTION" + ":" + "CSAR extraction error ! " +ErrorCodes.FILE_IO+" "+ e1.getMessage(), e1);
throw new ValidationException(ErrorCodes.FILE_IO);
- }
- }
+ }
+ }
}
diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java b/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java
index e92f2b2..b853ca2 100644
--- a/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java
+++ b/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java
@@ -49,10 +49,10 @@ public class CsarValidator {
private static ValidatorSchemaLoader vsl;
// Map of CSAR file and un-zipped file indices
- private static HashMap<String, String> csarFiles;
+ private static Map<String, String> csarFiles;
// Map of packageId and CSAR files
- private static HashMap<String, HashMap<String, String>> csar = new HashMap<>();
+ private static Map<String, Map<String, String>> csar = new HashMap<>();
private static String MAINSERV_TEMPLATE = CommonConstants.MAINSERV_TEMPLATE;
@@ -110,12 +110,12 @@ public class CsarValidator {
//String r02454 = r02454();
- if((CommonConstants.SUCCESS_STR != vsm) && (CommonConstants.SUCCESS_STR != vms)) {
+ if((!CommonConstants.SUCCESS_STR.equals(vsm)) && (!CommonConstants.SUCCESS_STR.equals(vms))) {
return vsm + " OR " + vms;
}
- if(CommonConstants.SUCCESS_STR != vtm) {
+ if(!CommonConstants.SUCCESS_STR.equals(vtm)) {
return vtm;
}
/*
@@ -422,19 +422,19 @@ public class CsarValidator {
}
}
- public static HashMap<String, HashMap<String, String>> getCsar() {
+ public static Map<String, Map<String, String>> getCsar() {
return csar;
}
- public static void setCsar(HashMap<String, HashMap<String, String>> csar) {
+ public static void setCsar(Map<String, Map<String, String>> csar) {
CsarValidator.csar = csar;
}
- public static HashMap<String, String> getCsarFiles() {
+ public static Map<String, String> getCsarFiles() {
return csarFiles;
}
- public static void setCsarFiles(HashMap<String, String> csarFiles) {
+ public static void setCsarFiles(Map<String, String> csarFiles) {
CsarValidator.csarFiles = csarFiles;
}
}
diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java b/csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java
index f7471bd..a488ed3 100644
--- a/csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java
+++ b/csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java
@@ -23,13 +23,15 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.ZipFile;
-
+import java.nio.file.Files;
+import java.nio.file.Paths;
public final class FileUtil {
public static final Logger logger = LoggerFactory.getLogger(FileUtil.class);
private static final int TRY_COUNT = 3;
+ public static final String FILE_IO_STR = "FILE_IO";
private FileUtil() {
@@ -63,18 +65,17 @@ public final class FileUtil {
*/
public static boolean deleteFile(File file) {
String hintInfo = file.isDirectory() ? "dir " : "file ";
- boolean isFileDeleted = file.delete();
- boolean isFileExist = file.exists();
- if (!isFileExist) {
- if (isFileDeleted) {
- logger.info("delete " + hintInfo + file.getAbsolutePath());
+ boolean isFileDeleted=false;
+ try {
+ if (file.exists()) {
+ Files.delete(Paths.get(file.getPath()));
+ logger.info("delete {} {}" ,hintInfo, file.getAbsolutePath());
} else {
- isFileDeleted = true;
- logger.info("file not exist. no need delete " + hintInfo + file.getAbsolutePath());
+ logger.info("file not exist. no need delete {} {}" ,hintInfo , file.getAbsolutePath());
}
- } else {
- logger.info("fail to delete " + hintInfo + file.getAbsolutePath());
-
+ isFileDeleted=true;
+ } catch (IOException e) {
+ logger.error("fail to delete {} {} ", hintInfo, file.getAbsolutePath(), ", exception :: ", e);
}
return isFileDeleted;
}
@@ -92,7 +93,7 @@ public final class FileUtil {
inputStream.close();
}
} catch (Exception e1) {
- logger.error("FILE_IO" + ":" + "close InputStream error! "+ErrorCodes.FILE_IO+ " " + e1.getMessage(), e1);
+ logger.error(FILE_IO_STR + ":" + "close InputStream error! "+ErrorCodes.FILE_IO+ " " + e1.getMessage(), e1);
throw new ValidationException(ErrorCodes.FILE_IO);
}
}
@@ -109,7 +110,7 @@ public final class FileUtil {
outputStream.close();
}
} catch (Exception e1) {
- logger.error("FILE_IO" + ":" + "close OutputStream error! "+ErrorCodes.FILE_IO+ " " + e1.getMessage(), e1);
+ logger.error(FILE_IO_STR + ":" + "close OutputStream error! "+ErrorCodes.FILE_IO+ " " + e1.getMessage(), e1);
throw new ValidationException(ErrorCodes.FILE_IO);
}
}
@@ -120,7 +121,7 @@ public final class FileUtil {
ifs.close();
}
} catch (Exception e1) {
- logger.error("FILE_IO" + ":" + "close OutputStream error! "+ErrorCodes.FILE_IO+ " " + e1.getMessage(), e1);
+ logger.error(FILE_IO_STR + ":" + "close OutputStream error! "+ErrorCodes.FILE_IO+ " " + e1.getMessage(), e1);
throw new ValidationException(ErrorCodes.FILE_IO);
}
}
@@ -172,6 +173,13 @@ public final class FileUtil {
deleteDirectory(f);
}
}
- return file.delete();
+ boolean isFileDeleted=false;
+ try {
+ Files.delete(Paths.get(file.getPath()));
+ isFileDeleted=true;
+ } catch (IOException e) {
+ logger.error("fail to delete {} {} ", file.getAbsolutePath(), ", exception :: ", e);
+ }
+ return isFileDeleted;
}
}
diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java b/csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java
index 0ed0bdc..b56e5f2 100644
--- a/csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java
+++ b/csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java
@@ -31,13 +31,13 @@ public class ValidatorSchemaLoader {
private static final Logger LOG = LoggerFactory.getLogger(ValidatorSchemaLoader.class);
// Map of Schema files
- private Map<String, ?> toscaMeta;
+ private Map<String, Object> toscaMeta;
- private Map<String, ?> csarentryd;
+ private Map<String, Object> csarentryd;
- private Map<String, ?> mrfYaml;
+ private Map<String, Object> mrfYaml;
- private Map<String, ?> mrfManifest;
+ private Map<String, Object> mrfManifest;
// List of configured schemas
static List<String> schemaFileList = new ArrayList<>();
@@ -62,9 +62,9 @@ public class ValidatorSchemaLoader {
}
}
- private Map<String, ?> readYaml(String fileName) {
+ private Map<String, Object> readYaml(String fileName) {
Yaml yaml = new Yaml();
- return (Map<String, ?>)yaml.load(this.getClass().getResourceAsStream(fileName));
+ return (Map<String, Object>)yaml.load(this.getClass().getResourceAsStream(fileName));
}
@SuppressWarnings("unchecked")
@@ -88,19 +88,19 @@ public class ValidatorSchemaLoader {
return true;
}
- public Map<String, ?> getToscaMeta() {
+ public Map<String, Object> getToscaMeta() {
return toscaMeta;
}
- public Map<String, ?> getCsarentryd() {
+ public Map<String, Object> getCsarentryd() {
return csarentryd;
}
- public Map<String, ?> getMrfYaml() {
+ public Map<String, Object> getMrfYaml() {
return mrfYaml;
}
- public Map<String, ?> getMrfManifest() {
+ public Map<String, Object> getMrfManifest() {
return mrfManifest;
}
}
diff --git a/csarvalidation/src/main/java/org/onap/validation/yaml/model/YamlDocument.java b/csarvalidation/src/main/java/org/onap/validation/yaml/model/YamlDocument.java
index 11582d1..557b6fd 100644
--- a/csarvalidation/src/main/java/org/onap/validation/yaml/model/YamlDocument.java
+++ b/csarvalidation/src/main/java/org/onap/validation/yaml/model/YamlDocument.java
@@ -21,13 +21,13 @@ import java.util.Map;
public class YamlDocument {
- private final Map<String, ?> yaml;
+ private final Map<String, Object> yaml;
- YamlDocument(Map<String, ?> yaml) {
+ YamlDocument(Map<String, Object> yaml) {
this.yaml = yaml;
}
- public Map<String, ?> getYaml() {
+ public Map<String, Object> getYaml() {
return yaml;
}