diff options
Diffstat (limited to 'common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java')
-rw-r--r-- | common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java index 55b9f7f87f..d31f8227dc 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java @@ -20,18 +20,12 @@ package org.openecomp.sdc.common.datastructure; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Formatter; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Locale; -import java.util.Map; -import java.util.TimeZone; - import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; +import java.text.SimpleDateFormat; +import java.util.*; + /** * Extending this class enforces the objects of implementing classes to have a * timestamp, so that like in logstash, we can derive the index name for those @@ -42,15 +36,16 @@ import org.codehaus.jettison.json.JSONObject; */ public class ESTimeBasedEvent { + protected SimpleDateFormat simpleDateFormat; protected static String dateFormatPattern = "yyyy-MM-dd HH:mm:ss.SSS z"; protected String timestamp; - protected Map<String, Object> fields = new HashMap<String, Object>(); + protected Map<String, Object> fields = new HashMap<>(); public ESTimeBasedEvent() { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); + simpleDateFormat = new SimpleDateFormat(dateFormatPattern); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); this.timestamp = simpleDateFormat.format(new Date()); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), this.timestamp); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), this.timestamp); } @@ -64,7 +59,7 @@ public class ESTimeBasedEvent { while (keys.hasNext()) { String key = (String) keys.next(); event.fields.put(key, gsonObj.get(key)); - if (key.equals(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName())) { + if (key.equals(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName())) { event.timestamp = (String) gsonObj.get(key); } } |