Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2006-11-22 01:16:33 -0500
committerspingel2006-11-22 01:16:33 -0500
commit6f1364ccaede162b2df21494b42799c699963c70 (patch)
tree0717b9d24b52e0aad36188b1de6b9a27eb93130c /org.eclipse.mylyn.trac.core/src
parent1f18365d1c8c872d154de80d082840b24cbf5350 (diff)
downloadorg.eclipse.mylyn.tasks-6f1364ccaede162b2df21494b42799c699963c70.tar.gz
org.eclipse.mylyn.tasks-6f1364ccaede162b2df21494b42799c699963c70.tar.xz
org.eclipse.mylyn.tasks-6f1364ccaede162b2df21494b42799c699963c70.zip
NEW - bug 165412: Trac does not use proxy
https://bugs.eclipse.org/bugs/show_bug.cgi?id=165412
Diffstat (limited to 'org.eclipse.mylyn.trac.core/src')
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/AbstractTracClient.java3
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/Trac09Client.java5
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientFactory.java17
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientManager.java6
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracXmlRpcClient.java22
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/util/TracHttpClientTransportFactory.java14
6 files changed, 40 insertions, 27 deletions
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/AbstractTracClient.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/AbstractTracClient.java
index ad01317f3..4106563ba 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/AbstractTracClient.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/AbstractTracClient.java
@@ -41,11 +41,12 @@ public abstract class AbstractTracClient implements ITracClient {
protected Proxy proxy;
- public AbstractTracClient(URL repositoryUrl, Version version, String username, String password) {
+ public AbstractTracClient(URL repositoryUrl, Version version, String username, String password, Proxy proxy) {
this.repositoryUrl = repositoryUrl;
this.version = version;
this.username = username;
this.password = password;
+ this.proxy = proxy;
this.data = new TracClientData();
}
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/Trac09Client.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/Trac09Client.java
index eba14b5c6..4cf8a0cdf 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/Trac09Client.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/Trac09Client.java
@@ -15,6 +15,7 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
+import java.net.Proxy;
import java.net.URL;
import java.text.ParseException;
import java.util.ArrayList;
@@ -67,8 +68,8 @@ public class Trac09Client extends AbstractTracClient {
private boolean authenticated;
- public Trac09Client(URL url, Version version, String username, String password) {
- super(url, version, username, password);
+ public Trac09Client(URL url, Version version, String username, String password, Proxy proxy) {
+ super(url, version, username, password, proxy);
}
private GetMethod connect(String serverURL) throws TracException {
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientFactory.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientFactory.java
index 50b7ea6e3..9d06153e8 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientFactory.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientFactory.java
@@ -12,6 +12,7 @@
package org.eclipse.mylar.internal.trac.core;
import java.net.MalformedURLException;
+import java.net.Proxy;
import java.net.URL;
import org.eclipse.mylar.internal.trac.core.ITracClient.Version;
@@ -21,14 +22,14 @@ import org.eclipse.mylar.internal.trac.core.ITracClient.Version;
*/
public class TracClientFactory {
- public static ITracClient createClient(String location, Version version, String username, String password)
- throws MalformedURLException {
+ public static ITracClient createClient(String location, Version version, String username, String password,
+ Proxy proxy) throws MalformedURLException {
URL url = new URL(location);
if (version == Version.TRAC_0_9) {
- return new Trac09Client(url, version, username, password);
+ return new Trac09Client(url, version, username, password, proxy);
} else if (version == Version.XML_RPC) {
- return new TracXmlRpcClient(url, version, username, password);
+ return new TracXmlRpcClient(url, version, username, password, proxy);
}
throw new RuntimeException("Invalid repository version: " + version);
@@ -41,16 +42,16 @@ public class TracClientFactory {
* <p>
* Order of the tried access types: XML-RPC, Trac 0.9
*/
- public static Version probeClient(String location, String username, String password) throws MalformedURLException,
- TracException {
+ public static Version probeClient(String location, String username, String password, Proxy proxy)
+ throws MalformedURLException, TracException {
URL url = new URL(location);
try {
- ITracClient repository = new TracXmlRpcClient(url, Version.XML_RPC, username, password);
+ ITracClient repository = new TracXmlRpcClient(url, Version.XML_RPC, username, password, proxy);
repository.validate();
return Version.XML_RPC;
} catch (TracException e) {
try {
- ITracClient repository = new Trac09Client(url, Version.TRAC_0_9, username, password);
+ ITracClient repository = new Trac09Client(url, Version.TRAC_0_9, username, password, proxy);
repository.validate();
return Version.TRAC_0_9;
} catch (TracLoginException e2) {
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientManager.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientManager.java
index 329b7104f..8480f9783 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientManager.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientManager.java
@@ -48,7 +48,8 @@ public class TracClientManager implements ITaskRepositoryListener {
ITracClient repository = clientByUrl.get(taskRepository.getUrl());
if (repository == null) {
repository = TracClientFactory.createClient(taskRepository.getUrl(), Version.fromVersion(taskRepository
- .getVersion()), taskRepository.getUserName(), taskRepository.getPassword());
+ .getVersion()), taskRepository.getUserName(), taskRepository.getPassword(), taskRepository
+ .getProxy());
clientByUrl.put(taskRepository.getUrl(), repository);
TracClientData data = clientDataByUrl.get(taskRepository.getUrl());
@@ -78,7 +79,8 @@ public class TracClientManager implements ITaskRepositoryListener {
public synchronized void repositorySettingsChanged(TaskRepository repository) {
clientByUrl.remove(repository.getUrl());
- // if url is changed a stale data object will be left in clientDataByUrl, bug #149939
+ // if url is changed a stale data object will be left in
+ // clientDataByUrl, bug #149939
}
@SuppressWarnings("unchecked")
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracXmlRpcClient.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracXmlRpcClient.java
index 60b9de3f1..8a78858c5 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracXmlRpcClient.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracXmlRpcClient.java
@@ -1,6 +1,7 @@
package org.eclipse.mylar.internal.trac.core;
import java.net.HttpURLConnection;
+import java.net.Proxy;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
@@ -48,8 +49,10 @@ public class TracXmlRpcClient extends AbstractTracClient {
private XmlRpcClient xmlrpc;
- public TracXmlRpcClient(URL url, Version version, String username, String password) {
- super(url, version, username, password);
+ private TracHttpClientTransportFactory factory;
+
+ public TracXmlRpcClient(URL url, Version version, String username, String password, Proxy proxy) {
+ super(url, version, username, password, proxy);
}
public synchronized XmlRpcClient getClient() throws TracException {
@@ -64,11 +67,12 @@ public class TracXmlRpcClient extends AbstractTracClient {
config.setServerURL(getXmlRpcUrl());
config.setTimeZone(TimeZone.getTimeZone(ITracClient.TIME_ZONE));
config.setContentLengthOptional(false);
-
+
xmlrpc = new XmlRpcClient();
xmlrpc.setConfig(config);
- TracHttpClientTransportFactory factory = new TracHttpClientTransportFactory(xmlrpc);
+ factory = new TracHttpClientTransportFactory(xmlrpc);
+ factory.setProxy(proxy);
xmlrpc.setTransportFactory(factory);
return xmlrpc;
@@ -448,4 +452,14 @@ public class TracXmlRpcClient extends AbstractTracClient {
return result;
}
+ @Override
+ public void setProxy(Proxy proxy) {
+ super.setProxy(proxy);
+
+ synchronized (this) {
+ if (factory != null) {
+ factory.setProxy(proxy);
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/util/TracHttpClientTransportFactory.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/util/TracHttpClientTransportFactory.java
index e620a4888..9e63471fd 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/util/TracHttpClientTransportFactory.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/util/TracHttpClientTransportFactory.java
@@ -54,9 +54,11 @@ public class TracHttpClientTransportFactory implements XmlRpcTransportFactory {
private Proxy proxy;
- public TracHttpClientTransport(XmlRpcClient client) {
+ public TracHttpClientTransport(XmlRpcClient client, Proxy proxy) {
super(client);
+ this.proxy = proxy;
+
XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) client.getConfig();
// this needs to be set to avoid exceptions
getHttpClient().getParams().setAuthenticationPreemptive(config.getBasicUserName() != null);
@@ -137,14 +139,6 @@ public class TracHttpClientTransportFactory implements XmlRpcTransportFactory {
method.getParams().setVersion(HttpVersion.HTTP_1_1);
}
- public void setProxy(Proxy proxy) {
- this.proxy = proxy;
- }
-
- public Proxy getProxy() {
- return this.proxy;
- }
-
}
private XmlRpcClient client;
@@ -155,7 +149,7 @@ public class TracHttpClientTransportFactory implements XmlRpcTransportFactory {
}
public XmlRpcTransport getTransport() {
- return new TracHttpClientTransport(client);
+ return new TracHttpClientTransport(client, proxy);
}
public Proxy getProxy() {

Back to the top