* * 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
\r
/**\r
* The representation of a Delivery Record, as retrieved from the DB.\r
+ *\r
* @author Robert Eby\r
* @version $Id: DeliveryRecord.java,v 1.9 2014/03/12 19:45:41 eby Exp $\r
*/\r
public class DeliveryRecord extends BaseLogRecord {\r
- private int subid;\r
- private String fileid;\r
- private int result;\r
- private String user;\r
-\r
- public DeliveryRecord(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.result = Integer.parseInt(pp[10]);\r
- this.user = pp[9];\r
- if (this.user != null && this.user.length() > 50)\r
- this.user = this.user.substring(0, 50);\r
- }\r
- public DeliveryRecord(ResultSet rs) throws SQLException {\r
- super(rs);\r
- this.subid = rs.getInt("DELIVERY_SUBID");\r
- this.fileid = rs.getString("DELIVERY_FILEID");\r
- this.result = rs.getInt("RESULT");\r
- this.user = rs.getString("USER");\r
- }\r
- public int getSubid() {\r
- return subid;\r
- }\r
- public void setSubid(int subid) {\r
- this.subid = subid;\r
- }\r
- public String getFileid() {\r
- return fileid;\r
- }\r
- public void setFileid(String fileid) {\r
- this.fileid = fileid;\r
- }\r
- public int getResult() {\r
- return result;\r
- }\r
- public void setResult(int result) {\r
- this.result = result;\r
- }\r
- public String getUser() {\r
- return user;\r
- }\r
- public void setUser(String user) {\r
- this.user = user;\r
- }\r
- \r
- \r
- public LOGJSONObject reOrderObject(LOGJSONObject jo) {\r
- LinkedHashMap<String,Object> logrecordObj = new LinkedHashMap<String,Object>();\r
- \r
- logrecordObj.put("statusCode", jo.get("statusCode"));\r
- logrecordObj.put("deliveryId", jo.get("deliveryId"));\r
- logrecordObj.put("publishId", jo.get("publishId"));\r
- logrecordObj.put("requestURI", jo.get("requestURI"));\r
- //logrecordObj.put("sourceIP", jo.get("sourceIP"));\r
- logrecordObj.put("method", jo.get("method"));\r
- logrecordObj.put("contentType", jo.get("contentType"));\r
- //logrecordObj.put("endpointId", jo.get("endpointId"));\r
- logrecordObj.put("type", jo.get("type"));\r
- logrecordObj.put("date", jo.get("date"));\r
- logrecordObj.put("contentLength", jo.get("contentLength"));\r
-\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", "del");\r
- jo.put("deliveryId", user);\r
- jo.put("statusCode", result);\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, "del"); // 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.setString(11, getUser());\r
- ps.setNull (12, Types.INTEGER);\r
- ps.setInt (13, getSubid());\r
- ps.setString(14, getFileid());\r
- ps.setInt (15, getResult());\r
- ps.setNull (16, Types.INTEGER);\r
- ps.setNull (17, Types.VARCHAR);\r
- ps.setNull (19, Types.BIGINT);\r
- }\r
+ private int subid;\r
+ private String fileid;\r
+ private int result;\r
+ private String user;\r
+\r
+ public DeliveryRecord(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.result = Integer.parseInt(pp[10]);\r
+ this.user = pp[9];\r
+ if (this.user != null && this.user.length() > 50)\r
+ this.user = this.user.substring(0, 50);\r
+ }\r
+\r
+ public DeliveryRecord(ResultSet rs) throws SQLException {\r
+ super(rs);\r
+ this.subid = rs.getInt("DELIVERY_SUBID");\r
+ this.fileid = rs.getString("DELIVERY_FILEID");\r
+ this.result = rs.getInt("RESULT");\r
+ this.user = rs.getString("USER");\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 getResult() {\r
+ return result;\r
+ }\r
+\r
+ public void setResult(int result) {\r
+ this.result = result;\r
+ }\r
+\r
+ public String getUser() {\r
+ return user;\r
+ }\r
+\r
+ public void setUser(String user) {\r
+ this.user = user;\r
+ }\r
+\r
+\r
+ public LOGJSONObject reOrderObject(LOGJSONObject jo) {\r
+ LinkedHashMap<String, Object> logrecordObj = new LinkedHashMap<String, Object>();\r
+\r
+ logrecordObj.put("statusCode", jo.get("statusCode"));\r
+ logrecordObj.put("deliveryId", jo.get("deliveryId"));\r
+ logrecordObj.put("publishId", jo.get("publishId"));\r
+ logrecordObj.put("requestURI", jo.get("requestURI"));\r
+ //logrecordObj.put("sourceIP", jo.get("sourceIP"));\r
+ logrecordObj.put("method", jo.get("method"));\r
+ logrecordObj.put("contentType", jo.get("contentType"));\r
+ //logrecordObj.put("endpointId", jo.get("endpointId"));\r
+ logrecordObj.put("type", jo.get("type"));\r
+ logrecordObj.put("date", jo.get("date"));\r
+ logrecordObj.put("contentLength", jo.get("contentLength"));\r
+\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", "del");\r
+ jo.put("deliveryId", user);\r
+ jo.put("statusCode", result);\r
+\r
+ LOGJSONObject newjo = this.reOrderObject(jo);\r
+ return newjo;\r
+ }\r
+\r
+ @Override\r
+ public void load(PreparedStatement ps) throws SQLException {\r
+ ps.setString(1, "del"); // 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.setString(11, getUser());\r
+ ps.setNull(12, Types.INTEGER);\r
+ ps.setInt(13, getSubid());\r
+ ps.setString(14, getFileid());\r
+ ps.setInt(15, getResult());\r
+ ps.setNull(16, Types.INTEGER);\r
+ ps.setNull(17, Types.VARCHAR);\r
+ ps.setNull(19, Types.BIGINT);\r
+ ps.setNull(20, Types.VARCHAR);\r
+ }\r
}\r