From 90cd502f8777e3e524d3c51cb40df6f7675e89c3 Mon Sep 17 00:00:00 2001 From: Subhobrata Dey Date: Wed, 4 Oct 2023 20:41:41 +0000 Subject: [PATCH] make category field optional Signed-off-by: Subhobrata Dey --- .../opensearch/securityanalytics/model/CustomLogType.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/opensearch/securityanalytics/model/CustomLogType.java b/src/main/java/org/opensearch/securityanalytics/model/CustomLogType.java index 8fb7a8daf..72b81ffa6 100644 --- a/src/main/java/org/opensearch/securityanalytics/model/CustomLogType.java +++ b/src/main/java/org/opensearch/securityanalytics/model/CustomLogType.java @@ -80,7 +80,7 @@ public CustomLogType(String id, this.version = version != null ? version : NO_VERSION; this.name = name; this.description = description; - this.category = category; + this.category = category != null? category: "Other"; this.source = source; this.tags = tags; } @@ -104,7 +104,7 @@ public CustomLogType(Map input) { null, input.get(NAME_FIELD).toString(), input.get(DESCRIPTION_FIELD).toString(), - input.get(CATEGORY_FIELD).toString(), + input.containsKey(CATEGORY_FIELD)? input.get(CATEGORY_FIELD).toString(): null, input.get(SOURCE_FIELD).toString(), (Map) input.get(TAGS_FIELD) ); @@ -159,7 +159,7 @@ public static CustomLogType parse(XContentParser xcp, String id, Long version) t description = xcp.text(); break; case CATEGORY_FIELD: - category = xcp.text(); + category = xcp.textOrNull(); break; case SOURCE_FIELD: source = xcp.text();