Fix sonar issues - ResourceWalker 59/26959/3
authorsiddharth0905 <siddharth.singh4@amdocs.com>
Wed, 27 Dec 2017 06:49:03 +0000 (12:19 +0530)
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>
Wed, 27 Dec 2017 11:51:38 +0000 (11:51 +0000)
Code refactor and Javadoc

Change-Id: Ic14f3fe0cc8e1903ec3ec73b9a6b63a694e0db81
Issue-ID: SDC-343
Signed-off-by: siddharth0905 <siddharth.singh4@amdocs.com>
openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java

index 9ff1ff9..6e5f0b4 100644 (file)
@@ -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)) {