|
Lines 34-39
Link Here
|
| 34 |
import org.eclipse.core.runtime.SubProgressMonitor; |
34 |
import org.eclipse.core.runtime.SubProgressMonitor; |
| 35 |
import org.eclipse.mylyn.commons.core.StatusHandler; |
35 |
import org.eclipse.mylyn.commons.core.StatusHandler; |
| 36 |
import org.eclipse.mylyn.commons.net.Policy; |
36 |
import org.eclipse.mylyn.commons.net.Policy; |
|
|
37 |
import org.eclipse.mylyn.internal.tasks.core.AbstractTask; |
| 37 |
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery; |
38 |
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery; |
| 38 |
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; |
39 |
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; |
| 39 |
import org.eclipse.mylyn.tasks.core.IRepositoryQuery; |
40 |
import org.eclipse.mylyn.tasks.core.IRepositoryQuery; |
|
Lines 223-229
Link Here
|
| 223 |
queryCounter++; |
224 |
queryCounter++; |
| 224 |
String newurlQueryString = URLEncoder.encode(task.getTaskId() + ",", repository.getCharacterEncoding()); //$NON-NLS-1$ |
225 |
String newurlQueryString = URLEncoder.encode(task.getTaskId() + ",", repository.getCharacterEncoding()); //$NON-NLS-1$ |
| 225 |
urlQueryString += newurlQueryString; |
226 |
urlQueryString += newurlQueryString; |
| 226 |
if (queryCounter >= 1000) { |
227 |
if (urlQueryString.length() >= 7000) { |
| 227 |
queryForChanged(repository, changedTasks, urlQueryString, session, new SubProgressMonitor(monitor, |
228 |
queryForChanged(repository, changedTasks, urlQueryString, session, new SubProgressMonitor(monitor, |
| 228 |
queryCounter)); |
229 |
queryCounter)); |
| 229 |
|
230 |
|
|
Lines 275-281
Link Here
|
| 275 |
changedTasks.add(changedTask); |
276 |
changedTasks.add(changedTask); |
| 276 |
} |
277 |
} |
| 277 |
} |
278 |
} |
| 278 |
if (collector.getQueryTimestamp() != null) { |
279 |
if (syncSession.getData() != null && collector.getQueryTimestamp() != null) { |
| 279 |
syncSession.setData(collector.getQueryTimestamp()); |
280 |
syncSession.setData(collector.getQueryTimestamp()); |
| 280 |
} |
281 |
} |
| 281 |
|
282 |
|
|
Lines 472-477
Link Here
|
| 472 |
return taskDataHandler; |
473 |
return taskDataHandler; |
| 473 |
} |
474 |
} |
| 474 |
|
475 |
|
|
|
476 |
private boolean hasTimzone(String dateString) { |
| 477 |
if (dateString == null || dateString.length() == 0) { |
| 478 |
return false; |
| 479 |
} |
| 480 |
String[] parts = dateString.split(" "); //$NON-NLS-1$ |
| 481 |
boolean hasTimeZone = (parts != null && parts.length == 3); |
| 482 |
return hasTimeZone; |
| 483 |
} |
| 484 |
|
| 475 |
@Override |
485 |
@Override |
| 476 |
public boolean hasTaskChanged(TaskRepository taskRepository, ITask task, TaskData taskData) { |
486 |
public boolean hasTaskChanged(TaskRepository taskRepository, ITask task, TaskData taskData) { |
| 477 |
if (taskData.isPartial() && task.getCreationDate() != null) { |
487 |
if (taskData.isPartial() && task.getCreationDate() != null) { |
|
Lines 487-495
Link Here
|
| 487 |
|
497 |
|
| 488 |
String lastKnownMod = task.getAttribute(BugzillaAttribute.DELTA_TS.getKey()); |
498 |
String lastKnownMod = task.getAttribute(BugzillaAttribute.DELTA_TS.getKey()); |
| 489 |
if (lastKnownMod != null) { |
499 |
if (lastKnownMod != null) { |
|
|
500 |
|
| 501 |
boolean oldFormatHasTimeZone = hasTimzone(lastKnownMod); |
| 502 |
|
| 490 |
TaskAttribute attrModification = taskData.getRoot().getMappedAttribute(TaskAttribute.DATE_MODIFICATION); |
503 |
TaskAttribute attrModification = taskData.getRoot().getMappedAttribute(TaskAttribute.DATE_MODIFICATION); |
| 491 |
if (attrModification != null) { |
504 |
if (attrModification != null && attrModification.getValue() != null |
| 492 |
return !lastKnownMod.equals(attrModification.getValue()); |
505 |
&& attrModification.getValue().length() > 0) { |
|
|
506 |
|
| 507 |
boolean newFormatHasTimeZone = hasTimzone(attrModification.getValue()); |
| 508 |
|
| 509 |
if (!oldFormatHasTimeZone && !newFormatHasTimeZone) { |
| 510 |
return !lastKnownMod.equals(attrModification.getValue()); |
| 511 |
} |
| 512 |
|
| 513 |
BugzillaAttributeMapper mapper = (BugzillaAttributeMapper) taskData.getAttributeMapper(); |
| 514 |
Date oldModDate = mapper.getDate(BugzillaAttribute.DELTA_TS.getKey(), lastKnownMod); |
| 515 |
Date newModDate = mapper.getDateValue(attrModification); |
| 516 |
|
| 517 |
if (oldModDate == null) { |
| 518 |
((AbstractTask) task).setStatus(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, |
| 519 |
"Unable to parse cached task modification timestamp " + lastKnownMod)); //$NON-NLS-1$ |
| 520 |
return false; |
| 521 |
} |
| 522 |
|
| 523 |
if (newModDate == null) { |
| 524 |
((AbstractTask) task).setStatus(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, |
| 525 |
"Unable to parse incoming task modification timestamp " + attrModification.getValue())); //$NON-NLS-1$ |
| 526 |
return false; |
| 527 |
} |
| 528 |
|
| 529 |
if (!oldFormatHasTimeZone && newFormatHasTimeZone) { |
| 530 |
long delta = Math.abs(newModDate.getTime() - oldModDate.getTime()); |
| 531 |
long hour = 1000 * 60 * 60; |
| 532 |
if (delta > 0 && delta % hour == 0 && delta < 24 * hour) { |
| 533 |
// assuming time zone changed, let new timestamp get set and ignore incoming |
| 534 |
return false; |
| 535 |
} |
| 536 |
return true; |
| 537 |
} else if (oldFormatHasTimeZone && !newFormatHasTimeZone) { |
| 538 |
((AbstractTask) task).setStatus(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, |
| 539 |
"Task modification timestamp missing timezone information: " + attrModification.getValue())); //$NON-NLS-1$ |
| 540 |
return false; |
| 541 |
} |
| 542 |
|
| 543 |
// If here, both have TIME ZONES, do date comparison |
| 544 |
return oldModDate.compareTo(newModDate) != 0; |
| 545 |
|
| 493 |
} |
546 |
} |
| 494 |
|
547 |
|
| 495 |
} |
548 |
} |