Author: adietish
Date: 2011-10-06 16:03:19 -0400 (Thu, 06 Oct 2011)
New Revision: 35437
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/client/OpenshiftService.java
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/internal/client/httpclient/UrlConnectionHttpClient.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
trunk/as/tests/org.jboss.tools.openshift.express.client.test/src/org/jboss/tools/openshift/express/internal/client/test/fakes/TestUser.java
Log:
[JBIDE-9857] corrected user-agent so that it would more look like a classic browser
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/client/OpenshiftService.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/client/OpenshiftService.java 2011-10-06
20:02:07 UTC (rev 35436)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/client/OpenshiftService.java 2011-10-06
20:03:19 UTC (rev 35437)
@@ -12,6 +12,7 @@
import java.net.MalformedURLException;
import java.net.URL;
+import java.text.MessageFormat;
import java.util.List;
import org.jboss.tools.openshift.express.internal.client.Application;
@@ -46,6 +47,10 @@
*/
public class OpenshiftService implements IOpenshiftService {
+ // TODO extract to properties file
+ public static final String VERSION = "0.1.0";
+ private static final String USERAGENT_FORMAT = "Java Openshift/{0} ({1})";
+
private String baseUrl;
private String id;
@@ -256,6 +261,7 @@
}
private IHttpClient createHttpClient(String id, String url) throws MalformedURLException
{
- return new UrlConnectionHttpClient(id, new URL(url));
+ String userAgent = MessageFormat.format(USERAGENT_FORMAT, VERSION, id);
+ return new UrlConnectionHttpClient(userAgent, new URL(url));
}
}
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/internal/client/httpclient/UrlConnectionHttpClient.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/internal/client/httpclient/UrlConnectionHttpClient.java 2011-10-06
20:02:07 UTC (rev 35436)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/internal/client/httpclient/UrlConnectionHttpClient.java 2011-10-06
20:03:19 UTC (rev 35437)
@@ -34,7 +34,7 @@
this.userAgent = userAgent;
this.url = url;
}
-
+
public String post(String data) throws HttpClientException {
HttpURLConnection connection = null;
try {
@@ -98,10 +98,7 @@
connection.setConnectTimeout(TIMEOUT);
connection.setRequestProperty(PROPERTY_CONTENT_TYPE,
"application/x-www-form-urlencoded");
connection.setInstanceFollowRedirects(true);
- if (userAgent != null
- && userAgent.length() > 0) {
- connection.setRequestProperty(USER_AGENT, userAgent);
- }
+ connection.setRequestProperty(USER_AGENT, userAgent);
return connection;
}
}
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2011-10-06
20:02:07 UTC (rev 35436)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2011-10-06
20:03:19 UTC (rev 35437)
@@ -27,8 +27,9 @@
*/
public class CredentialsWizardPageModel extends ObservableUIPojo {
- private static final String ID = OpenshiftUIActivator.PLUGIN_ID;
-
+ private static final String ID = OpenshiftUIActivator.PLUGIN_ID
+ + OpenshiftUIActivator.getDefault().getBundle().getVersion();
+
private static final String RHLOGIN_PREFS_KEY =
"org.jboss.tools.openshift.express.internal.ui.wizard.CredentialsWizardModel_RHLOGIN";
public static final String PROPERTY_SERVER_URL = "serverUrl";
Modified:
trunk/as/tests/org.jboss.tools.openshift.express.client.test/src/org/jboss/tools/openshift/express/internal/client/test/fakes/TestUser.java
===================================================================
---
trunk/as/tests/org.jboss.tools.openshift.express.client.test/src/org/jboss/tools/openshift/express/internal/client/test/fakes/TestUser.java 2011-10-06
20:02:07 UTC (rev 35436)
+++
trunk/as/tests/org.jboss.tools.openshift.express.client.test/src/org/jboss/tools/openshift/express/internal/client/test/fakes/TestUser.java 2011-10-06
20:03:19 UTC (rev 35437)
@@ -13,6 +13,7 @@
import org.jboss.tools.openshift.express.client.Cartridge;
import org.jboss.tools.openshift.express.client.IApplication;
import org.jboss.tools.openshift.express.client.OpenshiftException;
+import org.jboss.tools.openshift.express.client.OpenshiftService;
import org.jboss.tools.openshift.express.client.User;
import org.jboss.tools.openshift.express.internal.client.test.utils.ApplicationUtils;
@@ -21,7 +22,7 @@
*/
public class TestUser extends User {
- public static final String ID =
"org.jboss.tools.openshift.express.client.test";
+ public static final String ID = "org.jboss.tools.openshift.express.client.test
" + OpenshiftService.VERSION;
public static final String RHLOGIN_USER_WITHOUT_DOMAIN =
"toolsjboss.no.domain2(a)gmail.com";
public static final String PASSWORD_USER_WITHOUT_DOMAIN = "1q2w3e";
Show replies by date