Revision 6542
Added by ben leinfelder over 12 years ago
EventLog.java | ||
---|---|---|
92 | 92 |
* that initiated the event. |
93 | 93 |
* |
94 | 94 |
* @param ipAddress the internet protocol address for the event |
95 |
* @param userAgent the agent making the request |
|
95 | 96 |
* @param principal the principal for the event (a username, etc) |
96 | 97 |
* @param docid the identifier of the document to which the event applies |
97 | 98 |
* @param event the string code for the event |
98 | 99 |
*/ |
99 |
public void log(String ipAddress, String principal, String docid, |
|
100 |
String event) |
|
101 |
{ |
|
102 |
EventLogData logData = new EventLogData(ipAddress, principal, docid, |
|
103 |
event); |
|
100 |
public void log(String ipAddress, String userAgent, String principal, String docid, String event) { |
|
101 |
EventLogData logData = new EventLogData(ipAddress, principal, docid, event); |
|
104 | 102 |
insertLogEntry(logData); |
105 | 103 |
} |
106 | 104 |
|
... | ... | |
112 | 110 |
private void insertLogEntry(EventLogData logData) |
113 | 111 |
{ |
114 | 112 |
String insertString = "insert into access_log" |
115 |
+ "(ip_address, principal, docid, " |
|
113 |
+ "(ip_address, user_agent, principal, docid, "
|
|
116 | 114 |
+ "event, date_logged) " |
117 | 115 |
+ "values (" |
118 | 116 |
+ "'" + logData.getIpAddress() + "', " |
117 |
+ "'" + logData.getUserAgent() + "', " |
|
119 | 118 |
+ "'" + logData.getPrincipal() + "', " |
120 | 119 |
+ "'" + logData.getDocid() + "', " |
121 | 120 |
+ "'" + logData.getEvent() + "', " |
... | ... | |
160 | 159 |
{ |
161 | 160 |
StringBuffer resultDoc = new StringBuffer(); |
162 | 161 |
StringBuffer query = new StringBuffer(); |
163 |
query.append("select entryid, ip_address, principal, docid, " |
|
162 |
query.append("select entryid, ip_address, user_agent, principal, docid, "
|
|
164 | 163 |
+ "event, date_logged from access_log"); |
165 | 164 |
// + "" |
166 | 165 |
// + "event, date_logged) " + "values (" + "'" |
... | ... | |
233 | 232 |
generateXmlRecord( |
234 | 233 |
rs.getString(1), //id |
235 | 234 |
anonymous ? "" : rs.getString(2), //ip |
236 |
anonymous ? "" : rs.getString(3), //principal
|
|
237 |
rs.getString(4),
|
|
235 |
rs.getString(3), //userAgent
|
|
236 |
anonymous ? "" : rs.getString(4), //principal
|
|
238 | 237 |
rs.getString(5), |
239 |
rs.getTimestamp(6))); |
|
238 |
rs.getString(6), |
|
239 |
rs.getTimestamp(7))); |
|
240 | 240 |
} |
241 | 241 |
resultDoc.append("</log>"); |
242 | 242 |
stmt.close(); |
... | ... | |
286 | 286 |
* |
287 | 287 |
* @param entryId the identifier of the log entry |
288 | 288 |
* @param ipAddress the internet protocol address for the event |
289 |
* @param the agent making the request |
|
289 | 290 |
* @param principal the principal for the event (a username, etc) |
290 | 291 |
* @param docid the identifier of the document to which the event applies |
291 | 292 |
* @param event the string code for the event |
292 | 293 |
* @param dateLogged the date on which the event occurred |
293 | 294 |
* @return String containing the formatted XML |
294 | 295 |
*/ |
295 |
private String generateXmlRecord(String entryId, String ipAddress, |
|
296 |
private String generateXmlRecord(String entryId, String ipAddress, String userAgent,
|
|
296 | 297 |
String principal, String docid, String event, Timestamp dateLogged) |
297 | 298 |
{ |
298 | 299 |
StringBuffer rec = new StringBuffer(); |
299 | 300 |
rec.append("<logEntry>"); |
300 | 301 |
rec.append(generateXmlElement("entryid", entryId)); |
301 | 302 |
rec.append(generateXmlElement("ipAddress", ipAddress)); |
303 |
rec.append(generateXmlElement("userAgent", userAgent)); |
|
302 | 304 |
rec.append(generateXmlElement("principal", principal)); |
303 | 305 |
rec.append(generateXmlElement("docid", docid)); |
304 | 306 |
rec.append(generateXmlElement("event", event)); |
Also available in: Unified diff
add User-Agent logging to support D1 requirements