|
39 | 39 | import java.util.LinkedHashMap; |
40 | 40 | import java.util.List; |
41 | 41 | import java.util.Map; |
| 42 | +import java.util.Objects; |
42 | 43 |
|
43 | 44 | import org.apache.commons.lang3.BooleanUtils; |
44 | 45 | import org.apache.commons.lang3.tuple.Pair; |
@@ -124,25 +125,38 @@ public static ConfigurationManager getInstance() { |
124 | 125 | private void loadConfigurations() { |
125 | 126 | String lang = GeneralPreferences.language; |
126 | 127 |
|
127 | | - File fx = new File(ConfigFetch.getConfFolder() + CONF_DIR); |
| 128 | + String filePath = ConfigFetch.getConfFolder() + CONF_DIR; |
| 129 | + File fx = new File(filePath); |
128 | 130 | if (fx.exists()) { |
129 | | - for(File f : fx.listFiles(getFileFilterForConfigurationFiles())) { |
130 | | - if (!f.isFile()) |
131 | | - continue; |
132 | | - String fname = f.getName(); |
133 | | - String fext = FileUtil.getFileExtension(fname); |
134 | | - if (!fname.replaceAll("." + fext + "$", "").endsWith(lang)) |
135 | | - continue; |
| 131 | + try { |
| 132 | + for (File f : Objects.requireNonNull(fx.listFiles(getFileFilterForConfigurationFiles()))) { |
| 133 | + try { |
| 134 | + if (!f.isFile()) { |
| 135 | + continue; |
| 136 | + } |
| 137 | + String fname = f.getName(); |
| 138 | + String fext = FileUtil.getFileExtension(fname); |
| 139 | + if (!fname.replaceAll("." + fext + "$", "").endsWith(lang)) { |
| 140 | + continue; |
| 141 | + } |
136 | 142 |
|
137 | | - NeptusLog.pub().debug("Loading vehicle configuration from " + f.getName()); |
138 | | - String systemName = f.getName().split("\\.")[0]; |
139 | | - try { |
140 | | - map.put(systemName, readConfiguration(f)); |
141 | | - } |
142 | | - catch (InvalidConfigurationException e) { |
143 | | - NeptusLog.pub().error(e.getMessage()); |
144 | | - e.printStackTrace(); |
145 | | - } |
| 143 | + NeptusLog.pub().debug("Loading vehicle configuration from " + f.getName()); |
| 144 | + String systemName = f.getName().split("\\.")[0]; |
| 145 | + try { |
| 146 | + map.put(systemName, readConfiguration(f)); |
| 147 | + } |
| 148 | + catch (Exception e) { |
| 149 | + NeptusLog.pub().error(e.getMessage()); |
| 150 | + e.printStackTrace(); |
| 151 | + } |
| 152 | + } |
| 153 | + catch (Exception e) { |
| 154 | + NeptusLog.pub().error("Error processing systems parameters at '{}'", f); |
| 155 | + } |
| 156 | + } |
| 157 | + } |
| 158 | + catch (Exception e) { |
| 159 | + NeptusLog.pub().warn("No systems parameters found to process incide '{}'", filePath); |
146 | 160 | } |
147 | 161 | } |
148 | 162 | } |
|
0 commit comments