- public RowHandler(ServletOutputStream out, String fieldparam, boolean b) {\r
- this.out = out;\r
- this.firstrow = b;\r
- this.fields = (fieldparam != null) ? fieldparam.split(":") : null;\r
- }\r
- public void handleRow(ResultSet rs) {\r
- try {\r
- LOGJSONable js = buildJSONable(rs);\r
- LOGJSONObject jo = js.asJSONObject();\r
- if (fields != null) {\r
- // filter out unwanted fields\r
- LOGJSONObject j2 = new LOGJSONObject();\r
- for (String key : fields) {\r
- Object v = jo.opt(key);\r
- if (v != null)\r
- j2.put(key, v);\r
- }\r
- jo = j2;\r
- }\r
- String t = firstrow ? "\n" : ",\n";\r
- t += jo.toString();\r
- out.print(t);\r
- firstrow = false;\r
- } catch (Exception e) {\r
- // ignore\r
- }\r
- }\r
- public abstract LOGJSONable buildJSONable(ResultSet rs) throws SQLException;\r
- }\r
- public class PublishRecordRowHandler extends RowHandler {\r
- public PublishRecordRowHandler(ServletOutputStream out, String fields, boolean b) {\r
- super(out, fields, b);\r
- }\r
- @Override\r
- public LOGJSONable buildJSONable(ResultSet rs) throws SQLException {\r
- return new PublishRecord(rs);\r
- }\r
- }\r
- public class DeliveryRecordRowHandler extends RowHandler {\r
- public DeliveryRecordRowHandler(ServletOutputStream out, String fields, boolean b) {\r
- super(out, fields, b);\r
- }\r
- @Override\r
- public LOGJSONable buildJSONable(ResultSet rs) throws SQLException {\r
- return new DeliveryRecord(rs);\r
- }\r
- }\r
- public class ExpiryRecordRowHandler extends RowHandler {\r
- public ExpiryRecordRowHandler(ServletOutputStream out, String fields, boolean b) {\r
- super(out, fields, b);\r
- }\r
- @Override\r
- public LOGJSONable buildJSONable(ResultSet rs) throws SQLException {\r
- return new ExpiryRecord(rs);\r
- }\r
- }\r
+ public RowHandler(ServletOutputStream out, String fieldparam, boolean b) {\r
+ this.out = out;\r
+ this.firstrow = b;\r
+ this.fields = (fieldparam != null) ? fieldparam.split(":") : null;\r
+ }\r
+ public void handleRow(ResultSet rs) {\r
+ try {\r
+ LOGJSONable js = buildJSONable(rs);\r
+ LOGJSONObject jo = js.asJSONObject();\r
+ if (fields != null) {\r
+ // filter out unwanted fields\r
+ LOGJSONObject j2 = new LOGJSONObject();\r
+ for (String key : fields) {\r
+ Object v = jo.opt(key);\r
+ if (v != null)\r
+ j2.put(key, v);\r
+ }\r
+ jo = j2;\r
+ }\r
+ String t = firstrow ? "\n" : ",\n";\r
+ t += jo.toString();\r
+ out.print(t);\r
+ firstrow = false;\r
+ } catch (Exception e) {\r
+ // ignore\r
+ }\r
+ }\r
+ public abstract LOGJSONable buildJSONable(ResultSet rs) throws SQLException;\r
+ }\r
+ public class PublishRecordRowHandler extends RowHandler {\r
+ public PublishRecordRowHandler(ServletOutputStream out, String fields, boolean b) {\r
+ super(out, fields, b);\r
+ }\r
+ @Override\r
+ public LOGJSONable buildJSONable(ResultSet rs) throws SQLException {\r
+ return new PublishRecord(rs);\r
+ }\r
+ }\r
+ public class DeliveryRecordRowHandler extends RowHandler {\r
+ public DeliveryRecordRowHandler(ServletOutputStream out, String fields, boolean b) {\r
+ super(out, fields, b);\r
+ }\r
+ @Override\r
+ public LOGJSONable buildJSONable(ResultSet rs) throws SQLException {\r
+ return new DeliveryRecord(rs);\r
+ }\r
+ }\r
+ public class ExpiryRecordRowHandler extends RowHandler {\r
+ public ExpiryRecordRowHandler(ServletOutputStream out, String fields, boolean b) {\r
+ super(out, fields, b);\r
+ }\r
+ @Override\r
+ public LOGJSONable buildJSONable(ResultSet rs) throws SQLException {\r
+ return new ExpiryRecord(rs);\r
+ }\r
+ }\r
- /**\r
- * DELETE a logging URL -- not supported.\r
- */\r
- @Override\r
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws IOException {\r
- setIpAndFqdnForEelf("doDelete");\r
- eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER),getIdFromPath(req)+"");\r
- String message = "DELETE not allowed for the logURL.";\r
- EventLogRecord elr = new EventLogRecord(req);\r
- elr.setMessage(message);\r
- elr.setResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED);\r
- eventlogger.info(elr);\r
- resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, message);\r
- }\r
- /**\r
- * GET a logging URL -- retrieve logging data for a feed or subscription.\r
- * See the <b>Logging API</b> document for details on how this method should be invoked.\r
- */\r
- @Override\r
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {\r
- setIpAndFqdnForEelf("doGet");\r
- eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER),getIdFromPath(req)+"");\r
- int id = getIdFromPath(req);\r
- if (id < 0) {\r
- resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Missing or bad feed/subscription number.");\r
- return;\r
- }\r
- Map<String, String> map = buildMapFromRequest(req);\r
- if (map.get("err") != null) {\r
- resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid arguments: "+map.get("err"));\r
- return;\r
- }\r
- // check Accept: header??\r
+ /**\r
+ * DELETE a logging URL -- not supported.\r
+ */\r
+ @Override\r
+ public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws IOException {\r
+ setIpAndFqdnForEelf("doDelete");\r
+ eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER),getIdFromPath(req)+"");\r
+ String message = "DELETE not allowed for the logURL.";\r
+ EventLogRecord elr = new EventLogRecord(req);\r
+ elr.setMessage(message);\r
+ elr.setResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED);\r
+ eventlogger.info(elr);\r
+ resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, message);\r
+ }\r
+ /**\r
+ * GET a logging URL -- retrieve logging data for a feed or subscription.\r
+ * See the <b>Logging API</b> document for details on how this method should be invoked.\r
+ */\r
+ @Override\r
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {\r
+ setIpAndFqdnForEelf("doGet");\r
+ eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER),getIdFromPath(req)+"");\r
+ int id = getIdFromPath(req);\r
+ if (id < 0) {\r
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Missing or bad feed/subscription number.");\r
+ return;\r
+ }\r
+ Map<String, String> map = buildMapFromRequest(req);\r
+ if (map.get("err") != null) {\r
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid arguments: "+map.get("err"));\r
+ return;\r
+ }\r
+ // check Accept: header??\r
- // 3. Collect expiry records for subscriptions to this feed\r
- rh = new ExpiryRecordRowHandler(out, fields, firstrow);\r
- getExpiryRecordsForFeed(id, rh, map);\r
- } else {\r
- // Handle /sublog/subid request\r
- Subscription sub = Subscription.getSubscriptionById(id);\r
- if (sub != null) {\r
- // 1. Collect publish records for the feed this subscription feeds\r
- RowHandler rh = new PublishRecordRowHandler(out, fields, true);\r
- getPublishRecordsForFeed(sub.getFeedid(), rh, map);\r
+ // 3. Collect expiry records for subscriptions to this feed\r
+ rh = new ExpiryRecordRowHandler(out, fields, firstrow);\r
+ getExpiryRecordsForFeed(id, rh, map);\r
+ } else {\r
+ // Handle /sublog/subid request\r
+ Subscription sub = Subscription.getSubscriptionById(id);\r
+ if (sub != null) {\r
+ // 1. Collect publish records for the feed this subscription feeds\r
+ RowHandler rh = new PublishRecordRowHandler(out, fields, true);\r
+ getPublishRecordsForFeed(sub.getFeedid(), rh, map);\r
- // 3. Collect expiry records for this subscription\r
- rh = new ExpiryRecordRowHandler(out, fields, rh.firstrow);\r
- getExpiryRecordsForSubscription(id, rh, map);\r
- }\r
- }\r
- out.print("\n]");\r
- }\r
- /**\r
- * PUT a logging URL -- not supported.\r
- */\r
- @Override\r
- public void doPut(HttpServletRequest req, HttpServletResponse resp) throws IOException {\r
- setIpAndFqdnForEelf("doPut");\r
- eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER),getIdFromPath(req)+"");\r
- String message = "PUT not allowed for the logURL.";\r
- EventLogRecord elr = new EventLogRecord(req);\r
- elr.setMessage(message);\r
- elr.setResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED);\r
- eventlogger.info(elr);\r
- resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, message);\r
- }\r
- /**\r
- * POST a logging URL -- not supported.\r
- */\r
- @Override\r
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {\r
- setIpAndFqdnForEelf("doPost");\r
- eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF, req.getHeader(BEHALF_HEADER));\r
- String message = "POST not allowed for the logURL.";\r
- EventLogRecord elr = new EventLogRecord(req);\r
- elr.setMessage(message);\r
- elr.setResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED);\r
- eventlogger.info(elr);\r
- resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, message);\r
- }\r
+ // 3. Collect expiry records for this subscription\r
+ rh = new ExpiryRecordRowHandler(out, fields, rh.firstrow);\r
+ getExpiryRecordsForSubscription(id, rh, map);\r
+ }\r
+ }\r
+ out.print("\n]");\r
+ }\r
+ /**\r
+ * PUT a logging URL -- not supported.\r
+ */\r
+ @Override\r
+ public void doPut(HttpServletRequest req, HttpServletResponse resp) throws IOException {\r
+ setIpAndFqdnForEelf("doPut");\r
+ eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER),getIdFromPath(req)+"");\r
+ String message = "PUT not allowed for the logURL.";\r
+ EventLogRecord elr = new EventLogRecord(req);\r
+ elr.setMessage(message);\r
+ elr.setResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED);\r
+ eventlogger.info(elr);\r
+ resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, message);\r
+ }\r
+ /**\r
+ * POST a logging URL -- not supported.\r
+ */\r
+ @Override\r
+ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {\r
+ setIpAndFqdnForEelf("doPost");\r
+ eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF, req.getHeader(BEHALF_HEADER));\r
+ String message = "POST not allowed for the logURL.";\r
+ EventLogRecord elr = new EventLogRecord(req);\r
+ elr.setMessage(message);\r
+ elr.setResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED);\r
+ eventlogger.info(elr);\r
+ resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, message);\r
+ }\r
- private Map<String, String> buildMapFromRequest(HttpServletRequest req) {\r
- Map<String, String> map = new HashMap<String, String>();\r
- String s = req.getParameter("type");\r
- if (s != null) {\r
- if (s.equals("pub") || s.equals("del") || s.equals("exp")) {\r
- map.put("type", s);\r
- } else {\r
- map.put("err", "bad type");\r
- return map;\r
- }\r
- } else\r
- map.put("type", "all");\r
- map.put("publishSQL", "");\r
- map.put("statusSQL", "");\r
- map.put("resultSQL", "");\r
- map.put("reasonSQL", "");\r
+ private Map<String, String> buildMapFromRequest(HttpServletRequest req) {\r
+ Map<String, String> map = new HashMap<String, String>();\r
+ String s = req.getParameter("type");\r
+ if (s != null) {\r
+ if (s.equals("pub") || s.equals("del") || s.equals("exp")) {\r
+ map.put("type", s);\r
+ } else {\r
+ map.put("err", "bad type");\r
+ return map;\r
+ }\r
+ } else\r
+ map.put("type", "all");\r
+ map.put("publishSQL", "");\r
+ map.put("statusSQL", "");\r
+ map.put("resultSQL", "");\r
+ map.put("reasonSQL", "");\r
- s = req.getParameter("statusCode");\r
- if (s != null) {\r
- String sql = null;\r
- if (s.equals("success")) {\r
- sql = " AND STATUS >= 200 AND STATUS < 300";\r
- } else if (s.equals("redirect")) {\r
- sql = " AND STATUS >= 300 AND STATUS < 400";\r
- } else if (s.equals("failure")) {\r
- sql = " AND STATUS >= 400";\r
- } else {\r
- try {\r
- Integer n = Integer.parseInt(s);\r
- if ((n >= 100 && n < 600) || (n == -1))\r
- sql = " AND STATUS = " + n;\r
- } catch (NumberFormatException e) {\r
- }\r
- }\r
- if (sql == null) {\r
- map.put("err", "bad statusCode");\r
- return map;\r
- }\r
- map.put("statusSQL", sql);\r
- map.put("resultSQL", sql.replaceAll("STATUS", "RESULT"));\r
- }\r
+ s = req.getParameter("statusCode");\r
+ if (s != null) {\r
+ String sql = null;\r
+ if (s.equals("success")) {\r
+ sql = " AND STATUS >= 200 AND STATUS < 300";\r
+ } else if (s.equals("redirect")) {\r
+ sql = " AND STATUS >= 300 AND STATUS < 400";\r
+ } else if (s.equals("failure")) {\r
+ sql = " AND STATUS >= 400";\r
+ } else {\r
+ try {\r
+ Integer n = Integer.parseInt(s);\r
+ if ((n >= 100 && n < 600) || (n == -1))\r
+ sql = " AND STATUS = " + n;\r
+ } catch (NumberFormatException e) {\r
+ }\r
+ }\r
+ if (sql == null) {\r
+ map.put("err", "bad statusCode");\r
+ return map;\r
+ }\r
+ map.put("statusSQL", sql);\r
+ map.put("resultSQL", sql.replaceAll("STATUS", "RESULT"));\r
+ }\r
- s = req.getParameter("expiryReason");\r
- if (s != null) {\r
- map.put("type", "exp");\r
- if (s.equals("notRetryable")) {\r
- map.put("reasonSQL", " AND REASON = 'notRetryable'");\r
- } else if (s.equals("retriesExhausted")) {\r
- map.put("reasonSQL", " AND REASON = 'retriesExhausted'");\r
- } else if (s.equals("diskFull")) {\r
- map.put("reasonSQL", " AND REASON = 'diskFull'");\r
- } else if (s.equals("other")) {\r
- map.put("reasonSQL", " AND REASON = 'other'");\r
- } else {\r
- map.put("err", "bad expiryReason");\r
- return map;\r
- }\r
- }\r
+ s = req.getParameter("expiryReason");\r
+ if (s != null) {\r
+ map.put("type", "exp");\r
+ if (s.equals("notRetryable")) {\r
+ map.put("reasonSQL", " AND REASON = 'notRetryable'");\r
+ } else if (s.equals("retriesExhausted")) {\r
+ map.put("reasonSQL", " AND REASON = 'retriesExhausted'");\r
+ } else if (s.equals("diskFull")) {\r
+ map.put("reasonSQL", " AND REASON = 'diskFull'");\r
+ } else if (s.equals("other")) {\r
+ map.put("reasonSQL", " AND REASON = 'other'");\r
+ } else {\r
+ map.put("err", "bad expiryReason");\r
+ return map;\r
+ }\r
+ }\r
- long stime = getTimeFromParam(req.getParameter("start"));\r
- if (stime < 0) {\r
- map.put("err", "bad start");\r
- return map;\r
- }\r
- long etime = getTimeFromParam(req.getParameter("end"));\r
- if (etime < 0) {\r
- map.put("err", "bad end");\r
- return map;\r
- }\r
- if (stime == 0 && etime == 0) {\r
- etime = System.currentTimeMillis();\r
- stime = etime - TWENTYFOUR_HOURS;\r
- } else if (stime == 0) {\r
- stime = etime - TWENTYFOUR_HOURS;\r
- } else if (etime == 0) {\r
- etime = stime + TWENTYFOUR_HOURS;\r
- }\r
- map.put("timeSQL", String.format(" AND EVENT_TIME >= %d AND EVENT_TIME <= %d", stime, etime));\r
- return map;\r
- }\r
- private long getTimeFromParam(final String s) {\r
- if (s == null)\r
- return 0;\r
- try {\r
- // First, look for an RFC 3339 date\r
- String fmt = (s.indexOf('.') > 0) ? fmt2 : fmt1;\r
- SimpleDateFormat sdf = new SimpleDateFormat(fmt);\r
- Date d = sdf.parse(s);\r
- return d.getTime();\r
- } catch (ParseException e) {\r
- }\r
- try {\r
- // Also allow a long (in ms); useful for testing\r
- long n = Long.parseLong(s);\r
- return n;\r
- } catch (NumberFormatException e) {\r
- }\r
- intlogger.info("Error parsing time="+s);\r
- return -1;\r
- }\r
+ long stime = getTimeFromParam(req.getParameter("start"));\r
+ if (stime < 0) {\r
+ map.put("err", "bad start");\r
+ return map;\r
+ }\r
+ long etime = getTimeFromParam(req.getParameter("end"));\r
+ if (etime < 0) {\r
+ map.put("err", "bad end");\r
+ return map;\r
+ }\r
+ if (stime == 0 && etime == 0) {\r
+ etime = System.currentTimeMillis();\r
+ stime = etime - TWENTYFOUR_HOURS;\r
+ } else if (stime == 0) {\r
+ stime = etime - TWENTYFOUR_HOURS;\r
+ } else if (etime == 0) {\r
+ etime = stime + TWENTYFOUR_HOURS;\r
+ }\r
+ map.put("timeSQL", String.format(" AND EVENT_TIME >= %d AND EVENT_TIME <= %d", stime, etime));\r
+ return map;\r
+ }\r
+ private long getTimeFromParam(final String s) {\r
+ if (s == null)\r
+ return 0;\r
+ try {\r
+ // First, look for an RFC 3339 date\r
+ String fmt = (s.indexOf('.') > 0) ? fmt2 : fmt1;\r
+ SimpleDateFormat sdf = new SimpleDateFormat(fmt);\r
+ Date d = sdf.parse(s);\r
+ return d.getTime();\r
+ } catch (ParseException e) {\r
+ }\r
+ try {\r
+ // Also allow a long (in ms); useful for testing\r
+ long n = Long.parseLong(s);\r
+ return n;\r
+ } catch (NumberFormatException e) {\r
+ }\r
+ intlogger.info("Error parsing time="+s);\r
+ return -1;\r
+ }\r
- private void getPublishRecordsForFeed(int feedid, RowHandler rh, Map<String, String> map) {\r
- String type = map.get("type");\r
- if (type.equals("all") || type.equals("pub")) {\r
- String sql = "select * from LOG_RECORDS where FEEDID = "+feedid\r
- + " AND TYPE = 'pub'"\r
- + map.get("timeSQL") + map.get("publishSQL") + map.get("statusSQL");\r
- getRecordsForSQL(sql, rh);\r
- }\r
- }\r
- private void getDeliveryRecordsForFeed(int feedid, RowHandler rh, Map<String, String> map) {\r
- String type = map.get("type");\r
- if (type.equals("all") || type.equals("del")) {\r
- String sql = "select * from LOG_RECORDS where FEEDID = "+feedid\r
- + " AND TYPE = 'del'"\r
- + map.get("timeSQL") + map.get("publishSQL") + map.get("resultSQL");\r
- getRecordsForSQL(sql, rh);\r
- }\r
- }\r
- private void getDeliveryRecordsForSubscription(int subid, RowHandler rh, Map<String, String> map) {\r
- String type = map.get("type");\r
- if (type.equals("all") || type.equals("del")) {\r
- String sql = "select * from LOG_RECORDS where DELIVERY_SUBID = "+subid\r
- + " AND TYPE = 'del'"\r
- + map.get("timeSQL") + map.get("publishSQL") + map.get("resultSQL");\r
- getRecordsForSQL(sql, rh);\r
- }\r
- }\r
- private void getExpiryRecordsForFeed(int feedid, RowHandler rh, Map<String, String> map) {\r
- String type = map.get("type");\r
- if (type.equals("all") || type.equals("exp")) {\r
- String st = map.get("statusSQL");\r
- if (st == null || st.length() == 0) {\r
- String sql = "select * from LOG_RECORDS where FEEDID = "+feedid\r
- + " AND TYPE = 'exp'"\r
- + map.get("timeSQL") + map.get("publishSQL") + map.get("reasonSQL");\r
- getRecordsForSQL(sql, rh);\r
- }\r
- }\r
- }\r
- private void getExpiryRecordsForSubscription(int subid, RowHandler rh, Map<String, String> map) {\r
- String type = map.get("type");\r
- if (type.equals("all") || type.equals("exp")) {\r
- String st = map.get("statusSQL");\r
- if (st == null || st.length() == 0) {\r
- String sql = "select * from LOG_RECORDS where DELIVERY_SUBID = "+subid\r
- + " AND TYPE = 'exp'"\r
- + map.get("timeSQL") + map.get("publishSQL") + map.get("reasonSQL");\r
- getRecordsForSQL(sql, rh);\r
- }\r
- }\r
- }\r
- private void getRecordsForSQL(String sql, RowHandler rh) {\r
- intlogger.debug(sql);\r
- long start = System.currentTimeMillis();\r
- DB db = new DB();\r
- Connection conn = null;\r
- try {\r
- conn = db.getConnection();\r
- Statement stmt = conn.createStatement();\r
- ResultSet rs = stmt.executeQuery(sql);\r
- while (rs.next()) {\r
- rh.handleRow(rs);\r
- }\r
- rs.close();\r
- stmt.close();\r
- } catch (SQLException e) {\r
- e.printStackTrace();\r
- } finally {\r
- if (conn != null)\r
- db.release(conn);\r
- }\r
- intlogger.debug("Time: " + (System.currentTimeMillis()-start) + " ms");\r
- }\r
+ private void getPublishRecordsForFeed(int feedid, RowHandler rh, Map<String, String> map) {\r
+ String type = map.get("type");\r
+ if (type.equals("all") || type.equals("pub")) {\r
+ String sql = "select * from LOG_RECORDS where FEEDID = "+feedid\r
+ + " AND TYPE = 'pub'"\r
+ + map.get("timeSQL") + map.get("publishSQL") + map.get("statusSQL");\r
+ getRecordsForSQL(sql, rh);\r
+ }\r
+ }\r
+ private void getDeliveryRecordsForFeed(int feedid, RowHandler rh, Map<String, String> map) {\r
+ String type = map.get("type");\r
+ if (type.equals("all") || type.equals("del")) {\r
+ String sql = "select * from LOG_RECORDS where FEEDID = "+feedid\r
+ + " AND TYPE = 'del'"\r
+ + map.get("timeSQL") + map.get("publishSQL") + map.get("resultSQL");\r
+ getRecordsForSQL(sql, rh);\r
+ }\r
+ }\r
+ private void getDeliveryRecordsForSubscription(int subid, RowHandler rh, Map<String, String> map) {\r
+ String type = map.get("type");\r
+ if (type.equals("all") || type.equals("del")) {\r
+ String sql = "select * from LOG_RECORDS where DELIVERY_SUBID = "+subid\r
+ + " AND TYPE = 'del'"\r
+ + map.get("timeSQL") + map.get("publishSQL") + map.get("resultSQL");\r
+ getRecordsForSQL(sql, rh);\r
+ }\r
+ }\r
+ private void getExpiryRecordsForFeed(int feedid, RowHandler rh, Map<String, String> map) {\r
+ String type = map.get("type");\r
+ if (type.equals("all") || type.equals("exp")) {\r
+ String st = map.get("statusSQL");\r
+ if (st == null || st.length() == 0) {\r
+ String sql = "select * from LOG_RECORDS where FEEDID = "+feedid\r
+ + " AND TYPE = 'exp'"\r
+ + map.get("timeSQL") + map.get("publishSQL") + map.get("reasonSQL");\r
+ getRecordsForSQL(sql, rh);\r
+ }\r
+ }\r
+ }\r
+ private void getExpiryRecordsForSubscription(int subid, RowHandler rh, Map<String, String> map) {\r
+ String type = map.get("type");\r
+ if (type.equals("all") || type.equals("exp")) {\r
+ String st = map.get("statusSQL");\r
+ if (st == null || st.length() == 0) {\r
+ String sql = "select * from LOG_RECORDS where DELIVERY_SUBID = "+subid\r
+ + " AND TYPE = 'exp'"\r
+ + map.get("timeSQL") + map.get("publishSQL") + map.get("reasonSQL");\r
+ getRecordsForSQL(sql, rh);\r
+ }\r
+ }\r
+ }\r
+ private void getRecordsForSQL(String sql, RowHandler rh) {\r
+ intlogger.debug(sql);\r
+ long start = System.currentTimeMillis();\r
+ DB db = new DB();\r
+ Connection conn = null;\r
+ try {\r
+ conn = db.getConnection();\r
+ Statement stmt = conn.createStatement();\r
+ ResultSet rs = stmt.executeQuery(sql);\r
+ while (rs.next()) {\r
+ rh.handleRow(rs);\r
+ }\r
+ rs.close();\r
+ stmt.close();\r
+ } catch (SQLException e) {\r
+ e.printStackTrace();\r
+ } finally {\r
+ if (conn != null)\r
+ db.release(conn);\r
+ }\r
+ intlogger.debug("Time: " + (System.currentTimeMillis()-start) + " ms");\r
+ }\r