|
Lines 59-64
Link Here
|
| 59 |
"<a href=\"show_bug.cgi\\?id=(\\d+)\">\\d+</a>\\s*<td class=severity><nobr>([^>]+)</nobr><td class=priority><nobr>([^>]+)</nobr><td class=platform><nobr>([^>]*)</nobr><td class=owner><nobr>([^>]*)</nobr><td class=status><nobr>([^>]*)</nobr><td class=resolution><nobr>([^>]*)</nobr><td class=summary>(.*)$", |
59 |
"<a href=\"show_bug.cgi\\?id=(\\d+)\">\\d+</a>\\s*<td class=severity><nobr>([^>]+)</nobr><td class=priority><nobr>([^>]+)</nobr><td class=platform><nobr>([^>]*)</nobr><td class=owner><nobr>([^>]*)</nobr><td class=status><nobr>([^>]*)</nobr><td class=resolution><nobr>([^>]*)</nobr><td class=summary>(.*)$", |
| 60 |
"i"); |
60 |
"i"); |
| 61 |
|
61 |
|
|
|
62 |
private static final RegularExpression reColVal1 = new RegularExpression("<span class=\"issue_type\">([^>]+)</span>", "i"); |
| 63 |
private static final RegularExpression reColVal2 = new RegularExpression("<span class=\"priority\">([^>]+)</span>", "i"); |
| 64 |
private static final RegularExpression reColVal3 = new RegularExpression("<span class=\"platform\">([^>]+)</span>", "i"); |
| 65 |
private static final RegularExpression reColVal4 = new RegularExpression("<span class=\"owner\">([^>]+)</span>", "i"); |
| 66 |
private static final RegularExpression reColVal5 = new RegularExpression("<span class=\"status\">([^>]+)</span>", "i"); |
| 67 |
private static final RegularExpression reColVal6 = new RegularExpression("<span class=\"resolution\">([^>]+)</span>", "i"); |
| 68 |
private static final RegularExpression reColVal7 = new RegularExpression("<span class=\"summary\">([^>]+)</span>", "i"); |
| 69 |
|
| 62 |
private String urlString; |
70 |
private String urlString; |
| 63 |
|
71 |
|
| 64 |
private TaskRepository repository; |
72 |
private TaskRepository repository; |
|
Lines 243-260
Link Here
|
| 243 |
numCollected++; |
251 |
numCollected++; |
| 244 |
|
252 |
|
| 245 |
} else if (re.matches(line, match)) { |
253 |
} else if (re.matches(line, match)) { |
| 246 |
RegularExpression regularExpression; |
254 |
|
| 247 |
if (BugzillaPlugin.getDefault().isServerCompatability220()) { |
255 |
int id = Integer.parseInt(match.getCapturedText(1)); |
| 248 |
regularExpression = reValueBugzilla220; |
256 |
Match m1 = new Match(); |
| 249 |
} else { |
257 |
Match m2 = new Match(); |
| 250 |
regularExpression = reValue; |
258 |
Match m3 = new Match(); |
| 251 |
} |
259 |
BugzillaSearchHit hit = null; |
|
|
260 |
do |
| 261 |
{ |
| 262 |
if(monitor.isCanceled()) |
| 263 |
{ |
| 264 |
throw new OperationCanceledException("Search cancelled"); |
| 265 |
} |
| 266 |
line = in.readLine(); |
| 267 |
if(line == null) |
| 268 |
{ |
| 269 |
break; |
| 270 |
} |
| 271 |
line = line.trim(); |
| 272 |
|
| 273 |
} while(!reColVal1.matches(line, m1) && !reValueBugzilla220.matches(line, m2) && !reValue.matches(line, m3)); |
| 274 |
if(reColVal1.matches(line, m1)) |
| 275 |
{ |
| 276 |
hit = createHit(monitor, in, m1, repository.getUrl().toExternalForm(), id); |
| 277 |
} else |
| 278 |
if(reValueBugzilla220.matches(line, m2)) |
| 279 |
{ |
| 280 |
hit = createHit(reValueBugzilla220, monitor, in, m2, repository.getUrl().toExternalForm(), id); |
| 281 |
} |
| 282 |
if(reValue.matches(line, m3)) |
| 283 |
{ |
| 284 |
hit = createHit(reValue, monitor, in, m3, repository.getUrl().toExternalForm(), id); |
| 285 |
} |
| 286 |
collector.accept(hit); |
| 287 |
numCollected++; |
| 252 |
|
288 |
|
| 253 |
int id = Integer.parseInt(match.getCapturedText(1)); |
|
|
| 254 |
BugzillaSearchHit hit = createHit(regularExpression, monitor, in, match, repository.getUrl() |
| 255 |
.toExternalForm(), id); |
| 256 |
collector.accept(hit); |
| 257 |
numCollected++; |
| 258 |
} |
289 |
} |
| 259 |
if (monitor.isCanceled()) { |
290 |
if (monitor.isCanceled()) { |
| 260 |
throw new OperationCanceledException("Search cancelled"); |
291 |
throw new OperationCanceledException("Search cancelled"); |
|
Lines 307-352
Link Here
|
| 307 |
return status; |
338 |
return status; |
| 308 |
} |
339 |
} |
| 309 |
|
340 |
|
|
|
341 |
public static BugzillaSearchHit createHit(IProgressMonitor monitor, BufferedReader in, Match match, String serverUrl, int id) |
| 342 |
throws IOException |
| 343 |
{ |
| 344 |
String severity = "none"; |
| 345 |
try |
| 346 |
{ |
| 347 |
severity = match.getCapturedText(1); |
| 348 |
} |
| 349 |
catch(Exception exception) { } |
| 350 |
String priority = "none"; |
| 351 |
String platform = "none"; |
| 352 |
String owner = "none"; |
| 353 |
String state = "none"; |
| 354 |
String result = "none"; |
| 355 |
String summary = "none"; |
| 356 |
do |
| 357 |
{ |
| 358 |
if(monitor.isCanceled()) |
| 359 |
{ |
| 360 |
throw new OperationCanceledException("Search cancelled"); |
| 361 |
} |
| 362 |
String line = in.readLine(); |
| 363 |
if(line == null) |
| 364 |
{ |
| 365 |
break; |
| 366 |
} |
| 367 |
line = line.trim(); |
| 368 |
if(priority.equals("none")) |
| 369 |
{ |
| 370 |
priority = readPriority(line); |
| 371 |
} |
| 372 |
if(platform.equals("none")) |
| 373 |
{ |
| 374 |
platform = readPlatform(line); |
| 375 |
} |
| 376 |
if(owner.equals("none")) |
| 377 |
{ |
| 378 |
owner = readOwner(line); |
| 379 |
} |
| 380 |
if(state.equals("none")) |
| 381 |
{ |
| 382 |
state = readStatus(line); |
| 383 |
} |
| 384 |
if(result.equals("none")) |
| 385 |
{ |
| 386 |
result = readResolution(line); |
| 387 |
} |
| 388 |
if(summary.equals("none")) |
| 389 |
{ |
| 390 |
summary = readSummary(line); |
| 391 |
} |
| 392 |
} while(summary.equals("none")); |
| 393 |
|
| 394 |
String description = "<activate to view description>"; |
| 395 |
|
| 396 |
//String server = "<unknown server>"; |
| 397 |
|
| 398 |
String query = ""; |
| 399 |
try |
| 400 |
{ |
| 401 |
String recentQuery = BugzillaPlugin.getMostRecentQuery(); |
| 402 |
if(recentQuery != null) |
| 403 |
{ |
| 404 |
query = recentQuery; |
| 405 |
} |
| 406 |
//server = BugzillaPlugin.getDefault().getServerName(); |
| 407 |
} |
| 408 |
catch(Exception exception1) { } |
| 409 |
return new BugzillaSearchHit(serverUrl, id, description, severity, priority, platform, state, |
| 410 |
result, owner, query); |
| 411 |
} |
| 412 |
|
| 310 |
public static BugzillaSearchHit createHit(RegularExpression regularExpression, IProgressMonitor monitor, |
413 |
public static BugzillaSearchHit createHit(RegularExpression regularExpression, IProgressMonitor monitor, |
| 311 |
BufferedReader in, Match match, String serverUrl, int id) throws IOException { |
414 |
BufferedReader in, Match match, String serverUrl, int id) throws IOException { |
| 312 |
String line; |
415 |
|
| 313 |
String severity = null; |
416 |
int start = 0; |
| 314 |
String priority = null; |
417 |
String severity = null; |
| 315 |
String platform = null; |
418 |
try |
| 316 |
String owner = null; |
419 |
{ |
| 317 |
String state = null; |
420 |
severity = match.getCapturedText(1); |
| 318 |
String result = null; |
421 |
start = 1; |
| 319 |
for (int i = 0; i < 6; i++) { |
422 |
} |
| 320 |
do { |
423 |
catch(Exception exception) { } |
| 321 |
if (monitor.isCanceled()) { |
424 |
String priority = null; |
| 322 |
throw new OperationCanceledException("Search cancelled"); |
425 |
String platform = null; |
| 323 |
} |
426 |
String owner = null; |
| 324 |
line = in.readLine(); |
427 |
String state = null; |
| 325 |
if (line == null) |
428 |
String result = null; |
| 326 |
break; |
429 |
if(severity != null) |
| 327 |
line = line.trim(); |
430 |
{ |
| 328 |
} while (!regularExpression.matches(line, match)); |
431 |
start = 1; |
| 329 |
switch (i) { |
432 |
} |
| 330 |
case 0: |
433 |
String line; |
| 331 |
severity = match.getCapturedText(1); |
434 |
for(int i = start; i < 6; i++) |
| 332 |
break; |
435 |
{ |
| 333 |
case 1: |
436 |
do |
| 334 |
priority = match.getCapturedText(1); |
437 |
{ |
| 335 |
break; |
438 |
if(monitor.isCanceled()) |
| 336 |
case 2: |
439 |
{ |
| 337 |
platform = match.getCapturedText(1); |
440 |
throw new OperationCanceledException("Search cancelled"); |
| 338 |
break; |
441 |
} |
| 339 |
case 3: |
442 |
line = in.readLine(); |
| 340 |
owner = match.getCapturedText(1); |
443 |
if(line == null) |
| 341 |
break; |
444 |
{ |
| 342 |
case 4: |
445 |
break; |
| 343 |
state = match.getCapturedText(1); |
446 |
} |
| 344 |
break; |
447 |
line = line.trim(); |
| 345 |
case 5: |
448 |
} while(!regularExpression.matches(line, match)); |
| 346 |
result = match.getCapturedText(1); |
449 |
switch(i) |
| 347 |
break; |
450 |
{ |
| 348 |
} |
451 |
case 0: // '\0' |
| 349 |
} |
452 |
severity = match.getCapturedText(1); |
|
|
453 |
break; |
| 454 |
|
| 455 |
case 1: // '\001' |
| 456 |
priority = match.getCapturedText(1); |
| 457 |
break; |
| 458 |
|
| 459 |
case 2: // '\002' |
| 460 |
platform = match.getCapturedText(1); |
| 461 |
break; |
| 462 |
|
| 463 |
case 3: // '\003' |
| 464 |
owner = match.getCapturedText(1); |
| 465 |
break; |
| 466 |
|
| 467 |
case 4: // '\004' |
| 468 |
state = match.getCapturedText(1); |
| 469 |
break; |
| 470 |
|
| 471 |
case 5: // '\005' |
| 472 |
result = match.getCapturedText(1); |
| 473 |
break; |
| 474 |
} |
| 475 |
} |
| 350 |
|
476 |
|
| 351 |
// two more |
477 |
// two more |
| 352 |
line = in.readLine(); |
478 |
line = in.readLine(); |
|
Lines 372-378
Link Here
|
| 372 |
return hit; |
498 |
return hit; |
| 373 |
} |
499 |
} |
| 374 |
|
500 |
|
| 375 |
public boolean isMaxReached() { |
501 |
public boolean isMaxReached() |
| 376 |
return maxReached; |
502 |
{ |
| 377 |
} |
503 |
return maxReached; |
|
|
504 |
} |
| 505 |
|
| 506 |
public static String readPriority(String line) |
| 507 |
{ |
| 508 |
Match match = new Match(); |
| 509 |
if(reColVal2.matches(line, match)) |
| 510 |
{ |
| 511 |
return match.getCapturedText(1); |
| 512 |
} else |
| 513 |
{ |
| 514 |
return "none"; |
| 515 |
} |
| 516 |
} |
| 517 |
|
| 518 |
public static String readPlatform(String line) |
| 519 |
{ |
| 520 |
Match match = new Match(); |
| 521 |
if(reColVal3.matches(line, match)) |
| 522 |
{ |
| 523 |
return match.getCapturedText(1); |
| 524 |
} else |
| 525 |
{ |
| 526 |
return "none"; |
| 527 |
} |
| 528 |
} |
| 529 |
|
| 530 |
public static String readOwner(String line) |
| 531 |
{ |
| 532 |
Match match = new Match(); |
| 533 |
if(reColVal4.matches(line, match)) |
| 534 |
{ |
| 535 |
return match.getCapturedText(1); |
| 536 |
} else |
| 537 |
{ |
| 538 |
return "none"; |
| 539 |
} |
| 540 |
} |
| 541 |
|
| 542 |
public static String readStatus(String line) |
| 543 |
{ |
| 544 |
Match match = new Match(); |
| 545 |
if(reColVal5.matches(line, match)) |
| 546 |
{ |
| 547 |
return match.getCapturedText(1); |
| 548 |
} else |
| 549 |
{ |
| 550 |
return "none"; |
| 551 |
} |
| 552 |
} |
| 553 |
|
| 554 |
public static String readResolution(String line) |
| 555 |
{ |
| 556 |
Match match = new Match(); |
| 557 |
if(reColVal6.matches(line, match)) |
| 558 |
{ |
| 559 |
return match.getCapturedText(1); |
| 560 |
} else |
| 561 |
{ |
| 562 |
return "none"; |
| 563 |
} |
| 564 |
} |
| 565 |
|
| 566 |
public static String readSummary(String line) |
| 567 |
{ |
| 568 |
Match match = new Match(); |
| 569 |
if(reColVal7.matches(line, match)) |
| 570 |
{ |
| 571 |
return match.getCapturedText(1); |
| 572 |
} else |
| 573 |
{ |
| 574 |
return "none"; |
| 575 |
} |
| 576 |
} |
| 378 |
} |
577 |
} |