|
Lines 488-502
Link Here
|
| 488 |
|
488 |
|
| 489 |
String lastKnownMod = task.getAttribute(BugzillaAttribute.DELTA_TS.getKey()); |
489 |
String lastKnownMod = task.getAttribute(BugzillaAttribute.DELTA_TS.getKey()); |
| 490 |
if (lastKnownMod != null) { |
490 |
if (lastKnownMod != null) { |
|
|
491 |
|
| 491 |
TaskAttribute attrModification = taskData.getRoot().getMappedAttribute(TaskAttribute.DATE_MODIFICATION); |
492 |
TaskAttribute attrModification = taskData.getRoot().getMappedAttribute(TaskAttribute.DATE_MODIFICATION); |
| 492 |
if (attrModification != null) { |
493 |
if (attrModification != null && attrModification.getValue() != null |
| 493 |
return !lastKnownMod.equals(attrModification.getValue()); |
494 |
&& attrModification.getValue().length() > 0) { |
|
|
495 |
|
| 496 |
RepositoryConfiguration config = BugzillaCorePlugin.getRepositoryConfiguration(taskRepository.getRepositoryUrl()); |
| 497 |
if (config == null) { |
| 498 |
((AbstractTask) task).setStatus(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, |
| 499 |
"Repository configuration not found for " + taskRepository.getRepositoryUrl())); //$NON-NLS-1$ |
| 500 |
return !lastKnownMod.equals(attrModification.getValue()); |
| 501 |
} |
| 502 |
|
| 503 |
BugzillaVersion version = config.getInstallVersion(); |
| 504 |
|
| 505 |
if (version == null || version.compareTo(BugzillaVersion.BUGZILLA_3_4) < 0) { |
| 506 |
return !lastKnownMod.equals(attrModification.getValue()); |
| 507 |
} |
| 508 |
|
| 509 |
BugzillaAttributeMapper mapper = (BugzillaAttributeMapper) taskData.getAttributeMapper(); |
| 510 |
Date oldModDate = mapper.getDate(BugzillaAttribute.DELTA_TS.getKey(), lastKnownMod); |
| 511 |
Date newModDate = mapper.getDateValue(attrModification); |
| 512 |
|
| 513 |
if (oldModDate == null) { |
| 514 |
((AbstractTask) task).setStatus(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, |
| 515 |
"Unable to parse cached task modification timestamp " + lastKnownMod)); //$NON-NLS-1$ |
| 516 |
return !lastKnownMod.equals(attrModification.getValue()); |
| 517 |
} |
| 518 |
|
| 519 |
if (newModDate == null) { |
| 520 |
((AbstractTask) task).setStatus(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, |
| 521 |
"Unable to parse incoming task modification timestamp " + attrModification.getValue())); //$NON-NLS-1$ |
| 522 |
return !lastKnownMod.equals(attrModification.getValue()); |
| 523 |
} |
| 524 |
|
| 525 |
if (!sameTimeZone(lastKnownMod, attrModification.getValue())) { |
| 526 |
// We're talking to BZ 3.4 or greater but time zones differ, potential migration scenario |
| 527 |
long delta = Math.abs(newModDate.getTime() - oldModDate.getTime()); |
| 528 |
long hour = 1000 * 60 * 60; |
| 529 |
if (delta > 0 && delta % hour == 0 && delta < 24 * hour) { |
| 530 |
return false; |
| 531 |
} |
| 532 |
return true; |
| 533 |
} |
| 534 |
|
| 535 |
return oldModDate.compareTo(newModDate) != 0; |
| 536 |
|
| 494 |
} |
537 |
} |
| 495 |
|
538 |
|
| 496 |
} |
539 |
} |
| 497 |
return true; |
540 |
return true; |
| 498 |
} |
541 |
} |
| 499 |
|
542 |
|
|
|
543 |
private boolean sameTimeZone(String oldDate, String newDate) { |
| 544 |
String parts[] = oldDate.split(" "); |
| 545 |
String oldTZ = ""; |
| 546 |
if (parts.length == 3) { |
| 547 |
oldTZ = parts[2]; |
| 548 |
} else { |
| 549 |
return false; |
| 550 |
} |
| 551 |
|
| 552 |
parts = newDate.split(" "); |
| 553 |
String newTZ = ""; |
| 554 |
if (parts.length == 3) { |
| 555 |
newTZ = parts[2]; |
| 556 |
} else { |
| 557 |
return false; |
| 558 |
} |
| 559 |
|
| 560 |
return newTZ.equals(oldTZ); |
| 561 |
|
| 562 |
} |
| 563 |
|
| 564 |
private boolean hasTimzone(String dateString) { |
| 565 |
if (dateString == null || dateString.length() == 0) { |
| 566 |
return false; |
| 567 |
} |
| 568 |
String[] parts = dateString.split(" "); //$NON-NLS-1$ |
| 569 |
boolean hasTimeZone = (parts != null && parts.length == 3); |
| 570 |
return hasTimeZone; |
| 571 |
} |
| 572 |
|
| 500 |
@Override |
573 |
@Override |
| 501 |
public Collection<TaskRelation> getTaskRelations(TaskData taskData) { |
574 |
public Collection<TaskRelation> getTaskRelations(TaskData taskData) { |
| 502 |
List<TaskRelation> relations = new ArrayList<TaskRelation>(); |
575 |
List<TaskRelation> relations = new ArrayList<TaskRelation>(); |