1 package org.onap.config;
5 import java.nio.file.Path;
6 import java.nio.file.Paths;
7 import java.util.Collection;
8 import java.util.HashSet;
10 import java.util.function.Predicate;
13 * The type Non config resource.
15 public class NonConfigResource {
17 private static Set<URL> urls = new HashSet<>();
18 private static Set<File> files = new HashSet<>();
25 public static void add(URL url) {
32 * @param file the file
34 public static void add(File file) {
41 * @param resource the resource
44 public static Path locate(String resource) {
46 if (resource != null) {
47 File file = new File(resource);
49 return Paths.get(resource);
51 for (File availableFile : files) {
52 if (availableFile.getAbsolutePath().endsWith(resource) && availableFile.exists()) {
53 return Paths.get(availableFile.getAbsolutePath());
56 if (System.getProperty("node.config.location") != null) {
57 Path path = locate(new File(System.getProperty("node.config.location")), resource);
62 if (System.getProperty("config.location") != null) {
63 Path path = locate(new File(System.getProperty("config.location")), resource);
68 for (URL url : urls) {
69 if (url.getFile().endsWith(resource)) {
70 return Paths.get(url.toURI());
74 } catch (Exception exception) {
75 exception.printStackTrace();
80 private static Path locate(File root, String resource) {
82 Collection<File> filesystemResources = ConfigurationUtils.getAllFiles(root, true, false);
83 Predicate<File> f1 = ConfigurationUtils::isConfig;
84 for (File file : filesystemResources) {
87 if (file.getAbsolutePath().endsWith(resource)) {
88 return Paths.get(file.getAbsolutePath());