Bug 189917 [org.eclipse.core.net] provide a way to specify installation-specific proxy preferences
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/PreferenceModifyListener.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/PreferenceModifyListener.java
index 212407b..36a0155 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/PreferenceModifyListener.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/PreferenceModifyListener.java
@@ -20,7 +20,7 @@
}
public IEclipsePreferences preApply(IEclipsePreferences node) {
- ((ProxyManager)ProxyManager.getProxyManager()).migrateUpdateHttpProxy(node.node("instance")); //$NON-NLS-1$
+ ((ProxyManager)ProxyManager.getProxyManager()).migrateUpdateHttpProxy(node.node("instance"), false); //$NON-NLS-1$
return super.preApply(node);
}
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java
index f57c900..4b67eb8 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java
@@ -214,7 +214,7 @@
public void initialize() {
// First see if there is an http proxy to migrate
- migrateUpdateHttpProxy(new InstanceScope().getNode("")); //$NON-NLS-1$
+ migrateUpdateHttpProxy(new InstanceScope().getNode(""), true); //$NON-NLS-1$
((IEclipsePreferences)Activator.getInstance().getInstancePreferences()).addPreferenceChangeListener(this);
// Now initialize each proxy type
for (int i = 0; i < proxies.length; i++) {
@@ -305,31 +305,14 @@
}
}
- void migrateUpdateHttpProxy(Preferences node) {
+ void migrateUpdateHttpProxy(Preferences node, boolean checkSystemProperties) {
Preferences netPrefs = node.node(Activator.ID);
if (!netPrefs.getBoolean(PREF_HAS_MIGRATED, false)) {
netPrefs.putBoolean(PREF_HAS_MIGRATED, true);
Preferences updatePrefs = node.node("org.eclipse.update.core"); //$NON-NLS-1$
- String httpProxyHost = updatePrefs.get(HTTP_PROXY_HOST, ""); //$NON-NLS-1$
- if ("".equals(httpProxyHost)) //$NON-NLS-1$
- httpProxyHost = null;
- updatePrefs.remove(HTTP_PROXY_HOST);
-
- String httpProxyPort = updatePrefs.get(HTTP_PROXY_PORT, ""); //$NON-NLS-1$
- if ("".equals(httpProxyPort)) //$NON-NLS-1$
- httpProxyPort = null;
- int port = -1;
- if (httpProxyPort != null)
- try {
- port = Integer.parseInt(httpProxyPort);
- } catch (NumberFormatException e) {
- // Ignore
- }
- updatePrefs.remove(HTTP_PROXY_PORT);
-
- boolean httpProxyEnable = updatePrefs.getBoolean(HTTP_PROXY_ENABLE, false);
- updatePrefs.remove(HTTP_PROXY_ENABLE);
-
+ String httpProxyHost = getHostToMigrate(updatePrefs, checkSystemProperties);
+ int port = getPortToMigrate(updatePrefs, checkSystemProperties);
+ boolean httpProxyEnable = getEnablementToMigrate(updatePrefs, checkSystemProperties);
if (httpProxyHost != null) {
ProxyData proxyData = new ProxyData(IProxyData.HTTP_PROXY_TYPE, httpProxyHost, port, false);
ProxyType type = getType(proxyData);
@@ -341,6 +324,44 @@
}
}
+ private boolean getEnablementToMigrate(Preferences updatePrefs, boolean checkSystemProperties) {
+ boolean httpProxyEnable = false;
+ if (checkSystemProperties && updatePrefs.get(HTTP_PROXY_ENABLE, null) == null) {
+ httpProxyEnable = Boolean.getBoolean("http.proxySet"); //$NON-NLS-1$
+ } else {
+ httpProxyEnable = updatePrefs.getBoolean(HTTP_PROXY_ENABLE, false);
+ updatePrefs.remove(HTTP_PROXY_ENABLE);
+ }
+ return httpProxyEnable;
+ }
+
+ private int getPortToMigrate(Preferences updatePrefs, boolean checkSystemProperties) {
+ String httpProxyPort = updatePrefs.get(HTTP_PROXY_PORT, ""); //$NON-NLS-1$
+ if (checkSystemProperties && "".equals(httpProxyPort)) { //$NON-NLS-1$
+ httpProxyPort = System.getProperty("http.proxyPort", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ updatePrefs.remove(HTTP_PROXY_PORT);
+ int port = -1;
+ if (httpProxyPort != null && !"".equals(httpProxyPort)) //$NON-NLS-1$
+ try {
+ port = Integer.parseInt(httpProxyPort);
+ } catch (NumberFormatException e) {
+ // Ignore
+ }
+ return port;
+ }
+
+ private String getHostToMigrate(Preferences updatePrefs, boolean checkSystemProperties) {
+ String httpProxyHost = updatePrefs.get(HTTP_PROXY_HOST, ""); //$NON-NLS-1$
+ if (checkSystemProperties && "".equals(httpProxyHost)) { //$NON-NLS-1$
+ httpProxyHost = System.getProperty("http.proxyHost", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ if ("".equals(httpProxyHost)) //$NON-NLS-1$
+ httpProxyHost = null;
+ updatePrefs.remove(HTTP_PROXY_HOST);
+ return httpProxyHost;
+ }
+
public void preferenceChange(PreferenceChangeEvent event) {
if (event.getKey().equals(PREF_ENABLED)) {
internalSetEnabled(Activator.getInstance().getInstancePreferences().getBoolean(PREF_ENABLED, false));
diff --git a/bundles/org.eclipse.team.core/buildnotes_team.html b/bundles/org.eclipse.team.core/buildnotes_team.html
index 38ca2ff..833ddb6 100644
--- a/bundles/org.eclipse.team.core/buildnotes_team.html
+++ b/bundles/org.eclipse.team.core/buildnotes_team.html
@@ -12,6 +12,12 @@
<h1>Eclipse Platform Build Notes (3.3)<br>
Team, Compare and CVS</h1>
+<p>Integration Build (May 31, 2007, 4:28 p.m.)</p>
+ <p>Problem reports updated</p>
+ <p>
+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=189917">Bug 189917</a>. [org.eclipse.core.net] provide a way to specify installation-specific proxy preferences (ASSIGNED)<br>
+ </p>
+
<p>Integration Build (May 29, 2007, 1:16 p.m.)</p>
<p>Problem reports updated</p>
<p>