Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2012-12-08 20:47:06 +0000
committerSteffen Pingel2012-12-08 20:57:29 +0000
commit6a15b70c52501a22235d8cec9e910806af5c8fda (patch)
tree2bf5b684fd1ecbc9d89a5f97c3b3dc09f69813b3 /org.eclipse.mylyn.bugzilla.core
parentc6c540f90f8f2102135f5be8c70cb015e3a7fc7e (diff)
downloadorg.eclipse.mylyn.tasks-6a15b70c52501a22235d8cec9e910806af5c8fda.tar.gz
org.eclipse.mylyn.tasks-6a15b70c52501a22235d8cec9e910806af5c8fda.tar.xz
org.eclipse.mylyn.tasks-6a15b70c52501a22235d8cec9e910806af5c8fda.zip
310545: changed Bugzilla tasks occasionally do not show as incoming
Change-Id: I10322d4faa6c382f0fca02f93ccf2b8ab61ee04d Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=310545
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.core')
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java36
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java24
2 files changed, 23 insertions, 37 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java
index 7e0d240b5..e533289fd 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java
@@ -30,21 +30,21 @@ import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
*/
public class BugzillaAttributeMapper extends TaskAttributeMapper {
- private final String dateFormat_1 = "yyyy-MM-dd HH:mm:ss"; //$NON-NLS-1$
+ private static final String dateFormat_1 = "yyyy-MM-dd HH:mm:ss"; //$NON-NLS-1$
- private final String dateFormat_2 = "yyyy-MM-dd HH:mm"; //$NON-NLS-1$
+ private static final String dateFormat_2 = "yyyy-MM-dd HH:mm"; //$NON-NLS-1$
- private final String dateFormat_3 = "yyyy-MM-dd"; //$NON-NLS-1$
+ private static final String dateFormat_3 = "yyyy-MM-dd"; //$NON-NLS-1$
- private final String dateFormat_1_TimeZone = "yyyy-MM-dd HH:mm:ss Z"; //$NON-NLS-1$
+ private static final String dateFormat_1_TimeZone = "yyyy-MM-dd HH:mm:ss Z"; //$NON-NLS-1$
- private final String dateFormat_2_TimeZone = "yyyy-MM-dd HH:mm z"; //$NON-NLS-1$
+ private static final String dateFormat_2_TimeZone = "yyyy-MM-dd HH:mm z"; //$NON-NLS-1$
- private final String dateFormat_3_TimeZone = "yyyy-MM-dd z"; //$NON-NLS-1$
+ private static final String dateFormat_3_TimeZone = "yyyy-MM-dd z"; //$NON-NLS-1$
// Order is significant
- private final String[] dateFormats = { dateFormat_1_TimeZone, dateFormat_1, dateFormat_2_TimeZone, dateFormat_2,
- dateFormat_3_TimeZone, dateFormat_3 };
+ private static final String[] dateFormats = { dateFormat_1_TimeZone, dateFormat_1, dateFormat_2_TimeZone,
+ dateFormat_2, dateFormat_3_TimeZone, dateFormat_3 };
private final BugzillaRepositoryConnector connector;
@@ -58,13 +58,11 @@ public class BugzillaAttributeMapper extends TaskAttributeMapper {
if (attribute == null) {
return null;
}
- String dateString = attribute.getValue();
- String id = attribute.getId();
- Date parsedDate = getDate(id, dateString);
- if (parsedDate == null) {
- parsedDate = super.getDateValue(attribute);
+ Date parsedDate = parseDate(attribute.getValue());
+ if (parsedDate != null) {
+ return parsedDate;
}
- return parsedDate;
+ return super.getDateValue(attribute);
}
@Override
@@ -90,20 +88,16 @@ public class BugzillaAttributeMapper extends TaskAttributeMapper {
/**
* Note: Date formatter constructed within method for thread safety
*/
- protected Date getDate(String attributeId, String dateString) {
- Date parsedDate = null;
-
+ public static final Date parseDate(String dateString) {
for (String format : dateFormats) {
try {
SimpleDateFormat simpleFormatter = new SimpleDateFormat(format);
- parsedDate = simpleFormatter.parse(dateString);
- break;
+ return simpleFormatter.parse(dateString);
} catch (ParseException e) {
} catch (NumberFormatException e) {
}
}
-
- return parsedDate;
+ return null;
}
@Override
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java
index 70d63d570..5908592eb 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java
@@ -359,10 +359,14 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
changedTasks.add(changedTask);
}
}
+
if (syncSession.getData() == null && collector.getQueryTimestamp() != null) {
- syncSession.setData(collector.getQueryTimestamp());
+ Date queryDate = BugzillaAttributeMapper.parseDate(collector.getQueryTimestamp());
+ if (queryDate != null) {
+ // Ensure time is in right format
+ syncSession.setData(new SimpleDateFormat(TIMESTAMP_WITH_OFFSET).format(queryDate));
+ }
}
-
}
@Override
@@ -391,19 +395,6 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
client.logout(monitor);
client.getSearchHits(query, resultCollector, mapper, monitor);
}
-
- if (resultCollector instanceof BugzillaTaskDataCollector) {
- BugzillaTaskDataCollector bCollector = (BugzillaTaskDataCollector) resultCollector;
- if (bCollector.getQueryTimestamp() != null) {
- Date queryDate = ((BugzillaAttributeMapper) mapper).getDate(BugzillaAttribute.DELTA_TS.getKey(),
- bCollector.getQueryTimestamp());
- if (queryDate != null) {
- // Ensure time is in right format
- event.setData(new SimpleDateFormat(TIMESTAMP_WITH_OFFSET).format(queryDate));
- }
- }
- }
-
return Status.OK_STATUS;
} catch (UnrecognizedReponseException e) {
return new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, IStatus.INFO,
@@ -515,6 +506,7 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
@Override
public void postSynchronization(ISynchronizationSession event, IProgressMonitor monitor) throws CoreException {
+ monitor = Policy.monitorFor(monitor);
try {
monitor.beginTask("", 1); //$NON-NLS-1$
if (event.isFullSynchronization() && event.getStatus() == null) {
@@ -563,7 +555,7 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
}
BugzillaAttributeMapper mapper = (BugzillaAttributeMapper) taskData.getAttributeMapper();
- Date oldModDate = mapper.getDate(BugzillaAttribute.DELTA_TS.getKey(), lastKnownMod);
+ Date oldModDate = BugzillaAttributeMapper.parseDate(lastKnownMod);
Date newModDate = mapper.getDateValue(attrModification);
// If either of the dates can't be parsed, fall back to string comparison

Back to the top