From 1c9113ca5324f61be167e0938ce69e6ff93266f5 Mon Sep 17 00:00:00 2001 From: siddharth0905 Date: Wed, 27 Dec 2017 12:19:03 +0530 Subject: Fix sonar issues - ResourceWalker Code refactor and Javadoc Change-Id: Ic14f3fe0cc8e1903ec3ec73b9a6b63a694e0db81 Issue-ID: SDC-343 Signed-off-by: siddharth0905 --- .../sdc/translator/utils/ResourceWalker.java | 37 ++++++++++++++++++---- 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'openecomp-be') 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 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)) { -- cgit 1.2.3-korg