Author: adietish
Date: 2012-10-23 10:32:27 -0400 (Tue, 23 Oct 2012)
New Revision: 44610
Modified:
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/Connection.java
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/ConnectionUtils.java
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/ConnectionsModel.java
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/util/UrlUtils.java
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsSection.java
Log:
[JBIDE-12923] fixed parsing of connection-url when loading it from preferences. URI gets
confused by empty host name (returns null username), URL allows empty host name.
Modified:
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
===================================================================
---
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-10-23
12:13:59 UTC (rev 44609)
+++
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-10-23
14:32:27 UTC (rev 44610)
@@ -12,7 +12,6 @@
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
-import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -173,7 +172,7 @@
connectionValue = ConnectionUtils.getUrlForUsername(username);
} catch (UnsupportedEncodingException e) {
OpenShiftUIActivator.log(NLS.bind("Could not get connection url for user
{0}", username), e);
- } catch (URISyntaxException e) {
+ } catch (MalformedURLException e) {
OpenShiftUIActivator.log(NLS.bind("Could not get connection url for user
{0}", username), e);
}
}
Modified:
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/Connection.java
===================================================================
---
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/Connection.java 2012-10-23
12:13:59 UTC (rev 44609)
+++
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/Connection.java 2012-10-23
14:32:27 UTC (rev 44610)
@@ -15,10 +15,11 @@
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
-import java.net.URI;
import java.net.URL;
import java.util.List;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.osgi.util.NLS;
import org.jboss.tools.openshift.express.internal.core.util.UrlUtils;
import org.jboss.tools.openshift.express.internal.core.util.UrlUtils.UrlPortions;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
@@ -73,9 +74,12 @@
this.prompter = prompter;
}
- public Connection(URI url, ICredentialsPrompter prompter) throws
UnsupportedEncodingException {
+ public Connection(URL url, ICredentialsPrompter prompter) throws
UnsupportedEncodingException {
UrlPortions portions = UrlUtils.toPortions(url);
this.username = portions.getUsername();
+ Assert.isLegal(
+ StringUtils.isEmpty(username),
+ NLS.bind("There is no no username for connection to url {0}",
url.toString()));
this.password = portions.getPassword();
setHost(portions.getHost());
this.prompter = prompter;
Modified:
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/ConnectionUtils.java
===================================================================
---
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/ConnectionUtils.java 2012-10-23
12:13:59 UTC (rev 44609)
+++
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/ConnectionUtils.java 2012-10-23
14:32:27 UTC (rev 44610)
@@ -11,7 +11,7 @@
package org.jboss.tools.openshift.express.internal.core.connection;
import java.io.UnsupportedEncodingException;
-import java.net.URISyntaxException;
+import java.net.MalformedURLException;
import org.jboss.tools.openshift.express.internal.core.util.UrlUtils;
import org.jboss.tools.openshift.express.internal.core.util.UrlUtils.UrlPortions;
@@ -30,7 +30,7 @@
// inhibit instantiation
}
- public static String getUrlForUsername(String username) throws
UnsupportedEncodingException, URISyntaxException {
+ public static String getUrlForUsername(String username) throws
UnsupportedEncodingException, MalformedURLException {
UrlPortions portions = UrlUtils.toPortions(getDefaultHostUrl());
return UrlUtils.getUrlFor(username, portions.getHost(), portions.getProtocol());
}
Modified:
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/ConnectionsModel.java
===================================================================
---
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/ConnectionsModel.java 2012-10-23
12:13:59 UTC (rev 44609)
+++
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/ConnectionsModel.java 2012-10-23
14:32:27 UTC (rev 44610)
@@ -11,8 +11,8 @@
package org.jboss.tools.openshift.express.internal.core.connection;
import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -173,13 +173,15 @@
for (int i = 0; i < connections.length; i++) {
Connection connection = null;
try {
- URI connectionUrl = new URI(connections[i]);
+ URL connectionUrl = new URL(connections[i]);
connection = new Connection(connectionUrl, new CredentialsPrompter());
addConnection(connection);
- } catch (URISyntaxException e) {
+ } catch (MalformedURLException e) {
OpenShiftUIActivator.log(NLS.bind("Could not add connection for {0}.",
connections[i]), e);
} catch (UnsupportedEncodingException e) {
OpenShiftUIActivator.log(NLS.bind("Could not add connection for {0}.",
connections[i]), e);
+ } catch (IllegalArgumentException e) {
+ OpenShiftUIActivator.log(NLS.bind("Could not add connection for {0}.",
connections[i]), e);
}
}
}
Modified:
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/util/UrlUtils.java
===================================================================
---
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/util/UrlUtils.java 2012-10-23
12:13:59 UTC (rev 44609)
+++
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/util/UrlUtils.java 2012-10-23
14:32:27 UTC (rev 44610)
@@ -11,8 +11,8 @@
package org.jboss.tools.openshift.express.internal.core.util;
import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
@@ -34,11 +34,11 @@
// inhibit instantiation
}
- public static UrlPortions toPortions(String url) throws UnsupportedEncodingException,
URISyntaxException {
- return new UrlPortions(new URI(url));
+ public static UrlPortions toPortions(String url) throws UnsupportedEncodingException,
MalformedURLException {
+ return new UrlPortions(new URL(url));
}
- public static UrlPortions toPortions(URI url) throws UnsupportedEncodingException {
+ public static UrlPortions toPortions(URL url) throws UnsupportedEncodingException {
return new UrlPortions(url);
}
@@ -49,7 +49,7 @@
private String password;
private String host;
- private UrlPortions(URI url) throws UnsupportedEncodingException {
+ private UrlPortions(URL url) throws UnsupportedEncodingException {
String userInfo = url.getUserInfo();
if (userInfo != null) {
String[] userInfos = url.getUserInfo().split(":");
@@ -61,7 +61,7 @@
}
}
this.host = url.getHost();
- this.protocol = url.getScheme();
+ this.protocol = url.getProtocol();
}
public String getUsername() {
Modified:
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsSection.java
===================================================================
---
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsSection.java 2012-10-23
12:13:59 UTC (rev 44609)
+++
branches/jbosstools-4.0.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsSection.java 2012-10-23
14:32:27 UTC (rev 44610)
@@ -11,8 +11,8 @@
package org.jboss.tools.openshift.express.internal.ui.behaviour;
import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.Arrays;
import org.eclipse.core.resources.IFolder;
@@ -137,9 +137,9 @@
String connectionLabel = "";
if (!StringUtils.isEmpty(connectionUrl)) {
try {
- Connection connection = new Connection(new URI(connectionUrl), null);
+ Connection connection = new Connection(new URL(connectionUrl), null);
connectionLabel = connection.getUsername() + " - " + connection.getHost();
- } catch (URISyntaxException e) {
+ } catch (MalformedURLException e) {
OpenShiftUIActivator.log(NLS.bind("Could not get URL for connection {0}",
connectionUrl), e);
} catch (UnsupportedEncodingException e) {
OpenShiftUIActivator.log(NLS.bind("Could not get URL for connection {0}",
connectionUrl), e);