* @version $Id: ExpiryRecord.java,v 1.4 2013/10/28 18:06:52 eby Exp $\r
*/\r
public class ExpiryRecord extends BaseLogRecord {\r
+\r
+ public static final String EXPIRY_REASON = "expiryReason";\r
+ public static final String ATTEMPTS = "attempts";\r
private int subid;\r
private String fileid;\r
- private int attempts;\r
+ private int deliveryAttempts;\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
+ String thisFileid = pp[5];\r
+ if (thisFileid.lastIndexOf('/') >= 0) {\r
+ thisFileid = thisFileid.substring(thisFileid.lastIndexOf('/') + 1);\r
+ }\r
this.subid = Integer.parseInt(pp[4]);\r
- this.fileid = fileid;\r
- this.attempts = Integer.parseInt(pp[10]);\r
+ this.fileid = thisFileid;\r
+ this.deliveryAttempts = Integer.parseInt(pp[10]);\r
this.reason = pp[9];\r
- if (!reason.equals("notRetryable") && !reason.equals("retriesExhausted") && !reason.equals("diskFull"))\r
+ if (!"notRetryable".equals(reason) && !"retriesExhausted".equals(reason) && !"diskFull".equals(reason)) {\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.deliveryAttempts = rs.getInt("ATTEMPTS");\r
this.reason = rs.getString("REASON");\r
}\r
\r
this.fileid = fileid;\r
}\r
\r
- public int getAttempts() {\r
- return attempts;\r
+ public int getDeliveryAttempts() {\r
+ return deliveryAttempts;\r
}\r
\r
- public void setAttempts(int attempts) {\r
- this.attempts = attempts;\r
+ public void setDeliveryAttempts(int deliveryAttempts) {\r
+ this.deliveryAttempts = deliveryAttempts;\r
}\r
\r
public String getReason() {\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<String, Object>();\r
+ LinkedHashMap<String, Object> logrecordObj = new LinkedHashMap<>();\r
\r
- logrecordObj.put("expiryReason", jo.get("expiryReason"));\r
+ logrecordObj.put(EXPIRY_REASON, jo.get(EXPIRY_REASON));\r
logrecordObj.put("publishId", jo.get("publishId"));\r
- logrecordObj.put("attempts", jo.get("attempts"));\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("date", jo.get("date"));\r
logrecordObj.put("contentLength", jo.get("contentLength"));\r
\r
- LOGJSONObject newjo = new LOGJSONObject(logrecordObj);\r
- return newjo;\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
+ jo.put(EXPIRY_REASON, reason);\r
+ jo.put(ATTEMPTS, deliveryAttempts);\r
\r
- LOGJSONObject newjo = this.reOrderObject(jo);\r
- return newjo;\r
+ return reOrderObject(jo);\r
}\r
\r
@Override\r
ps.setInt(13, getSubid());\r
ps.setString(14, getFileid());\r
ps.setNull(15, Types.INTEGER);\r
- ps.setInt(16, getAttempts());\r
+ ps.setInt(16, getDeliveryAttempts());\r
ps.setString(17, getReason());\r
ps.setNull(19, Types.BIGINT);\r
+ ps.setNull(20, Types.VARCHAR);\r
}\r
}\r