Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2008-04-14 04:25:48 +0000
committerrelves2008-04-14 04:25:48 +0000
commitb0e40e6fed54b93f7a08d605d7d9452da485abe5 (patch)
tree45326b894558bd913a813087035105fa262ffeab
parent376eb3a0dbbca2a7df336dd71e97780e0bdc32ff (diff)
downloadorg.eclipse.mylyn.tasks-b0e40e6fed54b93f7a08d605d7d9452da485abe5.tar.gz
org.eclipse.mylyn.tasks-b0e40e6fed54b93f7a08d605d7d9452da485abe5.tar.xz
org.eclipse.mylyn.tasks-b0e40e6fed54b93f7a08d605d7d9452da485abe5.zip
NEW - bug 225872: implement cancellation support for Bugzilla
https://bugs.eclipse.org/bugs/show_bug.cgi?id=225872
-rw-r--r--org.eclipse.mylyn.bugzilla.core/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentHandler.java8
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java239
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientFactory.java36
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java14
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java9
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java19
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java129
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java43
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java8
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java10
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryEditorWizardTest.java54
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaTaskHistoryTest.java20
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java8
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/NewBugzillaTaskEditor.java3
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java12
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java59
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java5
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaProductPage.java5
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/SynchronizeRepositoriesJob.java8
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java6
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java5
22 files changed, 379 insertions, 324 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/META-INF/MANIFEST.MF b/org.eclipse.mylyn.bugzilla.core/META-INF/MANIFEST.MF
index 76e589ea8..21376838b 100644
--- a/org.eclipse.mylyn.bugzilla.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.bugzilla.core/META-INF/MANIFEST.MF
@@ -7,7 +7,8 @@ Bundle-Activator: org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.mylyn.tasks.core;bundle-version="[3.0.0,4.0.0)",
org.eclipse.mylyn.web.core;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.mylyn.monitor.core;bundle-version="[3.0.0,4.0.0)"
+ org.eclipse.mylyn.monitor.core;bundle-version="[3.0.0,4.0.0)",
+ org.eclipse.core.net
Eclipse-AutoStart: true
Bundle-Vendor: Eclipse.org
Bundle-ClassPath: .
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentHandler.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentHandler.java
index d1aae6cca..215b475bf 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentHandler.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentHandler.java
@@ -37,8 +37,8 @@ public class BugzillaAttachmentHandler extends AbstractAttachmentHandler {
public InputStream getAttachmentAsStream(TaskRepository repository, RepositoryAttachment attachment,
IProgressMonitor monitor) throws CoreException {
try {
- BugzillaClient client = connector.getClientManager().getClient(repository);
- return client.getAttachmentData(attachment.getId());
+ BugzillaClient client = connector.getClientManager().getClient(repository, monitor);
+ return client.getAttachmentData(attachment.getId(), monitor);
} catch (IOException e) {
throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
RepositoryStatus.ERROR_IO, repository.getRepositoryUrl(), e));
@@ -50,8 +50,8 @@ public class BugzillaAttachmentHandler extends AbstractAttachmentHandler {
String comment, IProgressMonitor monitor) throws CoreException {
try {
String bugId = task.getTaskId();
- BugzillaClient client = connector.getClientManager().getClient(repository);
- client.postAttachment(bugId, comment, attachment);
+ BugzillaClient client = connector.getClientManager().getClient(repository, monitor);
+ client.postAttachment(bugId, comment, attachment, monitor);
} catch (IOException e) {
throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
RepositoryStatus.ERROR_IO, repository.getRepositoryUrl(), e));
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 c55dfbe9c..b137f020e 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
@@ -12,6 +12,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
import java.net.Proxy;
import java.net.URL;
import java.net.URLDecoder;
@@ -29,6 +30,7 @@ import java.util.Set;
import javax.security.auth.login.LoginException;
import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
@@ -41,7 +43,9 @@ 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.eclipse.core.net.proxy.IProxyData;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.internal.bugzilla.core.history.BugzillaTaskHistoryParser;
@@ -53,9 +57,15 @@ import org.eclipse.mylyn.tasks.core.RepositoryStatus;
import org.eclipse.mylyn.tasks.core.RepositoryTaskAttribute;
import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataCollector;
+import org.eclipse.mylyn.web.core.AbstractWebLocation;
+import org.eclipse.mylyn.web.core.AuthenticationCredentials;
+import org.eclipse.mylyn.web.core.AuthenticationType;
import org.eclipse.mylyn.web.core.HtmlStreamTokenizer;
import org.eclipse.mylyn.web.core.HtmlTag;
+import org.eclipse.mylyn.web.core.Policy;
import org.eclipse.mylyn.web.core.WebClientUtil;
+import org.eclipse.mylyn.web.core.WebUtil;
+import org.eclipse.mylyn.web.core.WebUtil;
import org.eclipse.mylyn.web.core.HtmlStreamTokenizer.Token;
/**
@@ -65,6 +75,8 @@ import org.eclipse.mylyn.web.core.HtmlStreamTokenizer.Token;
*/
public class BugzillaClient {
+ protected static final String USER_AGENT = "BugzillaConnector";
+
private static final int MAX_RETRIEVED_PER_QUERY = 100;
private static final String QUERY_DELIMITER = "?";
@@ -153,33 +165,38 @@ public class BugzillaClient {
private BugzillaLanguageSettings bugzillaLanguageSettings;
private RepositoryConfiguration repositoryConfiguration;
-
- public BugzillaClient(URL url, String username, String password, String htAuthUser, String htAuthPass,
- String characterEncoding) {
- this(url, username, password, htAuthUser, htAuthPass, characterEncoding, new HashMap<String, String>(),
- BugzillaCorePlugin.getDefault().getLanguageSetting(IBugzillaConstants.DEFAULT_LANG));
- }
- /**
- * languageSettings must not be null
- */
- public BugzillaClient(URL url, String username, String password, String htAuthUser, String htAuthPass,
- String characterEncoding, Map<String, String> configParameters, BugzillaLanguageSettings languageSettings) {
- this.username = username;
- this.password = password;
- this.repositoryUrl = url;
- this.htAuthUser = htAuthUser;
- this.htAuthPass = htAuthPass;
+ private HostConfiguration hostConfiguration;
+
+ private AbstractWebLocation location;
+
+ public BugzillaClient(AbstractWebLocation location, String characterEncoding, Map<String, String> configParameters,
+ BugzillaLanguageSettings languageSettings) throws MalformedURLException {
+ AuthenticationCredentials credentials = location.getCredentials(AuthenticationType.REPOSITORY);
+ if (credentials != null) {
+ this.username = credentials.getUserName();
+ this.password = credentials.getPassword();
+ }
+ this.repositoryUrl = new URL(location.getUrl());
+ this.location = location;
+ credentials = location.getCredentials(AuthenticationType.HTTP);
+ if (credentials != null) {
+ this.htAuthUser = credentials.getUserName();
+ this.htAuthPass = credentials.getPassword();
+ }
this.characterEncoding = characterEncoding;
this.configParameters = configParameters;
this.bugzillaLanguageSettings = languageSettings;
+ this.proxy = location.getProxyForHost(location.getUrl(), IProxyData.HTTP_PROXY_TYPE);
+ WebUtil.configureHttpClient(httpClient, USER_AGENT);
}
- public void validate() throws IOException, CoreException {
+ public void validate(IProgressMonitor monitor) throws IOException, CoreException {
+ monitor = Policy.monitorFor(monitor);
GzipGetMethod method = null;
try {
- logout();
- method = getConnect(repositoryUrl + "/");
+ logout(monitor);
+ method = getConnect(repositoryUrl + "/", monitor);
} finally {
if (method != null) {
method.releaseConnection();
@@ -191,9 +208,9 @@ public class BugzillaClient {
return username != null && username.length() > 0;
}
- private GzipGetMethod getConnect(String serverURL) throws IOException, CoreException {
+ private GzipGetMethod getConnect(String serverURL, IProgressMonitor monitor) throws IOException, CoreException {
- return connectInternal(serverURL, false);
+ return connectInternal(serverURL, false, monitor);
}
@@ -209,21 +226,24 @@ public class BugzillaClient {
* @throws IOException
* @throws CoreException
*/
- private GzipGetMethod getConnectGzip(String serverURL) throws IOException, CoreException {
+ private GzipGetMethod getConnectGzip(String serverURL, IProgressMonitor monitor) throws IOException, CoreException {
- return connectInternal(serverURL, true);
+ return connectInternal(serverURL, true, monitor);
}
- private GzipGetMethod connectInternal(String requestURL, boolean gzip) throws IOException, CoreException {
- WebClientUtil.setupHttpClient(httpClient, proxy, requestURL, htAuthUser, htAuthPass);
+ private GzipGetMethod connectInternal(String requestURL, boolean gzip, IProgressMonitor monitor)
+ throws IOException, CoreException {
+ monitor = Policy.monitorFor(monitor);
+ hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor);
+
for (int attempt = 0; attempt < 2; attempt++) {
// force authentication
if (!authenticated && hasAuthenticationCredentials()) {
- authenticate();
+ authenticate(monitor);
}
- GzipGetMethod getMethod = new GzipGetMethod(WebClientUtil.getRequestPath(requestURL), gzip);
+ GzipGetMethod getMethod = new GzipGetMethod(WebUtil.getRequestPath(requestURL), gzip);
if (requestURL.contains(QUERY_DELIMITER)) {
getMethod.setQueryString(requestURL.substring(requestURL.indexOf(QUERY_DELIMITER)));
}
@@ -232,7 +252,7 @@ public class BugzillaClient {
+ characterEncoding);
if (gzip) {
- getMethod.setRequestHeader("Accept-encoding", WebClientUtil.CONTENT_ENCODING_GZIP);
+ getMethod.setRequestHeader("Accept-encoding", "gzip");
}
// Resolves bug#195113
@@ -250,7 +270,7 @@ public class BugzillaClient {
int code;
try {
- code = httpClient.executeMethod(getMethod);
+ code = WebUtil.execute(httpClient, hostConfiguration, getMethod, monitor);
} catch (IOException e) {
getMethod.getResponseBodyNoop();
getMethod.releaseConnection();
@@ -265,7 +285,7 @@ public class BugzillaClient {
// login or reauthenticate due to an expired session
getMethod.releaseConnection();
authenticated = false;
- authenticate();
+ authenticate(monitor);
} else if (code == HttpURLConnection.HTTP_PROXY_AUTH) {
// throw new LoginException("Proxy Authentication Required");
authenticated = false;
@@ -289,13 +309,14 @@ public class BugzillaClient {
+ " failed. Please verify connection and authentication information."));
}
- public void logout() throws IOException, CoreException {
+ public void logout(IProgressMonitor monitor) throws IOException, CoreException {
+ monitor = Policy.monitorFor(monitor);
authenticated = true;
String loginUrl = repositoryUrl + "/relogin.cgi";
GzipGetMethod method = null;
try {
- method = getConnect(loginUrl);
- BufferedReader responseReader = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream(),
+ method = getConnect(loginUrl, monitor);
+ BufferedReader responseReader = new BufferedReader(new InputStreamReader(WebUtil.getResponseBodyAsStream(method, monitor),
characterEncoding));
HtmlStreamTokenizer tokenizer = new HtmlStreamTokenizer(responseReader, null);
@@ -329,7 +350,8 @@ public class BugzillaClient {
}
}
- public void authenticate() throws CoreException {
+ public void authenticate(IProgressMonitor monitor) throws CoreException {
+ monitor = Policy.monitorFor(monitor);
if (!hasAuthenticationCredentials()) {
authenticated = false;
throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
@@ -341,13 +363,13 @@ public class BugzillaClient {
try {
- WebClientUtil.setupHttpClient(httpClient, proxy, repositoryUrl.toString(), htAuthUser, htAuthPass);
+ hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor);
NameValuePair[] formData = new NameValuePair[2];
formData[0] = new NameValuePair(IBugzillaConstants.POST_INPUT_BUGZILLA_LOGIN, username);
formData[1] = new NameValuePair(IBugzillaConstants.POST_INPUT_BUGZILLA_PASSWORD, password);
- postMethod = new GzipPostMethod(WebClientUtil.getRequestPath(repositoryUrl.toString()
+ postMethod = new GzipPostMethod(WebUtil.getRequestPath(repositoryUrl.toString()
+ IBugzillaConstants.URL_POST_LOGIN), true);
postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset="
@@ -357,11 +379,11 @@ public class BugzillaClient {
// if (!isValidation) {
// postMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new BugzillaRetryHandler());
// }
- // httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(WebClientUtil.CONNNECT_TIMEOUT);
+ // httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(WebUtil.CONNNECT_TIMEOUT);
postMethod.setFollowRedirects(false);
httpClient.getParams().setAuthenticationPreemptive(true);
- int code = httpClient.executeMethod(postMethod);
+ int code = WebUtil.execute(httpClient, hostConfiguration, postMethod, monitor);
if (code == HttpURLConnection.HTTP_UNAUTHORIZED || code == HttpURLConnection.HTTP_FORBIDDEN) {
authenticated = false;
postMethod.getResponseBodyNoop();
@@ -426,12 +448,12 @@ public class BugzillaClient {
}
}
- public RepositoryTaskData getTaskData(int id) throws IOException, CoreException {
+ public RepositoryTaskData getTaskData(int id, IProgressMonitor monitor) throws IOException, CoreException {
final String idString = String.valueOf(id);
Set<String> data = new HashSet<String>();
data.add(idString);
- Map<String, RepositoryTaskData> returnedData = getTaskData(data);
+ Map<String, RepositoryTaskData> returnedData = getTaskData(data, monitor);
return returnedData.get(idString);
@@ -468,38 +490,40 @@ public class BugzillaClient {
// }
}
- public boolean getSearchHits(AbstractRepositoryQuery query, AbstractTaskDataCollector collector) throws IOException,
- CoreException {
+ public boolean getSearchHits(AbstractRepositoryQuery query, AbstractTaskDataCollector collector,
+ IProgressMonitor monitor) throws IOException, CoreException {
GzipPostMethod postMethod = null;
try {
-
+
String queryUrl = query.getUrl();
int start = queryUrl.indexOf('?');
-
+
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
- if(start != -1) {
+ if (start != -1) {
queryUrl = queryUrl.substring(start + 1);
String[] result = queryUrl.split("&");
- if(result.length > 0) {
+ if (result.length > 0) {
for (String string : result) {
String[] nameValue = string.split("=");
- if(nameValue.length == 1) {
+ if (nameValue.length == 1) {
pairs.add(new NameValuePair(nameValue[0].trim(), ""));
- } else if(nameValue.length == 2 && nameValue[0] != null && nameValue[1] != null) {
- pairs.add(new NameValuePair(nameValue[0].trim(), URLDecoder.decode(nameValue[1].trim(), characterEncoding)));
+ } else if (nameValue.length == 2 && nameValue[0] != null && nameValue[1] != null) {
+ pairs.add(new NameValuePair(nameValue[0].trim(), URLDecoder.decode(nameValue[1].trim(),
+ characterEncoding)));
}
}
}
}
-
+
NameValuePair ctypePair = new NameValuePair("ctype", "rdf");
// Test that we don't specify content type twice.
- if(!pairs.contains(ctypePair)) {
+ if (!pairs.contains(ctypePair)) {
pairs.add(ctypePair);
}
-
- postMethod = postFormData(IBugzillaConstants.URL_BUGLIST, pairs.toArray(new NameValuePair[pairs.size()]));
+
+ postMethod = postFormData(IBugzillaConstants.URL_BUGLIST, pairs.toArray(new NameValuePair[pairs.size()]),
+ monitor);
//System.err.println(postMethod.getResponseBodyAsString());
if (postMethod.getResponseHeader("Content-Type") != null) {
Header responseTypeHeader = postMethod.getResponseHeader("Content-Type");
@@ -507,12 +531,13 @@ public class BugzillaClient {
if (responseTypeHeader.getValue().toLowerCase(Locale.ENGLISH).contains(type)) {
RepositoryQueryResultsFactory queryFactory = new RepositoryQueryResultsFactory(
postMethod.getResponseBodyAsUnzippedStream(), characterEncoding);
- int count = queryFactory.performQuery(repositoryUrl.toString(), collector, AbstractTaskDataCollector.MAX_HITS);
+ int count = queryFactory.performQuery(repositoryUrl.toString(), collector,
+ AbstractTaskDataCollector.MAX_HITS);
return count > 0;
}
}
}
-
+
parseHtmlError(new BufferedReader(new InputStreamReader(postMethod.getResponseBodyAsUnzippedStream(),
characterEncoding)));
} finally {
@@ -609,18 +634,11 @@ public class BugzillaClient {
return attributeFactory.createAttribute(tag.getKeyString());
}
- public void setProxy(Proxy proxy) {
- this.proxy = proxy;
- }
-
- public Proxy getProxy() {
- return proxy;
- }
-
- public RepositoryConfiguration getRepositoryConfiguration() throws IOException, CoreException {
+ public RepositoryConfiguration getRepositoryConfiguration(IProgressMonitor monitor) throws IOException,
+ CoreException {
GzipGetMethod method = null;
try {
- method = getConnectGzip(repositoryUrl + IBugzillaConstants.URL_GET_CONFIG_RDF);
+ method = getConnectGzip(repositoryUrl + IBugzillaConstants.URL_GET_CONFIG_RDF, monitor);
// provide a solution for bug 196056 by allowing a (cached) gzipped configuration to be sent
// modified to also accept "application/x-gzip" as results from a 302 redirect to a previously gzipped file.
@@ -632,7 +650,7 @@ public class BugzillaClient {
Header responseTypeHeader = method.getResponseHeader("Content-Type");
for (String type : VALID_CONFIG_CONTENT_TYPES) {
if (responseTypeHeader.getValue().toLowerCase(Locale.ENGLISH).contains(type)) {
- InputStream stream = method.getResponseBodyAsUnzippedStream();
+ InputStream stream = WebUtil.getResponseBodyAsStream(method, monitor);
RepositoryConfigurationFactory configFactory = new RepositoryConfigurationFactory(stream,
characterEncoding);
@@ -655,30 +673,33 @@ public class BugzillaClient {
}
}
- public InputStream getAttachmentData(String attachmentId) throws IOException, CoreException {
+ public InputStream getAttachmentData(String attachmentId, IProgressMonitor monitor) throws IOException,
+ CoreException {
String url = repositoryUrl + IBugzillaConstants.URL_GET_ATTACHMENT_DOWNLOAD + attachmentId;
- GzipGetMethod method = getConnectGzip(url);
+ GzipGetMethod method = getConnectGzip(url, monitor);
try {
- return method.getResponseBodyAsUnzippedStream();
+ return WebUtil.getResponseBodyAsStream(method, monitor);
} catch (IOException e) {
method.releaseConnection();
throw e;
}
}
- public void postAttachment(String bugReportID, String comment, ITaskAttachment attachment) throws HttpException,
- IOException, CoreException {
-
- // TODO: Throw IllegalArgumentException if passed null parameter
+ public void postAttachment(String bugReportID, String comment, ITaskAttachment attachment, IProgressMonitor monitor)
+ throws HttpException, IOException, CoreException {
+ monitor = Policy.monitorFor(monitor);
+ if (bugReportID == null || comment == null || attachment == null) {
+ throw new IllegalArgumentException("Must not pass in a null parameter");
+ }
- WebClientUtil.setupHttpClient(httpClient, proxy, repositoryUrl.toString(), htAuthUser, htAuthPass);
+ hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor);
if (!authenticated && hasAuthenticationCredentials()) {
- authenticate();
+ authenticate(monitor);
}
GzipPostMethod postMethod = null;
try {
- postMethod = new GzipPostMethod(WebClientUtil.getRequestPath(repositoryUrl
+ postMethod = new GzipPostMethod(WebUtil.getRequestPath(repositoryUrl
+ IBugzillaConstants.URL_POST_ATTACHMENT_UPLOAD), true);
// This option causes the client to first
// check
@@ -711,7 +732,7 @@ public class BugzillaClient {
postMethod.setRequestEntity(new MultipartRequestEntity(parts.toArray(new Part[1]), postMethod.getParams()));
postMethod.setDoAuthentication(true);
// httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(CONNECT_TIMEOUT);
- int status = httpClient.executeMethod(postMethod);
+ int status = WebUtil.execute(httpClient, hostConfiguration, postMethod, monitor);
if (status == HttpStatus.SC_OK) {
InputStreamReader reader = new InputStreamReader(postMethod.getResponseBodyAsUnzippedStream(),
postMethod.getResponseCharSet());
@@ -740,27 +761,26 @@ public class BugzillaClient {
*
* @throws CoreException
*/
- private GzipPostMethod postFormData(String formUrl, NameValuePair[] formData) throws IOException, CoreException {
+ private GzipPostMethod postFormData(String formUrl, NameValuePair[] formData, IProgressMonitor monitor)
+ throws IOException, CoreException {
GzipPostMethod postMethod = null;
-
- WebClientUtil.setupHttpClient(httpClient, proxy, repositoryUrl.toString(), htAuthUser, htAuthPass);
+ monitor = Policy.monitorFor(monitor);
+ hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor);
if (!authenticated && hasAuthenticationCredentials()) {
- authenticate();
+ authenticate(monitor);
}
- postMethod = new GzipPostMethod(WebClientUtil.getRequestPath(repositoryUrl.toString() + formUrl), true);
+ postMethod = new GzipPostMethod(WebUtil.getRequestPath(repositoryUrl.toString() + formUrl), true);
postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=" + characterEncoding);
- // Up the timout on sockets for posts
- // Bug#175054
- httpClient.getHttpConnectionManager().getParams().setSoTimeout(WebClientUtil.CONNNECT_TIMEOUT);
+ httpClient.getHttpConnectionManager().getParams().setSoTimeout(WebUtil.getConnectionTimeout());
// postMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new BugzillaRetryHandler());
postMethod.setRequestBody(formData);
postMethod.setDoAuthentication(true);
// httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(CONNECT_TIMEOUT);
- int status = httpClient.executeMethod(postMethod);
+ int status = WebUtil.execute(httpClient, hostConfiguration, postMethod, monitor);
if (status == HttpStatus.SC_OK) {
return postMethod;
} else {
@@ -775,13 +795,13 @@ public class BugzillaClient {
}
- public String postTaskData(RepositoryTaskData taskData) throws IOException, CoreException {
+ public String postTaskData(RepositoryTaskData taskData, IProgressMonitor monitor) throws IOException, CoreException {
NameValuePair[] formData = null;
String prefix = null;
String prefix2 = null;
String postfix = null;
String postfix2 = null;
-
+ monitor = Policy.monitorFor(monitor);
if (taskData == null) {
return null;
} else if (taskData.isNew()) {
@@ -798,9 +818,9 @@ public class BugzillaClient {
GzipPostMethod method = null;
try {
if (taskData.isNew()) {
- method = postFormData(POST_BUG_CGI, formData);
+ method = postFormData(POST_BUG_CGI, formData, monitor);
} else {
- method = postFormData(PROCESS_BUG_CGI, formData);
+ method = postFormData(PROCESS_BUG_CGI, formData, monitor);
}
if (method == null) {
@@ -1144,18 +1164,18 @@ public class BugzillaClient {
}
}
- public TaskHistory getHistory(String taskId) throws IOException, CoreException {
- WebClientUtil.setupHttpClient(httpClient, proxy, repositoryUrl.toString(), htAuthUser, htAuthPass);
+ public TaskHistory getHistory(String taskId, IProgressMonitor monitor) throws IOException, CoreException {
+ hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor);
if (!authenticated && hasAuthenticationCredentials()) {
- authenticate();
+ authenticate(monitor);
}
GzipGetMethod method = null;
try {
String url = repositoryUrl + IBugzillaConstants.SHOW_ACTIVITY + taskId;
- method = getConnectGzip(url);
+ method = getConnectGzip(url, monitor);
if (method != null) {
BugzillaTaskHistoryParser parser = new BugzillaTaskHistoryParser(
- method.getResponseBodyAsUnzippedStream(), characterEncoding);
+ WebUtil.getResponseBodyAsStream(method, monitor), characterEncoding);
try {
return parser.retrieveHistory(bugzillaLanguageSettings);
} catch (LoginException e) {
@@ -1179,7 +1199,8 @@ public class BugzillaClient {
return null;
}
- public Map<String, RepositoryTaskData> getTaskData(Set<String> taskIds) throws IOException, CoreException {
+ public Map<String, RepositoryTaskData> getTaskData(Set<String> taskIds, IProgressMonitor monitor)
+ throws IOException, CoreException {
GzipPostMethod method = null;
HashMap<String, RepositoryTaskData> taskDataMap = new HashMap<String, RepositoryTaskData>();
// make a copy to modify set
@@ -1212,12 +1233,12 @@ public class BugzillaClient {
formData[x++] = new NameValuePair("ctype", "xml");
formData[x] = new NameValuePair("excludefield", "attachmentdata");
- method = postFormData(IBugzillaConstants.URL_POST_SHOW_BUG, formData);
+ method = postFormData(IBugzillaConstants.URL_POST_SHOW_BUG, formData, monitor);
if (method == null) {
throw new IOException("Could not post form, client returned null method.");
}
-
+
boolean parseable = false;
List<BugzillaCustomField> customFields = repositoryConfiguration.getCustomFields();
if (method.getResponseHeader("Content-Type") != null) {
@@ -1239,7 +1260,7 @@ public class BugzillaClient {
characterEncoding)));
break;
}
-
+
} finally {
if (method != null) {
method.releaseConnection();
@@ -1250,14 +1271,14 @@ public class BugzillaClient {
return taskDataMap;
}
- public String getConfigurationTimestamp() throws CoreException {
+ public String getConfigurationTimestamp(IProgressMonitor monitor) throws CoreException {
if (!lastModifiedSupported) {
return null;
}
String lastModified = null;
HeadMethod method = null;
try {
- method = connectHead(repositoryUrl + IBugzillaConstants.URL_GET_CONFIG_RDF);
+ method = connectHead(repositoryUrl + IBugzillaConstants.URL_GET_CONFIG_RDF, monitor);
Header lastModifiedHeader = method.getResponseHeader("Last-Modified");
if (lastModifiedHeader != null && lastModifiedHeader.getValue() != null
@@ -1281,15 +1302,15 @@ public class BugzillaClient {
return lastModified;
}
- private HeadMethod connectHead(String requestURL) throws IOException, CoreException {
- WebClientUtil.setupHttpClient(httpClient, proxy, requestURL, htAuthUser, htAuthPass);
+ private HeadMethod connectHead(String requestURL, IProgressMonitor monitor) throws IOException, CoreException {
+ hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor);
for (int attempt = 0; attempt < 2; attempt++) {
// force authentication
if (!authenticated && hasAuthenticationCredentials()) {
- authenticate();
+ authenticate(monitor);
}
- HeadMethod headMethod = new HeadMethod(WebClientUtil.getRequestPath(requestURL));
+ HeadMethod headMethod = new HeadMethod(WebUtil.getRequestPath(requestURL));
if (requestURL.contains(QUERY_DELIMITER)) {
headMethod.setQueryString(requestURL.substring(requestURL.indexOf(QUERY_DELIMITER)));
}
@@ -1306,7 +1327,7 @@ public class BugzillaClient {
int code;
try {
- code = httpClient.executeMethod(headMethod);
+ code = WebUtil.execute(httpClient, hostConfiguration, headMethod, monitor);
} catch (IOException e) {
headMethod.getResponseBody();
headMethod.releaseConnection();
@@ -1321,7 +1342,7 @@ public class BugzillaClient {
// login or reauthenticate due to an expired session
headMethod.releaseConnection();
authenticated = false;
- authenticate();
+ authenticate(monitor);
} else if (code == HttpURLConnection.HTTP_PROXY_AUTH) {
authenticated = false;
headMethod.getResponseBody();
@@ -1348,4 +1369,8 @@ public class BugzillaClient {
this.repositoryConfiguration = repositoryConfiguration;
}
+ public RepositoryConfiguration getRepositoryConfiguration() {
+ return repositoryConfiguration;
+ }
+
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientFactory.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientFactory.java
index b226e9078..ffe0003d2 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientFactory.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientFactory.java
@@ -8,33 +8,29 @@
package org.eclipse.mylyn.internal.bugzilla.core;
import java.net.MalformedURLException;
-import java.net.Proxy;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
+
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.TaskRepositoryLocationFactory;
+import org.eclipse.mylyn.web.core.AbstractWebLocation;
/**
* @author Steffen Pingel
* @author Robert Elves (adaption for Bugzilla)
*/
public class BugzillaClientFactory {
+
+ private static TaskRepositoryLocationFactory taskRepositoryLocationFactory = new TaskRepositoryLocationFactory();
- public static BugzillaClient createClient(String hostUrl, String username, String password, String htAuthUser,
- String htAuthPass, Proxy proxy, String encoding) throws MalformedURLException {
- BugzillaLanguageSettings languageSettings = BugzillaCorePlugin.getDefault().getLanguageSetting(
- IBugzillaConstants.DEFAULT_LANG);
- return createClient(hostUrl, username, password, htAuthUser, htAuthPass, proxy, encoding,
- new HashMap<String, String>(), languageSettings);
- }
-
- public static BugzillaClient createClient(String hostUrl, String username, String password, String htAuthUser,
- String htAuthPass, Proxy proxy, String encoding, Map<String, String> configParameters,
- BugzillaLanguageSettings bugzillaLanguageSettings) throws MalformedURLException {
- URL url = new URL(hostUrl);
-
- BugzillaClient client = new BugzillaClient(url, username, password, htAuthUser, htAuthPass, encoding,
- configParameters, bugzillaLanguageSettings);
- client.setProxy(proxy);
+ public static BugzillaClient createClient(TaskRepository taskRepository) throws MalformedURLException {
+ String language = taskRepository.getProperty(IBugzillaConstants.BUGZILLA_LANGUAGE_SETTING);
+ if (language == null || language.equals("")) {
+ language = IBugzillaConstants.DEFAULT_LANG;
+ }
+ BugzillaLanguageSettings languageSettings = BugzillaCorePlugin.getDefault().getLanguageSetting(language);
+ AbstractWebLocation location = taskRepositoryLocationFactory.createWebLocation(taskRepository);
+ BugzillaClient client = new BugzillaClient(location, taskRepository.getCharacterEncoding(),
+ taskRepository.getProperties(), languageSettings);
return client;
+
}
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java
index cdc9e4aff..36a66bc10 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java
@@ -13,6 +13,7 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.mylyn.tasks.core.ITaskRepositoryListener;
import org.eclipse.mylyn.tasks.core.TaskRepository;
@@ -27,24 +28,17 @@ public class BugzillaClientManager implements ITaskRepositoryListener {
public BugzillaClientManager() {
}
- public synchronized BugzillaClient getClient(TaskRepository taskRepository) throws MalformedURLException, CoreException {
+ public synchronized BugzillaClient getClient(TaskRepository taskRepository, IProgressMonitor monitor) throws MalformedURLException, CoreException {
BugzillaClient client = clientByUrl.get(taskRepository.getRepositoryUrl());
if (client == null) {
- String htUser = taskRepository.getHttpUser() != null ? taskRepository.getHttpUser() : "";
- String htPass = taskRepository.getHttpPassword() != null ? taskRepository.getHttpPassword() : "";
-
String language = taskRepository.getProperty(IBugzillaConstants.BUGZILLA_LANGUAGE_SETTING);
if (language == null || language.equals("")) {
language = IBugzillaConstants.DEFAULT_LANG;
}
- BugzillaLanguageSettings languageSettings = BugzillaCorePlugin.getDefault().getLanguageSetting(language);
-
- client = BugzillaClientFactory.createClient(taskRepository.getRepositoryUrl(), taskRepository.getUserName(),
- taskRepository.getPassword(), htUser, htPass, taskRepository.getProxy(),
- taskRepository.getCharacterEncoding(), taskRepository.getProperties(), languageSettings);
+ client = BugzillaClientFactory.createClient(taskRepository);
clientByUrl.put(taskRepository.getRepositoryUrl(), client);
- client.setRepositoryConfiguration(BugzillaCorePlugin.getRepositoryConfiguration(taskRepository, false));
+ client.setRepositoryConfiguration(BugzillaCorePlugin.getRepositoryConfiguration(taskRepository, false, monitor));
}
return client;
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java
index 94dbfedc1..5f81cb65a 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java
@@ -19,6 +19,7 @@ import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
@@ -27,6 +28,7 @@ import org.eclipse.mylyn.monitor.core.StatusHandler;
import org.eclipse.mylyn.tasks.core.RepositoryTaskAttribute;
import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.web.core.Policy;
import org.osgi.framework.BundleContext;
/**
@@ -118,16 +120,17 @@ public class BugzillaCorePlugin extends Plugin {
/**
* Retrieves the latest repository configuration from the server
*/
- public static RepositoryConfiguration getRepositoryConfiguration(TaskRepository repository, boolean forceRefresh)
+ public static RepositoryConfiguration getRepositoryConfiguration(TaskRepository repository, boolean forceRefresh, IProgressMonitor monitor)
throws CoreException {
+ monitor = Policy.monitorFor(monitor);
try {
if (!cacheFileRead) {
readRepositoryConfigurationFile();
cacheFileRead = true;
}
if (repositoryConfigurations.get(repository.getRepositoryUrl()) == null || forceRefresh) {
- BugzillaClient client = connector.getClientManager().getClient(repository);
- RepositoryConfiguration config = client.getRepositoryConfiguration();
+ BugzillaClient client = connector.getClientManager().getClient(repository, monitor);
+ RepositoryConfiguration config = client.getRepositoryConfiguration(monitor);
if (config != null) {
addRepositoryConfiguration(config);
}
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 40a2167a6..5bcf4c9c5 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
@@ -399,13 +399,13 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
AbstractTaskDataCollector resultCollector, SynchronizationEvent event, IProgressMonitor monitor) {
try {
monitor.beginTask("Running query", IProgressMonitor.UNKNOWN);
- BugzillaClient client = getClientManager().getClient(repository);
- boolean hitsReceived = client.getSearchHits(query, resultCollector);
+ BugzillaClient client = getClientManager().getClient(repository, monitor);
+ boolean hitsReceived = client.getSearchHits(query, resultCollector, monitor);
if (!hitsReceived) {
// XXX: HACK in case of ip change bugzilla can return 0 hits
// due to invalid authorization token, forcing relogin fixes
- client.logout();
- client.getSearchHits(query, resultCollector);
+ client.logout(monitor);
+ client.getSearchHits(query, resultCollector, monitor);
}
return Status.OK_STATUS;
@@ -471,17 +471,18 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
@Override
public void updateRepositoryConfiguration(TaskRepository repository, IProgressMonitor monitor) throws CoreException {
if (repository != null) {
- BugzillaCorePlugin.getRepositoryConfiguration(repository, true);
+ BugzillaCorePlugin.getRepositoryConfiguration(repository, true, monitor);
}
}
- public boolean isRepositoryConfigurationStale(TaskRepository repository) throws CoreException {
- if (super.isRepositoryConfigurationStale(repository)) {
+ public boolean isRepositoryConfigurationStale(TaskRepository repository, IProgressMonitor monitor) throws CoreException {
+ if (super.isRepositoryConfigurationStale(repository, monitor)) {
boolean result = true;
try {
- BugzillaClient client = getClientManager().getClient(repository);
+ BugzillaClient client = getClientManager().getClient(repository, monitor);
if (client != null) {
- String timestamp = client.getConfigurationTimestamp();
+ int x;
+ String timestamp = client.getConfigurationTimestamp(monitor);
if (timestamp != null) {
String oldTimestamp = repository.getProperty(IBugzillaConstants.PROPERTY_CONFIGTIMESTAMP);
if (oldTimestamp != null) {
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java
index 5031860c1..cbcd18cbe 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java
@@ -16,10 +16,12 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants.BUGZILLA_OPERATION;
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants.BUGZILLA_REPORT_STATUS;
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants.BUGZILLA_RESOLUTION_2_0;
@@ -75,27 +77,27 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
public RepositoryTaskData getTaskData(TaskRepository repository, String taskId, IProgressMonitor monitor)
throws CoreException {
try {
- BugzillaClient client = connector.getClientManager().getClient(repository);
+ BugzillaClient client = connector.getClientManager().getClient(repository, new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN));
int bugId = BugzillaRepositoryConnector.getBugId(taskId);
RepositoryTaskData taskData;
try {
- taskData = client.getTaskData(bugId);
+ taskData = client.getTaskData(bugId, monitor);
} catch (CoreException e) {
// TODO: Move retry handling into client
if (e.getStatus().getCode() == RepositoryStatus.ERROR_REPOSITORY_LOGIN) {
- taskData = client.getTaskData(bugId);
+ taskData = client.getTaskData(bugId, monitor);
} else {
throw e;
}
}
if (taskData != null) {
try {
- configureTaskData(repository, taskData);
+ configureTaskData(client.getRepositoryConfiguration(), repository, taskData);
} catch (CoreException ce) {
// retry since data retrieved may be corrupt
- taskData = client.getTaskData(bugId);
+ taskData = client.getTaskData(bugId, monitor);
if (taskData != null) {
- configureTaskData(repository, taskData);
+ configureTaskData(client.getRepositoryConfiguration(), repository, taskData);
}
}
return taskData;
@@ -115,16 +117,16 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
monitor.beginTask("Receiving tasks", taskIds.size());
Set<RepositoryTaskData> result = new HashSet<RepositoryTaskData>();
- BugzillaClient client = connector.getClientManager().getClient(repository);
+ BugzillaClient client = connector.getClientManager().getClient(repository, new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN));
try {
- Map<String, RepositoryTaskData> dataReturned = client.getTaskData(taskIds);
+ Map<String, RepositoryTaskData> dataReturned = client.getTaskData(taskIds, monitor);
for (RepositoryTaskData repositoryTaskData : dataReturned.values()) {
result.add(repositoryTaskData);
}
} catch (CoreException e) {
// TODO: Move retry handling into client
if (e.getStatus().getCode() == RepositoryStatus.ERROR_REPOSITORY_LOGIN) {
- Map<String, RepositoryTaskData> dataReturned = client.getTaskData(taskIds);
+ Map<String, RepositoryTaskData> dataReturned = client.getTaskData(taskIds, monitor);
for (RepositoryTaskData repositoryTaskData : dataReturned.values()) {
result.add(repositoryTaskData);
}
@@ -133,16 +135,7 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
}
}
for (RepositoryTaskData repositoryTaskData : result) {
- try {
- configureTaskData(repository, repositoryTaskData);
- } catch (CoreException ce) {
- // retry since data retrieved may be corrupt
- //taskData = client.getTaskData(bugId);
- //if (taskData != null) {
- configureTaskData(repository, repositoryTaskData);
- // }
- }
-
+ configureTaskData(client.getRepositoryConfiguration(), repository, repositoryTaskData);
collector.accept(repositoryTaskData);
monitor.worked(1);
}
@@ -158,13 +151,13 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
public String postTaskData(TaskRepository repository, RepositoryTaskData taskData, IProgressMonitor monitor)
throws CoreException {
try {
- BugzillaClient client = connector.getClientManager().getClient(repository);
+ BugzillaClient client = connector.getClientManager().getClient(repository, new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN));
try {
- return client.postTaskData(taskData);
+ return client.postTaskData(taskData, monitor);
} catch (CoreException e) {
// TODO: Move retry handling into client
if (e.getStatus().getCode() == RepositoryStatus.ERROR_REPOSITORY_LOGIN) {
- return client.postTaskData(taskData);
+ return client.postTaskData(taskData, monitor);
} else {
throw e;
}
@@ -188,12 +181,12 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
return getAttributeFactory(taskData.getRepositoryUrl(), taskData.getConnectorKind(), taskData.getTaskKind());
}
- public void configureTaskData(TaskRepository repository, RepositoryTaskData taskData) throws CoreException {
- updateAttributeOptions(repository, taskData);
- addValidOperations(taskData, repository.getUserName(), repository);
+ public void configureTaskData(RepositoryConfiguration configuration, TaskRepository repository, RepositoryTaskData taskData) throws CoreException {
+ updateAttributeOptions(configuration, taskData);
+ addValidOperations(configuration, taskData, repository.getUserName());
}
- private void addValidOperations(RepositoryTaskData bugReport, String userName, TaskRepository repository)
+ private void addValidOperations(RepositoryConfiguration configuration, RepositoryTaskData bugReport,String userName)
throws CoreException {
BUGZILLA_REPORT_STATUS status;
try {
@@ -207,48 +200,45 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
case UNCONFIRMED:
case REOPENED:
case NEW:
- addOperation(repository, bugReport, BUGZILLA_OPERATION.none, userName);
- addOperation(repository, bugReport, BUGZILLA_OPERATION.accept, userName);
- addOperation(repository, bugReport, BUGZILLA_OPERATION.resolve, userName);
- addOperation(repository, bugReport, BUGZILLA_OPERATION.duplicate, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.none, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.accept, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.resolve, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.duplicate, userName);
break;
case ASSIGNED:
- addOperation(repository, bugReport, BUGZILLA_OPERATION.none, userName);
- addOperation(repository, bugReport, BUGZILLA_OPERATION.resolve, userName);
- addOperation(repository, bugReport, BUGZILLA_OPERATION.duplicate, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.none, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.resolve, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.duplicate, userName);
break;
case RESOLVED:
- addOperation(repository, bugReport, BUGZILLA_OPERATION.none, userName);
- addOperation(repository, bugReport, BUGZILLA_OPERATION.reopen, userName);
- addOperation(repository, bugReport, BUGZILLA_OPERATION.verify, userName);
- addOperation(repository, bugReport, BUGZILLA_OPERATION.close, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.none, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.reopen, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.verify, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.close, userName);
break;
case CLOSED:
- addOperation(repository, bugReport, BUGZILLA_OPERATION.none, userName);
- addOperation(repository, bugReport, BUGZILLA_OPERATION.reopen, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.none, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.reopen, userName);
break;
case VERIFIED:
- addOperation(repository, bugReport, BUGZILLA_OPERATION.none, userName);
- addOperation(repository, bugReport, BUGZILLA_OPERATION.reopen, userName);
- addOperation(repository, bugReport, BUGZILLA_OPERATION.close, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.none, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.reopen, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.close, userName);
}
- String bugzillaVersion;
- try {
- bugzillaVersion = BugzillaCorePlugin.getRepositoryConfiguration(repository, false).getInstallVersion();
- } catch (CoreException e1) {
- // ignore
+ String bugzillaVersion = configuration.getInstallVersion();
+ if (bugzillaVersion == null) {
bugzillaVersion = "2.18";
}
if (bugzillaVersion.compareTo("3.1") < 0
&& (status == BUGZILLA_REPORT_STATUS.NEW || status == BUGZILLA_REPORT_STATUS.ASSIGNED
|| status == BUGZILLA_REPORT_STATUS.REOPENED || status == BUGZILLA_REPORT_STATUS.UNCONFIRMED)) {
// old bugzilla workflow is used
- addOperation(repository, bugReport, BUGZILLA_OPERATION.reassign, userName);
- addOperation(repository, bugReport, BUGZILLA_OPERATION.reassignbycomponent, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.reassign, userName);
+ addOperation(configuration, bugReport, BUGZILLA_OPERATION.reassignbycomponent, userName);
}
}
- private void addOperation(TaskRepository repository, RepositoryTaskData bugReport, BUGZILLA_OPERATION opcode,
+ private void addOperation(RepositoryConfiguration config, RepositoryTaskData bugReport, BUGZILLA_OPERATION opcode,
String userName) {
RepositoryOperation newOperation = null;
switch (opcode) {
@@ -263,12 +253,6 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
case resolve:
newOperation = new RepositoryOperation(opcode.toString(), OPERATION_LABEL_RESOLVE);
newOperation.setUpOptions(OPERATION_OPTION_RESOLUTION);
- RepositoryConfiguration config;
- try {
- config = BugzillaCorePlugin.getRepositoryConfiguration(repository, false);
- } catch (CoreException e) {
- config = null;
- }
if (config != null) {
for (String resolution : config.getResolutions()) {
// DUPLICATE and MOVED have special meanings so do not show as resolution
@@ -276,17 +260,18 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
newOperation.addOption(resolution, resolution);
}
} else {
- // LATER and REMIND must not be there in Bugzilla >= 3.0 is used
- //If getVersion() returns "Automatic (Use Validate Settings)" we use the Version 3 Resolution
- if (repository.getVersion().compareTo("3.0") >= 0) {
- for (BUGZILLA_RESOLUTION_3_0 resolution : BUGZILLA_RESOLUTION_3_0.values()) {
- newOperation.addOption(resolution.toString(), resolution.toString());
- }
- } else {
- for (BUGZILLA_RESOLUTION_2_0 resolution : BUGZILLA_RESOLUTION_2_0.values()) {
- newOperation.addOption(resolution.toString(), resolution.toString());
- }
- }
+ StatusHandler.log(new Status(IStatus.INFO, BugzillaCorePlugin.PLUGIN_ID, "Configuration is null"));
+// // LATER and REMIND must not be there in Bugzilla >= 3.0 is used
+// //If getVersion() returns "Automatic (Use Validate Settings)" we use the Version 3 Resolution
+// if (repository.getVersion().compareTo("3.0") >= 0) {
+// for (BUGZILLA_RESOLUTION_3_0 resolution : BUGZILLA_RESOLUTION_3_0.values()) {
+// newOperation.addOption(resolution.toString(), resolution.toString());
+// }
+// } else {
+// for (BUGZILLA_RESOLUTION_2_0 resolution : BUGZILLA_RESOLUTION_2_0.values()) {
+// newOperation.addOption(resolution.toString(), resolution.toString());
+// }
+// }
}
break;
case duplicate:
@@ -336,7 +321,7 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
data.removeAllAttributes();
RepositoryConfiguration repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(repository,
- false);
+ false, monitor);
RepositoryTaskAttribute a = BugzillaClient.makeNewAttribute(BugzillaReportElement.PRODUCT);
List<String> optionValues = repositoryConfiguration.getProducts();
@@ -496,14 +481,13 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
return true;
}
- public void updateAttributeOptions(TaskRepository taskRepository, RepositoryTaskData existingReport)
+ public void updateAttributeOptions(RepositoryConfiguration configuration, RepositoryTaskData existingReport)
throws CoreException {
String product = existingReport.getAttributeValue(BugzillaReportElement.PRODUCT.getKeyString());
for (RepositoryTaskAttribute attribute : existingReport.getAttributes()) {
if (attribute.getId().startsWith("cf_")) {
attribute.clearOptions();
- List<BugzillaCustomField> customFields = BugzillaCorePlugin.getRepositoryConfiguration(taskRepository,
- false).getCustomFields();
+ List<BugzillaCustomField> customFields = configuration.getCustomFields();
for (BugzillaCustomField bugzillaCustomField : customFields) {
if (bugzillaCustomField.getName().equals(attribute.getId())) {
@@ -517,8 +501,7 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
BugzillaReportElement element = BugzillaReportElement.valueOf(attribute.getId().trim().toUpperCase(
Locale.ENGLISH));
attribute.clearOptions();
- List<String> optionValues = BugzillaCorePlugin.getRepositoryConfiguration(taskRepository, false)
- .getOptionValues(element, product);
+ List<String> optionValues = configuration.getOptionValues(element, product);
if (element != BugzillaReportElement.OP_SYS && element != BugzillaReportElement.BUG_SEVERITY
&& element != BugzillaReportElement.PRIORITY && element != BugzillaReportElement.BUG_STATUS) {
Collections.sort(optionValues);
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java
index f9d30007b..d10c84129 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java
@@ -12,19 +12,24 @@ import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
+import java.net.MalformedURLException;
import java.net.URL;
import junit.framework.TestCase;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientFactory;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientManager;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
import org.eclipse.mylyn.internal.bugzilla.core.SaxConfigurationContentHandler;
import org.eclipse.mylyn.internal.bugzilla.core.XmlCleaner;
-import org.eclipse.mylyn.web.core.WebClientUtil;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.web.core.AuthenticationCredentials;
+import org.eclipse.mylyn.web.core.AuthenticationType;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -34,6 +39,8 @@ import org.xml.sax.helpers.XMLReaderFactory;
public class BugzillaConfigurationTest extends TestCase {
+ BugzillaClientManager bugzillaClientManager = new BugzillaClientManager();
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -44,10 +51,24 @@ public class BugzillaConfigurationTest extends TestCase {
super.tearDown();
}
+ private BugzillaClient createClient(String hostUrl, String username, String password, String htAuthUser,
+ String htAuthPass, String encoding) throws MalformedURLException, CoreException {
+ TaskRepository taskRepository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, hostUrl);
+
+ AuthenticationCredentials credentials = new AuthenticationCredentials(username, password);
+ taskRepository.setCredentials(AuthenticationType.REPOSITORY, credentials, false);
+
+ AuthenticationCredentials webCredentials = new AuthenticationCredentials(htAuthUser,
+ htAuthPass);
+ taskRepository.setCredentials(AuthenticationType.HTTP, webCredentials, false);
+ taskRepository.setCharacterEncoding(encoding);
+ return bugzillaClientManager.getClient(taskRepository, null);
+ }
+
public void test222RDFProductConfig() throws Exception {
- BugzillaClient client = BugzillaClientFactory.createClient(IBugzillaConstants.TEST_BUGZILLA_222_URL, "", "",
- "", "", WebClientUtil.getPlatformProxy(), "UTF-8");
+ BugzillaClient client = createClient(IBugzillaConstants.TEST_BUGZILLA_222_URL, "", "",
+ "", "", "UTF-8");
RepositoryConfiguration config = client.getRepositoryConfiguration();
assertNotNull(config);
assertEquals("2.22.1", config.getInstallVersion());
@@ -65,8 +86,8 @@ public class BugzillaConfigurationTest extends TestCase {
}
public void test2201RDFProductConfig() throws Exception {
- BugzillaClient client = BugzillaClientFactory.createClient(IBugzillaConstants.TEST_BUGZILLA_2201_URL, "", "",
- "", "", WebClientUtil.getPlatformProxy(), "UTF-8");
+ BugzillaClient client = createClient(IBugzillaConstants.TEST_BUGZILLA_2201_URL, "", "",
+ "", "", "UTF-8");
RepositoryConfiguration config = client.getRepositoryConfiguration();
assertNotNull(config);
assertEquals("2.20.1", config.getInstallVersion());
@@ -84,8 +105,8 @@ public class BugzillaConfigurationTest extends TestCase {
}
public void test220RDFProductConfig() throws Exception {
- BugzillaClient client = BugzillaClientFactory.createClient(IBugzillaConstants.TEST_BUGZILLA_220_URL, "", "",
- "", "", WebClientUtil.getPlatformProxy(), "UTF-8");
+ BugzillaClient client = createClient(IBugzillaConstants.TEST_BUGZILLA_220_URL, "", "",
+ "", "", "UTF-8");
RepositoryConfiguration config = client.getRepositoryConfiguration();
assertNotNull(config);
assertEquals("2.20.3", config.getInstallVersion());
@@ -103,8 +124,8 @@ public class BugzillaConfigurationTest extends TestCase {
}
public void test218RDFProductConfig() throws Exception {
- BugzillaClient client = BugzillaClientFactory.createClient(IBugzillaConstants.TEST_BUGZILLA_218_URL, "", "",
- "", "", WebClientUtil.getPlatformProxy(), "UTF-8");
+ BugzillaClient client = createClient(IBugzillaConstants.TEST_BUGZILLA_218_URL, "", "",
+ "", "", "UTF-8");
RepositoryConfiguration config = client.getRepositoryConfiguration();
assertNotNull(config);
assertEquals("2.18.6", config.getInstallVersion());
@@ -122,8 +143,8 @@ public class BugzillaConfigurationTest extends TestCase {
}
public void testEclipseRDFProductConfig() throws Exception {
- BugzillaClient client = BugzillaClientFactory.createClient(IBugzillaConstants.ECLIPSE_BUGZILLA_URL, "", "", "",
- "", WebClientUtil.getPlatformProxy(), "UTF-8");
+ BugzillaClient client = createClient(IBugzillaConstants.ECLIPSE_BUGZILLA_URL, "", "", "",
+ "", "UTF-8");
RepositoryConfiguration config = client.getRepositoryConfiguration();
assertNotNull(config);
assertEquals("3.0.1", config.getInstallVersion());
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java
index 755d0ee66..6fdbd3f6d 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java
@@ -51,7 +51,7 @@ public class BugzillaProductParserTest extends TestCase {
public void test222Products() throws Exception {
setRepository(IBugzillaConstants.TEST_BUGZILLA_222_URL);
- List<String> productList = BugzillaCorePlugin.getRepositoryConfiguration(repository, false).getProducts();
+ List<String> productList = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, null).getProducts();
Iterator<String> itr = productList.iterator();
assertTrue(itr.hasNext());
assertEquals("Read Only Test Cases", itr.next());
@@ -59,7 +59,7 @@ public class BugzillaProductParserTest extends TestCase {
public void test2201Products() throws Exception {
setRepository(IBugzillaConstants.TEST_BUGZILLA_2201_URL);
- List<String> productList = BugzillaCorePlugin.getRepositoryConfiguration(repository, false).getProducts();
+ List<String> productList = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, null).getProducts();
Iterator<String> itr = productList.iterator();
assertTrue(itr.hasNext());
assertEquals("TestProduct", "TestProduct", itr.next());
@@ -68,7 +68,7 @@ public class BugzillaProductParserTest extends TestCase {
public void test220Products() throws Exception {
setRepository(IBugzillaConstants.TEST_BUGZILLA_220_URL);
- List<String> productList = BugzillaCorePlugin.getRepositoryConfiguration(repository, false).getProducts();
+ List<String> productList = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, null).getProducts();
assertEquals(2, productList.size());
assertTrue(productList.contains("TestProduct"));
assertTrue(productList.contains("Widget"));
@@ -77,7 +77,7 @@ public class BugzillaProductParserTest extends TestCase {
public void test218Products() throws Exception {
setRepository(IBugzillaConstants.TEST_BUGZILLA_218_URL);
- List<String> productList = BugzillaCorePlugin.getRepositoryConfiguration(repository, false).getProducts();
+ List<String> productList = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, null).getProducts();
assertEquals(1, productList.size());
assertTrue(productList.contains("TestProduct"));
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
index 3008f2f7a..d1a380089 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
@@ -460,7 +460,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
}
// test anonymous update of configuration
- RepositoryConfiguration config = BugzillaCorePlugin.getRepositoryConfiguration(repository, false);
+ RepositoryConfiguration config = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, null);
assertNotNull(config);
assertTrue(config.getComponents().size() > 0);
}
@@ -630,9 +630,9 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
attachment.setFilename("real-file");
// IAttachmentHandler attachmentHandler =
// connector.getAttachmentHandler();
- BugzillaClient client = connector.getClientManager().getClient(repository);
+ BugzillaClient client = connector.getClientManager().getClient(repository, new NullProgressMonitor());
try {
- client.postAttachment(attachment.getReport().getTaskId(), attachment.getComment(), attachment);
+ client.postAttachment(attachment.getReport().getTaskId(), attachment.getComment(), attachment, null);
fail();
} catch (Exception e) {
}
@@ -658,7 +658,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
// repository.getUserName(), repository.getPassword(),
// Proxy.NO_PROXY));
try {
- client.postAttachment(attachment.getReport().getTaskId(), attachment.getComment(), attachment);
+ client.postAttachment(attachment.getReport().getTaskId(), attachment.getComment(), attachment, null);
fail();
} catch (Exception e) {
}
@@ -678,7 +678,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
assertTrue(fileToAttach.exists());
attachment.setFile(fileToAttach);
attachment.setFilename(fileToAttach.getName());
- client.postAttachment(attachment.getReport().getTaskId(), attachment.getComment(), attachment);
+ client.postAttachment(attachment.getReport().getTaskId(), attachment.getComment(), attachment, null);
task = (BugzillaTask) TasksUiUtil.createTask(repository, taskNumber, new NullProgressMonitor());
TasksUi.synchronizeTask(connector, task, true, null);
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryEditorWizardTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryEditorWizardTest.java
index c32081269..2df9f2025 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryEditorWizardTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryEditorWizardTest.java
@@ -8,6 +8,7 @@
package org.eclipse.mylyn.bugzilla.tests;
+import java.net.MalformedURLException;
import java.net.UnknownHostException;
import junit.framework.TestCase;
@@ -25,7 +26,8 @@ import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.wizards.EditRepositoryWizard;
import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.web.core.WebClientUtil;
+import org.eclipse.mylyn.web.core.AuthenticationCredentials;
+import org.eclipse.mylyn.web.core.AuthenticationType;
import org.eclipse.ui.PlatformUI;
/**
@@ -50,6 +52,20 @@ public class RepositoryEditorWizardTest extends TestCase {
TasksUiPlugin.getDefault().getRepositoriesFilePath());
}
+ private BugzillaClient createClient(String hostUrl, String username, String password, String htAuthUser,
+ String htAuthPass, String encoding) throws MalformedURLException {
+ TaskRepository taskRepository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, hostUrl);
+
+ AuthenticationCredentials credentials = new AuthenticationCredentials(username, password);
+ taskRepository.setCredentials(AuthenticationType.REPOSITORY, credentials, false);
+
+ AuthenticationCredentials webCredentials = new AuthenticationCredentials(htAuthUser,
+ htAuthPass);
+ taskRepository.setCredentials(AuthenticationType.HTTP, webCredentials, false);
+ taskRepository.setCharacterEncoding(encoding);
+ return BugzillaClientFactory.createClient(taskRepository);
+ }
+
public void testValidationInvalidPassword() throws Exception {
EditRepositoryWizard wizard = new EditRepositoryWizard(repository);
@@ -62,10 +78,10 @@ public class RepositoryEditorWizardTest extends TestCase {
// page.getHttpAuthPassword(), page.getCharacterEncoding());
page.setPassword("bogus");
try {
- BugzillaClient client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(),
+ BugzillaClient client = createClient(page.getServerUrl(), page.getUserName(),
page.getPassword(), page.getHttpAuthUserId(), page.getHttpAuthPassword(),
- WebClientUtil.getPlatformProxy(), page.getCharacterEncoding());
- client.validate();
+ page.getCharacterEncoding());
+ client.validate(null);
} catch (CoreException e) {
return;
}
@@ -79,10 +95,10 @@ public class RepositoryEditorWizardTest extends TestCase {
BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
page.setUserId("bogus");
try {
- BugzillaClient client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(),
+ BugzillaClient client = createClient(page.getServerUrl(), page.getUserName(),
page.getPassword(), page.getHttpAuthUserId(), page.getHttpAuthPassword(),
- WebClientUtil.getPlatformProxy(), page.getCharacterEncoding());
- client.validate();
+ page.getCharacterEncoding());
+ client.validate(null);
} catch (CoreException e) {
return;
}
@@ -96,10 +112,10 @@ public class RepositoryEditorWizardTest extends TestCase {
BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
page.setUrl("http://mylar.eclipse.org");
try {
- BugzillaClient client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(),
+ BugzillaClient client = createClient(page.getServerUrl(), page.getUserName(),
page.getPassword(), page.getHttpAuthUserId(), page.getHttpAuthPassword(),
- WebClientUtil.getPlatformProxy(), page.getCharacterEncoding());
- client.validate();
+ page.getCharacterEncoding());
+ client.validate(null);
} catch (CoreException e) {
assertTrue(e.getStatus().getException() instanceof UnknownHostException);
return;
@@ -132,10 +148,10 @@ public class RepositoryEditorWizardTest extends TestCase {
WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
dialog.create();
BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
- BugzillaClient client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(),
+ BugzillaClient client = createClient(page.getServerUrl(), page.getUserName(),
page.getPassword(), page.getHttpAuthUserId(), page.getHttpAuthPassword(),
- WebClientUtil.getPlatformProxy(), page.getCharacterEncoding());
- client.validate();
+ page.getCharacterEncoding());
+ client.validate(null);
page.setUrl(IBugzillaConstants.TEST_BUGZILLA_218_URL);
wizard.performFinish();
assertEquals(1, manager.getAllRepositories().size());
@@ -152,10 +168,10 @@ public class RepositoryEditorWizardTest extends TestCase {
WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
dialog.create();
BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
- BugzillaClient client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(),
+ BugzillaClient client = createClient(page.getServerUrl(), page.getUserName(),
page.getPassword(), page.getHttpAuthUserId(), page.getHttpAuthPassword(),
- WebClientUtil.getPlatformProxy(), page.getCharacterEncoding());
- client.validate();
+ page.getCharacterEncoding());
+ client.validate(null);
page.setUserId("bogus");
wizard.performFinish();
assertEquals(1, manager.getAllRepositories().size());
@@ -167,10 +183,10 @@ public class RepositoryEditorWizardTest extends TestCase {
dialog.create();
page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
try {
- client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(), page.getPassword(),
- page.getHttpAuthUserId(), page.getHttpAuthPassword(), WebClientUtil.getPlatformProxy(),
+ client = createClient(page.getServerUrl(), page.getUserName(), page.getPassword(),
+ page.getHttpAuthUserId(), page.getHttpAuthPassword(),
page.getCharacterEncoding());
- client.validate();
+ client.validate(null);
} catch (CoreException e) {
return;
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaTaskHistoryTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaTaskHistoryTest.java
index b4b810753..94b652143 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaTaskHistoryTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaTaskHistoryTest.java
@@ -52,9 +52,9 @@ public class BugzillaTaskHistoryTest extends AbstractBugzillaTest {
public void testGetBugHistory() throws Exception {
- BugzillaClient client = connector.getClientManager().getClient(repository);
+ BugzillaClient client = connector.getClientManager().getClient(repository, null);
assertNotNull(client);
- TaskHistory history = client.getHistory("1");
+ TaskHistory history = client.getHistory("1", null);
assertNotNull(history);
assertEquals(1, history.getAssignmentEvents().size());
@@ -64,9 +64,9 @@ public class BugzillaTaskHistoryTest extends AbstractBugzillaTest {
}
public void testAssignmentEvent() throws Exception {
- BugzillaClient client = connector.getClientManager().getClient(repository);
+ BugzillaClient client = connector.getClientManager().getClient(repository, null);
assertNotNull(client);
- TaskHistory history = client.getHistory("1");
+ TaskHistory history = client.getHistory("1", null);
assertNotNull(history);
AssignmentEvent assignment = history.getAssignmentEvents().get(0);
@@ -80,9 +80,9 @@ public class BugzillaTaskHistoryTest extends AbstractBugzillaTest {
public void testStatusEvent() throws Exception {
- BugzillaClient client = connector.getClientManager().getClient(repository);
+ BugzillaClient client = connector.getClientManager().getClient(repository, null);
assertNotNull(client);
- TaskHistory history = client.getHistory("1");
+ TaskHistory history = client.getHistory("1", null);
assertNotNull(history);
StatusEvent statusChange = history.getStatusEvents().get(0);
@@ -94,9 +94,9 @@ public class BugzillaTaskHistoryTest extends AbstractBugzillaTest {
}
public void testResolutionEvent() throws Exception {
- BugzillaClient client = connector.getClientManager().getClient(repository);
+ BugzillaClient client = connector.getClientManager().getClient(repository, null);
assertNotNull(client);
- TaskHistory history = client.getHistory(REPORT_ID);
+ TaskHistory history = client.getHistory(REPORT_ID, null);
assertNotNull(history);
ResolutionEvent resolutionChange = history.getResolutionEvents().get(0);
@@ -108,9 +108,9 @@ public class BugzillaTaskHistoryTest extends AbstractBugzillaTest {
}
public void testStoredHistory() throws Exception {
- BugzillaClient client = connector.getClientManager().getClient(repository);
+ BugzillaClient client = connector.getClientManager().getClient(repository, null);
assertNotNull(client);
- TaskHistory history = client.getHistory(REPORT_ID);
+ TaskHistory history = client.getHistory(REPORT_ID, null);
assertNotNull(history);
storeHistory(history);
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java
index 8d8d655fb..ba50099f7 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java
@@ -16,6 +16,7 @@ import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -130,7 +131,8 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor {
RepositoryTaskAttribute attribute = null;
try {
RepositoryConfiguration configuration = BugzillaCorePlugin.getRepositoryConfiguration(this.repository,
- false);
+ false, new NullProgressMonitor());
+
if (configuration != null) {
List<BugzillaCustomField> customFields = configuration.getCustomFields();
if (!customFields.isEmpty()) {
@@ -621,7 +623,7 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor {
List<String> validKeywords = new ArrayList<String>();
try {
- validKeywords = BugzillaCorePlugin.getRepositoryConfiguration(repository, false).getKeywords();
+ validKeywords = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, new NullProgressMonitor()).getKeywords();
} catch (Exception ex) {
// ignore
}
@@ -709,7 +711,7 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor {
if (assignedAttribute != null) {
String bugzillaVersion;
try {
- bugzillaVersion = BugzillaCorePlugin.getRepositoryConfiguration(repository, false).getInstallVersion();
+ bugzillaVersion = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, new NullProgressMonitor()).getInstallVersion();
} catch (CoreException e1) {
// ignore
bugzillaVersion = "2.18";
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/NewBugzillaTaskEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/NewBugzillaTaskEditor.java
index be82d8e09..8fe99a018 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/NewBugzillaTaskEditor.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/NewBugzillaTaskEditor.java
@@ -9,6 +9,7 @@ package org.eclipse.mylyn.internal.bugzilla.ui.editor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
import org.eclipse.jface.layout.GridDataFactory;
@@ -164,7 +165,7 @@ public class NewBugzillaTaskEditor extends AbstractNewRepositoryTaskEditor {
if (assignedAttribute != null) {
String bugzillaVersion;
try {
- bugzillaVersion = BugzillaCorePlugin.getRepositoryConfiguration(repository, false).getInstallVersion();
+ bugzillaVersion = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, new NullProgressMonitor()).getInstallVersion();
} catch (CoreException e1) {
// ignore
bugzillaVersion = "2.18";
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java
index 487ae8a48..ff723e06f 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java
@@ -18,6 +18,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
@@ -1039,7 +1040,7 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L
updateAttributesFromConfiguration(null);
if (product.getItemCount() == 0) {
try {
- repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(repository, true);
+ repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(repository, true, new NullProgressMonitor());
updateAttributesFromConfiguration(null);
} catch (final CoreException e1) {
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@@ -1846,7 +1847,7 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L
}
try {
monitor.beginTask("Updating search options...", IProgressMonitor.UNKNOWN);
- repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(repository, force);
+ repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(repository, force, monitor);
} catch (final Exception e) {
throw new InvocationTargetException(e);
} finally {
@@ -1858,9 +1859,9 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L
try {
// TODO: make cancelable (bug 143011)
if (getContainer() != null) {
- getContainer().run(true, false, updateRunnable);
+ getContainer().run(true, true, updateRunnable);
} else if (scontainer != null) {
- scontainer.getRunnableContext().run(true, false, updateRunnable);
+ scontainer.getRunnableContext().run(true, true, updateRunnable);
} else {
IProgressService service = PlatformUI.getWorkbench().getProgressService();
service.busyCursorWhile(updateRunnable);
@@ -1901,6 +1902,9 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L
StatusHandler.log(new Status(IStatus.ERROR, BugzillaUiPlugin.PLUGIN_ID, cause.getMessage(),
cause));
}
+ }
+ if(ex.getCause() instanceof OperationCanceledException) {
+ return;
}
MessageDialog.openError(shell, "Error updating search options", "Error was: "
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java
index 35f6293b9..ad20a2188 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java
@@ -11,7 +11,6 @@ package org.eclipse.mylyn.internal.bugzilla.ui.tasklist;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
-import java.net.Proxy;
import java.net.URL;
import java.util.List;
@@ -213,7 +212,7 @@ public class BugzillaRepositorySettingsPage extends AbstractRepositorySettingsPa
try {
monitor.beginTask("Retrieving repository configuration", IProgressMonitor.UNKNOWN);
repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(repository,
- false);
+ false, monitor);
if (repositoryConfiguration != null) {
platform = repository.getProperty(IBugzillaConstants.BUGZILLA_DEF_PLATFORM);
os = repository.getProperty(IBugzillaConstants.BUGZILLA_DEF_OS);
@@ -423,34 +422,37 @@ public class BugzillaRepositorySettingsPage extends AbstractRepositorySettingsPa
public class BugzillaValidator extends Validator {
- final String serverUrl;
-
- final String newUserId;
-
- final String newPassword;
-
- final boolean isAnonymous;
-
- final String newEncoding;
-
- final String httpAuthUser;
-
- final String httpAuthPass;
-
- final Proxy proxy;
+// final String serverUrl;
+//
+// final String newUserId;
+//
+// final String newPassword;
+//
+// final boolean isAnonymous;
+//
+// final String newEncoding;
+//
+// final String httpAuthUser;
+//
+// final String httpAuthPass;
+//
+// final Proxy proxy;
+
+ final TaskRepository repository;
private String[] versions = new String[1];;
public BugzillaValidator(TaskRepository repository, String version) {
- serverUrl = getServerUrl();
- newUserId = getUserName();
- newPassword = getPassword();
- isAnonymous = isAnonymousAccess();
- newEncoding = getCharacterEncoding();
- httpAuthUser = getHttpAuthUserId();
- httpAuthPass = getHttpAuthPassword();
- proxy = repository.getProxy();
+// serverUrl = getServerUrl();
+// newUserId = getUserName();
+// newPassword = getPassword();
+// isAnonymous = isAnonymousAccess();
+// newEncoding = getCharacterEncoding();
+// httpAuthUser = getHttpAuthUserId();
+// httpAuthPass = getHttpAuthPassword();
+// proxy = repository.getProxy();
versions[0] = version;
+ this.repository = repository;
}
@Override
@@ -458,7 +460,7 @@ public class BugzillaRepositorySettingsPage extends AbstractRepositorySettingsPa
try {
validate(monitor);
} catch (Exception e) {
- displayError(serverUrl, e);
+ displayError(repository.getRepositoryUrl(), e);
}
}
@@ -505,9 +507,8 @@ public class BugzillaRepositorySettingsPage extends AbstractRepositorySettingsPa
// client.logout();
// } else
if (versions != null) {
- client = BugzillaClientFactory.createClient(serverUrl, newUserId, newPassword, httpAuthUser,
- httpAuthPass, proxy, newEncoding);
- client.validate();
+ client = BugzillaClientFactory.createClient(repository);
+ client.validate(monitor);
}
if (checkVersion && client != null) {
RepositoryConfiguration config = client.getRepositoryConfiguration();
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java
index bb8421da5..dbffc362f 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java
@@ -10,10 +10,12 @@
*/
package org.eclipse.mylyn.internal.bugzilla.ui.tasklist;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTask;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTaskDataHandler;
+import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TasksUi;
@@ -82,7 +84,8 @@ public class BugzillaTaskEditorInput extends RepositoryTaskEditorInput {
if (taskData != null) {
BugzillaRepositoryConnector bugzillaConnector = (BugzillaRepositoryConnector) TasksUi.getRepositoryManager()
.getRepositoryConnector(BugzillaCorePlugin.REPOSITORY_KIND);
- ((BugzillaTaskDataHandler)bugzillaConnector.getTaskDataHandler()).updateAttributeOptions(repository, taskData);
+ RepositoryConfiguration config = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, new NullProgressMonitor());
+ ((BugzillaTaskDataHandler)bugzillaConnector.getTaskDataHandler()).updateAttributeOptions(config, taskData);
}
} catch (Exception e) {
// ignore
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaProductPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaProductPage.java
index 73cacd6b6..0fbac1600 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaProductPage.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaProductPage.java
@@ -20,6 +20,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
@@ -254,7 +255,7 @@ public class BugzillaProductPage extends WizardPage {
RepositoryConfiguration repositoryConfiguration = null;
try {
- repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(repository, false);
+ repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, monitor);
} catch (final CoreException e) {
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
public void run() {
@@ -292,7 +293,7 @@ public class BugzillaProductPage extends WizardPage {
private void initProducts() {
// try to get the list of products from the server
try {
- products = BugzillaCorePlugin.getRepositoryConfiguration(repository, false).getProducts();
+ products = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, new NullProgressMonitor()).getProducts();
} catch (final CoreException e) {
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/SynchronizeRepositoriesJob.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/SynchronizeRepositoriesJob.java
index 01c564937..7be844e88 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/SynchronizeRepositoriesJob.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/SynchronizeRepositoriesJob.java
@@ -114,11 +114,11 @@ public class SynchronizeRepositoriesJob extends SynchronizationJob {
private void updateRepositoryConfiguration(TaskRepository repository, AbstractRepositoryConnector connector,
IProgressMonitor monitor) throws InterruptedException {
try {
+ if (!isUser()) {
+ monitor = Policy.backgroundMonitorFor(monitor);
+ }
monitor.beginTask("Updating repository configuration for " + repository.getRepositoryUrl(), 100);
- if (connector.isRepositoryConfigurationStale(repository)) {
- if (!isUser()) {
- monitor = Policy.backgroundMonitorFor(monitor);
- }
+ if (connector.isRepositoryConfigurationStale(repository, monitor)) {
connector.updateRepositoryConfiguration(repository, monitor);
}
} catch (CoreException e) {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java
index 16e3df54e..94fbd70f5 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java
@@ -421,10 +421,14 @@ public abstract class AbstractRepositoryConnector {
/**
* Default implementation returns true every 24hrs
*
+ * @param monitor
+ * TODO
+ *
* @return true to indicate that the repository configuration is stale and requires update
* @throws CoreException
*/
- public boolean isRepositoryConfigurationStale(TaskRepository repository) throws CoreException {
+ public boolean isRepositoryConfigurationStale(TaskRepository repository, IProgressMonitor monitor)
+ throws CoreException {
boolean isStale = true;
Date configDate = repository.getConfigurationDate();
if (configDate != null) {
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
index db142cacf..b64bb5508 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
@@ -21,7 +21,6 @@ import java.util.StringTokenizer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.mylyn.internal.trac.core.TracAttributeFactory.Attribute;
import org.eclipse.mylyn.internal.trac.core.TracTask.Kind;
@@ -380,7 +379,7 @@ public class TracTaskDataHandler extends AbstractTaskDataHandler {
throws CoreException {
try {
ITracClient client = connector.getClientManager().getRepository(repository);
- client.updateAttributes(new NullProgressMonitor(), false);
+ client.updateAttributes(monitor, false);
createDefaultAttributes(attributeFactory, data, client, false);
return true;
} catch (OperationCanceledException e) {
@@ -464,5 +463,5 @@ public class TracTaskDataHandler extends AbstractTaskDataHandler {
true));
}
}
-
+
}

Back to the top