Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 288309 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaVersion.java (-1 / +3 lines)
Lines 30-36 Link Here
30
30
31
	public final static BugzillaVersion BUGZILLA_3_2 = new BugzillaVersion("3.2"); //$NON-NLS-1$
31
	public final static BugzillaVersion BUGZILLA_3_2 = new BugzillaVersion("3.2"); //$NON-NLS-1$
32
32
33
	public final static BugzillaVersion MAX_VERSION = new BugzillaVersion("3.2"); //$NON-NLS-1$
33
	public final static BugzillaVersion BUGZILLA_3_4 = new BugzillaVersion("3.4"); //$NON-NLS-1$
34
35
	public final static BugzillaVersion MAX_VERSION = new BugzillaVersion("3.4"); //$NON-NLS-1$
34
36
35
	private final int major;
37
	private final int major;
36
38
(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java (-1 / +1 lines)
Lines 83-89 Link Here
83
	/**
83
	/**
84
	 * Note: Date formatters constructed within method for thread safety
84
	 * Note: Date formatters constructed within method for thread safety
85
	 */
85
	 */
86
	private Date getDate(String attributeId, String dateString) {
86
	protected Date getDate(String attributeId, String dateString) {
87
		Date parsedDate = null;
87
		Date parsedDate = null;
88
88
89
		/**
89
		/**
(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java (-5 / +58 lines)
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 312-318 Link Here
312
			if (resultCollector instanceof BugzillaTaskDataCollector) {
314
			if (resultCollector instanceof BugzillaTaskDataCollector) {
313
				BugzillaTaskDataCollector bCollector = (BugzillaTaskDataCollector) resultCollector;
315
				BugzillaTaskDataCollector bCollector = (BugzillaTaskDataCollector) resultCollector;
314
				if (bCollector.getQueryTimestamp() != null) {
316
				if (bCollector.getQueryTimestamp() != null) {
315
					event.setData(bCollector.getQueryTimestamp());
317
					Date queryDate = ((BugzillaAttributeMapper) mapper).getDate(BugzillaAttribute.DELTA_TS.getKey(),
318
							bCollector.getQueryTimestamp());
319
					if (queryDate == null) {
320
						event.setData(bCollector.getQueryTimestamp());
321
					} else {
322
						// Ensure time is in right format
323
						event.setData(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(queryDate)); //$NON-NLS-1$
324
					}
316
				}
325
				}
317
			}
326
			}
318
327
Lines 488-502 Link Here
488
497
489
		String lastKnownMod = task.getAttribute(BugzillaAttribute.DELTA_TS.getKey());
498
		String lastKnownMod = task.getAttribute(BugzillaAttribute.DELTA_TS.getKey());
490
		if (lastKnownMod != null) {
499
		if (lastKnownMod != null) {
500
491
			TaskAttribute attrModification = taskData.getRoot().getMappedAttribute(TaskAttribute.DATE_MODIFICATION);
501
			TaskAttribute attrModification = taskData.getRoot().getMappedAttribute(TaskAttribute.DATE_MODIFICATION);
492
			if (attrModification != null) {
502
			if (attrModification != null && attrModification.getValue() != null
493
				return !lastKnownMod.equals(attrModification.getValue());
503
					&& attrModification.getValue().length() > 0) {
494
			}
495
504
505
				boolean cachedHasTZ = hasTimzone(lastKnownMod);
506
				boolean repoHasTZ = hasTimzone(attrModification.getValue());
507
				if (!cachedHasTZ && !repoHasTZ) { // State 1
508
					return !lastKnownMod.equals(attrModification.getValue());
509
				}
510
511
				BugzillaAttributeMapper mapper = (BugzillaAttributeMapper) taskData.getAttributeMapper();
512
				Date oldModDate = mapper.getDate(BugzillaAttribute.DELTA_TS.getKey(), lastKnownMod);
513
				Date newModDate = mapper.getDateValue(attrModification);
514
515
				// If either of the dates can't be parsed, fall back to string comparison
516
				if (oldModDate == null) {
517
					((AbstractTask) task).setStatus(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN,
518
							"Unable to parse cached task modification timestamp " + lastKnownMod)); //$NON-NLS-1$
519
					return !lastKnownMod.equals(attrModification.getValue());
520
				} else if (newModDate == null) {
521
					((AbstractTask) task).setStatus(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN,
522
							"Unable to parse incoming task modification timestamp " + attrModification.getValue())); //$NON-NLS-1$
523
					return !lastKnownMod.equals(attrModification.getValue());
524
				}
525
526
				if ((cachedHasTZ && !repoHasTZ) || (!cachedHasTZ && repoHasTZ)) { // State 2 (unlikely) || Sate 3
527
					long delta = Math.abs(newModDate.getTime() - oldModDate.getTime());
528
					if (delta == 0) {
529
						return false;
530
					} else if (delta > 0 && delta % HOUR == 0 && delta < 24 * HOUR) {
531
						// If same time but in different time zones, ignore/migrate
532
						return false;
533
					}
534
					return true;
535
				} else if (cachedHasTZ && repoHasTZ) { //State 4 (of 4)
536
					// Date Compare
537
					return oldModDate.compareTo(newModDate) != 0;
538
				}
539
			}
496
		}
540
		}
497
		return true;
541
		return true;
498
	}
542
	}
499
543
544
	private boolean hasTimzone(String dateString) {
545
		if (dateString == null || dateString.length() == 0) {
546
			return false;
547
		}
548
		String[] parts = dateString.split(" "); //$NON-NLS-1$
549
		boolean hasTimeZone = (parts != null && parts.length == 3);
550
		return hasTimeZone;
551
	}
552
500
	@Override
553
	@Override
501
	public Collection<TaskRelation> getTaskRelations(TaskData taskData) {
554
	public Collection<TaskRelation> getTaskRelations(TaskData taskData) {
502
		List<TaskRelation> relations = new ArrayList<TaskRelation>();
555
		List<TaskRelation> relations = new ArrayList<TaskRelation>();
(-)src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java (-1 / +1 lines)
Lines 55-61 Link Here
55
55
56
	private static final String LABEL_SHORT_LOGINS = Messages.BugzillaRepositorySettingsPage_local_users_enabled;
56
	private static final String LABEL_SHORT_LOGINS = Messages.BugzillaRepositorySettingsPage_local_users_enabled;
57
57
58
	private static final String LABEL_VERSION_NUMBER = "2.18 - 3.2"; //$NON-NLS-1$
58
	private static final String LABEL_VERSION_NUMBER = "3.0 - 3.4"; //$NON-NLS-1$
59
59
60
	private static final String TITLE = Messages.BugzillaRepositorySettingsPage_bugzilla_repository_settings;
60
	private static final String TITLE = Messages.BugzillaRepositorySettingsPage_bugzilla_repository_settings;
61
61
(-)src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java (+78 lines)
Lines 23-31 Link Here
23
import org.eclipse.mylyn.commons.net.AuthenticationType;
23
import org.eclipse.mylyn.commons.net.AuthenticationType;
24
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
24
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
25
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
25
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
26
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
26
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
27
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
28
import org.eclipse.mylyn.internal.tasks.core.TaskTask;
27
import org.eclipse.mylyn.tasks.core.TaskRepository;
29
import org.eclipse.mylyn.tasks.core.TaskRepository;
28
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
30
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
31
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
29
import org.eclipse.mylyn.tasks.core.data.TaskData;
32
import org.eclipse.mylyn.tasks.core.data.TaskData;
30
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
33
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
31
34
Lines 52-57 Link Here
52
		handler = connector.getTaskDataHandler();
55
		handler = connector.getTaskDataHandler();
53
	}
56
	}
54
57
58
	public void testHasChanged() {
59
		AbstractTask task = new TaskTask(repository.getConnectorKind(), repository.getRepositoryUrl(), "1");
60
		task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2008-02-02 12:01:12");
61
		TaskData data = new TaskData(connector.getTaskDataHandler().getAttributeMapper(repository),
62
				repository.getConnectorKind(), repository.getRepositoryUrl(), "1");
63
		TaskAttribute attribute = data.getRoot().createAttribute(BugzillaAttribute.DELTA_TS.getKey());
64
65
		// Testing State 1
66
67
		// Offline no timezone, repository no timezone, same time
68
		attribute.setValue("2008-02-02 12:01:12");
69
		assertFalse(connector.hasTaskChanged(repository, task, data));
70
71
		// Offline no timezone, repository no timezone, different date
72
		attribute.setValue("2008-02-03 12:01:12");
73
		assertTrue(connector.hasTaskChanged(repository, task, data));
74
75
		// Offline no timezone, repository no timezone, different time
76
		attribute.setValue("2008-02-02 12:03:12");
77
		assertTrue(connector.hasTaskChanged(repository, task, data));
78
79
		// Offline no timezone, repository no timezone, different (older) time
80
		attribute.setValue("2008-02-02 12:03:00");
81
		assertTrue(connector.hasTaskChanged(repository, task, data));
82
83
		// Testing Fuzzy States 2 & 3
84
85
		// Offline have timezone, repository no timezone, same time
86
		task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2008-02-02 12:01:12 -0700");
87
		attribute.setValue("2008-02-02 12:01:12");
88
		assertFalse(connector.hasTaskChanged(repository, task, data));
89
90
		// Offline have timezone, repository no timezone, different time
91
		task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2008-02-02 12:01:12 -0700");
92
		attribute.setValue("2008-02-02 12:01:13");
93
		assertTrue(connector.hasTaskChanged(repository, task, data));
94
95
		// Offline no timezone, repository has timezone
96
		task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2008-02-02 12:01:12");
97
		attribute.setValue("2008-02-02 12:01:12 -0700");
98
		assertFalse(connector.hasTaskChanged(repository, task, data));
99
100
		// Offline no timezone, repository has timezone and different time (fuzzy check doesn't pass)
101
		attribute.setValue("2008-02-02 12:01:13 -0700");
102
		assertTrue(connector.hasTaskChanged(repository, task, data));
103
104
		// Test backwards in time
105
		task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2008-02-02 12:01:12");
106
		attribute.setValue("2008-02-02 12:01:03 -0700");
107
		assertTrue(connector.hasTaskChanged(repository, task, data));
108
109
		// Testing State 4
110
111
		// Same world time, reported wrt different time zones
112
		task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2009-09-04 00:00:00 PDT");
113
		attribute.setValue("2009-09-04 03:00:00 EDT");
114
		assertFalse(connector.hasTaskChanged(repository, task, data));
115
116
		// Different times, same time zone
117
		task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2009-09-04 12:00:00 PDT");
118
		attribute.setValue("2009-09-04 12:00:01 PDT");
119
		assertTrue(connector.hasTaskChanged(repository, task, data));
120
121
		// Same times, bogus format (string compare)
122
		task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2009-09-04 12:00:::01 PDT");
123
		attribute.setValue("2009-09-04 12:00:::01 PDT");
124
		assertFalse(connector.hasTaskChanged(repository, task, data));
125
126
		// Same times, bogus format (string compare)
127
		task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2009-09-04X12:00:::01 PDT");
128
		attribute.setValue("2009-09-04 12:00:::01 PDT");
129
		assertTrue(connector.hasTaskChanged(repository, task, data));
130
131
	}
132
55
	/**
133
	/**
56
	 * This is the first test so that the repository credentials are correctly set for the other tests
134
	 * This is the first test so that the repository credentials are correctly set for the other tests
57
	 */
135
	 */

Return to bug 288309