X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fprovisioning%2Fbeans%2FExpiryRecord.java;h=2b4e5a3d61ccd9fdd36a01ac81fe91572f1c9442;hb=06a86fa387e05f57bb1cec4295901e6d7786aa98;hp=3f85aec65b15a32436ce444e2c9f22a642a76424;hpb=8cbe8a88bc6dfe8673a33a017fe6a5a3e7ce86c3;p=dmaap%2Fdatarouter.git diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java index 3f85aec6..2b4e5a3d 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java @@ -41,29 +41,44 @@ import org.onap.dmaap.datarouter.provisioning.utils.LOGJSONObject; * @version $Id: ExpiryRecord.java,v 1.4 2013/10/28 18:06:52 eby Exp $ */ public class ExpiryRecord extends BaseLogRecord { + + public static final String EXPIRY_REASON = "expiryReason"; + public static final String ATTEMPTS = "attempts"; private int subid; private String fileid; - private int attempts; + private int deliveryAttempts; private String reason; + /** + * ExpiryRecord constructor. + * @param pp string array of ExpiryRecord attributes + * @throws ParseException in case of parse error + */ public ExpiryRecord(String[] pp) throws ParseException { super(pp); - String fileid = pp[5]; - if (fileid.lastIndexOf('/') >= 0) - fileid = fileid.substring(fileid.lastIndexOf('/') + 1); + String thisFileid = pp[5]; + if (thisFileid.lastIndexOf('/') >= 0) { + thisFileid = thisFileid.substring(thisFileid.lastIndexOf('/') + 1); + } this.subid = Integer.parseInt(pp[4]); - this.fileid = fileid; - this.attempts = Integer.parseInt(pp[10]); + this.fileid = thisFileid; + this.deliveryAttempts = Integer.parseInt(pp[10]); this.reason = pp[9]; - if (!reason.equals("notRetryable") && !reason.equals("retriesExhausted") && !reason.equals("diskFull")) + if (!"notRetryable".equals(reason) && !"retriesExhausted".equals(reason) && !"diskFull".equals(reason)) { this.reason = "other"; + } } + /** + * ExpiryRecord constructor from ResultSet. + * @param rs ResultSet of ExpiryREcord attributes + * @throws SQLException in case of error with SQL statement + */ public ExpiryRecord(ResultSet rs) throws SQLException { super(rs); this.subid = rs.getInt("DELIVERY_SUBID"); this.fileid = rs.getString("DELIVERY_FILEID"); - this.attempts = rs.getInt("ATTEMPTS"); + this.deliveryAttempts = rs.getInt("ATTEMPTS"); this.reason = rs.getString("REASON"); } @@ -83,12 +98,12 @@ public class ExpiryRecord extends BaseLogRecord { this.fileid = fileid; } - public int getAttempts() { - return attempts; + public int getDeliveryAttempts() { + return deliveryAttempts; } - public void setAttempts(int attempts) { - this.attempts = attempts; + public void setDeliveryAttempts(int deliveryAttempts) { + this.deliveryAttempts = deliveryAttempts; } public String getReason() { @@ -99,12 +114,17 @@ public class ExpiryRecord extends BaseLogRecord { this.reason = reason; } + /** + * Method to reorder LOGJSONObject. + * @param jo LOGJSONObject + * @return LOGJSONObject + */ public LOGJSONObject reOrderObject(LOGJSONObject jo) { - LinkedHashMap logrecordObj = new LinkedHashMap(); + LinkedHashMap logrecordObj = new LinkedHashMap<>(); - logrecordObj.put("expiryReason", jo.get("expiryReason")); + logrecordObj.put(EXPIRY_REASON, jo.get(EXPIRY_REASON)); logrecordObj.put("publishId", jo.get("publishId")); - logrecordObj.put("attempts", jo.get("attempts")); + logrecordObj.put(ATTEMPTS, jo.get(ATTEMPTS)); logrecordObj.put("requestURI", jo.get("requestURI")); logrecordObj.put("method", jo.get("method")); logrecordObj.put("contentType", jo.get("contentType")); @@ -112,19 +132,17 @@ public class ExpiryRecord extends BaseLogRecord { logrecordObj.put("date", jo.get("date")); logrecordObj.put("contentLength", jo.get("contentLength")); - LOGJSONObject newjo = new LOGJSONObject(logrecordObj); - return newjo; + return new LOGJSONObject(logrecordObj); } @Override public LOGJSONObject asJSONObject() { LOGJSONObject jo = super.asJSONObject(); jo.put("type", "exp"); - jo.put("expiryReason", reason); - jo.put("attempts", attempts); + jo.put(EXPIRY_REASON, reason); + jo.put(ATTEMPTS, deliveryAttempts); - LOGJSONObject newjo = this.reOrderObject(jo); - return newjo; + return reOrderObject(jo); } @Override @@ -138,8 +156,9 @@ public class ExpiryRecord extends BaseLogRecord { ps.setInt(13, getSubid()); ps.setString(14, getFileid()); ps.setNull(15, Types.INTEGER); - ps.setInt(16, getAttempts()); + ps.setInt(16, getDeliveryAttempts()); ps.setString(17, getReason()); ps.setNull(19, Types.BIGINT); + ps.setNull(20, Types.VARCHAR); } }