X-Git-Url: https://gerrit.onap.org/r/gitweb?p=dmaap%2Fdatarouter.git;a=blobdiff_plain;f=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fprovisioning%2Fbeans%2FExpiryRecord.java;h=4c7fffaa8b1d5e67239dd538e5c7c6b4aa959d5d;hp=8e841e6858997c7f156b85b873bd6806bbca98fa;hb=6c78b3e6a0a67c73f931337356a172cc69cee0e8;hpb=8ebd052e0b1066c432f5dba6ef69599eaf5ec27e 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 8e841e68..4c7fffaa 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 (!reason.equals("notRetryable") && !reason.equals("retriesExhausted") && !reason.equals("diskFull")) { 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<>(); - 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")); @@ -119,10 +139,10 @@ public class ExpiryRecord extends BaseLogRecord { 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); - return this.reOrderObject(jo); + return reOrderObject(jo); } @Override @@ -136,7 +156,7 @@ 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);