aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
authorsiddharth0905 <siddharth.singh4@amdocs.com>2017-12-27 12:19:03 +0530
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2017-12-27 11:51:38 +0000
commit1c9113ca5324f61be167e0938ce69e6ff93266f5 (patch)
tree1eee4d523aff329dadab656b0377c263276ebe5d /openecomp-be
parentb338b20c2969be56f7e075abb39abca861db4eae (diff)
Fix sonar issues - ResourceWalker
Code refactor and Javadoc Change-Id: Ic14f3fe0cc8e1903ec3ec73b9a6b63a694e0db81 Issue-ID: SDC-343 Signed-off-by: siddharth0905 <siddharth.singh4@amdocs.com>
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java37
1 files changed, 31 insertions, 6 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java
index 9ff1ff9992..6e5f0b4776 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.openecomp.sdc.translator.utils;
import org.apache.commons.io.IOUtils;
@@ -29,12 +45,18 @@ import java.util.function.Predicate;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-/**
- * @author EVITALIY.
- * @since 02 Apr 17
- */
public class ResourceWalker {
+ private ResourceWalker() {
+ }
+
+ /**
+ * Read resources from directory map.
+ *
+ * @param resourceDirectoryToStart the resource directory to start
+ * @return the map of file where key is file name and value is its data
+ * @throws Exception the exception
+ */
public static Map<String, String> readResourcesFromDirectory(String resourceDirectoryToStart)
throws
Exception {
@@ -131,8 +153,11 @@ public class ResourceWalker {
IOException {
if (file.isDirectory()) {
- for (File sub : file.listFiles()) {
- traverseFile(sub, handler);
+ File[] files = file.listFiles();
+ if (files != null) {
+ for (File sub : files) {
+ traverseFile(sub, handler);
+ }
}
} else {
try (FileInputStream stream = new FileInputStream(file)) {