|
Lines 68-73
Link Here
|
| 68 |
|
68 |
|
| 69 |
private static final String DEADLINE_FORMAT = "yyyy-MM-dd"; //$NON-NLS-1$ |
69 |
private static final String DEADLINE_FORMAT = "yyyy-MM-dd"; //$NON-NLS-1$ |
| 70 |
|
70 |
|
|
|
71 |
private static final long HOUR = 1000 * 60 * 60; |
| 72 |
|
| 71 |
private final BugzillaTaskAttachmentHandler attachmentHandler = new BugzillaTaskAttachmentHandler(this); |
73 |
private final BugzillaTaskAttachmentHandler attachmentHandler = new BugzillaTaskAttachmentHandler(this); |
| 72 |
|
74 |
|
| 73 |
private final BugzillaTaskDataHandler taskDataHandler = new BugzillaTaskDataHandler(this); |
75 |
private final BugzillaTaskDataHandler taskDataHandler = new BugzillaTaskDataHandler(this); |
|
Lines 76-82
Link Here
|
| 76 |
|
78 |
|
| 77 |
protected static BugzillaLanguageSettings enSetting; |
79 |
protected static BugzillaLanguageSettings enSetting; |
| 78 |
|
80 |
|
| 79 |
protected final static Set<BugzillaLanguageSettings> languages = new LinkedHashSet<BugzillaLanguageSettings>(); |
81 |
protected static final Set<BugzillaLanguageSettings> languages = new LinkedHashSet<BugzillaLanguageSettings>(); |
| 80 |
|
82 |
|
| 81 |
@Override |
83 |
@Override |
| 82 |
public String getLabel() { |
84 |
public String getLabel() { |
|
Lines 488-502
Link Here
|
| 488 |
|
490 |
|
| 489 |
String lastKnownMod = task.getAttribute(BugzillaAttribute.DELTA_TS.getKey()); |
491 |
String lastKnownMod = task.getAttribute(BugzillaAttribute.DELTA_TS.getKey()); |
| 490 |
if (lastKnownMod != null) { |
492 |
if (lastKnownMod != null) { |
|
|
493 |
|
| 491 |
TaskAttribute attrModification = taskData.getRoot().getMappedAttribute(TaskAttribute.DATE_MODIFICATION); |
494 |
TaskAttribute attrModification = taskData.getRoot().getMappedAttribute(TaskAttribute.DATE_MODIFICATION); |
| 492 |
if (attrModification != null) { |
495 |
if (attrModification != null && attrModification.getValue() != null |
| 493 |
return !lastKnownMod.equals(attrModification.getValue()); |
496 |
&& attrModification.getValue().length() > 0) { |
| 494 |
} |
|
|
| 495 |
|
497 |
|
|
|
498 |
boolean cachedHasTZ = hasTimzone(lastKnownMod); |
| 499 |
boolean repoHasTZ = hasTimzone(attrModification.getValue()); |
| 500 |
if (!cachedHasTZ && !repoHasTZ) { // State 1 |
| 501 |
return !lastKnownMod.equals(attrModification.getValue()); |
| 502 |
} |
| 503 |
|
| 504 |
BugzillaAttributeMapper mapper = (BugzillaAttributeMapper) taskData.getAttributeMapper(); |
| 505 |
Date oldModDate = mapper.getDate(BugzillaAttribute.DELTA_TS.getKey(), lastKnownMod); |
| 506 |
Date newModDate = mapper.getDateValue(attrModification); |
| 507 |
|
| 508 |
// If either of the dates can't be parsed, fall back to string comparison |
| 509 |
if (oldModDate == null) { |
| 510 |
((AbstractTask) task).setStatus(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, |
| 511 |
"Unable to parse cached task modification timestamp " + lastKnownMod)); //$NON-NLS-1$ |
| 512 |
return !lastKnownMod.equals(attrModification.getValue()); |
| 513 |
} else if (newModDate == null) { |
| 514 |
((AbstractTask) task).setStatus(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, |
| 515 |
"Unable to parse incoming task modification timestamp " + attrModification.getValue())); //$NON-NLS-1$ |
| 516 |
return !lastKnownMod.equals(attrModification.getValue()); |
| 517 |
} |
| 518 |
|
| 519 |
if ((cachedHasTZ && !repoHasTZ) || (!cachedHasTZ && repoHasTZ)) { // State 2 (unlikely) || Sate 3 |
| 520 |
long delta = Math.abs(newModDate.getTime() - oldModDate.getTime()); |
| 521 |
if (delta == 0) { |
| 522 |
return false; |
| 523 |
} else if (delta > 0 && delta % HOUR == 0 && delta < 24 * HOUR) { |
| 524 |
// If same time but in different time zones, ignore/migrate |
| 525 |
return false; |
| 526 |
} |
| 527 |
return true; |
| 528 |
} else if (cachedHasTZ && repoHasTZ) { //State 4 (of 4) |
| 529 |
// Date Compare |
| 530 |
return oldModDate.compareTo(newModDate) != 0; |
| 531 |
} |
| 532 |
} |
| 496 |
} |
533 |
} |
| 497 |
return true; |
534 |
return true; |
| 498 |
} |
535 |
} |
| 499 |
|
536 |
|
|
|
537 |
private boolean hasTimzone(String dateString) { |
| 538 |
if (dateString == null || dateString.length() == 0) { |
| 539 |
return false; |
| 540 |
} |
| 541 |
String[] parts = dateString.split(" "); //$NON-NLS-1$ |
| 542 |
boolean hasTimeZone = (parts != null && parts.length == 3); |
| 543 |
return hasTimeZone; |
| 544 |
} |
| 545 |
|
| 500 |
@Override |
546 |
@Override |
| 501 |
public Collection<TaskRelation> getTaskRelations(TaskData taskData) { |
547 |
public Collection<TaskRelation> getTaskRelations(TaskData taskData) { |
| 502 |
List<TaskRelation> relations = new ArrayList<TaskRelation>(); |
548 |
List<TaskRelation> relations = new ArrayList<TaskRelation>(); |