mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-28 00:38:56 +00:00
fixed file not found try/catch
This commit is contained in:
parent
cb12dce87d
commit
1c5bf6a48c
@ -3,6 +3,7 @@ package hirs.utils;
|
||||
import com.eclipsesource.json.Json;
|
||||
import com.eclipsesource.json.JsonObject;
|
||||
import hirs.utils.tpm.eventlog.uefi.UefiGuid;
|
||||
import hirs.utils.xjc.Resource;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
@ -127,29 +128,18 @@ public final class JsonUtils {
|
||||
}
|
||||
|
||||
public static JsonObject getJsonObject(final String jsonFilename, final Charset charset) {
|
||||
// find the file and load it
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
|
||||
try {
|
||||
InputStream jsonIs = UefiGuid.class
|
||||
.getClassLoader().getResourceAsStream(jsonFilename);
|
||||
if (jsonIs != null) {
|
||||
try {
|
||||
jsonObject = Json.parse(new InputStreamReader(jsonIs,
|
||||
charset)).asObject();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IOException ex) {
|
||||
jsonObject = new JsonObject();
|
||||
}
|
||||
}
|
||||
// if (Files.notExists(jsonPath)) {
|
||||
// log.warn(String.format("No file found at %s.", jsonPath.toString()));
|
||||
// } else {
|
||||
// try {
|
||||
// InputStream inputStream = new FileInputStream(jsonPath.toString());
|
||||
// jsonObject = Json.parse(new InputStreamReader(inputStream,
|
||||
// charset)).asObject();
|
||||
// } catch (IOException ex) {
|
||||
// // add log file thing here indication issue with JSON File
|
||||
// jsonObject = new JsonObject();
|
||||
// }
|
||||
// }
|
||||
|
||||
return jsonObject;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class UefiGuid {
|
||||
private static final Path JSON_PATH = FileSystems.getDefault().getPath("/etc",
|
||||
"hirs", "aca", "default-properties", "vendor-table.json");
|
||||
|
||||
private static final String JSON_FILENAME = "vendor-table3.json";
|
||||
private static final String JSON_FILENAME = "vendor-table2.json";
|
||||
|
||||
private JsonObject uefiVendorRef;
|
||||
/** Track status of vendor-table.json */
|
||||
|
Loading…
Reference in New Issue
Block a user