Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2010-09-01 17:06:02 -0400
committerspingel2010-09-01 17:06:02 -0400
commitaceb37decddf5b3b406a0d02434d7eb81f0024ab (patch)
tree9a959e8cba6d463751ac4a73aeb4601327e7b649
parent65eb9d6f324b77bc9bf3462367c1c956fde847f7 (diff)
downloadorg.eclipse.mylyn.tasks-aceb37decddf5b3b406a0d02434d7eb81f0024ab.tar.gz
org.eclipse.mylyn.tasks-aceb37decddf5b3b406a0d02434d7eb81f0024ab.tar.xz
org.eclipse.mylyn.tasks-aceb37decddf5b3b406a0d02434d7eb81f0024ab.zip
ASSIGNED - bug 321054: [backport] (automatic) updates of configuration can cause loss of attribute options
https://bugs.eclipse.org/bugs/show_bug.cgi?id=321054
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java59
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java21
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java11
3 files changed, 69 insertions, 22 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
index 2c7db7eb4..b520c9b48 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
@@ -26,6 +26,7 @@ import java.nio.charset.Charset;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -55,6 +56,8 @@ import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.methods.multipart.PartBase;
import org.apache.commons.httpclient.methods.multipart.StringPart;
import org.apache.commons.httpclient.params.HttpMethodParams;
+import org.apache.commons.httpclient.util.DateParseException;
+import org.apache.commons.httpclient.util.DateUtil;
import org.eclipse.core.net.proxy.IProxyData;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
@@ -67,17 +70,17 @@ import org.eclipse.mylyn.commons.net.AbstractWebLocation;
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.commons.net.HtmlStreamTokenizer;
+import org.eclipse.mylyn.commons.net.HtmlStreamTokenizer.Token;
import org.eclipse.mylyn.commons.net.HtmlTag;
import org.eclipse.mylyn.commons.net.Policy;
import org.eclipse.mylyn.commons.net.WebUtil;
-import org.eclipse.mylyn.commons.net.HtmlStreamTokenizer.Token;
import org.eclipse.mylyn.internal.bugzilla.core.history.BugzillaTaskHistoryParser;
import org.eclipse.mylyn.internal.bugzilla.core.history.TaskHistory;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
+import org.eclipse.mylyn.tasks.core.RepositoryResponse.ResponseKind;
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.core.RepositoryResponse.ResponseKind;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentSource;
import org.eclipse.mylyn.tasks.core.data.TaskAttachmentMapper;
import org.eclipse.mylyn.tasks.core.data.TaskAttachmentPartSource;
@@ -653,6 +656,16 @@ public class BugzillaClient {
} else {
repositoryConfiguration.setETagValue(null);
}
+ Header lastModifiedHeader = method.getResponseHeader("Last-Modified"); //$NON-NLS-1$
+ if (lastModifiedHeader != null) {
+ try {
+ repositoryConfiguration.setLastModifiedHeader(DateUtil.parseDate(lastModifiedHeader.getValue()));
+ } catch (DateParseException e) {
+ repositoryConfiguration.setLastModifiedHeader((Date) null);
+ }
+ } else {
+ repositoryConfiguration.setLastModifiedHeader((Date) null);
+ }
if (repositoryConfiguration != null) {
if (!repositoryConfiguration.getProducts().isEmpty()) {
@@ -1146,9 +1159,12 @@ public class BugzillaClient {
String id = a.getId();
if (id.equals(BugzillaAttribute.NEWCC.getKey())) {
TaskAttribute b = taskData.getRoot().createAttribute(BugzillaAttribute.CC.getKey());
- b.getMetaData().defaults().setReadOnly(BugzillaAttribute.CC.isReadOnly()).setKind(
- BugzillaAttribute.CC.getKind()).setLabel(BugzillaAttribute.CC.toString()).setType(
- BugzillaAttribute.CC.getType());
+ b.getMetaData()
+ .defaults()
+ .setReadOnly(BugzillaAttribute.CC.isReadOnly())
+ .setKind(BugzillaAttribute.CC.getKind())
+ .setLabel(BugzillaAttribute.CC.toString())
+ .setType(BugzillaAttribute.CC.getType());
for (String val : a.getValues()) {
if (val != null) {
b.addValue(val);
@@ -1183,8 +1199,8 @@ public class BugzillaClient {
}
if (bugzillaVersion.compareMajorMinorOnly(BugzillaVersion.BUGZILLA_2_18) == 0) {
- fields.put(KEY_COMMENT, new NameValuePair(KEY_COMMENT, formatTextToLineWrap(descAttribute.getValue(),
- true)));
+ fields.put(KEY_COMMENT,
+ new NameValuePair(KEY_COMMENT, formatTextToLineWrap(descAttribute.getValue(), true)));
} else {
fields.put(KEY_COMMENT, new NameValuePair(KEY_COMMENT, descAttribute.getValue()));
}
@@ -1342,8 +1358,9 @@ public class BugzillaClient {
fields.put(KEY_KNOB, new NameValuePair(KEY_KNOB, sel));
} else {
fields.put(KEY_KNOB, new NameValuePair(KEY_KNOB, attributeOperation.getValue()));
- TaskAttribute inputAttribute = attributeOperation.getTaskData().getRoot().getAttribute(
- inputAttributeId);
+ TaskAttribute inputAttribute = attributeOperation.getTaskData()
+ .getRoot()
+ .getAttribute(inputAttributeId);
if (inputAttribute != null) {
if (inputAttribute.getOptions().size() > 0) {
String sel = inputAttribute.getValue();
@@ -1365,8 +1382,10 @@ public class BugzillaClient {
}
if (model.getRoot().getMappedAttribute(TaskAttribute.COMMENT_NEW) != null
&& model.getRoot().getMappedAttribute(TaskAttribute.COMMENT_NEW).getValue().length() > 0) {
- fields.put(KEY_COMMENT, new NameValuePair(KEY_COMMENT, model.getRoot().getMappedAttribute(
- TaskAttribute.COMMENT_NEW).getValue()));
+ fields.put(KEY_COMMENT,
+ new NameValuePair(KEY_COMMENT, model.getRoot()
+ .getMappedAttribute(TaskAttribute.COMMENT_NEW)
+ .getValue()));
} else if (attributeOperation != null
&& attributeOperation.getValue().equals(BugzillaOperation.duplicate.toString())) {
// fix for bug#198677
@@ -1423,8 +1442,9 @@ public class BugzillaClient {
fields.put(fieldName, new NameValuePair(fieldName, selOp));
if (inputAttributeId != null && !inputAttributeId.equals("")) { //$NON-NLS-1$
- TaskAttribute inputAttribute = attributeOperation.getTaskData().getRoot().getAttribute(
- inputAttributeId);
+ TaskAttribute inputAttribute = attributeOperation.getTaskData()
+ .getRoot()
+ .getAttribute(inputAttributeId);
if (inputAttribute != null) {
if (inputAttribute.getOptions().size() > 0) {
String sel = inputAttribute.getValue();
@@ -1452,14 +1472,19 @@ public class BugzillaClient {
if (model.getRoot().getMappedAttribute(TaskAttribute.COMMENT_NEW) != null
&& model.getRoot().getMappedAttribute(TaskAttribute.COMMENT_NEW).getValue().length() > 0) {
- fields.put(KEY_COMMENT, new NameValuePair(KEY_COMMENT, model.getRoot().getMappedAttribute(
- TaskAttribute.COMMENT_NEW).getValue()));
+ fields.put(KEY_COMMENT,
+ new NameValuePair(KEY_COMMENT, model.getRoot()
+ .getMappedAttribute(TaskAttribute.COMMENT_NEW)
+ .getValue()));
}
}
if (model.getRoot().getMappedAttribute(BugzillaAttribute.SHORT_DESC.getKey()) != null) {
- fields.put(KEY_SHORT_DESC, new NameValuePair(KEY_SHORT_DESC, model.getRoot().getMappedAttribute(
- BugzillaAttribute.SHORT_DESC.getKey()).getValue()));
+ fields.put(
+ KEY_SHORT_DESC,
+ new NameValuePair(KEY_SHORT_DESC, model.getRoot()
+ .getMappedAttribute(BugzillaAttribute.SHORT_DESC.getKey())
+ .getValue()));
}
TaskAttribute attributeRemoveCC = model.getRoot().getMappedAttribute(BugzillaAttribute.REMOVECC.getKey());
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 5baf68e78..01dfb97fb 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
@@ -739,18 +739,29 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
configuration = repositoryConfigurations.get(repository.getRepositoryUrl());
if (configuration == null || forceRefresh) {
String eTag = null;
+ Date lastModifiedHeader = null;
if (configuration != null && !forceRefresh) {
eTag = configuration.getETagValue();
+ lastModifiedHeader = configuration.getLastModifiedHeader();
}
BugzillaClient client = getClientManager().getClient(repository, monitor);
configuration = client.getRepositoryConfiguration(monitor, eTag);
+ boolean newer = true;
if (configuration != null) {
- String configVersion = configuration.getInstallVersion().toString();
- String repositoryVersion = repository.getVersion();
- if (!configVersion.equals(repositoryVersion)) {
- repository.setVersion(configVersion);
+ if (lastModifiedHeader != null) {
+ Date configLastModifiedHeader = configuration.getLastModifiedHeader();
+ if (configLastModifiedHeader != null) {
+ newer = !configLastModifiedHeader.before(lastModifiedHeader);
+ }
+ }
+ if (newer) {
+ String configVersion = configuration.getInstallVersion().toString();
+ String repositoryVersion = repository.getVersion();
+ if (!configVersion.equals(repositoryVersion)) {
+ repository.setVersion(configVersion);
+ }
+ internalAddConfiguration(configuration);
}
- internalAddConfiguration(configuration);
}
}
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java
index 0b3918301..0f46a82ac 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java
@@ -14,6 +14,7 @@ package org.eclipse.mylyn.internal.bugzilla.core;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -74,6 +75,8 @@ public class RepositoryConfiguration implements Serializable {
private String eTagValue = null;
+ private Date lastModifiedHeader = null;
+
public RepositoryConfiguration() {
}
@@ -861,6 +864,14 @@ public class RepositoryConfiguration implements Serializable {
this.eTagValue = eTagValue;
}
+ public Date getLastModifiedHeader() {
+ return lastModifiedHeader;
+ }
+
+ public void setLastModifiedHeader(Date lastModifiedHeader) {
+ this.lastModifiedHeader = lastModifiedHeader;
+ }
+
public String getETagValue() {
return eTagValue;
}

Back to the top