diff options
author | Jakub Dudycz <jakub.dudycz@nokia.com> | 2018-02-26 12:38:53 +0100 |
---|---|---|
committer | Patrick Brady <pb071s@att.com> | 2018-02-26 19:11:11 +0000 |
commit | 312e9f071ef0a8b3482278e8909f66f4c986ba89 (patch) | |
tree | 8aecf342768b9d86fb1f68bf107ef5c313b2c7f8 /appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/LogParserTool.java | |
parent | 534f94b92547efab097040209e61fa06e07f6e43 (diff) |
appc-config-generator-provider sonar fixes part 2
Sonar fixes in whole module
Change-Id: I55856a6ce73a73098dadb2c5b9428437349ed8a8
Issue-ID: APPC-671
Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com>
Diffstat (limited to 'appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/LogParserTool.java')
-rw-r--r-- | appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/LogParserTool.java | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/LogParserTool.java b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/LogParserTool.java index ebd58b01c..a9a7ecaf1 100644 --- a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/LogParserTool.java +++ b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/LogParserTool.java @@ -37,14 +37,14 @@ public class LogParserTool { private static final EELFLogger log = EELFManager.getInstance().getLogger(JSONTool.class); private String[] singleLines; - private List<String> recentErrors = new ArrayList<String>(); - ; + private List<String> recentErrors = new ArrayList<>(); private Date todaysDate = new Date(); private SimpleDateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); - private final int minMilli = 60000; - private final int IN_TIME = 0; - private final int NOT_IN_TIME = 1; - private final int NO_DATE = 2; + + private static final int MIN_MILLI = 60000; + private static final int IN_TIME = 0; + private static final int NOT_IN_TIME = 1; + private static final int NO_DATE = 2; public String parseErrorLog(String data) { singleLines = data.split("\\r?\\n"); @@ -52,9 +52,9 @@ public class LogParserTool { getNearestDates(); } catch (Exception e) { - e.printStackTrace(); + log.error("Failed to get nearest dates", e); } - if (recentErrors.size() == 0) { + if (recentErrors.isEmpty()) { recentErrors.clear(); return "Did not find the string 'Starting orchestration of file backed up to /var/opt/MetaSwitch/orch/orch_conf.json' in the log file with timestamp within the last 5 minutes"; } else if (recentErrors.size() == 1) { @@ -68,7 +68,7 @@ public class LogParserTool { } } - public void getNearestDates() throws ParseException { + private void getNearestDates() throws ParseException { int result; for (int i = singleLines.length - 1; i >= 0; i--) { if (singleLines[i].contains("Starting orchestration of file backed up to") @@ -87,16 +87,14 @@ public class LogParserTool { Date newDate; try { newDate = dFormat.parse(line.substring(0, 19)); - if ((todaysDate.getTime() - newDate.getTime()) <= 5 * minMilli) { + if ((todaysDate.getTime() - newDate.getTime()) <= 5 * MIN_MILLI) { return IN_TIME; } else { return NOT_IN_TIME; } } catch (ParseException e) { - e.printStackTrace(); + log.error("Failed to parse date", e); return NO_DATE; } } - - } |