Code style cleanup for prov authz and beans
[dmaap/datarouter.git] / datarouter-prov / src / main / java / org / onap / dmaap / datarouter / provisioning / beans / BaseLogRecord.java
index 8534bc0..8cb4c15 100644 (file)
@@ -53,13 +53,9 @@ public class BaseLogRecord implements LOGJSONable, Loadable {
     private long contentLength;\r
 \r
     protected BaseLogRecord(String[] pp) throws ParseException {\r
-//        This throws exceptions occasionally - don't know why.\r
-//        Date d = null;\r
-//        synchronized (sdf) {\r
-//            d = sdf.parse(pp[0]);\r
-//        }\r
-        Date d = parseDate(pp[0]);\r
-        this.eventTime     = d.getTime();\r
+\r
+        Date dt = parseDate(pp[0]);\r
+        this.eventTime     = dt.getTime();\r
         this.publishId     = pp[2];\r
         this.feedid        = Integer.parseInt(pp[3]);\r
         if (pp[1].equals("DLX")) {\r
@@ -79,6 +75,7 @@ public class BaseLogRecord implements LOGJSONable, Loadable {
             this.contentLength = Long.parseLong(pp[8]);\r
         }\r
     }\r
+\r
     protected BaseLogRecord(ResultSet rs) throws SQLException {\r
         this.eventTime     = rs.getLong("EVENT_TIME");\r
         this.publishId     = rs.getString("PUBLISH_ID");\r
@@ -88,81 +85,99 @@ public class BaseLogRecord implements LOGJSONable, Loadable {
         this.contentType   = rs.getString("CONTENT_TYPE");\r
         this.contentLength = rs.getLong("CONTENT_LENGTH");\r
     }\r
-    protected Date parseDate(final String s) throws ParseException {\r
-        int[] n = new int[7];\r
-        int p = 0;\r
-        for (int i = 0; i < s.length(); i++) {\r
-            char c = s.charAt(i);\r
-            if (c < '0' || c > '9') {\r
-                p++;\r
+\r
+    protected Date parseDate(final String str) throws ParseException {\r
+        int[] num = new int[7];\r
+        int place = 0;\r
+        for (int i = 0; i < str.length(); i++) {\r
+            char chr = str.charAt(i);\r
+            if (chr < '0' || chr > '9') {\r
+                place++;\r
             } else {\r
-                if (p > n.length)\r
+                if (place > num.length) {\r
                     throw new ParseException("parseDate()", 0);\r
-                n[p] = (n[p] * 10) + (c - '0');\r
+                }\r
+                num[place] = (num[place] * 10) + (chr - '0');\r
             }\r
         }\r
-        if (p != 7)\r
+        if (place != 7) {\r
             throw new ParseException("parseDate()", 1);\r
+        }\r
         Calendar cal = new GregorianCalendar();\r
-        cal.set(Calendar.YEAR, n[0]);\r
-        cal.set(Calendar.MONTH, n[1]-1);\r
-        cal.set(Calendar.DAY_OF_MONTH, n[2]);\r
-        cal.set(Calendar.HOUR_OF_DAY, n[3]);\r
-        cal.set(Calendar.MINUTE, n[4]);\r
-        cal.set(Calendar.SECOND, n[5]);\r
-        cal.set(Calendar.MILLISECOND, n[6]);\r
+        cal.set(Calendar.YEAR, num[0]);\r
+        cal.set(Calendar.MONTH, num[1] - 1);\r
+        cal.set(Calendar.DAY_OF_MONTH, num[2]);\r
+        cal.set(Calendar.HOUR_OF_DAY, num[3]);\r
+        cal.set(Calendar.MINUTE, num[4]);\r
+        cal.set(Calendar.SECOND, num[5]);\r
+        cal.set(Calendar.MILLISECOND, num[6]);\r
         return cal.getTime();\r
     }\r
+\r
     public long getEventTime() {\r
         return eventTime;\r
     }\r
+\r
     public void setEventTime(long eventTime) {\r
         this.eventTime = eventTime;\r
     }\r
+\r
     public String getPublishId() {\r
         return publishId;\r
     }\r
+\r
     public void setPublishId(String publishId) {\r
         this.publishId = publishId;\r
     }\r
+\r
     public int getFeedid() {\r
         return feedid;\r
     }\r
+\r
     public void setFeedid(int feedid) {\r
         this.feedid = feedid;\r
     }\r
+\r
     public String getRequestUri() {\r
         return requestUri;\r
     }\r
+\r
     public void setRequestUri(String requestUri) {\r
         this.requestUri = requestUri;\r
     }\r
+\r
     public String getMethod() {\r
         return method;\r
     }\r
+\r
     public void setMethod(String method) {\r
         this.method = method;\r
     }\r
+\r
     public String getContentType() {\r
         return contentType;\r
     }\r
+\r
     public void setContentType(String contentType) {\r
         this.contentType = contentType;\r
     }\r
+\r
     public long getContentLength() {\r
         return contentLength;\r
     }\r
+\r
     public void setContentLength(long contentLength) {\r
         this.contentLength = contentLength;\r
     }\r
+\r
     @Override\r
     public LOGJSONObject asJSONObject() {\r
         LOGJSONObject jo = new LOGJSONObject();\r
-        String t = "";\r
+        String str = "";\r
         synchronized (sdf) {\r
-            t = sdf.format(eventTime);\r
+            str = sdf.format(eventTime);\r
         }\r
-        jo.put("date", t);\r
+        jo.put("date", str);\r
         jo.put("publishId", publishId);\r
         jo.put("requestURI", requestUri);\r
         jo.put("method", method);\r
@@ -172,14 +187,16 @@ public class BaseLogRecord implements LOGJSONable, Loadable {
         }\r
         return jo;\r
     }\r
+\r
     @Override\r
     public void load(PreparedStatement ps) throws SQLException {\r
-        ps.setLong  (2, getEventTime());\r
+        ps.setLong(2, getEventTime());\r
         ps.setString(3, getPublishId());\r
-        ps.setInt   (4, getFeedid());\r
+        ps.setInt(4, getFeedid());\r
         ps.setString(5, getRequestUri());\r
         ps.setString(6, getMethod());\r
         ps.setString(7, getContentType());\r
-        ps.setLong  (8, getContentLength());\r
+        ps.setLong(8, getContentLength());\r
     }\r
 }\r
+\r