Code style cleanup for prov authz and beans
[dmaap/datarouter.git] / datarouter-prov / src / main / java / org / onap / dmaap / datarouter / provisioning / beans / ExpiryRecord.java
index 29a7fea..d812036 100644 (file)
@@ -7,9 +7,9 @@
  * * Licensed under the Apache License, Version 2.0 (the "License");\r
  * * you may not use this file except in compliance with the License.\r
  * * You may obtain a copy of the License at\r
- * * \r
+ * *\r
  *  *      http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
+ * *\r
  *  * Unless required by applicable law or agreed to in writing, software\r
  * * distributed under the License is distributed on an "AS IS" BASIS,\r
  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
@@ -31,111 +31,131 @@ import java.sql.Types;
 import java.text.ParseException;\r
 import java.util.LinkedHashMap;\r
 \r
-import org.json.LOGJSONObject;\r
+import org.onap.dmaap.datarouter.provisioning.utils.LOGJSONObject;\r
+\r
 \r
 /**\r
  * The representation of a Expiry Record, as retrieved from the DB.\r
+ *\r
  * @author Robert Eby\r
  * @version $Id: ExpiryRecord.java,v 1.4 2013/10/28 18:06:52 eby Exp $\r
  */\r
 public class ExpiryRecord extends BaseLogRecord {\r
-       private int subid;\r
-       private String fileid;\r
-       private int attempts;\r
-       private String reason;\r
-\r
-       public ExpiryRecord(String[] pp) throws ParseException {\r
-               super(pp);\r
-               String fileid = pp[5];\r
-               if (fileid.lastIndexOf('/') >= 0)\r
-                       fileid = fileid.substring(fileid.lastIndexOf('/')+1);\r
-               this.subid    = Integer.parseInt(pp[4]);\r
-               this.fileid   = fileid;\r
-               this.attempts = Integer.parseInt(pp[10]);\r
-               this.reason   = pp[9];\r
-               if (!reason.equals("notRetryable") && !reason.equals("retriesExhausted") && !reason.equals("diskFull"))\r
-                       this.reason = "other";\r
-       }\r
-       public ExpiryRecord(ResultSet rs) throws SQLException {\r
-               super(rs);\r
-               this.subid    = rs.getInt("DELIVERY_SUBID");\r
-               this.fileid   = rs.getString("DELIVERY_FILEID");\r
-               this.attempts = rs.getInt("ATTEMPTS");\r
-               this.reason   = rs.getString("REASON");\r
-       }\r
-\r
-       public int getSubid() {\r
-               return subid;\r
-       }\r
-\r
-       public void setSubid(int subid) {\r
-               this.subid = subid;\r
-       }\r
-\r
-       public String getFileid() {\r
-               return fileid;\r
-       }\r
-\r
-       public void setFileid(String fileid) {\r
-               this.fileid = fileid;\r
-       }\r
-\r
-       public int getAttempts() {\r
-               return attempts;\r
-       }\r
-\r
-       public void setAttempts(int attempts) {\r
-               this.attempts = attempts;\r
-       }\r
-\r
-       public String getReason() {\r
-               return reason;\r
-       }\r
-\r
-       public void setReason(String reason) {\r
-               this.reason = reason;\r
-       }\r
-       \r
-       public LOGJSONObject reOrderObject(LOGJSONObject jo) {\r
-               LinkedHashMap<String,Object> logrecordObj = new LinkedHashMap<String,Object>();\r
-               \r
-               logrecordObj.put("expiryReason", jo.get("expiryReason"));\r
-               logrecordObj.put("publishId", jo.get("publishId"));\r
-               logrecordObj.put("attempts", jo.get("attempts"));\r
-               logrecordObj.put("requestURI", jo.get("requestURI"));\r
-               logrecordObj.put("method", jo.get("method"));\r
-               logrecordObj.put("contentType", jo.get("contentType"));\r
-               logrecordObj.put("type", jo.get("type"));\r
-               logrecordObj.put("date", jo.get("date"));\r
-               logrecordObj.put("contentLength", jo.get("contentLength"));\r
-\r
-               LOGJSONObject newjo = new LOGJSONObject(logrecordObj);\r
-               return newjo;\r
-       }\r
-       \r
-       @Override\r
-       public LOGJSONObject asJSONObject() {\r
-               LOGJSONObject jo = super.asJSONObject();\r
-               jo.put("type", "exp");\r
-               jo.put("expiryReason", reason);\r
-               jo.put("attempts", attempts);\r
-               \r
-               LOGJSONObject newjo = this.reOrderObject(jo);\r
-               return newjo;\r
-       }\r
-       @Override\r
-       public void load(PreparedStatement ps) throws SQLException {\r
-               ps.setString(1, "exp");         // field 1: type\r
-               super.load(ps);                         // loads fields 2-8\r
-               ps.setNull  (9,  Types.VARCHAR);\r
-               ps.setNull  (10, Types.VARCHAR);\r
-               ps.setNull  (11, Types.VARCHAR);\r
-               ps.setNull  (12, Types.INTEGER);\r
-               ps.setInt   (13, getSubid());\r
-               ps.setString(14, getFileid());\r
-               ps.setNull  (15, Types.INTEGER);\r
-               ps.setInt   (16, getAttempts());\r
-               ps.setString(17, getReason());\r
-               ps.setNull  (19, Types.BIGINT);\r
-       }\r
+    private int subid;\r
+    private String fileid;\r
+    private int attempts;\r
+    private String reason;\r
+\r
+    /**\r
+     * ExpiryRecord constructor.\r
+     * @param pp string array of ExpiryRecord attributes\r
+     * @throws ParseException in case of parse error\r
+     */\r
+    public ExpiryRecord(String[] pp) throws ParseException {\r
+        super(pp);\r
+        String fileid = pp[5];\r
+        if (fileid.lastIndexOf('/') >= 0) {\r
+            fileid = fileid.substring(fileid.lastIndexOf('/') + 1);\r
+        }\r
+        this.subid = Integer.parseInt(pp[4]);\r
+        this.fileid = fileid;\r
+        this.attempts = Integer.parseInt(pp[10]);\r
+        this.reason = pp[9];\r
+        if (!reason.equals("notRetryable") && !reason.equals("retriesExhausted") && !reason.equals("diskFull")) {\r
+            this.reason = "other";\r
+        }\r
+    }\r
+\r
+    /**\r
+     * ExpiryRecord constructor from ResultSet.\r
+     * @param rs ResultSet of ExpiryREcord attributes\r
+     * @throws SQLException in case of error with SQL statement\r
+     */\r
+    public ExpiryRecord(ResultSet rs) throws SQLException {\r
+        super(rs);\r
+        this.subid = rs.getInt("DELIVERY_SUBID");\r
+        this.fileid = rs.getString("DELIVERY_FILEID");\r
+        this.attempts = rs.getInt("ATTEMPTS");\r
+        this.reason = rs.getString("REASON");\r
+    }\r
+\r
+    public int getSubid() {\r
+        return subid;\r
+    }\r
+\r
+    public void setSubid(int subid) {\r
+        this.subid = subid;\r
+    }\r
+\r
+    public String getFileid() {\r
+        return fileid;\r
+    }\r
+\r
+    public void setFileid(String fileid) {\r
+        this.fileid = fileid;\r
+    }\r
+\r
+    public int getAttempts() {\r
+        return attempts;\r
+    }\r
+\r
+    public void setAttempts(int attempts) {\r
+        this.attempts = attempts;\r
+    }\r
+\r
+    public String getReason() {\r
+        return reason;\r
+    }\r
+\r
+    public void setReason(String reason) {\r
+        this.reason = reason;\r
+    }\r
+\r
+    /**\r
+     * Method to reorder LOGJSONObject.\r
+     * @param jo LOGJSONObject\r
+     * @return LOGJSONObject\r
+     */\r
+    public LOGJSONObject reOrderObject(LOGJSONObject jo) {\r
+        LinkedHashMap<String, Object> logrecordObj = new LinkedHashMap<>();\r
+\r
+        logrecordObj.put("expiryReason", jo.get("expiryReason"));\r
+        logrecordObj.put("publishId", jo.get("publishId"));\r
+        logrecordObj.put("attempts", jo.get("attempts"));\r
+        logrecordObj.put("requestURI", jo.get("requestURI"));\r
+        logrecordObj.put("method", jo.get("method"));\r
+        logrecordObj.put("contentType", jo.get("contentType"));\r
+        logrecordObj.put("type", jo.get("type"));\r
+        logrecordObj.put("date", jo.get("date"));\r
+        logrecordObj.put("contentLength", jo.get("contentLength"));\r
+\r
+        return new LOGJSONObject(logrecordObj);\r
+    }\r
+\r
+    @Override\r
+    public LOGJSONObject asJSONObject() {\r
+        LOGJSONObject jo = super.asJSONObject();\r
+        jo.put("type", "exp");\r
+        jo.put("expiryReason", reason);\r
+        jo.put("attempts", attempts);\r
+\r
+        return reOrderObject(jo);\r
+    }\r
+\r
+    @Override\r
+    public void load(PreparedStatement ps) throws SQLException {\r
+        ps.setString(1, "exp");        // field 1: type\r
+        super.load(ps);                // loads fields 2-8\r
+        ps.setNull(9, Types.VARCHAR);\r
+        ps.setNull(10, Types.VARCHAR);\r
+        ps.setNull(11, Types.VARCHAR);\r
+        ps.setNull(12, Types.INTEGER);\r
+        ps.setInt(13, getSubid());\r
+        ps.setString(14, getFileid());\r
+        ps.setNull(15, Types.INTEGER);\r
+        ps.setInt(16, getAttempts());\r
+        ps.setString(17, getReason());\r
+        ps.setNull(19, Types.BIGINT);\r
+        ps.setNull(20, Types.VARCHAR);\r
+    }\r
 }\r