private void buildHistoryMap (TableHistory th, Map<String, String> map)
throws SQLException, HttpMalformedHeaderException {
// Get the first session id
RecordHistory rh = null;
for (int i=0; i < 100; i++ ) {
rh = th.read(i);
if (rh != null) {
break;
}
}
if (rh == null) {
return;
}
@SuppressWarnings("unchecked")
Vector<Integer> hIds = th.getHistoryList(rh.getSessionId(), HistoryReference.TYPE_MANUAL);
for (Integer hId : hIds) {
RecordHistory recH = th.read(hId);
URI uri = recH.getHttpMessage().getRequestHeader().getURI();
String mapKey = recH.getHttpMessage().getRequestHeader().getMethod() +
" " + uri.toString();
// TODO Optionally strip off params?
if (mapKey.indexOf("?") > -1) {
mapKey = mapKey.substring(0, mapKey.indexOf("?"));
}
String val = map.get(mapKey);
String code = recH.getHttpMessage().getResponseHeader().getStatusCode() + " ";
if (val == null) {
map.put(mapKey, code);
} else if (val.indexOf(code) < 0){
map.put(mapKey, val + code);
}