Revision: 8669
Author: [email protected]
Date: Mon Aug 30 08:52:55 2010
Log: Updated GWT code with the latest Apache HttpClient 4.0. Removed httpclient-3.

http://code.google.com/p/google-web-toolkit/source/detail?r=8669

Modified:
 /trunk/dev/build.xml
 /trunk/eclipse/user/.classpath
/trunk/user/src/com/google/gwt/requestfactory/server/SampleDataPopulator.java

=======================================
--- /trunk/dev/build.xml        Thu Aug 12 17:25:52 2010
+++ /trunk/dev/build.xml        Mon Aug 30 08:52:55 2010
@@ -91,12 +91,11 @@
           <include name="apache/http/httpmime-4.0.1.jar" />
           <include name="apache/james/apache-mime4j-0.6.jar" />
           <include name="apache/commons/commons-codec-1.3.jar" />
-          <include name="apache/commons/commons-httpclient-3.1.jar" />
           <include name="apache/commons/commons-io-1.4.jar" />
           <include name="apache/commons/commons-lang-2.4.jar" />
           <include name="cssparser/cssparser-0.9.5.jar" />
-         <include name="htmlunit/htmlunit-r5940/htmlunit-r5940.jar" />
-         <include name="htmlunit/htmlunit-r5940/htmlunit-core-js-r5940.jar" />
+          <include name="htmlunit/htmlunit-r5940/htmlunit-r5940.jar" />
+ <include name="htmlunit/htmlunit-r5940/htmlunit-core-js-r5940.jar" />
           <include name="nekohtml/nekohtml-1.9.13.jar" />
           <include name="xalan/xalan-2.7.1.jar" />
           <include name="xerces/xerces-2_9_1/serializer.jar" />
@@ -152,12 +151,11 @@
<zipfileset src="${gwt.tools.lib}/apache/http/httpmime-4.0.1.jar" /> <zipfileset src="${gwt.tools.lib}/apache/james/apache-mime4j-0.6.jar" /> <zipfileset src="${gwt.tools.lib}/apache/commons/commons-codec-1.3.jar" /> - <zipfileset src="${gwt.tools.lib}/apache/commons/commons-httpclient-3.1.jar" /> <zipfileset src="${gwt.tools.lib}/apache/commons/commons-io-1.4.jar" /> <zipfileset src="${gwt.tools.lib}/apache/commons/commons-lang-2.4.jar" /> <zipfileset src="${gwt.tools.lib}/cssparser/cssparser-0.9.5.jar" /> - <zipfileset src="${gwt.tools.lib}/htmlunit/htmlunit-r5940/htmlunit-r5940.jar" /> - <zipfileset src="${gwt.tools.lib}/htmlunit/htmlunit-r5940/htmlunit-core-js-r5940.jar" /> + <zipfileset src="${gwt.tools.lib}/htmlunit/htmlunit-r5940/htmlunit-r5940.jar" /> + <zipfileset src="${gwt.tools.lib}/htmlunit/htmlunit-r5940/htmlunit-core-js-r5940.jar" /> <zipfileset src="${gwt.tools.lib}/nekohtml/nekohtml-1.9.13.jar" />
           <zipfileset src="${gwt.tools.lib}/xalan/xalan-2.7.1.jar" />
<zipfileset src="${gwt.tools.lib}/xerces/xerces-2_9_1/serializer.jar" />
=======================================
--- /trunk/eclipse/user/.classpath      Thu Aug 26 15:18:52 2010
+++ /trunk/eclipse/user/.classpath      Mon Aug 30 08:52:55 2010
@@ -15,7 +15,6 @@
<classpathentry kind="var" path="GWT_TOOLS/lib/apache/james/apache-mime4j-0.6.jar"/> <classpathentry kind="var" path="GWT_TOOLS/lib/apache/commons/commons-codec-1.3.jar"/> <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/commons-collections-3.1.jar"/> - <classpathentry kind="var" path="GWT_TOOLS/lib/apache/commons/commons-httpclient-3.1.jar"/> <classpathentry kind="var" path="GWT_TOOLS/lib/apache/commons/commons-lang-2.4.jar"/> <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/commons-logging-1.0.jar"/> <classpathentry kind="var" path="GWT_TOOLS/lib/apache/commons/commons-io-1.4.jar"/>
=======================================
--- /trunk/user/src/com/google/gwt/requestfactory/server/SampleDataPopulator.java Wed Aug 25 17:41:41 2010 +++ /trunk/user/src/com/google/gwt/requestfactory/server/SampleDataPopulator.java Mon Aug 30 08:52:55 2010
@@ -17,13 +17,15 @@

 import com.google.gwt.requestfactory.shared.RequestData;
 import com.google.gwt.requestfactory.shared.RequestFactory;
-import com.google.gwt.requestfactory.shared.WriteOperation;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.json.JSONArray;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpException;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
 import org.json.JSONException;
 import org.json.JSONObject;

@@ -86,22 +88,21 @@
   @SuppressWarnings("deprecation")
   private void postJsonFile(JSONObject contentData) throws HttpException,
       IOException, JSONException {
-    PostMethod post = new PostMethod(url);
+    HttpPost post = new HttpPost(url);
     JSONObject request = new JSONObject();
-    // TODO: fix
     request.put(RequestData.OPERATION_TOKEN, "DOESNT_WORK");
     request.put(RequestData.CONTENT_TOKEN, contentData);
-    post.setRequestBody(request.toString());
-    HttpClient client = new HttpClient();
-    int status = client.executeMethod(post);
-    JSONObject response = new JSONObject(post.getResponseBodyAsString());
- JSONArray records = response.getJSONArray(WriteOperation.CREATE.name());
-    if (status == HttpStatus.SC_OK) {
-      System.out.println("SUCCESS: Put " + records.length()
+    StringEntity reqEntity = new StringEntity(request.toString());
+    post.setEntity(reqEntity);
+    HttpClient client = new DefaultHttpClient();
+    HttpResponse response = client.execute(post);
+    HttpEntity resEntity = response.getEntity();
+    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+      System.out.println("SUCCESS: Put " + resEntity.getContentLength()
           + " records in the datastore!");
       return;
     }
-    System.err.println("POST failed: Status line " + post.getStatusLine()
+ System.err.println("POST failed: Status line " + response.getStatusLine()
         + ", please check your URL");
   }

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to