public void run() {
_runThread = Thread.currentThread();
_model.setRunning(true);
int count = 0;
ConversationID id = null;
ConversationModel cmodel = _model.getConversationModel();
while (!_model.isStopping()) {
try {
synchronized(_lock) {
_lock.wait();
}
if (id != _selected) {
id = _selected;
_model.setBusy(true);
HttpUrl baseUrl = cmodel.getRequestUrl(id);
if (baseUrl.getQuery() != null)
baseUrl = baseUrl.getParentUrl();
Response baseResponse = cmodel.getResponse(id);
byte[] baseBytes = baseResponse.getContent();
String type = baseResponse.getHeader("Content-Type");
if (type == null || !type.startsWith("text")) {
_logger.warning("Base response is not text, skipping!");
return;
}
List baseline = tokenize(baseBytes);
_diff = new LevenshteinDistance(baseline);
count = cmodel.getConversationCount();
_logger.info("Checking " + count + " conversaitons");
for (int i=0; i<count; i++) {
ConversationID cid = cmodel.getConversationAt(i);
HttpUrl curl = cmodel.getRequestUrl(cid);
if (curl.getQuery() != null)
curl = curl.getParentUrl();
if (!curl.equals(baseUrl))
continue;
_logger.info("Checking conversation " + i + " == " + cid);
if (cid.equals(id)) {
_model.setDistance(cid, 0);
} else {
Response response = cmodel.getResponse(cid);
String ctype = response.getHeader("Content-Type");
_logger.info("Content-type is " + ctype);